多名MVP主讲人:如何沟通和分享信息?
我正在设计一个遵循 MVP 模式的 Winforms MDI 应用程序,但我遇到了一些与应用程序不同部分之间的通信相关的问题。
这是该应用程序的简单图片: 1 - 左侧是树形视图 2-中间有一个绘图组件 3-右侧是“财产”表格。 这三个部分是用 MVP 三元组管理的(好吧,不是真的,模型对所有三元组都是通用的)
当我单击树视图上的一个节点时,我想在绘图组件中看到相应选定对象的绘图,并且我想要在属性表单中查看与此选定对象相对应的一些属性。
我的基本问题是: a) 在哪里存储“选定对象”信息? b) 如何警告绘图组件和属性窗体“选定对象”已更改?
我开始想象一些解决方案,但我很不高兴。
我不购买将“选定对象”放入模型中并执行观察者同步。 “选定的对象”不属于模型
所以我想,我会将此信息存储在演示者中 如果我将“选定的对象”放入树视图演示器中,在我看来,绘图组件的演示器和属性表单的演示器都必须保留树视图演示器的引用,以检索此信息。
它在演示者之间造成了一些耦合,我也不喜欢。
所以我正在寻找其他想法或评论。感谢您抽出时间。
I am designing a Winforms MDI application following MVP pattern, and I'm stuck on some problems related to communication between different part of my application.
Here a simple picture of this application:
1 -On the left a treeview
2- In the middle a drawing component
3- on the right, a "property" form.
These 3 parts are managed with a MVP triad ( well ,not really , Model is common to all triads)
When I click on a node on the treeview, I want to see a drawing of the corresponding selected object in the drawing component ,and I want to see some properties corresponding to this selected object in the property form.
My basic question are :
a) Where to store "Selected object " information ?
b) How to warn Drawing component and property form that "Selected object " has changed ?
I started to imagine some solutions but I am quite unhappy.
I don't buy putting "Selected object " in the Model and perform observer synchronization.
"Selected object " does not belong to the Model
SO I imagine, I would store this information in a presenter
If I put "Selected object " in Treeview presenter, it seems to me that both Presenter for drawing component and Presenter for Property form will have to hold a reference on treeview presenter, to retrieve this information.
It creates some coupling between presenters , and I don't like also.
So I am looking for other ideas, and or comments. thanks for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,很抱歉回复晚了:)有很多东西要完成:D
我不知道你的代码到底是如何构建的,但也许你可以使用 Retlang。然后,您可以轻松地传递消息中的 ID 列表,并在您喜欢的任何地方处理该消息。
另外,对我来说,听到你一年前如何解决你的问题也很有趣。
First of all, sorry for a late response :) had lots of stuff to finish :D
I don't know how exactly your code is built but may be you could use Retlang. Then you could easily pass list of IDs in the message and handle this message wherever you like.
Also it would be quite interesting for me to hear how you managed to solve your problem a year ago.