tags:

views:

65

answers:

2

Hi,

I would like to draw in C# with the mouse, like if the mouse were a pen. I am trying with Graphics class, using DrawLines method receiving an array of points as parameter.

Do you think this is the better option, or do yo know if is there another easy way to do it?

Thanks in advance

Regards.

+1  A: 

Look at this sample:

http://www.codeproject.com/KB/graphics/drawtools.aspx

Specifically, the Pencil tool does what you need.

Alex Farber
+3  A: 

You have to use a combination of the MouseMove, MouseDown, and MouseUp events. MouseDown and MouseUp will set and clear a flag telling you the user is holding down the button. While this flag is set, any MouseMove events should result in a line being drawn from the last known mouse position to the new one (a LOT of MouseMove events can be fired in this way, so I would check VERY quickly to make sure you actually needed to do something, and it might be a good idea to make the handler single-threaded using locking).

KeithS