Changeset 2306 for trunk/sources/HeuristicLab.MainForm
- Timestamp:
- 08/21/09 17:24:31 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.MainForm/3.2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/DockingMainForm.cs
r2305 r2306 45 45 if (InvokeRequired) Invoke((Action<IView>)ShowView, view); 46 46 else { 47 base.ShowView(view); 48 DockContent dockForm = new DockForm(view); 49 dockForm.Activated += new EventHandler(DockFormActivated); 50 dockForm.FormClosing += new FormClosingEventHandler(view.FormClosing); 51 dockForm.FormClosed += new FormClosedEventHandler(DockFormClosed); 52 foreach (IToolStripItem item in ToolStripItems) 53 view.StateChanged += new EventHandler(item.ViewChanged); 54 dockForm.Show(dockPanel); 47 if (views.Contains(view)) { 48 DockForm dockform = FindForm(view); 49 if (dockform != null) 50 dockform.Activate(); 51 } else { 52 base.ShowView(view); 53 DockContent dockForm = new DockForm(view); 54 dockForm.Activated += new EventHandler(DockFormActivated); 55 dockForm.FormClosing += new FormClosingEventHandler(view.FormClosing); 56 dockForm.FormClosed += new FormClosedEventHandler(DockFormClosed); 57 foreach (IToolStripItem item in ToolStripItems) 58 view.StateChanged += new EventHandler(item.ViewChanged); 59 dockForm.Show(dockPanel); 60 } 55 61 } 56 62 } 57 63 58 64 public override void CloseView(IView view) { 59 DockForm dockform = null; 60 IEnumerable<DockForm> dockforms; 61 62 if (dockPanel.Documents.Count() != 0) { 63 dockforms = dockPanel.Documents.Cast<DockForm>().Where(df => df.View == view); 64 if (dockforms.Count() == 1) 65 dockform = dockforms.Single(); 66 } 67 if (dockPanel.FloatWindows.Count() != 0) { 68 foreach (FloatWindow fw in dockPanel.FloatWindows) { 69 foreach (DockContentCollection dc in fw.NestedPanes.Select(np => np.Contents)) { 70 dockforms = dc.Cast<DockForm>().Where(df => df.View == view); 71 if (dockforms.Count() == 1) { 72 dockform = dockforms.Single(); 73 break; 74 } 75 } 76 } 77 } 78 if (dockPanel.DockWindows.Count != 0) { 79 foreach (DockWindow dw in dockPanel.DockWindows) { 80 foreach (DockContentCollection dc in dw.NestedPanes.Select(np => np.Contents)) { 81 dockforms = dc.Cast<DockForm>().Where(df => df.View == view); 82 if (dockforms.Count() == 1) { 83 dockform = dockforms.Single(); 84 break; 85 } 86 } 87 } 88 } 65 DockForm dockform = FindForm(view); 89 66 if (dockform != null) 90 67 dockform.Close(); … … 108 85 base.ActiveView = ((DockForm)sender).View; 109 86 } 87 88 protected DockForm FindForm(IView view) { 89 IEnumerable<DockForm> dockforms; 90 91 if (dockPanel.Documents.Count() != 0) { 92 dockforms = dockPanel.Documents.Cast<DockForm>().Where(df => df.View == view); 93 if (dockforms.Count() == 1) 94 return dockforms.Single(); 95 } 96 if (dockPanel.FloatWindows.Count() != 0) { 97 foreach (FloatWindow fw in dockPanel.FloatWindows) { 98 foreach (DockContentCollection dc in fw.NestedPanes.Select(np => np.Contents)) { 99 dockforms = dc.Cast<DockForm>().Where(df => df.View == view); 100 if (dockforms.Count() == 1) 101 return dockforms.Single(); 102 } 103 } 104 } 105 if (dockPanel.DockWindows.Count != 0) { 106 foreach (DockWindow dw in dockPanel.DockWindows) { 107 foreach (DockContentCollection dc in dw.NestedPanes.Select(np => np.Contents)) { 108 dockforms = dc.Cast<DockForm>().Where(df => df.View == view); 109 if (dockforms.Count() == 1) 110 return dockforms.Single(); 111 } 112 } 113 } 114 return null; 115 } 110 116 } 111 117 } -
trunk/sources/HeuristicLab.MainForm/3.2/MainFormBase.cs
r2305 r2306 114 114 115 115 public virtual void ShowView(IView view) { 116 view.MainForm = this; 117 views.Add(view); 118 ActiveView = view; 116 if (!views.Contains(view)) { 117 view.MainForm = this; 118 views.Add(view); 119 ActiveView = view; 120 } 119 121 } 120 122 -
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 } -
trunk/sources/HeuristicLab.MainForm/3.2/SingleDocumentMainForm.cs
r2305 r2306 45 45 if (InvokeRequired) Invoke((Action<IView>)ShowView, view); 46 46 else { 47 base.ShowView(view); 48 DocumentForm form = new DocumentForm(view); 49 form.ShowInTaskbar = true; 50 form.Activated += new EventHandler(DockFormActivated); 51 form.FormClosing += new FormClosingEventHandler(view.FormClosing); 52 form.FormClosed += new FormClosedEventHandler(DockFormClosed); 53 foreach (IToolStripItem item in ToolStripItems) 54 view.StateChanged += new EventHandler(item.ViewChanged); 55 form.Show(this); 47 if (views.Contains(view)) { 48 DocumentForm documentForm = FindForm(view); 49 if (documentForm != null) 50 documentForm.Focus(); 51 } else { 52 base.ShowView(view); 53 DocumentForm form = new DocumentForm(view); 54 form.ShowInTaskbar = true; 55 form.Activated += new EventHandler(DockFormActivated); 56 form.FormClosing += new FormClosingEventHandler(view.FormClosing); 57 form.FormClosed += new FormClosedEventHandler(DockFormClosed); 58 foreach (IToolStripItem item in ToolStripItems) 59 view.StateChanged += new EventHandler(item.ViewChanged); 60 form.Show(this); 61 } 56 62 } 57 63 } 58 64 59 65 public override void CloseView(IView view) { 60 DocumentForm documentForm = this.OwnedForms.Cast<DocumentForm>().Where(df => df.View == view).Single(); 61 documentForm.Close(); 66 DocumentForm documentForm = FindForm(view); 67 if (documentForm != null) 68 documentForm.Close(); 62 69 } 63 70 … … 79 86 base.ActiveView = ((DocumentForm)sender).View; 80 87 } 88 89 protected DocumentForm FindForm(IView view) { 90 IEnumerable<DocumentForm> forms = this.OwnedForms.Cast<DocumentForm>().Where(df => df.View == view); 91 if (forms.Count() == 1) 92 return forms.Single(); 93 return null; 94 } 81 95 } 82 96 }
Note: See TracChangeset
for help on using the changeset viewer.