C#多面板/层winform应用程序
我一直在设计一个非常复杂的航空电子应用程序。问题是,它有许多菜单按钮可供单击(确切地说是 12 个),并且每个按钮都执行不同的操作。例如,一个可以是登录面板,另一个可以是 PDF 阅读器。我如何以编程方式组织这个?
目前,我一直在设置面板中的每个项目,并根据活动或单击的项目将其设置为可见或不可见。
你们会怎么做? 提前致谢!
I've been designing a pretty complicated avionics application. The thing is, it has many menu buttons to be clicked (12 to be exact) and each one of them perform a different action. For instance, one could be a login panel and the other one a PDF reader. How could I organize this programmatically?
Currently, I've been setting each item in a panel and setting it to visible or invisible, according to the active or clicked item.
How would you guys do this?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会考虑 FlowLayoutPanel,尽管我'我不确定它在满足您的要求方面有多灵活。如果您使用对接属性设置面板,您应该能够进行管理。
我还建议使用
UserControl
来分离代码和功能。如果面板需要通信,请实现观察者/可观察模式,而不是订阅用户控件之间的事件。You might consider a FlowLayoutPanel, although I'm not sure how flexible it would be in meeting your requirements. If you set your panels up with docking properties, you should be able to manage.
I would also recommend using a
UserControl
to separate code and functionality. If panels need to communicate, implement the observer/observable pattern instead of subscribing to events between user controls.就像 IAbstract 所说,您应该考虑将不同的 UI 元素分离为 UserControl。然后,您可以执行一些操作,例如使用工厂来构造它们并根据需要将它们添加到窗口中。
我发现这种方法与模型-视图-演示者类型模式一起使用,对于具有动态用户界面的 WinForms 应用程序非常有效。
Like IAbstract says, you should consider separating the different UI elements as UserControls. You can then do things like use a factory to construct them and add them to your window as required.
I've found this sort of approach, used with a Model-View-Presenter type pattern, works really well for WinForms apps with dynamic user interfaces.