UserControl帮助,用于创建线,圆等图形 [英] UserControl Help for Creating Drawing like line,circle etc

查看:66
本文介绍了UserControl帮助,用于创建线,圆等图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何开发使用用户控件执行通过画布绘制线条,圆形,矩形等图形的应用程序.

How to develop an application which perform to draw line, circle, rectangle etc figures through canvas using user control. it also perform zooming and panning and selection of any figures separately and also combine.

推荐答案

如果这是一个类似CAD的应用程序(希望您不要创建另一个AutoCAD :-)),我建议考虑使用WPF,WPF是为此类应用程序而设计的.特别是,您可能会考虑围绕System.Windows.Controls.Canvas:
构建所有图形设计 http://msdn.microsoft.com/en-us/library/system. windows.controls.canvas.aspx [ ^ ].

您无需关心图形渲染和许多其他细节,例如鼠标点击测试,缩放,平移等等.您可以在Canvas实例上放置任何类型的UI元素,这些元素可以是原始的(如like或矩形)或复杂的.您甚至可以将其他实例放在Canvas上以表示复合元素.这样,您可以实现分层分组和取消分组.您甚至可以允许用户创建自己的元素并将其放在Canvas上.

用户甚至可以使用某些第三方工具来创建任何元素.例如,我强烈推荐Inkscape:
http://en.wikipedia.org/wiki/Inkspace [ http://inkscape.org/ [ ^ ].

即使其图形基于SVG( http://inkscape.org/ [
If this is a CAD like application (I hope you are not going to create another AutoCAD :-)), I would recommend to think about using WPF, which was designed with this sort of application in mind. In particular, you may think about building all you graphical design around System.Windows.Controls.Canvas:
http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.aspx[^].

You won''t need to care about graphical rendering and many other detail like mouse hit test, zooming, panning and more. You can put any kinds of UI elements on the instance of Canvas, primitive (like like or rectangle) or complex. You can even put other instances on Canvas to represent compound elements. This way, you can implement hierarchical grouping and ungrouping. You can even allow the users to create their own elements and put them on Canvas.

The user can create any elements even using some 3-rd party tools. For example, I would highly recommend Inkscape:
http://en.wikipedia.org/wiki/Inkspace[^],
http://inkscape.org/[^].

Even though its graphics is based on SVG (http://inkscape.org/[^]), it can be converted to XAML, so you can easily use user''s graphic elements in your WPF applications. The users should understand that SVG graphics is somewhat richer than XAML, so they should not use some advanced properties not allowed by XAML, such as blurring.

This is just one of possible approaches, but I think it would be most promising. Potentially, you can even develop it for both WPF and Silverlight and make the online tool out of it.

—SA


这篇关于UserControl帮助,用于创建线,圆等图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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