MVVM如何进行矢量图形处理? [英] How do to MVVM for vector graphics?
问题描述
我希望显示一些矢量图形,并让用户选择项目。
I wish to display some vector graphic and let the user select items.
为方便起见,假设我显示的办公计划包含
For augment sake assume I am displaying an office plan that contains
- 墙壁,
- 角落,
- 门,
- Windows,
- 桌面
- Walls,
- Corners,
- Doors,
- Windows,
- Desks
我希望能够针对视图模型编写测试,以检查逻辑布局和物理布局。例如。我希望能够编写一个测试来确定墙壁是否在拐角处,以及确定如何显示墙。
I wish to be able to write tests against the view model to check both the "logical" and "physical" layout. E.g. I wish to be able to write a test that confirm the walls meets the corner as well as tests that confirm how they are displayed.
我还需要测试
有人尝试过这样做吗?
数据绑定有什么问题
推荐答案
我将或多或少地做同一件事。我还没有意识到,但是我的想法是要有一个ViewModelCanvas,在其中放置逻辑,所包含的对象是WallViewModel,DoorViewModel等。这些对象中的每个对象都包含坐标,方向和其他属性。
然后,在视图层中,我有一个WPFCanvas,其中ViewModelCanvas作为Datacontext,还有每个viewmodel类的模板,用于定义应如何显示。
I'm going to do more or less the same thing. I do not have realized yet but my idea was to have a ViewModelCanvas where I put the logic and where the contained objects are WallViewModel, DoorViewModel etc.. Each of those object contains coordiantes, orientation and other properties. Then in the view layer I have a WPFCanvas with ViewModelCanvas as Datacontext and a template for each viewmodel class that define how it should be appear.
它应该可以工作用于静态可视化。不确定是否具有交互视图是否足够灵活,但是很有可能;)
It should work for static visualization. Not sure if it is enough flexible to have an interactive view however there is a good probability ;)
这篇关于MVVM如何进行矢量图形处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!