Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/14/15 15:21:47 (8 years ago)
Author:
pfleck
Message:

#1235 Added a context menu to the DockForm to close (this, all, all but this) and clone the item of the current tab.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/DockForm.cs

    r12012 r13458  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using System.Windows.Forms;
     26using HeuristicLab.Common;
    2427using WeifenLuo.WinFormsUI.Docking;
    2528
     
    111114    }
    112115    #endregion
     116
     117    #region Context Menu Events
     118    private void closeToolStripMenuItem_Click(object sender, EventArgs e) {
     119      Close();
     120    }
     121    private void closeAllToolStripMenuItem_Click(object sender, EventArgs e) {
     122      foreach (var dockForm in CurrentDockForms.ToList()) {
     123        dockForm.Close();
     124      }
     125    }
     126    private void closeAllButThisToolStripMenuItem_Click(object sender, EventArgs e) {
     127      foreach (var dockForm in CurrentDockForms.Except(this.ToEnumerable()).ToList()) {
     128        dockForm.Close();
     129      }
     130    }
     131    private IEnumerable<DockForm> CurrentDockForms {
     132      get {
     133        return DockPanel.ActivePane.IsActiveDocumentPane
     134            ? DockPanel.Documents.OfType<DockForm>()
     135            : DockPanel.ActivePane.Contents.OfType<DockForm>();
     136        // ActivePane.Contents contains all dockforms if ActivePane is the main DocumentPane
     137      }
     138    }
     139
     140    private void cloneToolStripMenuItem_Click(object sender, EventArgs e) {
     141      var contentView = View as IContentView;
     142      if (contentView == null) return;
     143
     144      var cloneable = contentView.Content as IDeepCloneable;
     145      if (cloneable == null) return;
     146
     147      var clone = (IContent)cloneable.Clone();
     148      MainFormManager.MainForm.ShowContent(clone);
     149    }
     150    #endregion
    113151  }
    114152}
Note: See TracChangeset for help on using the changeset viewer.