Changeset 12400
- Timestamp:
- 05/26/15 14:12:02 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs
r12398 r12400 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Reflection; … … 397 398 searchTextBox.Focus(); 398 399 } 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 } 399 450 #endregion 400 451
Note: See TracChangeset
for help on using the changeset viewer.