How to use WPF to build a simple shape diagramming app?
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 sho开发者_C百科w 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.
I would suggest you to have a look at this CodeProject article/series -
WPF Diagram Designer - Part 4 http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part4.aspx
One more project based on this can be found at codeplex-
http://simulo.codeplex.com/
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!
精彩评论