Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13883


Ignore:
Timestamp:
06/08/16 15:26:41 (8 years ago)
Author:
mkommend
Message:

#1235: Merged r13458,r13614,r13627,r13628 into stable.

Location:
stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/DockForm.Designer.cs

    r12009 r13883  
    3434    /// </summary>
    3535    private void InitializeComponent() {
     36      this.components = new System.ComponentModel.Container();
    3637      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DockForm));
    3738      this.viewPanel = new System.Windows.Forms.Panel();
     39      this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     40      this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     41      this.closeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     42      this.closeAllButThisToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     43      this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
     44      this.cloneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     45      this.contextMenuStrip.SuspendLayout();
    3846      this.SuspendLayout();
    3947      //
    4048      // viewPanel
    4149      //
    42       this.viewPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    43                   | System.Windows.Forms.AnchorStyles.Left)
    44                   | System.Windows.Forms.AnchorStyles.Right)));
     50      this.viewPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     51            | System.Windows.Forms.AnchorStyles.Left)
     52            | System.Windows.Forms.AnchorStyles.Right)));
    4553      this.viewPanel.Location = new System.Drawing.Point(12, 12);
    4654      this.viewPanel.Name = "viewPanel";
     
    4856      this.viewPanel.TabIndex = 0;
    4957      //
     58      // contextMenuStrip
     59      //
     60      this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     61            this.closeToolStripMenuItem,
     62            this.closeAllToolStripMenuItem,
     63            this.closeAllButThisToolStripMenuItem,
     64            this.toolStripSeparator1,
     65            this.cloneToolStripMenuItem});
     66      this.contextMenuStrip.Name = "contextMenuStrip";
     67      this.contextMenuStrip.Size = new System.Drawing.Size(167, 120);
     68      this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
     69      //
     70      // closeToolStripMenuItem
     71      //
     72      this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
     73      this.closeToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
     74      this.closeToolStripMenuItem.Text = "Close";
     75      this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
     76      //
     77      // closeAllToolStripMenuItem
     78      //
     79      this.closeAllToolStripMenuItem.Name = "closeAllToolStripMenuItem";
     80      this.closeAllToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
     81      this.closeAllToolStripMenuItem.Text = "Close All";
     82      this.closeAllToolStripMenuItem.Click += new System.EventHandler(this.closeAllToolStripMenuItem_Click);
     83      //
     84      // closeAllButThisToolStripMenuItem
     85      //
     86      this.closeAllButThisToolStripMenuItem.Name = "closeAllButThisToolStripMenuItem";
     87      this.closeAllButThisToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
     88      this.closeAllButThisToolStripMenuItem.Text = "Close All But This";
     89      this.closeAllButThisToolStripMenuItem.Click += new System.EventHandler(this.closeAllButThisToolStripMenuItem_Click);
     90      //
     91      // toolStripSeparator1
     92      //
     93      this.toolStripSeparator1.Name = "toolStripSeparator1";
     94      this.toolStripSeparator1.Size = new System.Drawing.Size(163, 6);
     95      //
     96      // cloneToolStripMenuItem
     97      //
     98      this.cloneToolStripMenuItem.Name = "cloneToolStripMenuItem";
     99      this.cloneToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
     100      this.cloneToolStripMenuItem.Text = "Create Copy";
     101      this.cloneToolStripMenuItem.Click += new System.EventHandler(this.cloneToolStripMenuItem_Click);
     102      //
    50103      // DockForm
    51104      //
    52       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    53105      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    54106      this.ClientSize = new System.Drawing.Size(632, 446);
     
    59111      this.ShowInTaskbar = false;
    60112      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
     113      this.TabPageContextMenuStrip = this.contextMenuStrip;
     114      this.contextMenuStrip.ResumeLayout(false);
    61115      this.ResumeLayout(false);
     116
    62117    }
    63118
     
    65120
    66121    private System.Windows.Forms.Panel viewPanel;
     122    private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
     123    private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
     124    private System.Windows.Forms.ToolStripMenuItem closeAllToolStripMenuItem;
     125    private System.Windows.Forms.ToolStripMenuItem closeAllButThisToolStripMenuItem;
     126    private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
     127    private System.Windows.Forms.ToolStripMenuItem cloneToolStripMenuItem;
    67128  }
    68129}
  • stable/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/DockForm.cs

    r12009 r13883  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using System.Windows.Forms;
     26using HeuristicLab.Common;
    2427using WeifenLuo.WinFormsUI.Docking;
    2528
     
    2932  /// </summary>
    3033  internal partial class DockForm : DockContent {
    31     public DockForm(IView view) {
     34    public DockForm(IView view, bool allowContextMenu) {
    3235      InitializeComponent();
    3336      this.view = view;
     37      this.allowContextMenu = allowContextMenu;
     38
    3439      if (view != null) {
    3540        if (view is UserControl) {
     
    8792      get { return this.view; }
    8893    }
     94    private readonly bool allowContextMenu;
    8995
    9096    private void UpdateText() {
     
    111117    }
    112118    #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
    113167  }
    114168}
  • stable/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/DockingMainForm.cs

    r12009 r13883  
    2525namespace HeuristicLab.MainForm.WindowsForms {
    2626  public partial class DockingMainForm : MainForm {
     27
     28    public bool AllowContexMenu { get; set; }
     29
    2730    public DockingMainForm()
    2831      : base() {
    2932      InitializeComponent();
     33      AllowContexMenu = true;
    3034    }
    3135    public DockingMainForm(Type userInterfaceItemType)
    3236      : base(userInterfaceItemType) {
    3337      InitializeComponent();
     38      AllowContexMenu = true;
    3439    }
    3540    public DockingMainForm(Type userInterfaceItemType, bool showContentInViewHost)
     
    6065
    6166    protected override Form CreateForm(IView view) {
    62       return new DockForm(view);
     67      return new DockForm(view, AllowContexMenu);
    6368    }
    6469
  • stable/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r13640 r13883  
    214214    }
    215215
    216     internal Form GetForm(IView view) {
     216    protected internal Form GetForm(IView view) {
    217217      if (views.ContainsKey(view))
    218218        return views[view];
Note: See TracChangeset for help on using the changeset viewer.