Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12400 for trunk/sources


Ignore:
Timestamp:
05/26/15 14:12:02 (10 years ago)
Author:
pfleck
Message:

#2387 Forgot to commit a file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs

    r12398 r12400  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using System.Linq;
    2526using System.Reflection;
     
    397398      searchTextBox.Focus();
    398399    }
     400
     401    private TreeNode toolStripMenuNode = null;
     402    private void typesTreeView_MouseDown(object sender, MouseEventArgs e) {
     403      if (e.Button == MouseButtons.Right) {
     404        Point coordinates = typesTreeView.PointToClient(Cursor.Position);
     405        toolStripMenuNode = typesTreeView.GetNodeAt(coordinates);
     406
     407        if (toolStripMenuNode != null && coordinates.X >= toolStripMenuNode.Bounds.Left &&
     408            coordinates.X <= toolStripMenuNode.Bounds.Right) {
     409          typesTreeView.SelectedNode = toolStripMenuNode;
     410
     411          expandToolStripMenuItem.Enabled =
     412            expandToolStripMenuItem.Visible = !toolStripMenuNode.IsExpanded && toolStripMenuNode.Nodes.Count > 0;
     413          collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = toolStripMenuNode.IsExpanded;
     414        } else {
     415          expandToolStripMenuItem.Enabled = expandToolStripMenuItem.Visible = false;
     416          collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = false;
     417        }
     418        expandAllToolStripMenuItem.Enabled =
     419          expandAllToolStripMenuItem.Visible =
     420            !typesTreeView.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x));
     421        collapseAllToolStripMenuItem.Enabled =
     422          collapseAllToolStripMenuItem.Visible = typesTreeView.Nodes.OfType<TreeNode>().Any(x => x.IsExpanded);
     423        if (contextMenuStrip.Items.Cast<ToolStripMenuItem>().Any(item => item.Enabled))
     424          contextMenuStrip.Show(Cursor.Position);
     425      }
     426    }
     427    private bool TreeNodeIsFullyExpanded(TreeNode node) {
     428      return (node.Nodes.Count == 0) || (node.IsExpanded && node.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x)));
     429    }
     430    private void expandToolStripMenuItem_Click(object sender, EventArgs e) {
     431      typesTreeView.BeginUpdate();
     432      if (toolStripMenuNode != null) toolStripMenuNode.ExpandAll();
     433      typesTreeView.EndUpdate();
     434    }
     435    private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) {
     436      typesTreeView.BeginUpdate();
     437      typesTreeView.ExpandAll();
     438      typesTreeView.EndUpdate();
     439    }
     440    private void collapseToolStripMenuItem_Click(object sender, EventArgs e) {
     441      typesTreeView.BeginUpdate();
     442      if (toolStripMenuNode != null) toolStripMenuNode.Collapse();
     443      typesTreeView.EndUpdate();
     444    }
     445    private void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) {
     446      typesTreeView.BeginUpdate();
     447      typesTreeView.CollapseAll();
     448      typesTreeView.EndUpdate();
     449    }
    399450    #endregion
    400451
Note: See TracChangeset for help on using the changeset viewer.