简体   繁体   English

转换SDI成MDI

[英]Convert SDI to MDI

I'm taking my first class in C# development for winforms. 我正在上C#开发Winforms的第一堂课。 I'm using VS Premium 2013. 我正在使用VS Premium 2013。

We've been working on an application all semester. 我们整个学期都在研究应用程序。 For our final project one of our tasks is to convert it from an SDI to an MDI. 对于我们的最终项目,我们的任务之一是将其从SDI转换为MDI。

The mainform is structured as follows: 主要形式的结构如下:

  1. menustrip 的MenuStrip
  2. toolstrip 工具条
  3. split panel with a treeview control in its own class, a listview control in its own class, and a rich text box in its own class (these are all then displayed on the mainform) 拆分面板,在其自己的类中具有一个treeview控件,在其自己的类中具有一个listview控件,并在其自己的类中具有一个富文本框(这些都将显示在主窗体上)
  4. user control that functions as a status bar docked at the bottom of the form 用作状态栏的用户控件停靠在表单底部

The code for all the click events and business logic is already written. 所有单击事件和业务逻辑的代码已经编写。 This is already a robust application. 这已经是一个强大的应用程序。

Is there a "best practice" for converting an SDI like this to an MDI? 是否有将这样的SDI转换为MDI的“最佳实践”? There's a ton of code here, and unless I get better guidance, I assume I'm going to have to create a new project, move over the classes that I can and then rewrite all the supporting event handlers and associated logic. 这里有大量的代码,除非获得更好的指导,否则我假设我将不得不创建一个新项目,移走我可以的类,然后重写所有支持的事件处理程序和相关的逻辑。

Is there a more time-efficient option that someone can recommend? 有人可以推荐更省时的选择吗?

There is no single answer because the specifics of the migration depend on the specifics of your current application. 没有一个唯一的答案,因为迁移的细节取决于当前应用程序的细节。 If you have written it well then there should be almost no change at all. 如果您写得不错,那么几乎应该没有任何变化。 It should be mostly just setting the MdiParent of each document form before showing it. 应该只在显示每个文档表单之前设置它的MdiParent。 There would still be a few details to consider but that would be the bulk of. 仍然有一些细节需要考虑,但这只是大部分。

So that changes like this are relatively painless is one of the main reasons that design patterns are used in development. 这样的更改相对不费吹灰之力是开发中使用设计模式的主要原因之一。 Also, the less coupled the types are in your project, the easier they move around in these cases. 而且,项目中类型之间的耦合越少,在这些情况下它们越容易移动。 For instance, if you have two types that each rely on the other to be exactly as they are then any change is going to have significant impact on both. 例如,如果您有两种类型,每种类型都完全依赖彼此,那么任何更改都会对两者产生重大影响。 If those types are decoupled though, a change in one may have absolutely no effect on the other. 如果将这些类型解耦,则其中一种更改可能对另一种完全没有影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM