组织 GUI 代码 [英] Organizing GUI code

查看:27
本文介绍了组织 GUI 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题有两个部分:

  • 有没有人有关于如何编写易于阅读、编写和维护的 GUI 代码的任何提示或参考网络上的某些文档?

  • Does anyone have any tips or references to some documentation on the web about how to write GUI code that is easy to read, write, and maintain?

示例.

我发现我的 GUI 表单变得越广泛,我最终会得到一长串相当短的事件处理程序方法.如果我尝试添加任何私有辅助方法,它们只会在混乱中迷失方向,而且我必须不断滚动页面以遵循一条思路.

I find that the more extensive my GUI forms become, I end up with a long list of fairly short event handler methods. If I try to add any private helper methods, they just get lost in the shuffle, and I constantly have to scroll around the page to follow a single line of thought.

  • 如何轻松管理整个应用程序的设置?

  • How can I easily manage settings across the application?

示例.

如果用户在下拉列表中选择了一个新项目,我可能需要在 GUI 上启用一些组件,更新应用程序配置文件,并将新值存储在局部变量中以备后用.我通常选择不为所有设置创建事件处理程序(见上文),并以LoadGUISettings"和SaveGUISettings"等方法结束,但我最终在我的代码中调用这些方法,并且它运行了很多代码只是为了更新很少的实际更改.

If the user selects a new item in a drop-down list, I might need to enable some components on the GUI, update an app config file, and store the new value in a local variable for later. I usually opt to not create event handlers for all the settings (see above), and end up with methods like "LoadGUISettings" and "SaveGUISettings", but then I end up calling these methods all over my code, and it runs through a lot of code just to update very few, if any, actual changes.

谢谢!

推荐答案

如果您使用 WPF,您可能需要阅读 WPF 复合应用指南.

If you're using WPF, you might want to read the Composite Application Guideance for WPF.

它讨论了其中的许多主题(以及许多其他主题).该指南的主要目标是以灵活、可维护的方式构建大型应用程序.

It discusses many of these topics (as well as many others). The main goal of that guideance is to make large scale applications in a flexible, maintainable manner.

这篇关于组织 GUI 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆