Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6573 for trunk


Ignore:
Timestamp:
07/18/11 16:24:20 (13 years ago)
Author:
mkommend
Message:

#1587: Updated ViewHost after node selection with arrow keys and handled item move operations more efficiently.

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

    r6550 r6573  
    171171      this.treeView.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(treeView_AfterLabelEdit);
    172172      this.treeView.BeforeLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(treeView_BeforeLabelEdit);
     173      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeView_AfterSelect);
    173174      this.treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.optimizerTreeView_ItemDrag);
    174175      this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeview_NodeMouseClick);
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.cs

    r6552 r6573  
    265265
    266266      foreach (TreeNodeCollection parentNode in parentNodes) {
    267         //get all effected child nodes
    268         foreach (TreeNode childNode in parentNode.OfType<TreeNode>()
    269           .Where(n => e.OldItems.Select(x => x.Value).Contains((IOptimizer)n.Tag)).ToList()) {
    270           DisposeTreeNode(childNode);
    271           childNode.Remove();
    272         }
    273 
    274         foreach (var childOptimizer in e.Items) {
    275           TreeNode childNode = CreateTreeNode(childOptimizer.Value);
    276           UpdateChildTreeNodes(childNode.Nodes, childOptimizer.Value);
    277           childNode.ExpandAll();
    278           parentNode.Insert(childOptimizer.Index, childNode);
    279         }
    280       }
    281       RebuildImageList();
    282       UpdateDetailsViewHost();
     267        var backup = parentNode.OfType<TreeNode>().ToList();
     268        foreach (var indexedItem in e.Items) {
     269          var node = backup.Where(n => n.Tag == indexedItem.Value).First();
     270          node.Remove();
     271          parentNode.Insert(indexedItem.Index, node);
     272        }
     273      }
    283274    }
    284275    private void Optimizers_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
     
    640631    }
    641632
     633
     634    private void treeView_AfterSelect(object sender, TreeViewEventArgs e) {
     635      if (e.Action == TreeViewAction.ByKeyboard) {
     636        UpdateDetailsViewHost();
     637        //NOTE: necessary because algorithm view steals the focus
     638        treeView.Focus();
     639      }
     640    }
     641
    642642    private bool rightClickOccured = true;
    643643    private TreeNode toolStripMenuNode = null;
     
    736736      else experiment = (Experiment)treeView.SelectedNode.Parent.Tag;
    737737
     738      var selectedNode = treeView.SelectedNode;
    738739      int index = treeView.SelectedNode.Index;
    739740      experiment.Optimizers.Reverse(index - 1, 2);
    740       treeView.SelectedNode = treeNodeTagMapping[optimizer].First();
     741      treeView.SelectedNode = selectedNode;
    741742      SetEnabledStateOfControls();
    742       UpdateDetailsViewHost();
    743       RebuildImageList();
    744743    }
    745744    private void moveDownButton_Click(object sender, EventArgs e) {
     
    749748      else experiment = (Experiment)treeView.SelectedNode.Parent.Tag;
    750749
     750      var selectedNode = treeView.SelectedNode;
    751751      int index = treeView.SelectedNode.Index;
    752752      experiment.Optimizers.Reverse(index, 2);
    753       treeView.SelectedNode = treeNodeTagMapping[optimizer].First();
     753      treeView.SelectedNode = selectedNode;
    754754      SetEnabledStateOfControls();
    755       UpdateDetailsViewHost();
    756       RebuildImageList();
    757755    }
    758756
     
    885883      var topLevelNodes = treeView.Nodes.OfType<TreeNode>().ToArray();
    886884      var nodes = IterateTreeNodes().ToList();
     885      var selectedNode = treeView.SelectedNode;
    887886      treeView.Nodes.Clear();
    888887
     
    894893      }
    895894      treeView.Nodes.AddRange(topLevelNodes);
     895      treeView.SelectedNode = selectedNode;
    896896      treeView.EndUpdate();
    897897    }
Note: See TracChangeset for help on using the changeset viewer.