Changeset 6550
- Timestamp:
- 07/08/11 10:03:44 (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
r6526 r6550 172 172 this.treeView.BeforeLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(treeView_BeforeLabelEdit); 173 173 this.treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.optimizerTreeView_ItemDrag); 174 this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this. optimizerTreeview_NodeMouseClick);175 this.treeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this. optimizerTreeView_NodeMouseDoubleClick);174 this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeview_NodeMouseClick); 175 this.treeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_NodeMouseDoubleClick); 176 176 this.treeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.optimizerTreeView_DragDrop); 177 177 this.treeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.optimizerTreeView_DragEnter); 178 178 this.treeView.DragOver += new System.Windows.Forms.DragEventHandler(this.optimizerTreeView_DragOver); 179 this.treeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this. optimizerTreeView_KeyDown);180 this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this. optimizerTreeView_MouseDown);181 this.treeView.RightClick += new System.EventHandler( optimizerTreeView_RightClick);179 this.treeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView_KeyDown); 180 this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown); 181 this.treeView.RightClick += new System.EventHandler(treeView_RightClick); 182 182 // 183 183 // imageList -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.cs
r6549 r6550 583 583 584 584 #region control events 585 private void optimizerTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) {585 private void treeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { 586 586 if (rightClickOccured) return; 587 587 if (e.X < e.Node.Bounds.Left || e.X > e.Node.Bounds.Right) return; … … 590 590 MainFormManager.MainForm.ShowContent(optimizer); 591 591 } 592 private void optimizerTreeview_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) {592 private void treeview_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { 593 593 if (e.X < e.Node.Bounds.Left || e.X > e.Node.Bounds.Right) return; 594 594 treeView.SelectedNode = e.Node; … … 596 596 SetEnabledStateOfControls(); 597 597 } 598 private void optimizerTreeView_MouseDown(object sender, MouseEventArgs e) {598 private void treeView_MouseDown(object sender, MouseEventArgs e) { 599 599 // enables deselection of treeNodes 600 600 if (e.Button != MouseButtons.Right) rightClickOccured = false; … … 610 610 611 611 612 private void optimizerTreeView_KeyDown(object sender, KeyEventArgs e) { 613 if (ReadOnly) return; 614 if (e.KeyCode != Keys.Delete) return; 612 private void treeView_KeyDown(object sender, KeyEventArgs e) { 613 if (Locked || ReadOnly) return; 615 614 if (treeView.SelectedNode == null) return; 616 if (!(treeView.SelectedNode.Tag is I Optimizer)) return;615 if (!(treeView.SelectedNode.Tag is INamedItem)) return; 617 616 618 617 var treeNode = treeView.SelectedNode; 619 var optimizer = (IOptimizer)treeNode.Tag; 620 621 if (treeNode.Parent == null) 622 Content.Optimizers.Remove(optimizer); 623 else { 624 var batchRun = treeNode.Parent.Tag as BatchRun; 625 var experiment = treeNode.Parent.Tag as Experiment; 626 if (batchRun != null) batchRun.Optimizer = null; 627 else if (experiment != null) experiment.Optimizers.Remove(optimizer); 628 else throw new NotSupportedException("Handling for specific type not implemented" + treeView.SelectedNode.Tag.GetType()); 629 } 630 SetEnabledStateOfControls(); 631 UpdateDetailsViewHost(); 632 RebuildImageList(); 618 var namedItem = (NamedItem)treeNode.Tag; 619 var optimizer = namedItem as IOptimizer; 620 621 if (e.KeyCode == Keys.F2 && !treeNode.IsEditing) { 622 treeNode.BeginEdit(); 623 return; 624 } 625 626 if (e.KeyCode == Keys.Delete && optimizer != null) { 627 if (treeNode.Parent == null) 628 Content.Optimizers.Remove(optimizer); 629 else { 630 var batchRun = treeNode.Parent.Tag as BatchRun; 631 var experiment = treeNode.Parent.Tag as Experiment; 632 if (batchRun != null) batchRun.Optimizer = null; 633 else if (experiment != null) experiment.Optimizers.Remove(optimizer); 634 else throw new NotSupportedException("Handling for specific type not implemented" + treeView.SelectedNode.Tag.GetType()); 635 } 636 SetEnabledStateOfControls(); 637 UpdateDetailsViewHost(); 638 RebuildImageList(); 639 } 633 640 } 634 641 635 642 private bool rightClickOccured = true; 636 643 private TreeNode toolStripMenuNode = null; 637 private void optimizerTreeView_RightClick(object sender, EventArgs e) {644 private void treeView_RightClick(object sender, EventArgs e) { 638 645 rightClickOccured = true; 639 646 Point coordinates = treeView.PointToClient(Cursor.Position); … … 656 663 } 657 664 658 private void ExpandToolStripMenuItem_Click(object sender, EventArgs e) {659 if (toolStripMenuNode != null) toolStripMenuNode.ExpandAll();660 }661 private void CollapseToolStripMenuItem_Click(object sender, EventArgs e) {662 if (toolStripMenuNode != null) toolStripMenuNode.Collapse();663 }664 private void EditNodeLabelToolStripMenuItem_Click(object sender, EventArgs e) {665 if (toolStripMenuNode != null) {666 if (!toolStripMenuNode.IsEditing) toolStripMenuNode.BeginEdit();667 }668 }669 670 671 665 private void treeView_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) { 672 666 if (Locked) e.CancelEdit = true; 673 667 if (ReadOnly) e.CancelEdit = true; 674 668 if (e.Node.Tag == null) e.CancelEdit = true; 675 if (!(e.Node.Tag is NamedItem)) e.CancelEdit = true; 669 var namedItem = e.Node.Tag as INamedItem; 670 if (namedItem == null) e.CancelEdit = true; 671 else if (!namedItem.CanChangeName) e.CancelEdit = true; 676 672 } 677 673 private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { 678 674 if (e.Label == null) return; 679 680 675 e.Node.EndEdit(false); 681 676 var namedItem = (INamedItem)e.Node.Tag; 682 677 namedItem.Name = e.Label; 678 } 679 680 private void ExpandToolStripMenuItem_Click(object sender, EventArgs e) { 681 if (toolStripMenuNode != null) toolStripMenuNode.ExpandAll(); 682 } 683 private void CollapseToolStripMenuItem_Click(object sender, EventArgs e) { 684 if (toolStripMenuNode != null) toolStripMenuNode.Collapse(); 685 } 686 private void EditNodeLabelToolStripMenuItem_Click(object sender, EventArgs e) { 687 if (toolStripMenuNode != null) { 688 if (!toolStripMenuNode.IsEditing) toolStripMenuNode.BeginEdit(); 689 } 683 690 } 684 691
Note: See TracChangeset
for help on using the changeset viewer.