Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3528


Ignore:
Timestamp:
04/26/10 04:14:27 (15 years ago)
Author:
swagner
Message:

Implemented reviewers' comments (#893)

Location:
trunk/sources
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.Designer.cs

    r3248 r3528  
    3434      if (disposing) {
    3535        if (scopesTreeView.Nodes.Count > 0) {
    36           RemoveTreeNode(scopesTreeView.Nodes[0]);
     36          ClearTreeNode(scopesTreeView.Nodes[0]);
    3737        }
    3838        if (components != null) components.Dispose();
     
    7171      this.scopesTreeView.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.scopesTreeView_AfterCollapse);
    7272      this.scopesTreeView.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.scopesTreeView_BeforeExpand);
     73      this.scopesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.scopesTreeView_AfterSelect);
    7374      this.scopesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.scopesTreeView_MouseDown);
    7475      this.scopesTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.scopesTreeView_ItemDrag);
     
    111112                  | System.Windows.Forms.AnchorStyles.Right)));
    112113      this.variableCollectionView.Caption = "VariableCollection";
     114      this.variableCollectionView.Content = null;
    113115      this.variableCollectionView.Location = new System.Drawing.Point(3, 3);
    114116      this.variableCollectionView.Name = "variableCollectionView";
     117      this.variableCollectionView.ReadOnly = false;
    115118      this.variableCollectionView.Size = new System.Drawing.Size(394, 190);
    116119      this.variableCollectionView.TabIndex = 0;
  • trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.cs

    r3455 r3528  
    7474    protected override void OnContentChanged() {
    7575      base.OnContentChanged();
    76       if (scopesTreeView.Nodes.Count > 0) {
    77         RemoveTreeNode(scopesTreeView.Nodes[0]);
    78         scopesTreeView.Nodes.Clear();
    79       }
     76      if (scopesTreeView.Nodes.Count > 0)
     77        ClearTreeNode(scopesTreeView.Nodes[0]);
     78      scopesTreeView.Nodes.Clear();
    8079      variableCollectionView.Content = null;
    8180      Caption = "Scope";
    8281      if (Content != null) {
    83         Caption = Content.Name + " (" + Content.GetType().Name + ")";
     82        Caption = Content.Name + " (" + Content.ItemName + ")";
    8483        scopesTreeView.Nodes.Add(CreateTreeNode(Content));
    8584      }
     
    9796    }
    9897
     98    #region TreeNode Management
    9999    private TreeNode CreateTreeNode(IScope scope) {
    100100      TreeNode node = new TreeNode();
     
    104104      scopeNodeTable.Add(scope, node);
    105105      scope.NameChanged += new EventHandler(Scope_NameChanged);
     106      subScopesScopeTable.Add(scope.SubScopes, scope);
    106107      scope.SubScopes.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsAdded);
    107108      scope.SubScopes.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsRemoved);
     
    109110      scope.SubScopes.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsMoved);
    110111      scope.SubScopes.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);
    111       subScopesScopeTable.Add(scope.SubScopes, scope);
    112112      if (scope.SubScopes.Count > 0)
    113113        node.Nodes.Add(new TreeNode());
     
    115115    }
    116116
    117     private void RemoveTreeNode(TreeNode node) {
     117    private void ClearTreeNode(TreeNode node) {
     118      if (scopesTreeView.SelectedNode == node) {
     119        scopesTreeView.SelectedNode = null;
     120        UpdateVariables();
     121      }
     122
    118123      foreach (TreeNode child in node.Nodes)
    119         RemoveTreeNode(child);
     124        ClearTreeNode(child);
    120125
    121126      IScope scope = node.Tag as IScope;
    122127      if (scope != null) {
     128        scope.NameChanged -= new EventHandler(Scope_NameChanged);
    123129        scopeNodeTable.Remove(scope);
    124         scope.NameChanged -= new EventHandler(Scope_NameChanged);
    125130        scope.SubScopes.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsAdded);
    126131        scope.SubScopes.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsRemoved);
     
    131136      }
    132137    }
     138    #endregion
    133139
    134140    #region TreeView Events
     141    private void scopesTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
     142      UpdateVariables();
     143    }
    135144    private void scopesTreeView_MouseDown(object sender, MouseEventArgs e) {
    136145      TreeNode node = scopesTreeView.GetNodeAt(e.X, e.Y);
    137       if ((node != null) && (node.Tag is IScope)) {
    138         variableCollectionView.Content = ((IScope)node.Tag).Variables;
    139         variableCollectionView.Enabled = true;
    140       } else {
    141         variableCollectionView.Content = null;
    142         variableCollectionView.Enabled = false;
    143         if (node == null) scopesTreeView.SelectedNode = null;
    144       }
     146      scopesTreeView.SelectedNode = node;
     147      UpdateVariables();
    145148    }
    146149    private void scopesTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) {
     
    158161      if (node.Nodes.Count > 0) {
    159162        for (int i = 0; i < node.Nodes.Count; i++)
    160           RemoveTreeNode(node.Nodes[i]);
     163          ClearTreeNode(node.Nodes[i]);
    161164        node.Nodes.Clear();
    162165        node.Nodes.Add(new TreeNode());
     
    177180    #endregion
    178181
    179     #region Scope Events
     182    #region Content Events
    180183    private void Scope_NameChanged(object sender, EventArgs e) {
    181184      if (InvokeRequired)
     
    186189      }
    187190    }
    188     #endregion
    189 
    190     #region SubScopes Events
    191191    private void SubScopes_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IScope>> e) {
    192192      if (InvokeRequired)
     
    195195        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
    196196        TreeNode parentNode = scopeNodeTable[parentScope];
     197        scopesTreeView.BeginUpdate();
    197198        if (parentNode.IsExpanded) {
    198199          foreach (IndexedItem<IScope> item in e.Items) {
     
    203204          parentNode.Nodes.Add(new TreeNode());
    204205        }
     206        scopesTreeView.EndUpdate();
    205207      }
    206208    }
     
    211213        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
    212214        TreeNode parentNode = scopeNodeTable[parentScope];
     215        scopesTreeView.BeginUpdate();
    213216        if (parentNode.IsExpanded) {
    214217          foreach (IndexedItem<IScope> item in e.Items) {
    215218            TreeNode node = scopeNodeTable[item.Value];
    216             RemoveTreeNode(node);
     219            ClearTreeNode(node);
    217220            node.Remove();
    218221          }
     
    220223          parentNode.Nodes.Clear();
    221224        }
     225        scopesTreeView.EndUpdate();
    222226      }
    223227    }
     
    228232        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
    229233        TreeNode parentNode = scopeNodeTable[parentScope];
     234        scopesTreeView.BeginUpdate();
    230235        if (parentNode.IsExpanded) {
    231236          foreach (IndexedItem<IScope> item in e.Items) {
    232237            TreeNode node = parentNode.Nodes[item.Index];
    233             RemoveTreeNode(node);
     238            ClearTreeNode(node);
    234239            node.Remove();
    235240            node = CreateTreeNode(item.Value);
    236241            parentNode.Nodes.Insert(item.Index, node);
    237242          }
     243          scopesTreeView.EndUpdate();
    238244        }
    239245      }
     
    245251        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
    246252        TreeNode parentNode = scopeNodeTable[parentScope];
     253        scopesTreeView.BeginUpdate();
    247254        if (parentNode.IsExpanded) {
    248255          parentNode.Nodes.Clear();
     
    250257            parentNode.Nodes.Insert(item.Index, scopeNodeTable[item.Value]);
    251258        }
     259        scopesTreeView.EndUpdate();
    252260      }
    253261    }
     
    258266        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
    259267        TreeNode parentNode = scopeNodeTable[parentScope];
     268        scopesTreeView.BeginUpdate();
    260269        if (parentNode.IsExpanded) {
    261270          foreach (TreeNode node in parentNode.Nodes)
    262             RemoveTreeNode(node);
     271            ClearTreeNode(node);
    263272          parentNode.Nodes.Clear();
    264273          foreach (IndexedItem<IScope> item in e.Items) {
     
    271280            parentNode.Nodes.Add(new TreeNode());
    272281        }
     282        scopesTreeView.EndUpdate();
     283      }
     284    }
     285    #endregion
     286
     287    #region Helpers
     288    private void UpdateVariables() {
     289      if (scopesTreeView.SelectedNode == null) {
     290        variableCollectionView.Content = null;
     291        variableCollectionView.Enabled = false;
     292      } else {
     293        variableCollectionView.Enabled = true;
     294        variableCollectionView.Content = ((IScope)scopesTreeView.SelectedNode.Tag).Variables;
    273295      }
    274296    }
  • trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs

    r3516 r3528  
    9191        imageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Namespace);  // plugins
    9292        imageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Interface);  // interfaces
    93         imageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.OrgChart);   // abstract types
    9493        imageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Template);   // generic types
    9594
     
    119118              typeNode.ImageIndex = 0;
    120119              if (type.IsInterface) typeNode.ImageIndex = 2;
    121               else if (type.IsAbstract) typeNode.ImageIndex = 3;
    122               else if (type.ContainsGenericParameters) typeNode.ImageIndex = 4;
     120              else if (type.ContainsGenericParameters) typeNode.ImageIndex = 3;
    123121              else if (imageList.Images.ContainsKey(type.FullName)) typeNode.ImageIndex = imageList.Images.IndexOfKey(type.FullName);
    124122              else if (typeof(IItem).IsAssignableFrom(type)) {
  • trunk/sources/HeuristicLab.Core/3.3/Scope.cs

    r3431 r3528  
    2020#endregion
    2121
     22using System.Drawing;
    2223using HeuristicLab.Collections;
    2324using HeuristicLab.Common;
     
    3132  [StorableClass]
    3233  public sealed class Scope : NamedItem, IScope {
     34    public override Image ItemImage {
     35      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.OrgChart; }
     36    }
     37
    3338    [Storable]
    3439    private IScope parent;
  • trunk/sources/HeuristicLab.Optimization/3.3/UserDefinedAlgorithm.cs

    r3393 r3528  
    3030  /// An algorithm which can be defined by the user.
    3131  /// </summary>
    32   [Item("UserDefinedAlgorithm", "An algorithm which can be defined by the user.")]
     32  [Item("User-Defined Algorithm", "An algorithm which can be defined by the user.")]
    3333  [Creatable("Algorithms")]
    3434  [StorableClass]
  • trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs

    r3462 r3528  
    3838
    3939namespace HeuristicLab.Problems.ArtificialAnt {
    40   [Item("ArtificialAntProblem", "Represents the Artificial Ant problem.")]
     40  [Item("Artificial Ant Problem", "Represents the Artificial Ant problem.")]
    4141  [Creatable("Problems")]
    4242  [StorableClass]
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs

    r3513 r3528  
    4040
    4141namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
    42   [Item("SymbolicRegressionProblem", "Represents a symbolic regression problem.")]
     42  [Item("Symbolic Regression Problem", "Represents a symbolic regression problem.")]
    4343  [Creatable("Problems")]
    4444  [StorableClass]
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs

    r3376 r3528  
    3333
    3434namespace HeuristicLab.Problems.DataAnalysis {
    35   [Item("DataAnalysisProblem", "Represents a data analysis problem.")]
     35  [Item("Data Analysis Problem", "Represents a data analysis problem.")]
    3636  [Creatable("Problems")]
    3737  [StorableClass]
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r3467 r3528  
    3535
    3636namespace HeuristicLab.Problems.Knapsack {
    37   [Item("KnapsackProblem", "Represents a Knapsack Problem.")]
     37  [Item("Knapsack Problem", "Represents a Knapsack Problem.")]
    3838  [Creatable("Problems")]
    3939  [StorableClass]
  • trunk/sources/HeuristicLab.Problems.OneMax/3.3/OnemaxProblem.cs

    r3303 r3528  
    3434
    3535namespace HeuristicLab.Problems.OneMax {
    36   [Item("OneMaxProblem", "Represents a OneMax Problem.")]
     36  [Item("OneMax Problem", "Represents a OneMax Problem.")]
    3737  [Creatable("Problems")]
    3838  [StorableClass]
Note: See TracChangeset for help on using the changeset viewer.