Click here to Skip to main content
15,607,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all,

Could any one give me idea how to join mouse clicks with a line at runtime.
i have a Joinbutton on window by clicking button the mouse clicks should join.
for eg.
on window, if i click two times and click on Joinbutton the two mouseclick positions should join with a line.
if i click three times on window and click on Joinbutton the three mouseclick positions should join and form a triangle, similarly for four click , the mouse click positions should join and form a rectangle.

Plz give your suggestions to resolve this.


Here is an article on drawing various objects in WPF;
WPF DrawTools[^]

Enough to get you going I think.
Share this answer
BobJanova 25-Jul-11 11:36am    
Nice link, but possibly too complex for this questioner.
On mouse down, add the location to a list (List<Point>) should do the trick. On pressing the button, read all the points out of the list and make a new polygon (unless there are only two points, in which case a line) and add it to the parent.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900