Nevron Forum

Can not set location on horizontal line

https://www.nevron.com/Forum/Topic10754.aspx

By Jason Irby - Monday, May 16, 2016


I have a NLineShape that I am trying to move by programatically.
It has a start location and has a width, but because it is exactly horizontal the bounds height is 0;

When I try and do 

myLine.Location = new NPointF(10.0f,10.0f);

It throws an exception complaining that the new bounds can not have a 0 height or width.
If the line is NOT exactly horizontal by even a pixel, this error does not occur.

Can I change the horizontal lines location without it throwing that exception?

Thanks in advance,
Jason 


By Nevron Support - Tuesday, May 17, 2016

Hi,

The best way to move a shape is to use its Translate method. For example, to move a line shape 40 pixels down, you can use the following line of code:

// Move the line shape
lineShape.Translate(0, 40);

// Repaint the view
document.SmartRefreshAllViews();


Alternatively, you can change the StartPoint and EndPoint of the line shape.