Changeset 14029 for branches/crossvalidation-2434/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/DockForm.cs
- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/DockForm.cs
r12012 r14029 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using System.Windows.Forms; 26 using HeuristicLab.Common; 24 27 using WeifenLuo.WinFormsUI.Docking; 25 28 … … 29 32 /// </summary> 30 33 internal partial class DockForm : DockContent { 31 public DockForm(IView view ) {34 public DockForm(IView view, bool allowContextMenu) { 32 35 InitializeComponent(); 33 36 this.view = view; 37 this.allowContextMenu = allowContextMenu; 38 34 39 if (view != null) { 35 40 if (view is UserControl) { … … 87 92 get { return this.view; } 88 93 } 94 private readonly bool allowContextMenu; 89 95 90 96 private void UpdateText() { … … 111 117 } 112 118 #endregion 119 120 #region Context Menu Events 121 private void contextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e) { 122 if (!allowContextMenu) { 123 e.Cancel = true; 124 return; 125 } 126 127 var contentView = View as IContentView; 128 var content = contentView != null ? contentView.Content : null; 129 130 cloneToolStripMenuItem.Enabled = contentView != null && !contentView.Locked && content is IDeepCloneable; 131 } 132 133 private void closeToolStripMenuItem_Click(object sender, EventArgs e) { 134 Close(); 135 } 136 private void closeAllToolStripMenuItem_Click(object sender, EventArgs e) { 137 foreach (var dockForm in CurrentDockForms) { 138 dockForm.Close(); 139 } 140 } 141 private void closeAllButThisToolStripMenuItem_Click(object sender, EventArgs e) { 142 foreach (var dockForm in CurrentDockForms.Except(this.ToEnumerable())) { 143 dockForm.Close(); 144 } 145 } 146 private IEnumerable<DockForm> CurrentDockForms { 147 get { 148 var dockForms = Pane.Contents.OfType<DockForm>().Where(c => c.Pane == Pane); // Pane.Contents contains DockForms that are not placed on that pane 149 return dockForms.ToList(); // .ToList() necessary because closing a DockForm removes it from the Content collection 150 } 151 } 152 153 private void cloneToolStripMenuItem_Click(object sender, EventArgs e) { 154 var contentView = View as IContentView; 155 if (contentView == null) return; 156 157 var cloneable = contentView.Content as IDeepCloneable; 158 if (cloneable == null) return; 159 160 var clone = (IContent)cloneable.Clone(); 161 162 var viewHost = contentView as ViewHost; 163 var newView = viewHost != null ? viewHost.ViewType : contentView.GetType(); 164 MainFormManager.MainForm.ShowContent(clone, newView); 165 } 166 #endregion 113 167 } 114 168 }
Note: See TracChangeset
for help on using the changeset viewer.