Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6485


Ignore:
Timestamp:
06/27/11 16:28:33 (13 years ago)
Author:
mkommend
Message:

#1555: Added remove by keystroke functionality and refactored the code.

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

    r6471 r6485  
    3434    private void InitializeComponent() {
    3535      this.components = new System.ComponentModel.Container();
    36       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExperimentTreeView));
    3736      this.optimizersGroupBox = new System.Windows.Forms.GroupBox();
    3837      this.splitContainer = new System.Windows.Forms.SplitContainer();
     
    167166      this.optimizerTreeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.optimizerTreeView_DragEnter);
    168167      this.optimizerTreeView.DragOver += new System.Windows.Forms.DragEventHandler(this.optimizerTreeView_DragOver);
     168      this.optimizerTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.optimizerTreeView_KeyDown);
    169169      this.optimizerTreeView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.optimizerTreeview_MouseClick);
    170170      this.optimizerTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.optimizerTreeView_MouseDown);
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.cs

    r6471 r6485  
    162162      }
    163163      RebuildImageList();
     164      UpdateDetailsViewHost();
    164165    }
    165166
     
    219220      }
    220221      RebuildImageList();
     222      UpdateDetailsViewHost();
    221223    }
    222224    private void Optimizers_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
     
    242244      }
    243245      RebuildImageList();
     246      UpdateDetailsViewHost();
    244247    }
    245248    private void Optimizers_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
     
    270273      }
    271274      RebuildImageList();
     275      UpdateDetailsViewHost();
    272276    }
    273277    private void Optimizers_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
     
    298302      }
    299303      RebuildImageList();
     304      UpdateDetailsViewHost();
    300305    }
    301306
     
    382387            else throw new NotSupportedException("Handling for specific type not implemented" + parentOptimizer.GetType());
    383388          }
    384           if (optimizerTreeView.SelectedNode != null)
    385             detailsViewHost.Content = (IOptimizer)optimizerTreeView.SelectedNode.Tag;
    386389          SetEnabledStateOfControls();
     390          UpdateDetailsViewHost();
    387391          RebuildImageList();
    388392        }
     
    494498    }
    495499
     500    private void optimizerTreeView_KeyDown(object sender, KeyEventArgs e) {
     501      if (ReadOnly) return;
     502      if (optimizerTreeView.SelectedNode == null) return;
     503      if (e.KeyCode != Keys.Delete) return;
     504
     505      var treeNode = optimizerTreeView.SelectedNode;
     506      var optimizer = (IOptimizer)treeNode.Tag;
     507
     508      if (treeNode.Parent == null)
     509        Content.Optimizers.Remove(optimizer);
     510      else {
     511        var batchRun = treeNode.Parent.Tag as BatchRun;
     512        var experiment = treeNode.Parent.Tag as Experiment;
     513        if (batchRun != null) batchRun.Optimizer = null;
     514        else if (experiment != null) experiment.Optimizers.Remove(optimizer);
     515        else throw new NotSupportedException("Handling for specific type not implemented" + optimizerTreeView.SelectedNode.Tag.GetType());
     516      }
     517      SetEnabledStateOfControls();
     518      UpdateDetailsViewHost();
     519      RebuildImageList();
     520    }
     521
    496522    private void addButton_Click(object sender, System.EventArgs e) {
    497523      if (typeSelectorDialog == null) {
     
    526552      else experiment = (Experiment)optimizerTreeView.SelectedNode.Parent.Tag;
    527553
    528       detailsViewHost.SuspendRepaint();
    529554      int index = optimizerTreeView.SelectedNode.Index;
    530555      experiment.Optimizers.Reverse(index - 1, 2);
    531556      optimizerTreeView.SelectedNode = optimizerTreeViewMapping[optimizer].First();
    532       detailsViewHost.Content = (IOptimizer)optimizerTreeView.SelectedNode.Tag;
    533557      SetEnabledStateOfControls();
    534       detailsViewHost.ResumeRepaint(true);
     558      UpdateDetailsViewHost();
     559      RebuildImageList();
    535560    }
    536561    private void moveDownButton_Click(object sender, EventArgs e) {
     
    543568      experiment.Optimizers.Reverse(index, 2);
    544569      optimizerTreeView.SelectedNode = optimizerTreeViewMapping[optimizer].First();
    545       detailsViewHost.Content = (IOptimizer)optimizerTreeView.SelectedNode.Tag;
    546570      SetEnabledStateOfControls();
    547     }
    548 
    549     private void removeButton_Click(object sender, System.EventArgs e) {
     571      UpdateDetailsViewHost();
     572      RebuildImageList();
     573    }
     574
     575    private void removeButton_Click(object sender, EventArgs e) {
    550576      var treeNode = optimizerTreeView.SelectedNode;
    551577      var optimizer = (IOptimizer)treeNode.Tag;
     
    561587      }
    562588      SetEnabledStateOfControls();
    563       detailsViewHost.Content = (IOptimizer)optimizerTreeView.SelectedNode.Tag;
     589      UpdateDetailsViewHost();
     590      RebuildImageList();
    564591    }
    565592
     
    577604
    578605    #region helpers
     606    private void UpdateDetailsViewHost() {
     607      if (optimizerTreeView.SelectedNode != null)
     608        detailsViewHost.Content = (IOptimizer)optimizerTreeView.SelectedNode.Tag;
     609      else
     610        detailsViewHost.Content = null;
     611    }
     612
    579613    private TreeNode CreateTreeNode(IOptimizer optimizer) {
    580614      TreeNode node = new TreeNode(optimizer.ToString());
Note: See TracChangeset for help on using the changeset viewer.