在WPF中在运行时将鼠标单击与行连接 [英] Joining Mouse clicks with a line at runtime in WPF

查看:98
本文介绍了在WPF中在运行时将鼠标单击与行连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

任何人都可以给我一个想法,如何在运行时将鼠标单击与一行连接起来.
我通过单击按钮在窗口上有一个Joinbutton,鼠标单击应该加入.
例如 在窗口上,如果我单击两次并单击Joinbutton,则两个mouseclick位置应用一条线连接.
如果我在窗口上单击三下并单击Joinbutton,则三个mouseclick位置应连接并形成一个三角形,类似地,对于四单击,鼠标单击位置应连接并形成一个矩形.

请提出您的建议以解决此问题.

谢谢,

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.

Thanks,

推荐答案

此处是有关在WPF中绘制各种对象的文章;
WPF DrawTools [
Here is an article on drawing various objects in WPF;
WPF DrawTools[^]

Enough to get you going I think.


在鼠标按下时,将位置添加到列表(List< Point>)应该可以解决问题.按下按钮后,从列表中读取所有点并创建一个新的多边形(除非只有两个点,在这种情况下为一条线)并将其添加到父级.
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.


这篇关于在WPF中在运行时将鼠标单击与行连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆