M
Mike D Sutton
Please excuse the terribly 'newbie'ness of this question, unfortunately my C# is very rusty..
What I'm trying to do is write a simple interactive drawing application where a few lines can be moved around on the form. What I'm
trying to do is in the MouseDown() event hit test each line point and when I find one, store a _reference_ to it. The MouseMove
event then checks to see if this reference has been set, if so it will edit this point and cause a redraw which should use the new
coordinates since I'm using a reference to the original point.
The way I understand it is that PointF is a value type and as such I have to box it using (object)Point; and store it in an Object
variable in order to create a reference to it. I then unbox it using PointF p = Point; in MouseMove to edit it's fields, however
this is not editing my original line. Is it just my syntax or am I 'just not getting it'? If this is the case does anyone know of
a good reference for boxing and unboxing and what they're actually used for. I could easily write a simple point class which would
already be an object but I'm curious as to how this would be achieved with value types.
Cheers,
Mike
What I'm trying to do is write a simple interactive drawing application where a few lines can be moved around on the form. What I'm
trying to do is in the MouseDown() event hit test each line point and when I find one, store a _reference_ to it. The MouseMove
event then checks to see if this reference has been set, if so it will edit this point and cause a redraw which should use the new
coordinates since I'm using a reference to the original point.
The way I understand it is that PointF is a value type and as such I have to box it using (object)Point; and store it in an Object
variable in order to create a reference to it. I then unbox it using PointF p = Point; in MouseMove to edit it's fields, however
this is not editing my original line. Is it just my syntax or am I 'just not getting it'? If this is the case does anyone know of
a good reference for boxing and unboxing and what they're actually used for. I could easily write a simple point class which would
already be an object but I'm curious as to how this would be achieved with value types.
Cheers,
Mike