Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13433


Ignore:
Timestamp:
12/02/15 14:32:33 (8 years ago)
Author:
pfleck
Message:

#2494

  • Now, also categories are searched for. If a category matches, all items and subcategories within are displayed.
  • Fixed an issue that the wrong item was preselected (eg NSGA instead of GA).
  • The dialog does not save the previous selected type anymore when closing and reopening the dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/NewItemDialog.cs

    r12649 r13433  
    9393    }
    9494
     95    #region Create Tree
    9596    private TreeNode CreateCategoryTree(IEnumerable<IGrouping<string, Type>> categories) {
    9697      imageList.Images.Add(VSImageLibrary.Class);      // default icon
     
    176177      return itemNode;
    177178    }
     179    #endregion
    178180
    179181    private void NewItemDialog_Shown(object sender, EventArgs e) {
    180       searchTextBox.Text = string.Empty;
    181       searchTextBox.Focus();
    182       SelectedType = null;
    183       typesTreeView.SelectedNode = null;
    184       UpdateDescription();
    185 
    186       foreach (TreeNode node in typesTreeView.Nodes)
    187         node.Expand();
    188       typesTreeView.Nodes[0].EnsureVisible();
     182      Reset();
    189183    }
    190184
     
    221215        // select first item
    222216        typesTreeView.BeginUpdate();
     217        typesTreeView.ExpandAll();
    223218        var firstNode = FirstVisibleNode;
    224219        while (firstNode != null && !(firstNode.Tag is Type))
     
    243238    private bool FilterNode(TreeNode node, string[] searchTokens) {
    244239      if (node.Tag is string) { // Category node
    245         int i = 0;
    246         while (i < node.Nodes.Count) {
    247           bool remove = FilterNode(node.Nodes[i], searchTokens);
    248           if (remove)
    249             node.Nodes.RemoveAt(i);
    250           else i++;
     240        var text = node.Text;
     241        if (searchTokens.Any(token => !text.ToLower().Contains(token))) {
     242          int i = 0;
     243          while (i < node.Nodes.Count) {
     244            bool remove = FilterNode(node.Nodes[i], searchTokens);
     245            if (remove)
     246              node.Nodes.RemoveAt(i);
     247            else i++;
     248          }
    251249        }
    252250        return node.Nodes.Count == 0;
    253       } if (node.Tag is Type) { // Type node
     251      }
     252      if (node.Tag is Type) { // Type node
    254253        var text = node.Text;
    255254        if (searchTokens.Any(searchToken => !text.ToLower().Contains(searchToken))) {
     
    308307    protected virtual void searchTextBox_TextChanged(object sender, EventArgs e) {
    309308      Filter(searchTextBox.Text);
     309      if (string.IsNullOrWhiteSpace(searchTextBox.Text))
     310        Reset();
    310311    }
    311312
     
    333334    private void SetTreeNodeVisibility() {
    334335      TreeNode selectedNode = typesTreeView.SelectedNode;
    335       if (string.IsNullOrEmpty(currentSearchString) && (typesTreeView.Nodes.Count > 1)) {
     336      if (string.IsNullOrWhiteSpace(currentSearchString) && (typesTreeView.Nodes.Count > 1)) {
    336337        typesTreeView.CollapseAll();
    337338        if (selectedNode != null) typesTreeView.SelectedNode = selectedNode;
     
    339340        typesTreeView.ExpandAll();
    340341      }
    341       if (selectedNode != null) selectedNode.EnsureVisible();
     342      if (selectedNode != null) {
     343        typesTreeView.Nodes[0].EnsureVisible(); // scroll top first
     344        selectedNode.EnsureVisible();
     345      }
     346    }
     347    private void Reset() {
     348      searchTextBox.Text = string.Empty;
     349      searchTextBox.Focus();
     350      SelectedType = null;
     351      typesTreeView.SelectedNode = null;
     352      UpdateDescription();
     353
     354      typesTreeView.BeginUpdate();
     355      typesTreeView.CollapseAll();
     356      foreach (TreeNode node in typesTreeView.Nodes)
     357        node.Expand();
     358      typesTreeView.Nodes[0].EnsureVisible();
     359      typesTreeView.EndUpdate();
    342360    }
    343361    #endregion
Note: See TracChangeset for help on using the changeset viewer.