Changeset 6517 for trunk/sources
- Timestamp:
- 07/06/11 17:01:30 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.Designer.cs
r6496 r6517 34 34 private void InitializeComponent() { 35 35 this.components = new System.ComponentModel.Container(); 36 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExperimentTreeView)); 36 37 this.optimizersGroupBox = new System.Windows.Forms.GroupBox(); 37 38 this.splitContainer = new System.Windows.Forms.SplitContainer(); … … 41 42 this.moveDownButton = new System.Windows.Forms.Button(); 42 43 this.addButton = new System.Windows.Forms.Button(); 43 this.optimizerTreeView = new System.Windows.Forms.TreeView();44 this.optimizerTreeView = new HeuristicLab.Optimization.Views.ExperimentTreeView.CustomTreeView(); 44 45 this.imageList = new System.Windows.Forms.ImageList(this.components); 45 46 this.detailsGroupBox = new System.Windows.Forms.GroupBox(); 46 47 this.detailsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 48 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 49 this.ExpandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 50 this.CollapseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 47 51 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 48 52 this.optimizersGroupBox.SuspendLayout(); … … 52 56 this.splitContainer.SuspendLayout(); 53 57 this.detailsGroupBox.SuspendLayout(); 58 this.contextMenuStrip.SuspendLayout(); 54 59 this.SuspendLayout(); 55 60 // … … 163 168 this.optimizerTreeView.TabIndex = 10; 164 169 this.optimizerTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.optimizerTreeView_ItemDrag); 170 this.optimizerTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.optimizerTreeview_NodeMouseClick); 171 this.optimizerTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.optimizerTreeView_NodeMouseDoubleClick); 165 172 this.optimizerTreeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.optimizerTreeView_DragDrop); 166 173 this.optimizerTreeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.optimizerTreeView_DragEnter); … … 168 175 this.optimizerTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.optimizerTreeView_KeyDown); 169 176 this.optimizerTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.optimizerTreeView_MouseDown); 170 this.optimizerTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.optimizerTreeview_NodeMouseClick); 171 this.optimizerTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(optimizerTreeView_NodeMouseDoubleClick); 177 this.optimizerTreeView.RightClick += new System.EventHandler(optimizerTreeView_RightClick); 172 178 // 173 179 // imageList … … 206 212 this.detailsViewHost.ViewType = null; 207 213 // 214 // contextMenuStrip 215 // 216 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 217 this.ExpandToolStripMenuItem, 218 this.CollapseToolStripMenuItem}); 219 this.contextMenuStrip.Name = "contextMenuStrip"; 220 this.contextMenuStrip.Size = new System.Drawing.Size(120, 48); 221 // 222 // ExpandToolStripMenuItem 223 // 224 this.ExpandToolStripMenuItem.Name = "ExpandToolStripMenuItem"; 225 this.ExpandToolStripMenuItem.Size = new System.Drawing.Size(119, 22); 226 this.ExpandToolStripMenuItem.Text = "Expand"; 227 this.ExpandToolStripMenuItem.Click += new System.EventHandler(this.ExpandToolStripMenuItem_Click); 228 // 229 // CollapseToolStripMenuItem 230 // 231 this.CollapseToolStripMenuItem.Name = "CollapseToolStripMenuItem"; 232 this.CollapseToolStripMenuItem.Size = new System.Drawing.Size(119, 22); 233 this.CollapseToolStripMenuItem.Text = "Collapse"; 234 this.CollapseToolStripMenuItem.Click += new System.EventHandler(this.CollapseToolStripMenuItem_Click); 235 // 208 236 // ExperimentTreeView 209 237 // … … 219 247 this.splitContainer.ResumeLayout(false); 220 248 this.detailsGroupBox.ResumeLayout(false); 249 this.contextMenuStrip.ResumeLayout(false); 221 250 this.ResumeLayout(false); 222 251 … … 226 255 private System.Windows.Forms.GroupBox optimizersGroupBox; 227 256 private System.Windows.Forms.SplitContainer splitContainer; 228 private System.Windows.Forms.TreeView optimizerTreeView;257 private HeuristicLab.Optimization.Views.ExperimentTreeView.CustomTreeView optimizerTreeView; 229 258 private System.Windows.Forms.GroupBox detailsGroupBox; 230 259 private MainForm.WindowsForms.ViewHost detailsViewHost; … … 236 265 private System.Windows.Forms.Button addButton; 237 266 private System.Windows.Forms.ImageList imageList; 267 private System.Windows.Forms.ContextMenuStrip contextMenuStrip; 268 private System.Windows.Forms.ToolStripMenuItem ExpandToolStripMenuItem; 269 private System.Windows.Forms.ToolStripMenuItem CollapseToolStripMenuItem; 238 270 239 271 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.cs
r6513 r6517 498 498 #region control events 499 499 private void optimizerTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { 500 if (rightClickOccured) return; 500 501 if (e.X < e.Node.Bounds.Left || e.X > e.Node.Bounds.Right) return; 501 optimizerTreeView.SelectedNode.Toggle();502 e.Node.Toggle(); 502 503 IOptimizer optimizer = (IOptimizer)e.Node.Tag; 503 504 MainFormManager.MainForm.ShowContent(optimizer); … … 511 512 private void optimizerTreeView_MouseDown(object sender, MouseEventArgs e) { 512 513 // enables deselection of treeNodes 513 if (e.Button != System.Windows.Forms.MouseButtons.Left) return;514 if (e.Button != MouseButtons.Right) rightClickOccured = false; 514 515 if (optimizerTreeView.SelectedNode == null) return; 515 516 Point coordinates = new Point(e.X, e.Y); … … 522 523 } 523 524 525 524 526 private void optimizerTreeView_KeyDown(object sender, KeyEventArgs e) { 525 527 if (ReadOnly) return; … … 542 544 UpdateDetailsViewHost(); 543 545 RebuildImageList(); 546 } 547 548 private bool rightClickOccured = true; 549 private TreeNode toolStripMenuNode = null; 550 private void optimizerTreeView_RightClick(object sender, EventArgs e) { 551 rightClickOccured = true; 552 Point coordinates = optimizerTreeView.PointToClient(Cursor.Position); 553 toolStripMenuNode = optimizerTreeView.GetNodeAt(coordinates); 554 555 if (toolStripMenuNode != null && coordinates.X >= toolStripMenuNode.Bounds.Left && coordinates.X <= toolStripMenuNode.Bounds.Right) { 556 optimizerTreeView.SelectedNode = toolStripMenuNode; 557 detailsViewHost.Content = (IContent)toolStripMenuNode.Tag; 558 SetEnabledStateOfControls(); 559 560 ExpandToolStripMenuItem.Enabled = !toolStripMenuNode.IsExpanded && toolStripMenuNode.Nodes.Count > 0; 561 ExpandToolStripMenuItem.Visible = !toolStripMenuNode.IsExpanded && toolStripMenuNode.Nodes.Count > 0; 562 CollapseToolStripMenuItem.Enabled = toolStripMenuNode.IsExpanded; 563 CollapseToolStripMenuItem.Visible = toolStripMenuNode.IsExpanded; 564 if (contextMenuStrip.Items.Cast<ToolStripMenuItem>().Any(item => item.Enabled)) 565 contextMenuStrip.Show(Cursor.Position); 566 } 567 } 568 569 private void ExpandToolStripMenuItem_Click(object sender, EventArgs e) { 570 if (toolStripMenuNode != null) toolStripMenuNode.ExpandAll(); 571 } 572 private void CollapseToolStripMenuItem_Click(object sender, EventArgs e) { 573 if (toolStripMenuNode != null) toolStripMenuNode.Collapse(); 544 574 } 545 575 … … 689 719 } 690 720 #endregion 721 722 723 public sealed class CustomTreeView : System.Windows.Forms.TreeView { 724 protected override void WndProc(ref System.Windows.Forms.Message m) { 725 const int WM_RBUTTONDOWN = 0x204; 726 if (m.Msg == WM_RBUTTONDOWN) { 727 //Raise your custom event right click event to prevent node highlighting 728 OnRightClick(); 729 return; 730 } 731 base.WndProc(ref m); 732 } 733 734 public event EventHandler RightClick; 735 private void OnRightClick() { 736 var handler = RightClick; 737 if (handler != null) RightClick(this, EventArgs.Empty); 738 } 739 } 691 740 } 692 741 }
Note: See TracChangeset
for help on using the changeset viewer.