Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13614


Ignore:
Timestamp:
02/09/16 10:26:09 (9 years ago)
Author:
pfleck
Message:

#1235

  • Clone menuitem is enabled only if view is not locked and content is deep cloneable.
  • Cloned item shows in same view as the original item.
  • Fixed possible NullReferenceException.
  • Fixed inconsistency which views were closed on "close all (but this)".
Location:
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms
Files:
2 edited

Legend:

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

    r13458 r13614  
    6666      this.contextMenuStrip.Name = "contextMenuStrip";
    6767      this.contextMenuStrip.Size = new System.Drawing.Size(167, 120);
     68      this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
    6869      //
    6970      // closeToolStripMenuItem
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/DockForm.cs

    r13458 r13614  
    116116
    117117    #region Context Menu Events
     118    private void contextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e) {
     119      var contentView = View as IContentView;
     120      var content = contentView != null ? contentView.Content : null;
     121
     122      cloneToolStripMenuItem.Enabled = contentView != null && !contentView.Locked && content is IDeepCloneable;
     123    }
     124
    118125    private void closeToolStripMenuItem_Click(object sender, EventArgs e) {
    119126      Close();
    120127    }
    121128    private void closeAllToolStripMenuItem_Click(object sender, EventArgs e) {
    122       foreach (var dockForm in CurrentDockForms.ToList()) {
     129      foreach (var dockForm in CurrentDockForms) {
    123130        dockForm.Close();
    124131      }
    125132    }
    126133    private void closeAllButThisToolStripMenuItem_Click(object sender, EventArgs e) {
    127       foreach (var dockForm in CurrentDockForms.Except(this.ToEnumerable()).ToList()) {
     134      foreach (var dockForm in CurrentDockForms.Except(this.ToEnumerable())) {
    128135        dockForm.Close();
    129136      }
     
    131138    private IEnumerable<DockForm> CurrentDockForms {
    132139      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
     140        var dockForms = Pane.Contents.OfType<DockForm>().Where(c => c.Pane == Pane); // Pane.Contents contains DockForms that are not placed on that pane
     141        return dockForms.ToList(); // .ToList() necessary because closing a DockForm removes it from the Content collection
    137142      }
    138143    }
     
    146151
    147152      var clone = (IContent)cloneable.Clone();
    148       MainFormManager.MainForm.ShowContent(clone);
     153
     154      var viewHost = contentView as ViewHost;
     155      var newView = viewHost != null ? viewHost.ViewType : contentView.GetType();
     156      MainFormManager.MainForm.ShowContent(clone, newView);
    149157    }
    150158    #endregion
Note: See TracChangeset for help on using the changeset viewer.