开发者

Which design pattern to manage windows?

I am using .NET 2.0 & C# to develop a WinForm Mdi application. It will have a Main Window and a lot of mdi windows. I am thinking I should use which design pattern to manage mdi windows. Because I want only one instance for each window, if window is existed, I will show it on top, & otherwise I will create and show it.

开发者_StackOverflowNote: a mdi window is opened from Menus of Main Window or open from another mdi window. An example is very good.

Update: Menu's status is depended on mdi window's status. Ex: If Window 'A' is openned -> menu 'A' -> disabled. When window 'A' is closed -> I update menu 'A' status to Enabled.

Thanks.


I would suggest a good perusal of Martin Fowler's page on GUI Patterns.

You won't find a quick example, but then again the problem set doesn't warrant a quick solution. You need to spend some time understanding the different UI design patterns available and make an informed decision about which one will work best in your application.

Martin Fowler's site will give you enough information to begin your journey at least. You can dive perhaps a little deeper by looking over Jeremy Miller's series to get specific .Net examples.

Again, there won't be a quick fix around either of those corners, but it will be worth it to learn from industry leaders.


I dont think you will find one pattern to solve the problem, but will be a collaboration of pattern. The links provided by Josh are interesting read.

A simple suggestion based on GoF pattern will be as below:

  • Use Command pattern to handle your menu click event
  • Use Factory pattern to create your window. You can custom your factory so that it creates only single instance of the window, using approach from Singleton pattern
  • Use Subject-Observer pattern for the menu state. The MDI child window will be the subject and you will need to structure your code so that you can embedded observer logic in your menu controller.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜