WPF画布中的可拖动对象 [英] connest dragable object in canvas wpf

查看:78
本文介绍了WPF画布中的可拖动对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我的项目中有一个画布,其中包含一些对象,例如图像类型,矩形或标签....

可以将这些对象拖到画布上.我想做的是用线将这些对象连接起来.(该线将任何对象连接到另一个对象上)

这条线有一个特殊的属性,那就是它不能越过一个对象.

实际上,这条线是智能的,不会越过对象,并且路径与对象之间是空的.

请帮我,解释一下我该怎么办

因为我是程序设计的初学者,而且是wpf的专业人士,所以请给我完整的解释.

非常感谢

hi all

I have a canvas in my project and there are some objects in it , type of image or rectangle or label.... for example.

These objects can be dragged throgh the canvas . what I wants to do , is connect these objects with a line.(the line connect any objects to onother one)

This line have a special propertie that it must not cross over one object.

actually , this line is intelligent that not cross over object and its path is empty from objects .

help me please , explain me what can I do this

because I am very beginner in programming and special in wpf so give me complete explain please.

Thanks so much

推荐答案

仅需注意:这称为连接器路由,这是一个非常困难的问题.

抱歉,我的回答无法为您提供此问题的解决方案.

到目前为止,从我所知道的所有产品(我尝试了很多)中,没有人做得足够好,所以我总是使用(半)手动路由.您还应该理解,用户总是可以创建一些几何图形,而根本不可能进行自动布线,因此您需要以某种方式进行处理.当存在解决方案时,通常情况是模棱两可的.但是主要的问题是路由算法本身,以及一系列相关的问题.例如,接近垂直或水平方向的线应捕捉"到该方向,线的断点可能应捕捉到某个网格点,等等.

这带来了许多真正困难的问题,对于初学者来说太困难了.也许您需要简化问题或进行其他操作.

—SA
Just a note: this is called connector routing and is a pretty difficult problem.

Sorry that my answer won''t provide you with a solution of this problem.

From all the products I knew by this time (and I tried a good number of them), no one does it well enough, so I always use (semi-)manual routing. You should also understand that that the user can always create some geometry, where automatic routing is not possible at all, so you need to deal with it somehow. When a solution exists, it is in general case ambiguous. But the major problem is routing algorithm itself, coupled with a set of related problems. For example, the line close to vertical or horizontal orientation should "snap" to this orientation, the breaking point of lines should possibly snap to some grid point, etc.

This presents a complex of really difficult problems, way too difficult for a beginner. Perhaps you need to simplify the problem or work at something else.

—SA


如果您还没有,可以看看以下内容:

WPF图设计器:第1部分 [ WPF图设计器-第2部分 [ WPF图设计器-第3部分 [ WPF图设计器-第4部分 [
If you haven''t already, you might want to take a look at these:

WPF Diagram Designer: Part 1[^]
WPF Diagram Designer - Part 2[^]
WPF Diagram Designer - Part 3[^]
WPF Diagram Designer - Part 4[^]


这篇关于WPF画布中的可拖动对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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