如何使用 WPF 构建一个简单的形状图表应用程序?
我正在尝试使用 WPF 构建一个简单的图表应用程序,但遇到了一些主要障碍。
该应用程序非常基础。我有一个画布元素和一组基本形状 - 椭圆形、矩形等。用户将选择一个形状并单击将它们放置在画布上。然后,应用程序会将数据导出为 xml。
放置形状的代码很简单,但是我现在想要添加额外的功能,例如调整形状大小、移动和旋转形状。我知道这都是通过渲染/布局转换完成的。为了加快速度,我使用滑块来控制各种参数,但我将切换到(装饰器+拇指?),以便界面更加直观。
我见过的所有示例都显示了使这些类型的功能正常工作的大量代码。
然而,代码库只有几天的历史,但维护起来已经很痛苦了,这意味着我在阿尔伯克基完全走错了方向。
WPF 是构建我想要的应用程序的正确工具吗?或者我应该考虑一组不同的工具。
I'm trying to build a simple diagramming application using WPF, and I'm running into some major hurdles.
The application is very basic. I have a canvas element, and set of basic shapes-ellipse, rectangle etc. Users will choose a shape and click to place them on the canvas. Afterwards, the app will export the data into xml.
The code to place shapes was straight forward, however I'm at the point where I want to add extra functionality, like resizing, moving, and rotating the shapes. I know this is all done with Render/Layout transforms. To speed things up, I used sliders to control the various parameters, but I'm going to switch to (adorners+thumbs?) so the interface is more intuitive.
All the examples I've seen show just massive amounts of code to get these types of features working.
However the code base is only a few days old, but it's already a pain to maintain, which means I totally took a wrong turn at Albuquerque.
Is WPF the proper tool to build the application that I want, or should I look at a different set of tools.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您看看这篇 CodeProject 文章/系列 -
另一个基于此的项目可以在 codeplex- 找到
这些应用程序与您的几乎相同,调整大小,移动,这些项目中实现了保存/加载和许多其他有用的功能。
我已经构建了一个与您类似的应用程序,我想说 WPF 是此类应用程序的正确选择,因为您可以非常轻松地实现许多用户友好的功能。看看上面的应用程序是如何实现的,如果您正确地设计和实现您的应用程序,那么维护它将会非常容易且轻松。
I would suggest you to have a look at this CodeProject article/series -
One more project based on this can be found at codeplex-
These applications are almost same as yours, Re-size, move, Save/Load and many other useful functionality are implemented in these projects.
I have built an application similar to yours and I would say that WPF is right choice for this kind of applications, as you can implement a lot of user friendly features very easily. Have a look at how things are implemented in above applications, if you design and implement your application properly it will be really easy and painless to maintain it.
切换到装饰器等是可行的方法。不过,除非您找到一个具有有用控件/逻辑的库,否则您将需要进行相当多的编码。仅布置连接器就需要相当多的努力。
但这是一个有趣的练习!
Switching to Adorners etc. is the way to go. Still, unless you find a library with useful controls/logic you are in for quite some coding. Arranging connectors only will take quite some effort.
It is a fun exercise though!