Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/10 03:55:16 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • implemented ideas which came up during today's presentation of HeuristicLab.Core and related plugins
Location:
trunk/sources/HeuristicLab.Core.Views/3.3
Files:
7 edited

Legend:

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

    r2676 r2687  
    4848      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
    4949      this.executionTimeLabel = new System.Windows.Forms.Label();
    50       this.splitContainer = new System.Windows.Forms.SplitContainer();
    5150      this.operatorGraphView = new HeuristicLab.Core.Views.OperatorGraphView();
    5251      this.scopeView = new HeuristicLab.Core.Views.ScopeView();
     
    5554      this.startButton = new System.Windows.Forms.Button();
    5655      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    57       this.splitContainer.Panel1.SuspendLayout();
    58       this.splitContainer.Panel2.SuspendLayout();
    59       this.splitContainer.SuspendLayout();
     56      this.tabControl = new System.Windows.Forms.TabControl();
     57      this.operatorGraphTabPage = new System.Windows.Forms.TabPage();
     58      this.globalScopeTabPage = new System.Windows.Forms.TabPage();
     59      this.tabControl.SuspendLayout();
     60      this.operatorGraphTabPage.SuspendLayout();
     61      this.globalScopeTabPage.SuspendLayout();
    6062      this.SuspendLayout();
    6163      //
     
    6365      //
    6466      this.executionTimeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    65       this.executionTimeTextBox.Location = new System.Drawing.Point(655, 620);
     67      this.executionTimeTextBox.Location = new System.Drawing.Point(661, 620);
    6668      this.executionTimeTextBox.Name = "executionTimeTextBox";
    6769      this.executionTimeTextBox.ReadOnly = true;
    6870      this.executionTimeTextBox.Size = new System.Drawing.Size(141, 20);
    69       this.executionTimeTextBox.TabIndex = 4;
     71      this.executionTimeTextBox.TabIndex = 5;
    7072      //
    7173      // executionTimeLabel
     
    7375      this.executionTimeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    7476      this.executionTimeLabel.AutoSize = true;
    75       this.executionTimeLabel.Location = new System.Drawing.Point(566, 623);
     77      this.executionTimeLabel.Location = new System.Drawing.Point(572, 623);
    7678      this.executionTimeLabel.Name = "executionTimeLabel";
    7779      this.executionTimeLabel.Size = new System.Drawing.Size(83, 13);
    78       this.executionTimeLabel.TabIndex = 3;
     80      this.executionTimeLabel.TabIndex = 4;
    7981      this.executionTimeLabel.Text = "&Execution Time:";
    80       //
    81       // splitContainer
    82       //
    83       this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    84                   | System.Windows.Forms.AnchorStyles.Left)
    85                   | System.Windows.Forms.AnchorStyles.Right)));
    86       this.splitContainer.Location = new System.Drawing.Point(0, 0);
    87       this.splitContainer.Name = "splitContainer";
    88       //
    89       // splitContainer.Panel1
    90       //
    91       this.splitContainer.Panel1.Controls.Add(this.operatorGraphView);
    92       //
    93       // splitContainer.Panel2
    94       //
    95       this.splitContainer.Panel2.Controls.Add(this.scopeView);
    96       this.splitContainer.Size = new System.Drawing.Size(802, 611);
    97       this.splitContainer.SplitterDistance = 401;
    98       this.splitContainer.TabIndex = 0;
    9982      //
    10083      // operatorGraphView
     
    10588      this.operatorGraphView.Caption = "Operator Graph";
    10689      this.operatorGraphView.Item = null;
    107       this.operatorGraphView.Location = new System.Drawing.Point(3, 3);
     90      this.operatorGraphView.Location = new System.Drawing.Point(6, 6);
    10891      this.operatorGraphView.Name = "operatorGraphView";
    10992      this.operatorGraphView.Object = null;
    11093      this.operatorGraphView.OperatorGraph = null;
    111       this.operatorGraphView.Size = new System.Drawing.Size(395, 605);
     94      this.operatorGraphView.Size = new System.Drawing.Size(782, 573);
    11295      this.operatorGraphView.TabIndex = 0;
    11396      //
     
    119102      this.scopeView.Caption = "Scope";
    120103      this.scopeView.Item = null;
    121       this.scopeView.Location = new System.Drawing.Point(3, 3);
     104      this.scopeView.Location = new System.Drawing.Point(6, 6);
    122105      this.scopeView.Name = "scopeView";
    123106      this.scopeView.Object = null;
    124107      this.scopeView.Scope = null;
    125       this.scopeView.Size = new System.Drawing.Size(391, 605);
     108      this.scopeView.Size = new System.Drawing.Size(782, 573);
    126109      this.scopeView.TabIndex = 0;
    127110      //
     
    130113      this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    131114      this.resetButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Restart;
    132       this.resetButton.Location = new System.Drawing.Point(63, 617);
     115      this.resetButton.Location = new System.Drawing.Point(58, 617);
    133116      this.resetButton.Name = "resetButton";
    134117      this.resetButton.Size = new System.Drawing.Size(23, 23);
    135       this.resetButton.TabIndex = 2;
     118      this.resetButton.TabIndex = 3;
    136119      this.toolTip.SetToolTip(this.resetButton, "Reset Engine");
    137120      this.resetButton.UseVisualStyleBackColor = true;
     
    143126      this.stopButton.Enabled = false;
    144127      this.stopButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Stop;
    145       this.stopButton.Location = new System.Drawing.Point(34, 617);
     128      this.stopButton.Location = new System.Drawing.Point(29, 617);
    146129      this.stopButton.Name = "stopButton";
    147130      this.stopButton.Size = new System.Drawing.Size(23, 23);
    148       this.stopButton.TabIndex = 1;
     131      this.stopButton.TabIndex = 2;
    149132      this.toolTip.SetToolTip(this.stopButton, "Stop Engine");
    150133      this.stopButton.UseVisualStyleBackColor = true;
     
    155138      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    156139      this.startButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Play;
    157       this.startButton.Location = new System.Drawing.Point(5, 617);
     140      this.startButton.Location = new System.Drawing.Point(0, 617);
    158141      this.startButton.Name = "startButton";
    159142      this.startButton.Size = new System.Drawing.Size(23, 23);
    160       this.startButton.TabIndex = 0;
     143      this.startButton.TabIndex = 1;
    161144      this.toolTip.SetToolTip(this.startButton, "Start Engine");
    162145      this.startButton.UseVisualStyleBackColor = true;
    163146      this.startButton.Click += new System.EventHandler(this.startButton_Click);
    164147      //
     148      // tabControl
     149      //
     150      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     151                  | System.Windows.Forms.AnchorStyles.Left)
     152                  | System.Windows.Forms.AnchorStyles.Right)));
     153      this.tabControl.Controls.Add(this.operatorGraphTabPage);
     154      this.tabControl.Controls.Add(this.globalScopeTabPage);
     155      this.tabControl.Location = new System.Drawing.Point(0, 0);
     156      this.tabControl.Name = "tabControl";
     157      this.tabControl.SelectedIndex = 0;
     158      this.tabControl.Size = new System.Drawing.Size(802, 611);
     159      this.tabControl.TabIndex = 0;
     160      //
     161      // operatorGraphTabPage
     162      //
     163      this.operatorGraphTabPage.Controls.Add(this.operatorGraphView);
     164      this.operatorGraphTabPage.Location = new System.Drawing.Point(4, 22);
     165      this.operatorGraphTabPage.Name = "operatorGraphTabPage";
     166      this.operatorGraphTabPage.Padding = new System.Windows.Forms.Padding(3);
     167      this.operatorGraphTabPage.Size = new System.Drawing.Size(794, 585);
     168      this.operatorGraphTabPage.TabIndex = 0;
     169      this.operatorGraphTabPage.Text = "Operator Graph";
     170      this.operatorGraphTabPage.UseVisualStyleBackColor = true;
     171      //
     172      // globalScopeTabPage
     173      //
     174      this.globalScopeTabPage.Controls.Add(this.scopeView);
     175      this.globalScopeTabPage.Location = new System.Drawing.Point(4, 22);
     176      this.globalScopeTabPage.Name = "globalScopeTabPage";
     177      this.globalScopeTabPage.Padding = new System.Windows.Forms.Padding(3);
     178      this.globalScopeTabPage.Size = new System.Drawing.Size(794, 585);
     179      this.globalScopeTabPage.TabIndex = 1;
     180      this.globalScopeTabPage.Text = "Global Scope";
     181      this.globalScopeTabPage.UseVisualStyleBackColor = true;
     182      //
    165183      // EngineView
    166184      //
    167185      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    168186      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     187      this.Controls.Add(this.tabControl);
    169188      this.Controls.Add(this.executionTimeTextBox);
    170189      this.Controls.Add(this.stopButton);
    171190      this.Controls.Add(this.executionTimeLabel);
    172       this.Controls.Add(this.splitContainer);
    173191      this.Controls.Add(this.resetButton);
    174192      this.Controls.Add(this.startButton);
    175193      this.Name = "EngineView";
    176194      this.Size = new System.Drawing.Size(802, 640);
    177       this.splitContainer.Panel1.ResumeLayout(false);
    178       this.splitContainer.Panel2.ResumeLayout(false);
    179       this.splitContainer.ResumeLayout(false);
     195      this.tabControl.ResumeLayout(false);
     196      this.operatorGraphTabPage.ResumeLayout(false);
     197      this.globalScopeTabPage.ResumeLayout(false);
    180198      this.ResumeLayout(false);
    181199      this.PerformLayout();
     
    187205    protected System.Windows.Forms.TextBox executionTimeTextBox;
    188206    protected System.Windows.Forms.Label executionTimeLabel;
    189     protected System.Windows.Forms.SplitContainer splitContainer;
    190207    protected System.Windows.Forms.Button resetButton;
    191208    protected System.Windows.Forms.Button stopButton;
     
    194211    protected HeuristicLab.Core.Views.ScopeView scopeView;
    195212    protected System.Windows.Forms.ToolTip toolTip;
     213    protected System.Windows.Forms.TabControl tabControl;
     214    protected System.Windows.Forms.TabPage operatorGraphTabPage;
     215    protected System.Windows.Forms.TabPage globalScopeTabPage;
    196216
    197217  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ScopeListView.cs

    r2655 r2687  
    1212namespace HeuristicLab.Core.Views {
    1313  [Content(typeof(ScopeList), true)]
    14   [Content(typeof(IObservableList<Scope>), true)]
    15   public partial class ScopeListView : ItemListView<Scope> {
     14  [Content(typeof(IObservableList<IScope>), true)]
     15  public partial class ScopeListView : ItemListView<IScope> {
    1616    /// <summary>
    1717    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
     
    2828    /// <remarks>Calls <see cref="VariablesScopeView()"/>.</remarks>
    2929    /// <param name="scope">The scope whose variables should be represented visually.</param>
    30     public ScopeListView(IObservableList<Scope> scopeList)
     30    public ScopeListView(IObservableList<IScope> scopeList)
    3131      : this() {
    3232      ItemList = scopeList;
  • trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.cs

    r2676 r2687  
    3838  [Content(typeof(Scope), true)]
    3939  public sealed partial class ScopeView : ItemView {
    40     private Dictionary<Scope, TreeNode> scopeNodeTable;
    41     private Dictionary<ScopeList, Scope> subScopesScopeTable;
     40    private Dictionary<IScope, TreeNode> scopeNodeTable;
     41    private Dictionary<ScopeList, IScope> subScopesScopeTable;
    4242
    4343    /// <summary>
     
    4646    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    4747    /// No own data storage present.</remarks>
    48     public Scope Scope {
    49       get { return (Scope)Item; }
     48    public IScope Scope {
     49      get { return (IScope)Item; }
    5050      set { base.Item = value; }
    5151    }
     
    5858      InitializeComponent();
    5959      Caption = "Scope";
    60       scopeNodeTable = new Dictionary<Scope, TreeNode>();
    61       subScopesScopeTable = new Dictionary<ScopeList, Scope>();
     60      scopeNodeTable = new Dictionary<IScope, TreeNode>();
     61      subScopesScopeTable = new Dictionary<ScopeList, IScope>();
    6262
    6363    }
     
    6767    /// <remarks>Calls <see cref="ScopeView()"/>.</remarks>
    6868    /// <param name="scope">The scope to represent visually.</param>
    69     public ScopeView(Scope scope)
     69    public ScopeView(IScope scope)
    7070      : this() {
    7171      Scope = scope;
     
    9494    }
    9595
    96     private TreeNode CreateTreeNode(Scope scope) {
     96    private TreeNode CreateTreeNode(IScope scope) {
    9797      TreeNode node = new TreeNode();
    9898      node.Text = scope.Name;
     
    101101      scopeNodeTable.Add(scope, node);
    102102      scope.NameChanged += new EventHandler(Scope_NameChanged);
    103       scope.SubScopes.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsAdded);
    104       scope.SubScopes.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsRemoved);
    105       scope.SubScopes.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsReplaced);
    106       scope.SubScopes.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsMoved);
    107       scope.SubScopes.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_CollectionReset);
     103      scope.SubScopes.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsAdded);
     104      scope.SubScopes.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsRemoved);
     105      scope.SubScopes.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);
     106      scope.SubScopes.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsMoved);
     107      scope.SubScopes.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);
    108108      subScopesScopeTable.Add(scope.SubScopes, scope);
    109109      if (scope.SubScopes.Count > 0)
     
    116116        RemoveTreeNode(child);
    117117
    118       Scope scope = node.Tag as Scope;
     118      IScope scope = node.Tag as IScope;
    119119      if (scope != null) {
    120120        scopeNodeTable.Remove(scope);
    121121        scope.NameChanged -= new EventHandler(Scope_NameChanged);
    122         scope.SubScopes.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsAdded);
    123         scope.SubScopes.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsRemoved);
    124         scope.SubScopes.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsReplaced);
    125         scope.SubScopes.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsMoved);
    126         scope.SubScopes.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_CollectionReset);
     122        scope.SubScopes.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsAdded);
     123        scope.SubScopes.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsRemoved);
     124        scope.SubScopes.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);
     125        scope.SubScopes.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsMoved);
     126        scope.SubScopes.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);
    127127        subScopesScopeTable.Remove(scope.SubScopes);
    128128      }
     
    132132    private void scopesTreeView_MouseDown(object sender, MouseEventArgs e) {
    133133      TreeNode node = scopesTreeView.GetNodeAt(e.X, e.Y);
    134       if ((node != null) && (node.Tag is Scope)) {
    135         variableCollectionView.NamedItemCollection = ((Scope)node.Tag).Variables;
     134      if ((node != null) && (node.Tag is IScope)) {
     135        variableCollectionView.NamedItemCollection = ((IScope)node.Tag).Variables;
    136136        variableCollectionView.Enabled = true;
    137137      } else {
     
    143143    private void scopesTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) {
    144144      TreeNode node = e.Node;
    145       Scope scope = (Scope)node.Tag;
     145      IScope scope = (IScope)node.Tag;
    146146
    147147      node.Nodes.Clear();
     
    151151    private void scopesTreeView_AfterCollapse(object sender, System.Windows.Forms.TreeViewEventArgs e) {
    152152      TreeNode node = e.Node;
    153       Scope scope = (Scope)node.Tag;
     153      IScope scope = (IScope)node.Tag;
    154154
    155155      if (node.Nodes.Count > 0) {
     
    162162    private void scopesTreeView_ItemDrag(object sender, ItemDragEventArgs e) {
    163163      TreeNode node = (TreeNode)e.Item;
    164       Scope scope = node.Tag as Scope;
     164      IScope scope = node.Tag as IScope;
    165165      if (scope != null) {
    166166        DataObject data = new DataObject();
     
    177177        Invoke(new EventHandler(Scope_NameChanged), sender, e);
    178178      else {
    179         Scope scope = (Scope)sender;
     179        IScope scope = (IScope)sender;
    180180        scopeNodeTable[scope].Text = scope.Name;
    181181      }
     
    184184
    185185    #region SubScopes Events
    186     private void SubScopes_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Scope>> e) {
    187       if (InvokeRequired)
    188         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsAdded), sender, e);
    189       else {
    190         Scope parentScope = subScopesScopeTable[(ScopeList)sender];
    191         TreeNode parentNode = scopeNodeTable[parentScope];
    192         if (parentNode.IsExpanded) {
    193           foreach (IndexedItem<Scope> item in e.Items) {
     186    private void SubScopes_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IScope>> e) {
     187      if (InvokeRequired)
     188        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsAdded), sender, e);
     189      else {
     190        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
     191        TreeNode parentNode = scopeNodeTable[parentScope];
     192        if (parentNode.IsExpanded) {
     193          foreach (IndexedItem<IScope> item in e.Items) {
    194194            TreeNode node = CreateTreeNode(item.Value);
    195195            parentNode.Nodes.Insert(item.Index, node);
     
    200200      }
    201201    }
    202     private void SubScopes_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Scope>> e) {
    203       if (InvokeRequired)
    204         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsRemoved), sender, e);
    205       else {
    206         Scope parentScope = subScopesScopeTable[(ScopeList)sender];
    207         TreeNode parentNode = scopeNodeTable[parentScope];
    208         if (parentNode.IsExpanded) {
    209           foreach (IndexedItem<Scope> item in e.Items) {
     202    private void SubScopes_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IScope>> e) {
     203      if (InvokeRequired)
     204        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsRemoved), sender, e);
     205      else {
     206        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
     207        TreeNode parentNode = scopeNodeTable[parentScope];
     208        if (parentNode.IsExpanded) {
     209          foreach (IndexedItem<IScope> item in e.Items) {
    210210            TreeNode node = scopeNodeTable[item.Value];
    211211            RemoveTreeNode(node);
     
    217217      }
    218218    }
    219     private void SubScopes_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<Scope>> e) {
    220       if (InvokeRequired)
    221         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsReplaced), sender, e);
    222       else {
    223         Scope parentScope = subScopesScopeTable[(ScopeList)sender];
    224         TreeNode parentNode = scopeNodeTable[parentScope];
    225         if (parentNode.IsExpanded) {
    226           foreach (IndexedItem<Scope> item in e.Items) {
     219    private void SubScopes_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IScope>> e) {
     220      if (InvokeRequired)
     221        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced), sender, e);
     222      else {
     223        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
     224        TreeNode parentNode = scopeNodeTable[parentScope];
     225        if (parentNode.IsExpanded) {
     226          foreach (IndexedItem<IScope> item in e.Items) {
    227227            TreeNode node = parentNode.Nodes[item.Index];
    228228            RemoveTreeNode(node);
     
    234234      }
    235235    }
    236     private void SubScopes_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Scope>> e) {
    237       if (InvokeRequired)
    238         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_ItemsMoved), sender, e);
    239       else {
    240         Scope parentScope = subScopesScopeTable[(ScopeList)sender];
    241         TreeNode parentNode = scopeNodeTable[parentScope];
    242         if (parentNode.IsExpanded) {
    243           parentNode.Nodes.Clear();
    244           foreach (IndexedItem<Scope> item in e.Items)
     236    private void SubScopes_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IScope>> e) {
     237      if (InvokeRequired)
     238        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsMoved), sender, e);
     239      else {
     240        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
     241        TreeNode parentNode = scopeNodeTable[parentScope];
     242        if (parentNode.IsExpanded) {
     243          parentNode.Nodes.Clear();
     244          foreach (IndexedItem<IScope> item in e.Items)
    245245            parentNode.Nodes.Insert(item.Index, scopeNodeTable[item.Value]);
    246246        }
    247247      }
    248248    }
    249     private void SubScopes_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<Scope>> e) {
    250       if (InvokeRequired)
    251         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Scope>>(SubScopes_CollectionReset), sender, e);
    252       else {
    253         Scope parentScope = subScopesScopeTable[(ScopeList)sender];
     249    private void SubScopes_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IScope>> e) {
     250      if (InvokeRequired)
     251        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset), sender, e);
     252      else {
     253        IScope parentScope = subScopesScopeTable[(ScopeList)sender];
    254254        TreeNode parentNode = scopeNodeTable[parentScope];
    255255        if (parentNode.IsExpanded) {
     
    257257            RemoveTreeNode(node);
    258258          parentNode.Nodes.Clear();
    259           foreach (IndexedItem<Scope> item in e.Items) {
     259          foreach (IndexedItem<IScope> item in e.Items) {
    260260            TreeNode node = CreateTreeNode(item.Value);
    261261            parentNode.Nodes.Insert(item.Index, node);
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableCollectionView.cs

    r2655 r2687  
    1212namespace HeuristicLab.Core.Views {
    1313  [Content(typeof(VariableCollection), true)]
    14   [Content(typeof(IObservableKeyedCollection<string, Variable>), true)]
    15   public partial class VariableCollectionView : NamedItemCollectionView<Variable> {
     14  [Content(typeof(IObservableKeyedCollection<string, IVariable>), true)]
     15  public partial class VariableCollectionView : NamedItemCollectionView<IVariable> {
    1616    /// <summary>
    1717    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
     
    2828    /// <remarks>Calls <see cref="VariablesScopeView()"/>.</remarks>
    2929    /// <param name="scope">The scope whose variables should be represented visually.</param>
    30     public VariableCollectionView(IObservableKeyedCollection<string, Variable> variableCollection)
     30    public VariableCollectionView(IObservableKeyedCollection<string, IVariable> variableCollection)
    3131      : this() {
    3232      NamedItemCollection = variableCollection;
    3333    }
     34
     35    protected override IVariable CreateItem() {
     36      IVariable item = new Variable();
     37      item.Name = GetUniqueName(item.Name);
     38      return item;
     39    }
    3440  }
    3541}
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs

    r2676 r2687  
    6565
    6666    /// <summary>
    67     /// Removes the eventhandlers from the underlying <see cref="IVariable"/>.
     67    /// Removes the eventhandlers from the underlying <see cref="Variable"/>.
    6868    /// </summary>
    6969    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
     
    7474
    7575    /// <summary>
    76     /// Adds eventhandlers to the underlying <see cref="IVariable"/>.
     76    /// Adds eventhandlers to the underlying <see cref="Variable"/>.
    7777    /// </summary>
    7878    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
  • trunk/sources/HeuristicLab.Core.Views/3.3/ViewHost.Designer.cs

    r2676 r2687  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.viewPanel = new System.Windows.Forms.Panel();
    4849      this.messageLabel = new System.Windows.Forms.Label();
    49       this.viewLabel = new System.Windows.Forms.Label();
    50       this.viewComboBox = new System.Windows.Forms.ComboBox();
     50      this.viewsLabel = new System.Windows.Forms.Label();
     51      this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    5152      this.SuspendLayout();
    5253      //
     
    5657                  | System.Windows.Forms.AnchorStyles.Left)
    5758                  | System.Windows.Forms.AnchorStyles.Right)));
    58       this.viewPanel.Location = new System.Drawing.Point(0, 27);
     59      this.viewPanel.Location = new System.Drawing.Point(0, 0);
    5960      this.viewPanel.Name = "viewPanel";
    60       this.viewPanel.Size = new System.Drawing.Size(227, 157);
     61      this.viewPanel.Size = new System.Drawing.Size(205, 184);
    6162      this.viewPanel.TabIndex = 2;
    6263      //
     
    7172      this.messageLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    7273      //
    73       // viewLabel
     74      // viewsLabel
    7475      //
    75       this.viewLabel.AutoSize = true;
    76       this.viewLabel.Location = new System.Drawing.Point(3, 3);
    77       this.viewLabel.Name = "viewLabel";
    78       this.viewLabel.Size = new System.Drawing.Size(33, 13);
    79       this.viewLabel.TabIndex = 0;
    80       this.viewLabel.Text = "&View:";
     76      this.viewsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     77      this.viewsLabel.ContextMenuStrip = this.contextMenuStrip;
     78      this.viewsLabel.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Windows;
     79      this.viewsLabel.Location = new System.Drawing.Point(211, 0);
     80      this.viewsLabel.Name = "viewsLabel";
     81      this.viewsLabel.Size = new System.Drawing.Size(16, 16);
     82      this.viewsLabel.TabIndex = 0;
    8183      //
    82       // viewComboBox
     84      // contextMenuStrip
    8385      //
    84       this.viewComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    85                   | System.Windows.Forms.AnchorStyles.Right)));
    86       this.viewComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    87       this.viewComboBox.FormattingEnabled = true;
    88       this.viewComboBox.Location = new System.Drawing.Point(42, 0);
    89       this.viewComboBox.Name = "viewComboBox";
    90       this.viewComboBox.Size = new System.Drawing.Size(185, 21);
    91       this.viewComboBox.TabIndex = 1;
    92       this.viewComboBox.SelectedIndexChanged += new System.EventHandler(this.viewComboBox_SelectedIndexChanged);
     86      this.contextMenuStrip.Name = "contextMenuStrip";
     87      this.contextMenuStrip.ShowCheckMargin = true;
     88      this.contextMenuStrip.ShowImageMargin = false;
     89      this.contextMenuStrip.Size = new System.Drawing.Size(61, 4);
     90      this.contextMenuStrip.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStrip_ItemClicked);
    9391      //
    9492      // ViewHost
     
    9694      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    9795      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    98       this.Controls.Add(this.viewComboBox);
    99       this.Controls.Add(this.viewLabel);
    10096      this.Controls.Add(this.viewPanel);
     97      this.Controls.Add(this.viewsLabel);
    10198      this.Controls.Add(this.messageLabel);
    10299      this.Name = "ViewHost";
    103100      this.Size = new System.Drawing.Size(227, 184);
    104101      this.ResumeLayout(false);
    105       this.PerformLayout();
    106102
    107103    }
     
    110106
    111107    protected System.Windows.Forms.Panel viewPanel;
    112     protected System.Windows.Forms.Label viewLabel;
    113     protected System.Windows.Forms.ComboBox viewComboBox;
     108    protected System.Windows.Forms.Label viewsLabel;
    114109    protected System.Windows.Forms.Label messageLabel;
     110    protected System.Windows.Forms.ContextMenuStrip contextMenuStrip;
    115111
    116112  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ViewHost.cs

    r2684 r2687  
    3232namespace HeuristicLab.Core.Views {
    3333  public partial class ViewHost : UserControl {
     34    private Dictionary<Type, ToolStripMenuItem> typeMenuItemTable;
     35
    3436    private object obj;
    3537    public object Object {
     
    4446
    4547    public ViewHost() {
     48      typeMenuItemTable = new Dictionary<Type, ToolStripMenuItem>();
    4649      InitializeComponent();
    4750      Initialize();
     
    4952
    5053    protected virtual void Initialize() {
    51       viewLabel.Visible = false;
    52       viewComboBox.Items.Clear();
    53       viewComboBox.Enabled = false;
    54       viewComboBox.Visible = false;
     54      viewsLabel.Enabled = false;
     55      viewsLabel.Visible = false;
     56      typeMenuItemTable.Clear();
     57      contextMenuStrip.Items.Clear();
     58      contextMenuStrip.Enabled = false;
    5559      messageLabel.Visible = false;
    5660      if (viewPanel.Controls.Count > 0) viewPanel.Controls[0].Dispose();
     
    6367                        orderby t.Name ascending
    6468                        select t;
    65         foreach (Type viewType in viewTypes)
    66           viewComboBox.Items.Add(viewType);
    67         if (viewComboBox.Items.Count == 0) {
     69        foreach (Type viewType in viewTypes) {
     70          ToolStripMenuItem item = new ToolStripMenuItem(viewType.Name);
     71          item.Name = viewType.FullName;
     72          item.ToolTipText = viewType.FullName;
     73          item.Tag = viewType;
     74          contextMenuStrip.Items.Add(item);
     75          typeMenuItemTable.Add(viewType, item);
     76        }
     77        if (contextMenuStrip.Items.Count == 0) {
    6878          messageLabel.Visible = true;
    6979        } else {
    70           viewLabel.Visible = true;
    71           viewComboBox.Enabled = true;
    72           viewComboBox.Visible = true;
     80          viewsLabel.Enabled = true;
     81          viewsLabel.Visible = true;
     82          contextMenuStrip.Enabled = true;
    7383          messageLabel.Visible = false;
    7484        }
     
    8191          viewPanel.Enabled = true;
    8292          viewPanel.Visible = true;
    83           viewComboBox.SelectedItem = view.GetType();
     93          typeMenuItemTable[view.GetType()].Checked = true;
     94          typeMenuItemTable[view.GetType()].Enabled = false;
    8495        }
    8596      }
    8697    }
    8798
    88     protected virtual void viewComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    89       if (viewComboBox.SelectedItem != viewPanel.Tag) {
    90         if (viewPanel.Controls.Count > 0) viewPanel.Controls[0].Dispose();
    91         viewPanel.Controls.Clear();
    92         Control view = (Control)MainFormManager.CreateView((Type)viewComboBox.SelectedItem, Object);
    93         viewPanel.Controls.Add(view);
    94         viewPanel.Tag = view;
    95         view.Dock = DockStyle.Fill;
     99    protected void contextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {
     100      Type viewType = (Type)e.ClickedItem.Tag;
     101      foreach (ToolStripMenuItem item in typeMenuItemTable.Values) {
     102        item.Checked = false;
     103        item.Enabled = true;
    96104      }
     105      typeMenuItemTable[viewType].Checked = true;
     106      typeMenuItemTable[viewType].Enabled = false;
     107
     108      if (viewPanel.Controls.Count > 0) viewPanel.Controls[0].Dispose();
     109      viewPanel.Controls.Clear();
     110      Control view = (Control)MainFormManager.CreateView(viewType, Object);
     111      viewPanel.Controls.Add(view);
     112      viewPanel.Tag = view;
     113      view.Dock = DockStyle.Fill;
    97114    }
    98115  }
Note: See TracChangeset for help on using the changeset viewer.