- Timestamp:
- 08/21/09 17:24:31 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/MultipleDocumentMainForm.cs
r2305 r2306 51 51 if (InvokeRequired) Invoke((Action<IView>)ShowView, view); 52 52 else { 53 base.ShowView(view); 54 DocumentForm form = new DocumentForm(view); 55 form.Activated += new EventHandler(MultipleDocumentFormActivated); 56 form.FormClosing += new FormClosingEventHandler(view.FormClosing); 57 form.FormClosed += new FormClosedEventHandler(MultipleDocumentFormClosed); 58 form.MdiParent = this; 59 foreach (IToolStripItem item in ToolStripItems) 60 view.StateChanged += new EventHandler(item.ViewChanged); 61 form.Show(); 53 if (views.Contains(view)) { 54 DocumentForm documentForm = FindForm(view); 55 if (documentForm != null) 56 documentForm.Focus(); 57 } else { 58 base.ShowView(view); 59 DocumentForm form = new DocumentForm(view); 60 form.Activated += new EventHandler(MultipleDocumentFormActivated); 61 form.FormClosing += new FormClosingEventHandler(view.FormClosing); 62 form.FormClosed += new FormClosedEventHandler(MultipleDocumentFormClosed); 63 form.MdiParent = this; 64 foreach (IToolStripItem item in ToolStripItems) 65 view.StateChanged += new EventHandler(item.ViewChanged); 66 form.Show(); 67 } 62 68 } 63 69 } 64 70 65 71 public override void CloseView(IView view) { 66 DocumentForm documentForm = this.MdiChildren.Cast<DocumentForm>().Where(df => df.View == view).Single(); 67 documentForm.Close(); 72 DocumentForm documentForm = FindForm(view); 73 if (documentForm != null) 74 documentForm.Close(); 68 75 } 69 76 … … 85 92 form.View.StateChanged -= new EventHandler(item.ViewChanged); 86 93 } 94 95 protected DocumentForm FindForm(IView view) { 96 IEnumerable<DocumentForm> forms = this.MdiChildren.Cast<DocumentForm>().Where(df => df.View == view); 97 if (forms.Count() == 1) 98 return forms.Single(); 99 return null; 100 } 87 101 } 88 102 }
Note: See TracChangeset
for help on using the changeset viewer.