【发布时间】:2016-07-16 17:50:40
【问题描述】:
我使用了 MVP 设计模式,我 MainForm(MDI) 我想在父 mdi 容器中显示子表单。
我的问题是:
将初始化子表单的代码放在view 或presenter 中是一种好习惯吗?
从视图中调用演示者方法ShowMusicLibrary的方法:
查看
public void ShowLibraryButton_Click(object sender, EventArgs e)
{
this.Presenter.ShowMusicLibrary();
// put here or in presenter
}
演讲者:
public void ShowMusicLibrary()
{
this._model.ShowAll();
}
初始化子表单的代码在这里:
foreach (Form topList in Application.OpenForms)
{
if (topList.GetType() == typeof(MusicLibrary))
{
form.Activate();
return;
}
_ms = new MusicLibrary();
_ms.MdiParent = this;
_ms.Show();
}
【问题讨论】: