Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2655


Ignore:
Timestamp:
01/20/10 05:04:31 (14 years ago)
Author:
swagner
Message:

Committing first results of the refactoring of HeuristicLab.Core and related plugins (#95)

Location:
trunk/sources/HeuristicLab.Core.Views/3.3
Files:
42 added
33 deleted
16 edited
1 moved

Legend:

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

    r2546 r2655  
    3232    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    3333    protected override void Dispose(bool disposing) {
    34       if (disposing && (components != null)) {
    35         components.Dispose();
     34      if (disposing) {
     35        if (components != null) components.Dispose();
    3636      }
    3737      base.Dispose(disposing);
     
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
    4849      this.executionTimeLabel = new System.Windows.Forms.Label();
    49       this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    50       this.operatorGraphGroupBox = new System.Windows.Forms.GroupBox();
     50      this.splitContainer = new System.Windows.Forms.SplitContainer();
    5151      this.operatorGraphView = new HeuristicLab.Core.Views.OperatorGraphView();
    52       this.globalScopeGroupBox = new System.Windows.Forms.GroupBox();
    5352      this.scopeView = new HeuristicLab.Core.Views.ScopeView();
    5453      this.resetButton = new System.Windows.Forms.Button();
    55       this.abortButton = new System.Windows.Forms.Button();
    56       this.executeButton = new System.Windows.Forms.Button();
    57       this.splitContainer1.Panel1.SuspendLayout();
    58       this.splitContainer1.Panel2.SuspendLayout();
    59       this.splitContainer1.SuspendLayout();
    60       this.operatorGraphGroupBox.SuspendLayout();
    61       this.globalScopeGroupBox.SuspendLayout();
     54      this.stopButton = new System.Windows.Forms.Button();
     55      this.startButton = new System.Windows.Forms.Button();
     56      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     57      this.splitContainer.Panel1.SuspendLayout();
     58      this.splitContainer.Panel2.SuspendLayout();
     59      this.splitContainer.SuspendLayout();
    6260      this.SuspendLayout();
    6361      //
     
    6563      //
    6664      this.executionTimeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    67       this.executionTimeTextBox.Location = new System.Drawing.Point(499, 460);
     65      this.executionTimeTextBox.Location = new System.Drawing.Point(661, 620);
    6866      this.executionTimeTextBox.Name = "executionTimeTextBox";
    6967      this.executionTimeTextBox.ReadOnly = true;
    7068      this.executionTimeTextBox.Size = new System.Drawing.Size(141, 20);
    71       this.executionTimeTextBox.TabIndex = 5;
     69      this.executionTimeTextBox.TabIndex = 4;
    7270      //
    7371      // executionTimeLabel
     
    7573      this.executionTimeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    7674      this.executionTimeLabel.AutoSize = true;
    77       this.executionTimeLabel.Location = new System.Drawing.Point(496, 444);
     75      this.executionTimeLabel.Location = new System.Drawing.Point(572, 623);
    7876      this.executionTimeLabel.Name = "executionTimeLabel";
    7977      this.executionTimeLabel.Size = new System.Drawing.Size(83, 13);
    80       this.executionTimeLabel.TabIndex = 4;
     78      this.executionTimeLabel.TabIndex = 3;
    8179      this.executionTimeLabel.Text = "&Execution Time:";
    8280      //
    83       // splitContainer1
     81      // splitContainer
    8482      //
    85       this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     83      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    8684                  | System.Windows.Forms.AnchorStyles.Left)
    8785                  | System.Windows.Forms.AnchorStyles.Right)));
    88       this.splitContainer1.Location = new System.Drawing.Point(0, 0);
    89       this.splitContainer1.Name = "splitContainer1";
     86      this.splitContainer.Location = new System.Drawing.Point(0, 0);
     87      this.splitContainer.Name = "splitContainer";
    9088      //
    91       // splitContainer1.Panel1
     89      // splitContainer.Panel1
    9290      //
    93       this.splitContainer1.Panel1.Controls.Add(this.operatorGraphGroupBox);
     91      this.splitContainer.Panel1.Controls.Add(this.operatorGraphView);
    9492      //
    95       // splitContainer1.Panel2
     93      // splitContainer.Panel2
    9694      //
    97       this.splitContainer1.Panel2.Controls.Add(this.globalScopeGroupBox);
    98       this.splitContainer1.Size = new System.Drawing.Size(640, 441);
    99       this.splitContainer1.SplitterDistance = 320;
    100       this.splitContainer1.TabIndex = 0;
    101       //
    102       // operatorGraphGroupBox
    103       //
    104       this.operatorGraphGroupBox.Controls.Add(this.operatorGraphView);
    105       this.operatorGraphGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    106       this.operatorGraphGroupBox.Location = new System.Drawing.Point(0, 0);
    107       this.operatorGraphGroupBox.Name = "operatorGraphGroupBox";
    108       this.operatorGraphGroupBox.Size = new System.Drawing.Size(320, 441);
    109       this.operatorGraphGroupBox.TabIndex = 0;
    110       this.operatorGraphGroupBox.TabStop = false;
    111       this.operatorGraphGroupBox.Text = "Operator &Graph";
     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;
    11299      //
    113100      // operatorGraphView
     
    115102      this.operatorGraphView.Caption = "Operator Graph";
    116103      this.operatorGraphView.Dock = System.Windows.Forms.DockStyle.Fill;
    117       this.operatorGraphView.Location = new System.Drawing.Point(3, 16);
     104      this.operatorGraphView.Item = null;
     105      this.operatorGraphView.Location = new System.Drawing.Point(0, 0);
    118106      this.operatorGraphView.Name = "operatorGraphView";
    119107      this.operatorGraphView.OperatorGraph = null;
    120       this.operatorGraphView.Size = new System.Drawing.Size(314, 422);
     108      this.operatorGraphView.Size = new System.Drawing.Size(401, 611);
    121109      this.operatorGraphView.TabIndex = 0;
    122       //
    123       // globalScopeGroupBox
    124       //
    125       this.globalScopeGroupBox.Controls.Add(this.scopeView);
    126       this.globalScopeGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    127       this.globalScopeGroupBox.Location = new System.Drawing.Point(0, 0);
    128       this.globalScopeGroupBox.Name = "globalScopeGroupBox";
    129       this.globalScopeGroupBox.Size = new System.Drawing.Size(316, 441);
    130       this.globalScopeGroupBox.TabIndex = 0;
    131       this.globalScopeGroupBox.TabStop = false;
    132       this.globalScopeGroupBox.Text = "Global &Scope";
    133110      //
    134111      // scopeView
     
    136113      this.scopeView.Caption = "Scope";
    137114      this.scopeView.Dock = System.Windows.Forms.DockStyle.Fill;
    138       this.scopeView.Location = new System.Drawing.Point(3, 16);
     115      this.scopeView.Item = null;
     116      this.scopeView.Location = new System.Drawing.Point(0, 0);
    139117      this.scopeView.Name = "scopeView";
    140118      this.scopeView.Scope = null;
    141       this.scopeView.Size = new System.Drawing.Size(310, 422);
     119      this.scopeView.Size = new System.Drawing.Size(397, 611);
    142120      this.scopeView.TabIndex = 0;
    143121      //
     
    145123      //
    146124      this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    147       this.resetButton.Location = new System.Drawing.Point(196, 457);
     125      this.resetButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Restart;
     126      this.resetButton.Location = new System.Drawing.Point(58, 617);
    148127      this.resetButton.Name = "resetButton";
    149       this.resetButton.Size = new System.Drawing.Size(92, 23);
    150       this.resetButton.TabIndex = 3;
    151       this.resetButton.Text = "&Reset";
     128      this.resetButton.Size = new System.Drawing.Size(23, 23);
     129      this.resetButton.TabIndex = 2;
     130      this.toolTip.SetToolTip(this.resetButton, "Reset Engine");
    152131      this.resetButton.UseVisualStyleBackColor = true;
    153132      this.resetButton.Click += new System.EventHandler(this.resetButton_Click);
    154133      //
    155       // abortButton
     134      // stopButton
    156135      //
    157       this.abortButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    158       this.abortButton.Enabled = false;
    159       this.abortButton.Location = new System.Drawing.Point(98, 457);
    160       this.abortButton.Name = "abortButton";
    161       this.abortButton.Size = new System.Drawing.Size(92, 23);
    162       this.abortButton.TabIndex = 2;
    163       this.abortButton.Text = "&Abort";
    164       this.abortButton.UseVisualStyleBackColor = true;
    165       this.abortButton.Click += new System.EventHandler(this.abortButton_Click);
     136      this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     137      this.stopButton.Enabled = false;
     138      this.stopButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Stop;
     139      this.stopButton.Location = new System.Drawing.Point(29, 617);
     140      this.stopButton.Name = "stopButton";
     141      this.stopButton.Size = new System.Drawing.Size(23, 23);
     142      this.stopButton.TabIndex = 1;
     143      this.toolTip.SetToolTip(this.stopButton, "Stop Engine");
     144      this.stopButton.UseVisualStyleBackColor = true;
     145      this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
    166146      //
    167       // executeButton
     147      // startButton
    168148      //
    169       this.executeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    170       this.executeButton.Location = new System.Drawing.Point(0, 457);
    171       this.executeButton.Name = "executeButton";
    172       this.executeButton.Size = new System.Drawing.Size(92, 23);
    173       this.executeButton.TabIndex = 1;
    174       this.executeButton.Text = "&Execute";
    175       this.executeButton.UseVisualStyleBackColor = true;
    176       this.executeButton.Click += new System.EventHandler(this.executeButton_Click);
     149      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     150      this.startButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Play;
     151      this.startButton.Location = new System.Drawing.Point(0, 617);
     152      this.startButton.Name = "startButton";
     153      this.startButton.Size = new System.Drawing.Size(23, 23);
     154      this.startButton.TabIndex = 0;
     155      this.toolTip.SetToolTip(this.startButton, "Start Engine");
     156      this.startButton.UseVisualStyleBackColor = true;
     157      this.startButton.Click += new System.EventHandler(this.startButton_Click);
    177158      //
    178       // EngineBaseEditor
     159      // EngineBaseView
    179160      //
    180161      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     
    182163      this.Controls.Add(this.executionTimeTextBox);
    183164      this.Controls.Add(this.executionTimeLabel);
    184       this.Controls.Add(this.splitContainer1);
     165      this.Controls.Add(this.splitContainer);
    185166      this.Controls.Add(this.resetButton);
    186       this.Controls.Add(this.abortButton);
    187       this.Controls.Add(this.executeButton);
    188       this.Name = "EngineBaseEditor";
    189       this.Size = new System.Drawing.Size(640, 480);
    190       this.splitContainer1.Panel1.ResumeLayout(false);
    191       this.splitContainer1.Panel2.ResumeLayout(false);
    192       this.splitContainer1.ResumeLayout(false);
    193       this.operatorGraphGroupBox.ResumeLayout(false);
    194       this.globalScopeGroupBox.ResumeLayout(false);
     167      this.Controls.Add(this.stopButton);
     168      this.Controls.Add(this.startButton);
     169      this.Name = "EngineBaseView";
     170      this.Size = new System.Drawing.Size(802, 640);
     171      this.splitContainer.Panel1.ResumeLayout(false);
     172      this.splitContainer.Panel2.ResumeLayout(false);
     173      this.splitContainer.ResumeLayout(false);
    195174      this.ResumeLayout(false);
    196175      this.PerformLayout();
     
    202181    protected System.Windows.Forms.TextBox executionTimeTextBox;
    203182    protected System.Windows.Forms.Label executionTimeLabel;
    204     protected System.Windows.Forms.SplitContainer splitContainer1;
    205     protected System.Windows.Forms.GroupBox operatorGraphGroupBox;
    206     protected System.Windows.Forms.GroupBox globalScopeGroupBox;
     183    protected System.Windows.Forms.SplitContainer splitContainer;
    207184    protected System.Windows.Forms.Button resetButton;
    208     protected System.Windows.Forms.Button abortButton;
    209     protected System.Windows.Forms.Button executeButton;
     185    protected System.Windows.Forms.Button stopButton;
     186    protected System.Windows.Forms.Button startButton;
    210187    protected HeuristicLab.Core.Views.OperatorGraphView operatorGraphView;
    211188    protected HeuristicLab.Core.Views.ScopeView scopeView;
     189    private System.Windows.Forms.ToolTip toolTip;
    212190
    213191  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/EngineBaseView.cs

    r2546 r2655  
    4343    /// </summary>
    4444    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="EditorBase"/>.</remarks>
    45     public IEngine Engine {
    46       get { return (IEngine)Item; }
     45    public EngineBase Engine {
     46      get { return (EngineBase)Item; }
    4747      set { base.Item = value; }
    4848    }
     
    5454      InitializeComponent();
    5555    }
     56    public EngineBaseView(EngineBase engine)
     57      : this() {
     58      Engine = engine;
     59    }
    5660
    5761    /// <summary>
     
    5963    /// </summary>
    6064    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    61     protected override void RemoveItemEvents() {
     65    protected override void DeregisterObjectEvents() {
     66      Engine.OperatorGraphChanged -= new EventHandler(Engine_OperatorGraphChanged);
    6267      Engine.Initialized -= new EventHandler(Engine_Initialized);
     68      Engine.Started -= new EventHandler(Engine_Started);
     69      Engine.Stopped -= new EventHandler(Engine_Stopped);
     70      Engine.ExecutionTimeChanged -= new EventHandler(Engine_ExecutionTimeChanged);
    6371      Engine.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
    64       Engine.ExecutionTimeChanged -= new EventHandler(Engine_ExecutionTimeChanged);
    65       Engine.Finished -= new EventHandler(Engine_Finished);
    66       operatorGraphView.OperatorGraph = null;
    67       scopeView.Scope = null;
    68       base.RemoveItemEvents();
     72      base.DeregisterObjectEvents();
    6973    }
     74
    7075    /// <summary>
    7176    /// Adds event handlers to the underlying <see cref="IEngine"/>.
    7277    /// </summary>
    7378    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    74     protected override void AddItemEvents() {
    75       base.AddItemEvents();
     79    protected override void RegisterObjectEvents() {
     80      base.RegisterObjectEvents();
     81      Engine.OperatorGraphChanged += new EventHandler(Engine_OperatorGraphChanged);
    7682      Engine.Initialized += new EventHandler(Engine_Initialized);
     83      Engine.Started += new EventHandler(Engine_Started);
     84      Engine.Stopped += new EventHandler(Engine_Stopped);
     85      Engine.ExecutionTimeChanged += new EventHandler(Engine_ExecutionTimeChanged);
    7786      Engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
    78       Engine.ExecutionTimeChanged += new EventHandler(Engine_ExecutionTimeChanged);
    79       Engine.Finished += new EventHandler(Engine_Finished);
    80       operatorGraphView.OperatorGraph = Engine.OperatorGraph;
    81       scopeView.Scope = Engine.GlobalScope;
    8287    }
    8388
     
    8691    /// </summary>
    8792    /// <remarks>Calls <see cref="EditorBase.UpdateControls"/> of base class <see cref="EditorBase"/>.</remarks>
    88     protected override void UpdateControls() {
    89       base.UpdateControls();
    90       abortButton.Enabled = false;
     93    protected override void OnObjectChanged() {
     94      base.OnObjectChanged();
     95      stopButton.Enabled = false;
    9196      if (Engine == null) {
    92         executeButton.Enabled = false;
     97        operatorGraphView.Enabled = false;
     98        scopeView.Enabled = false;
     99        startButton.Enabled = false;
    93100        resetButton.Enabled = false;
    94101        executionTimeTextBox.Enabled = false;
    95102      } else {
    96         executeButton.Enabled = true;
     103        operatorGraphView.OperatorGraph = Engine.OperatorGraph;
     104        scopeView.Scope = Engine.GlobalScope;
     105        startButton.Enabled = !Engine.Finished;
    97106        resetButton.Enabled = true;
    98         executionTimeCounter = 0;
    99107        executionTimeTextBox.Text = Engine.ExecutionTime.ToString();
    100108        executionTimeTextBox.Enabled = true;
     
    103111
    104112    #region Engine Events
     113    private void Engine_OperatorGraphChanged(object sender, EventArgs e) {
     114      if (InvokeRequired)
     115        Invoke(new EventHandler(Engine_OperatorGraphChanged), sender, e);
     116      else
     117        operatorGraphView.OperatorGraph = Engine.OperatorGraph;
     118    }
    105119    private void Engine_Initialized(object sender, EventArgs e) {
    106       Refresh();
     120      if (InvokeRequired)
     121        Invoke(new EventHandler(Engine_Initialized), sender, e);
     122      else {
     123        operatorGraphView.Enabled = true;
     124        scopeView.Enabled = true;
     125        startButton.Enabled = !Engine.Finished;
     126        stopButton.Enabled = false;
     127        resetButton.Enabled = true;
     128        executionTimeTextBox.Text = Engine.ExecutionTime.ToString();
     129      }
    107130    }
    108     private delegate void OnExceptionEventDelegate(object sender, EventArgs<Exception> e);
    109     private void Engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
     131    private void Engine_Started(object sender, EventArgs e) {
     132      executionTimeCounter = 0;
    110133      if (InvokeRequired)
    111         Invoke(new OnExceptionEventDelegate(Engine_ExceptionOccurred), sender, e);
    112       else
    113         Auxiliary.ShowErrorMessageBox(e.Value);
     134        Invoke(new EventHandler(Engine_Started), sender, e);
     135      else {
     136        operatorGraphView.Enabled = false;
     137        scopeView.Enabled = false;
     138        startButton.Enabled = false;
     139        stopButton.Enabled = true;
     140        resetButton.Enabled = false;
     141        executionTimeTextBox.Text = Engine.ExecutionTime.ToString();
     142      }
     143    }
     144    private void Engine_Stopped(object sender, EventArgs e) {
     145      if (InvokeRequired)
     146        Invoke(new EventHandler(Engine_Stopped), sender, e);
     147      else {
     148        operatorGraphView.Enabled = true;
     149        scopeView.Enabled = true;
     150        startButton.Enabled = !Engine.Finished;
     151        stopButton.Enabled = false;
     152        resetButton.Enabled = true;
     153        executionTimeTextBox.Text = Engine.ExecutionTime.ToString();
     154      }
    114155    }
    115156    private void Engine_ExecutionTimeChanged(object sender, EventArgs e) {
    116157      executionTimeCounter++;
    117       if (executionTimeCounter == 1000)
    118         UpdateExecutionTimeTextBox();
    119     }
    120     private void Engine_Finished(object sender, EventArgs e) {
    121       UpdateExecutionTimeTextBox();
    122       if (globalScopeGroupBox.Controls.Count > 0) {
    123         ScopeView scopeEditor = (ScopeView)globalScopeGroupBox.Controls[0];
    124         if (!scopeEditor.AutomaticUpdating)
    125           scopeEditor.Refresh();
    126       }
    127       EnableDisableControls();
    128     }
    129     private void UpdateExecutionTimeTextBox() {
    130       if (InvokeRequired)
    131         Invoke(new MethodInvoker(UpdateExecutionTimeTextBox));
    132       else {
     158      if ((executionTimeCounter == 1000) || !Engine.Running) {
    133159        executionTimeCounter = 0;
    134         executionTimeTextBox.Text = Engine.ExecutionTime.ToString();
     160        if (InvokeRequired)
     161          Invoke(new EventHandler(Engine_ExecutionTimeChanged), sender, e);
     162        else
     163          executionTimeTextBox.Text = Engine.ExecutionTime.ToString();
    135164      }
    136165    }
    137     private void EnableDisableControls() {
     166    private void Engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    138167      if (InvokeRequired)
    139         Invoke(new MethodInvoker(EnableDisableControls));
    140       else {
    141         executeButton.Enabled = true;
    142         abortButton.Enabled = false;
    143         resetButton.Enabled = true;
    144         operatorGraphGroupBox.Enabled = true;
    145         globalScopeGroupBox.Enabled = true;
    146       }
     168        Invoke(new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred), sender, e);
     169      else
     170        Auxiliary.ShowErrorMessageBox(e.Value);
    147171    }
    148172    #endregion
    149173
    150174    #region Button events
    151     private void executeButton_Click(object sender, EventArgs e) {
    152       executeButton.Enabled = false;
    153       abortButton.Enabled = true;
    154       resetButton.Enabled = false;
    155       operatorGraphGroupBox.Enabled = false;
    156       globalScopeGroupBox.Enabled = false;
    157       Engine.Execute();
     175    private void startButton_Click(object sender, EventArgs e) {
     176      Engine.Start();
    158177    }
    159     private void abortButton_Click(object sender, EventArgs e) {
    160       Engine.Abort();
     178    private void stopButton_Click(object sender, EventArgs e) {
     179      Engine.Stop();
    161180    }
    162181    private void resetButton_Click(object sender, EventArgs e) {
    163       Engine.Reset();
    164       UpdateExecutionTimeTextBox();
    165       if (globalScopeGroupBox.Controls.Count > 0) {
    166         ScopeView scopeEditor = (ScopeView)globalScopeGroupBox.Controls[0];
    167         if (!scopeEditor.AutomaticUpdating)
    168           scopeEditor.Refresh();
    169       }
     182      Engine.Initialize();
    170183    }
    171184    #endregion
  • trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj

    r2546 r2655  
    3939      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    4040    </Reference>
     41    <Reference Include="System.Design" />
    4142    <Reference Include="System.Drawing" />
    4243    <Reference Include="System.Windows.Forms" />
     
    5152  </ItemGroup>
    5253  <ItemGroup>
     54    <Compile Include="CreateParameterDialog.cs">
     55      <SubType>Form</SubType>
     56    </Compile>
     57    <Compile Include="CreateParameterDialog.Designer.cs">
     58      <DependentUpon>CreateParameterDialog.cs</DependentUpon>
     59    </Compile>
    5360    <Compile Include="Auxiliary.cs" />
    54     <Compile Include="ChooseItemDialog.cs">
    55       <SubType>Form</SubType>
    56     </Compile>
    57     <Compile Include="ChooseItemDialog.Designer.cs">
    58       <DependentUpon>ChooseItemDialog.cs</DependentUpon>
    59     </Compile>
    60     <Compile Include="ChooseOperatorDialog.cs">
    61       <SubType>Form</SubType>
    62     </Compile>
    63     <Compile Include="ChooseOperatorDialog.Designer.cs">
    64       <DependentUpon>ChooseOperatorDialog.cs</DependentUpon>
    65     </Compile>
    66     <Compile Include="ChooseTypeDialog.cs">
    67       <SubType>Form</SubType>
    68     </Compile>
    69     <Compile Include="ChooseTypeDialog.Designer.cs">
    70       <DependentUpon>ChooseTypeDialog.cs</DependentUpon>
    71     </Compile>
    7261    <Compile Include="EngineBaseView.cs">
    7362      <SubType>UserControl</SubType>
     
    7665      <DependentUpon>EngineBaseView.cs</DependentUpon>
    7766    </Compile>
     67    <Compile Include="OperatorGraphView.cs">
     68      <SubType>UserControl</SubType>
     69    </Compile>
     70    <Compile Include="OperatorGraphView.Designer.cs">
     71      <DependentUpon>OperatorGraphView.cs</DependentUpon>
     72    </Compile>
     73    <Compile Include="OperatorsSidebar.cs">
     74      <SubType>UserControl</SubType>
     75    </Compile>
     76    <Compile Include="OperatorsSidebar.Designer.cs">
     77      <DependentUpon>OperatorsSidebar.cs</DependentUpon>
     78    </Compile>
     79    <Compile Include="OperatorTreeView.cs">
     80      <SubType>UserControl</SubType>
     81    </Compile>
     82    <Compile Include="OperatorTreeView.Designer.cs">
     83      <DependentUpon>OperatorTreeView.cs</DependentUpon>
     84    </Compile>
     85    <Compile Include="TypeSelectorDialog.cs">
     86      <SubType>Form</SubType>
     87    </Compile>
     88    <Compile Include="TypeSelectorDialog.Designer.cs">
     89      <DependentUpon>TypeSelectorDialog.cs</DependentUpon>
     90    </Compile>
     91    <Compile Include="TypeSelector.cs">
     92      <SubType>UserControl</SubType>
     93    </Compile>
     94    <Compile Include="TypeSelector.Designer.cs">
     95      <DependentUpon>TypeSelector.cs</DependentUpon>
     96    </Compile>
     97    <Compile Include="ViewHost.cs">
     98      <SubType>UserControl</SubType>
     99    </Compile>
     100    <Compile Include="ViewHost.Designer.cs">
     101      <DependentUpon>ViewHost.cs</DependentUpon>
     102    </Compile>
     103    <Compile Include="ParameterBaseView.cs">
     104      <SubType>UserControl</SubType>
     105    </Compile>
     106    <Compile Include="ParameterBaseView.Designer.cs">
     107      <DependentUpon>ParameterBaseView.cs</DependentUpon>
     108    </Compile>
     109    <Compile Include="OperatorCollectionView.cs">
     110      <SubType>UserControl</SubType>
     111    </Compile>
     112    <Compile Include="OperatorCollectionView.Designer.cs">
     113      <DependentUpon>OperatorCollectionView.cs</DependentUpon>
     114    </Compile>
     115    <Compile Include="OperatorSetView.cs">
     116      <SubType>UserControl</SubType>
     117    </Compile>
     118    <Compile Include="OperatorSetView.Designer.cs">
     119      <DependentUpon>OperatorSetView.cs</DependentUpon>
     120    </Compile>
     121    <Compile Include="ItemSetView.cs">
     122      <SubType>UserControl</SubType>
     123    </Compile>
     124    <Compile Include="ItemSetView.Designer.cs">
     125      <DependentUpon>ItemSetView.cs</DependentUpon>
     126    </Compile>
     127    <Compile Include="ItemCollectionView.cs">
     128      <SubType>UserControl</SubType>
     129    </Compile>
     130    <Compile Include="ItemCollectionView.Designer.cs">
     131      <DependentUpon>ItemCollectionView.cs</DependentUpon>
     132    </Compile>
     133    <Compile Include="ScopeListView.cs">
     134      <SubType>UserControl</SubType>
     135    </Compile>
     136    <Compile Include="ScopeListView.Designer.cs">
     137      <DependentUpon>ScopeListView.cs</DependentUpon>
     138    </Compile>
     139    <Compile Include="OperatorListView.cs">
     140      <SubType>UserControl</SubType>
     141    </Compile>
     142    <Compile Include="OperatorListView.Designer.cs">
     143      <DependentUpon>OperatorListView.cs</DependentUpon>
     144    </Compile>
     145    <Compile Include="ItemListView.cs">
     146      <SubType>UserControl</SubType>
     147    </Compile>
     148    <Compile Include="ItemListView.Designer.cs">
     149      <DependentUpon>ItemListView.cs</DependentUpon>
     150    </Compile>
     151    <Compile Include="IObjectView.cs" />
     152    <Compile Include="ObjectViewBase.cs">
     153      <SubType>UserControl</SubType>
     154    </Compile>
     155    <Compile Include="ObjectViewBase.Designer.cs">
     156      <DependentUpon>ObjectViewBase.cs</DependentUpon>
     157    </Compile>
     158    <Compile Include="OperatorBaseView.cs">
     159      <SubType>UserControl</SubType>
     160    </Compile>
     161    <Compile Include="OperatorBaseView.Designer.cs">
     162      <DependentUpon>OperatorBaseView.cs</DependentUpon>
     163    </Compile>
     164    <Compile Include="NamedItemBaseView.cs">
     165      <SubType>UserControl</SubType>
     166    </Compile>
     167    <Compile Include="NamedItemBaseView.Designer.cs">
     168      <DependentUpon>NamedItemBaseView.cs</DependentUpon>
     169    </Compile>
     170    <Compile Include="IntDataView.cs">
     171      <SubType>UserControl</SubType>
     172    </Compile>
     173    <Compile Include="IntDataView.Designer.cs">
     174      <DependentUpon>IntDataView.cs</DependentUpon>
     175    </Compile>
     176    <Compile Include="ParameterView.cs">
     177      <SubType>UserControl</SubType>
     178    </Compile>
     179    <Compile Include="ParameterView.Designer.cs">
     180      <DependentUpon>ParameterView.cs</DependentUpon>
     181    </Compile>
     182    <Compile Include="ScopeView.cs">
     183      <SubType>UserControl</SubType>
     184    </Compile>
     185    <Compile Include="ScopeView.Designer.cs">
     186      <DependentUpon>ScopeView.cs</DependentUpon>
     187    </Compile>
     188    <Compile Include="VariableCollectionView.cs">
     189      <SubType>UserControl</SubType>
     190    </Compile>
     191    <Compile Include="VariableCollectionView.Designer.cs">
     192      <DependentUpon>VariableCollectionView.cs</DependentUpon>
     193    </Compile>
     194    <Compile Include="ParameterCollectionView.cs">
     195      <SubType>UserControl</SubType>
     196    </Compile>
     197    <Compile Include="ParameterCollectionView.Designer.cs">
     198      <DependentUpon>ParameterCollectionView.cs</DependentUpon>
     199    </Compile>
     200    <Compile Include="NamedItemCollectionView.cs">
     201      <SubType>UserControl</SubType>
     202    </Compile>
     203    <Compile Include="NamedItemCollectionView.Designer.cs">
     204      <DependentUpon>NamedItemCollectionView.cs</DependentUpon>
     205    </Compile>
    78206    <Compile Include="HeuristicLabCoreViewsPlugin.cs" />
    79     <Compile Include="IItemView.cs" />
    80207    <Compile Include="ItemBaseView.cs">
    81208      <SubType>UserControl</SubType>
     
    90217      <DependentUpon>ItemViewBase.cs</DependentUpon>
    91218    </Compile>
    92     <Compile Include="OperatorBaseDescriptionView.cs">
    93       <SubType>UserControl</SubType>
    94     </Compile>
    95     <Compile Include="OperatorBaseDescriptionView.Designer.cs">
    96       <DependentUpon>OperatorBaseDescriptionView.cs</DependentUpon>
    97     </Compile>
    98     <Compile Include="OperatorBaseVariableInfosView.cs">
    99       <SubType>UserControl</SubType>
    100     </Compile>
    101     <Compile Include="OperatorBaseVariableInfosView.Designer.cs">
    102       <DependentUpon>OperatorBaseVariableInfosView.cs</DependentUpon>
    103     </Compile>
    104     <Compile Include="OperatorBaseVariablesView.cs">
    105       <SubType>UserControl</SubType>
    106     </Compile>
    107     <Compile Include="OperatorBaseVariablesView.Designer.cs">
    108       <DependentUpon>OperatorBaseVariablesView.cs</DependentUpon>
    109     </Compile>
    110     <Compile Include="OperatorBaseView.cs">
    111       <SubType>UserControl</SubType>
    112     </Compile>
    113     <Compile Include="OperatorBaseView.Designer.cs">
    114       <DependentUpon>OperatorBaseView.cs</DependentUpon>
    115     </Compile>
    116     <Compile Include="OperatorGraphView.cs">
    117       <SubType>UserControl</SubType>
    118     </Compile>
    119     <Compile Include="OperatorGraphView.Designer.cs">
    120       <DependentUpon>OperatorGraphView.cs</DependentUpon>
    121     </Compile>
    122     <Compile Include="OperatorLibraryView.cs">
    123       <SubType>UserControl</SubType>
    124     </Compile>
    125     <Compile Include="OperatorLibraryView.Designer.cs">
    126       <DependentUpon>OperatorLibraryView.cs</DependentUpon>
    127     </Compile>
    128219    <Compile Include="Properties\AssemblyInfo.cs" />
    129     <Compile Include="ScopeView.cs">
    130       <SubType>UserControl</SubType>
    131     </Compile>
    132     <Compile Include="ScopeView.Designer.cs">
    133       <DependentUpon>ScopeView.cs</DependentUpon>
    134     </Compile>
    135     <Compile Include="VariableInfoView.cs">
    136       <SubType>UserControl</SubType>
    137     </Compile>
    138     <Compile Include="VariableInfoView.Designer.cs">
    139       <DependentUpon>VariableInfoView.cs</DependentUpon>
    140     </Compile>
    141     <Compile Include="VariablesScopeView.cs">
    142       <SubType>UserControl</SubType>
    143     </Compile>
    144     <Compile Include="VariablesScopeView.Designer.cs">
    145       <DependentUpon>VariablesScopeView.cs</DependentUpon>
    146     </Compile>
    147220    <Compile Include="VariableView.cs">
    148221      <SubType>UserControl</SubType>
     
    157230  </ItemGroup>
    158231  <ItemGroup>
     232    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
     233      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
     234      <Name>HeuristicLab.Collections-3.3</Name>
     235    </ProjectReference>
    159236    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.2\HeuristicLab.Common.Resources-3.2.csproj">
    160237      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
     
    177254      <Name>HeuristicLab.MainForm-3.2</Name>
    178255    </ProjectReference>
     256    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
     257      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
     258      <Name>HeuristicLab.Persistence-3.3</Name>
     259    </ProjectReference>
    179260    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    180261      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    181262      <Name>HeuristicLab.PluginInfrastructure</Name>
    182263    </ProjectReference>
    183   </ItemGroup>
    184   <ItemGroup>
    185     <Content Include="Resources\CombinedOperator.bmp" />
    186     <Content Include="Resources\HeuristicLab.ico" />
    187     <Content Include="Resources\Operator.bmp" />
    188     <Content Include="Resources\ProgrammableOperator.bmp" />
    189   </ItemGroup>
    190   <ItemGroup>
    191     <EmbeddedResource Include="ChooseItemDialog.resx">
    192       <DependentUpon>ChooseItemDialog.cs</DependentUpon>
    193     </EmbeddedResource>
    194     <EmbeddedResource Include="ChooseOperatorDialog.resx">
    195       <DependentUpon>ChooseOperatorDialog.cs</DependentUpon>
    196     </EmbeddedResource>
    197     <EmbeddedResource Include="ChooseTypeDialog.resx">
    198       <DependentUpon>ChooseTypeDialog.cs</DependentUpon>
    199     </EmbeddedResource>
    200     <EmbeddedResource Include="EngineBaseView.resx">
    201       <DependentUpon>EngineBaseView.cs</DependentUpon>
    202     </EmbeddedResource>
    203     <EmbeddedResource Include="ItemBaseView.resx">
    204       <DependentUpon>ItemBaseView.cs</DependentUpon>
    205     </EmbeddedResource>
    206     <EmbeddedResource Include="OperatorBaseDescriptionView.resx">
    207       <DependentUpon>OperatorBaseDescriptionView.cs</DependentUpon>
    208     </EmbeddedResource>
    209     <EmbeddedResource Include="OperatorBaseVariableInfosView.resx">
    210       <DependentUpon>OperatorBaseVariableInfosView.cs</DependentUpon>
    211     </EmbeddedResource>
    212     <EmbeddedResource Include="OperatorBaseVariablesView.resx">
    213       <DependentUpon>OperatorBaseVariablesView.cs</DependentUpon>
    214     </EmbeddedResource>
    215     <EmbeddedResource Include="OperatorBaseView.resx">
    216       <DependentUpon>OperatorBaseView.cs</DependentUpon>
    217     </EmbeddedResource>
    218     <EmbeddedResource Include="OperatorGraphView.resx">
    219       <DependentUpon>OperatorGraphView.cs</DependentUpon>
    220     </EmbeddedResource>
    221     <EmbeddedResource Include="OperatorLibraryView.resx">
    222       <DependentUpon>OperatorLibraryView.cs</DependentUpon>
    223     </EmbeddedResource>
    224     <EmbeddedResource Include="ScopeView.resx">
    225       <DependentUpon>ScopeView.cs</DependentUpon>
    226     </EmbeddedResource>
    227     <EmbeddedResource Include="VariableInfoView.resx">
    228       <DependentUpon>VariableInfoView.cs</DependentUpon>
    229     </EmbeddedResource>
    230     <EmbeddedResource Include="VariablesScopeView.resx">
    231       <DependentUpon>VariablesScopeView.cs</DependentUpon>
    232     </EmbeddedResource>
    233     <EmbeddedResource Include="VariableView.resx">
    234       <DependentUpon>VariableView.cs</DependentUpon>
    235     </EmbeddedResource>
    236264  </ItemGroup>
    237265  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLabCoreViewsPlugin.cs

    r2520 r2655  
    2929  /// Plugin class for HeuristicLab.Core.Views plugin.
    3030  /// </summary>
    31   [ClassInfo(Name = "HeuristicLab.Core.Views-3.3")]
    32   [PluginFile(Filename = "HeuristicLab.Core.Views-3.3.dll", Filetype = PluginFileType.Assembly)]
    33   [Dependency(Dependency = "HeuristicLab.Common-3.2")]
    34   [Dependency(Dependency = "HeuristicLab.Common.Resources-3.2")]
    35   [Dependency(Dependency = "HeuristicLab.Core-3.3")]
    36   [Dependency(Dependency = "HeuristicLab.MainForm-3.2")]
    37   [Dependency(Dependency = "HeuristicLab.MainForm.WindowsForms-3.2")]
     31  [Plugin("HeuristicLab.Core.Views-3.3")]
     32  [PluginFile("HeuristicLab.Core.Views-3.3.dll", PluginFileType.Assembly)]
     33  [PluginDependency("HeuristicLab.Collections-3.3")]
     34  [PluginDependency("HeuristicLab.Common-3.2")]
     35  [PluginDependency("HeuristicLab.Common.Resources-3.2")]
     36  [PluginDependency("HeuristicLab.Persistence-3.3")]
     37  [PluginDependency("HeuristicLab.Core-3.3")]
     38  [PluginDependency("HeuristicLab.MainForm-3.2")]
     39  [PluginDependency("HeuristicLab.MainForm.WindowsForms-3.2")]
    3840  public class HeuristicLabCoreViewsPlugin : PluginBase {
    3941  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/IObjectView.cs

    r2617 r2655  
    3030  /// An interface for all kinds visual representations of items (objects, operators...).
    3131  /// </summary>
    32   public interface IItemView : IView {
     32  public interface IObjectView : IView {
    3333    /// <summary>
    3434    /// Gets the current item instance.
    3535    /// </summary>
    36     IItem Item { get; }
     36    object Object { get; }
    3737
    3838    /// <summary>
    39     /// Occurs when the item was changed.
     39    /// Occurs when the current item was changed.
    4040    /// </summary>
    41     event EventHandler ItemChanged;
     41    event EventHandler ObjectChanged;
    4242  }
    4343}
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemBaseView.Designer.cs

    r2520 r2655  
    3232    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    3333    protected override void Dispose(bool disposing) {
    34       if (disposing && (components != null)) {
    35         components.Dispose();
     34      if (disposing) {
     35        if (components != null) components.Dispose();
    3636      }
    3737      base.Dispose(disposing);
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemBaseView.cs

    r2546 r2655  
    4545    /// </summary>
    4646    /// <param name="item">The item that should be displayed.</param>
    47     public ItemBaseView(IItem item)
     47    public ItemBaseView(ItemBase item)
    4848      : this() {
    4949      Item = item;
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemViewBase.Designer.cs

    r2546 r2655  
    3434    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    3535    protected override void Dispose(bool disposing) {
    36       if (Item != null)
    37         RemoveItemEvents();
    38       if (disposing && (components != null)) {
    39         components.Dispose();
     36      if (disposing) {
     37        if (components != null) components.Dispose();
    4038      }
    4139      base.Dispose(disposing);
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemViewBase.cs

    r2555 r2655  
    3434  /// Base class for all visual representations.
    3535  /// </summary>
    36   public partial class ItemViewBase : ViewBase, IItemView {
    37     private IItem myItem;
    38     /// <summary>
    39     /// Gets or sets the item to represent visually.
    40     /// </summary>
    41     /// <remarks>Calls <see cref="OnItemChanged"/>, <see cref="Refresh"/>,
    42     /// <see cref="RemoveItemEvents"/> (if the current item is not null) and
    43     /// <see cref="AddItemEvents"/> (if the new item is not null) in the setter.</remarks>
     36  public partial class ItemViewBase : ObjectViewBase {
    4437    public IItem Item {
    45       get { return myItem; }
    46       protected set {
    47         if (value != myItem) {
    48           if (myItem != null)
    49             RemoveItemEvents();
    50           myItem = value;
    51           if (myItem != null)
    52             AddItemEvents();
    53           OnItemChanged();
    54           Refresh();
    55         }
    56       }
     38      get { return (IItem)base.Object; }
     39      set { base.Object = value; }
    5740    }
    5841
     
    6548    }
    6649
    67     /// <summary>
    68     /// Removes the eventhandlers from the current instance.
    69     /// </summary>
    70     protected virtual void RemoveItemEvents() { }
    71     /// <summary>
    72     /// Adds eventhandlers to the current instance.
    73     /// </summary>
    74     protected virtual void AddItemEvents() { }
    75 
    76     /// <summary>
    77     /// Refreshes the current view.
    78     /// </summary>
    79     /// <remarks>Creates a new <see cref="MethodInvoker"/> if an invoke is required
    80     /// (see <see cref="Control.InvokeRequired"/>.<br/>
    81     /// Otherwise calls <see cref="UpdateControls"/> and <see cref="Control.Refresh"/> of base class
    82     /// <see cref="System.Windows.Forms.UserControl"/>.</remarks>
    83     public override void Refresh() {
    84       if (InvokeRequired) {
    85         Invoke(new Action(Refresh));
     50    protected override void OnObjectChanged() {
     51      if (Item == null) {
     52        Caption = "View";
    8653      } else {
    87         UpdateControls();
    88         base.Refresh();
     54        Caption = Item.ItemName;
    8955      }
    90     }
    91     /// <summary>
    92     /// Updates the controls with the latest values of the model.
    93     /// </summary>
    94     protected virtual void UpdateControls() {
    95       if (Item == null)
    96         Caption = "View";
    97       else
    98         Caption = Item.Name;
    99      
    100     }
    101 
    102     /// <summary>
    103     /// Occurs when the current item was changed.
    104     /// </summary>
    105     public event EventHandler ItemChanged;
    106     /// <summary>
    107     /// Fires a new <c>ItemChanged</c> event.
    108     /// </summary>
    109     protected virtual void OnItemChanged() {
    110       if (ItemChanged != null)
    111         ItemChanged(this, new EventArgs());
    112     }
    113 
    114     /// <summary>
    115     /// Asynchron call of GUI updating.
    116     /// </summary>
    117     /// <param name="method">The delegate to invoke.</param>
    118     protected new void Invoke(Delegate method) {
    119       // enforce context switch to improve GUI response time
    120       System.Threading.Thread.Sleep(0);
    121 
    122       // prevent blocking of worker thread in Invoke, if the control is disposed
    123       IAsyncResult result = BeginInvoke(method);
    124       while ((!result.AsyncWaitHandle.WaitOne(100, false)) && (!IsDisposed)) { }
    125       if (!IsDisposed) EndInvoke(result);
    126     }
    127     /// <summary>
    128     /// Asynchron call of GUI updating.
    129     /// </summary>
    130     /// <param name="method">The delegate to invoke.</param>
    131     /// <param name="args">The invoke arguments.</param>
    132     protected new void Invoke(Delegate method, params object[] args) {
    133       // enforce context switch to improve GUI response time
    134       System.Threading.Thread.Sleep(0);
    135 
    136       // prevent blocking of worker thread in Invoke, if the control is disposed
    137       IAsyncResult result = BeginInvoke(method, args);
    138       while ((!result.AsyncWaitHandle.WaitOne(100, false)) && (!IsDisposed)) { }
    139       if (!IsDisposed) EndInvoke(result);
    14056    }
    14157  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorBaseView.Designer.cs

    r2524 r2655  
    2020#endregion
    2121
    22 using System;
    23 using System.Windows.Forms;
    24 
    2522namespace HeuristicLab.Core.Views {
    2623  partial class OperatorBaseView {
     
    3532    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    3633    protected override void Dispose(bool disposing) {
    37       if (disposing && (components != null)) {
    38         components.Dispose();
     34      if (disposing) {
     35        if (components != null) components.Dispose();
    3936      }
    4037      base.Dispose(disposing);
     
    4845    /// </summary>
    4946    private void InitializeComponent() {
    50       this.tabControl = new System.Windows.Forms.TabControl();
    51       this.variableInfosTabPage = new System.Windows.Forms.TabPage();
    52       this.operatorBaseVariableInfosView = new HeuristicLab.Core.Views.OperatorBaseVariableInfosView();
    53       this.variablesTabPage = new System.Windows.Forms.TabPage();
    54       this.operatorBaseVariablesView = new HeuristicLab.Core.Views.OperatorBaseVariablesView();
    55       this.descriptionTabPage = new System.Windows.Forms.TabPage();
    56       this.operatorBaseDescriptionView = new HeuristicLab.Core.Views.OperatorBaseDescriptionView();
    57       this.tabControl.SuspendLayout();
    58       this.variableInfosTabPage.SuspendLayout();
    59       this.variablesTabPage.SuspendLayout();
    60       this.descriptionTabPage.SuspendLayout();
     47      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    6148      this.SuspendLayout();
    6249      //
    63       // tabControl
     50      // nameTextBox
    6451      //
    65       this.tabControl.Controls.Add(this.variableInfosTabPage);
    66       this.tabControl.Controls.Add(this.variablesTabPage);
    67       this.tabControl.Controls.Add(this.descriptionTabPage);
    68       this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
    69       this.tabControl.Location = new System.Drawing.Point(0, 0);
    70       this.tabControl.Name = "tabControl";
    71       this.tabControl.SelectedIndex = 0;
    72       this.tabControl.Size = new System.Drawing.Size(423, 333);
    73       this.tabControl.TabIndex = 0;
     52      this.nameTextBox.Size = new System.Drawing.Size(418, 20);
    7453      //
    75       // variableInfosTabPage
     54      // descriptionTextBox
    7655      //
    77       this.variableInfosTabPage.Controls.Add(this.operatorBaseVariableInfosView);
    78       this.variableInfosTabPage.Location = new System.Drawing.Point(4, 22);
    79       this.variableInfosTabPage.Name = "variableInfosTabPage";
    80       this.variableInfosTabPage.Padding = new System.Windows.Forms.Padding(3);
    81       this.variableInfosTabPage.Size = new System.Drawing.Size(415, 307);
    82       this.variableInfosTabPage.TabIndex = 0;
    83       this.variableInfosTabPage.Text = "Variable Infos";
    84       this.variableInfosTabPage.UseVisualStyleBackColor = true;
     56      this.descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     57                  | System.Windows.Forms.AnchorStyles.Right)));
     58      this.descriptionTextBox.Size = new System.Drawing.Size(418, 90);
    8559      //
    86       // operatorBaseVariableInfosView
     60      // parameterCollectionView
    8761      //
    88       this.operatorBaseVariableInfosView.Caption = "Operator";
    89       this.operatorBaseVariableInfosView.Dock = System.Windows.Forms.DockStyle.Fill;
    90       this.operatorBaseVariableInfosView.Location = new System.Drawing.Point(3, 3);
    91       this.operatorBaseVariableInfosView.Name = "operatorBaseVariableInfosView";
    92       this.operatorBaseVariableInfosView.Operator = null;
    93       this.operatorBaseVariableInfosView.Size = new System.Drawing.Size(409, 301);
    94       this.operatorBaseVariableInfosView.TabIndex = 0;
    95       //
    96       // variablesTabPage
    97       //
    98       this.variablesTabPage.Controls.Add(this.operatorBaseVariablesView);
    99       this.variablesTabPage.Location = new System.Drawing.Point(4, 22);
    100       this.variablesTabPage.Name = "variablesTabPage";
    101       this.variablesTabPage.Padding = new System.Windows.Forms.Padding(3);
    102       this.variablesTabPage.Size = new System.Drawing.Size(415, 307);
    103       this.variablesTabPage.TabIndex = 1;
    104       this.variablesTabPage.Text = "Local Variables";
    105       this.variablesTabPage.UseVisualStyleBackColor = true;
    106       //
    107       // operatorBaseVariablesView
    108       //
    109       this.operatorBaseVariablesView.Caption = "Operator";
    110       this.operatorBaseVariablesView.Dock = System.Windows.Forms.DockStyle.Fill;
    111       this.operatorBaseVariablesView.Location = new System.Drawing.Point(3, 3);
    112       this.operatorBaseVariablesView.Name = "operatorBaseVariablesView";
    113       this.operatorBaseVariablesView.Operator = null;
    114       this.operatorBaseVariablesView.Size = new System.Drawing.Size(409, 301);
    115       this.operatorBaseVariablesView.TabIndex = 0;
    116       //
    117       // descriptionTabPage
    118       //
    119       this.descriptionTabPage.Controls.Add(this.operatorBaseDescriptionView);
    120       this.descriptionTabPage.Location = new System.Drawing.Point(4, 22);
    121       this.descriptionTabPage.Name = "descriptionTabPage";
    122       this.descriptionTabPage.Padding = new System.Windows.Forms.Padding(3);
    123       this.descriptionTabPage.Size = new System.Drawing.Size(415, 307);
    124       this.descriptionTabPage.TabIndex = 3;
    125       this.descriptionTabPage.Text = "Description";
    126       this.descriptionTabPage.UseVisualStyleBackColor = true;
    127       //
    128       // operatorBaseDescriptionView
    129       //
    130       this.operatorBaseDescriptionView.Caption = "Operator";
    131       this.operatorBaseDescriptionView.Dock = System.Windows.Forms.DockStyle.Fill;
    132       this.operatorBaseDescriptionView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    133       this.operatorBaseDescriptionView.Location = new System.Drawing.Point(3, 3);
    134       this.operatorBaseDescriptionView.Name = "operatorBaseDescriptionView";
    135       this.operatorBaseDescriptionView.Operator = null;
    136       this.operatorBaseDescriptionView.Size = new System.Drawing.Size(409, 301);
    137       this.operatorBaseDescriptionView.TabIndex = 0;
     62      this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     63                  | System.Windows.Forms.AnchorStyles.Left)
     64                  | System.Windows.Forms.AnchorStyles.Right)));
     65      this.parameterCollectionView.Caption = "ParameterCollection";
     66      this.parameterCollectionView.ItemCollection = null;
     67      this.parameterCollectionView.Location = new System.Drawing.Point(0, 122);
     68      this.parameterCollectionView.Name = "parameterCollectionView";
     69      this.parameterCollectionView.NamedItemCollection = null;
     70      this.parameterCollectionView.Size = new System.Drawing.Size(490, 231);
     71      this.parameterCollectionView.TabIndex = 4;
    13872      //
    13973      // OperatorBaseView
     
    14175      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    14276      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    143       this.Controls.Add(this.tabControl);
     77      this.Controls.Add(this.parameterCollectionView);
    14478      this.Name = "OperatorBaseView";
    145       this.Size = new System.Drawing.Size(423, 333);
    146       this.tabControl.ResumeLayout(false);
    147       this.variableInfosTabPage.ResumeLayout(false);
    148       this.variablesTabPage.ResumeLayout(false);
    149       this.descriptionTabPage.ResumeLayout(false);
     79      this.Size = new System.Drawing.Size(490, 353);
     80      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
     81      this.Controls.SetChildIndex(this.nameLabel, 0);
     82      this.Controls.SetChildIndex(this.descriptionLabel, 0);
     83      this.Controls.SetChildIndex(this.nameTextBox, 0);
     84      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
    15085      this.ResumeLayout(false);
     86      this.PerformLayout();
    15187
    15288    }
     
    15490    #endregion
    15591
    156     protected TabControl tabControl;
    157     protected TabPage variableInfosTabPage;
    158     protected TabPage variablesTabPage;
    159     protected OperatorBaseVariableInfosView operatorBaseVariableInfosView;
    160     protected OperatorBaseVariablesView operatorBaseVariablesView;
    161     private TabPage descriptionTabPage;
    162     private OperatorBaseDescriptionView operatorBaseDescriptionView;
     92    protected ParameterCollectionView parameterCollectionView;
    16393
    16494
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorBaseView.cs

    r2546 r2655  
    2929using HeuristicLab.MainForm;
    3030
    31 namespace HeuristicLab.Core.Views {
     31namespace HeuristicLab.Core.Views { 
    3232  /// <summary>
    33   /// The base class for visual representation of operators (contains description view, variable view,
    34   /// variable info view,...).
     33  /// The base class for visual representations of items.
    3534  /// </summary>
    3635  [Content(typeof(OperatorBase), true)]
    37   public partial class OperatorBaseView : ItemViewBase {
    38     /// <summary>
    39     /// Gets or sets the operator to represent visually.
    40     /// </summary>
    41     /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    42     /// No own data storage present.</remarks>
    43     public IOperator Operator {
    44       get { return (IOperator)Item; }
    45       set {base.Item = value; }
     36  public partial class OperatorBaseView : NamedItemBaseView {
     37    public OperatorBase OperatorBase {
     38      get { return (OperatorBase)base.Item; }
     39      set { base.Item = value; }
    4640    }
    4741
    4842    /// <summary>
    49     /// Initializes a new instance of <see cref="OperatorBaseView"/> with caption "Operator".
     43    /// Initializes a new instance of <see cref="ItemBaseView"/>.
    5044    /// </summary>
    5145    public OperatorBaseView() {
    5246      InitializeComponent();
    53       Caption = "Operator";
    5447    }
    5548    /// <summary>
    56     /// Initializes a new instance of <see cref="OperatorBaseView"/>
    57     /// with the given operator <paramref name="op"/>.
     49    /// Intializes a new instance of <see cref="ItemBaseView"/> with the given <paramref name="item"/>.
    5850    /// </summary>
    59     /// <remarks>Calls <see cref="OperatorBaseView()"/>.</remarks>
    60     /// <param name="op">The operator to represent visually.</param>
    61     public OperatorBaseView(IOperator op)
     51    /// <param name="item">The item that should be displayed.</param>
     52    public OperatorBaseView(OperatorBase operatorBase)
    6253      : this() {
    63       Operator = op;
     54      OperatorBase = operatorBase;
    6455    }
    6556
    66     /// <summary>
    67     /// Removes event handlers in all children.
    68     /// </summary>
    69     protected override void RemoveItemEvents() {
    70       operatorBaseVariableInfosView.Operator = null;
    71       operatorBaseVariablesView.Operator = null;
    72       operatorBaseDescriptionView.Operator = null;
    73       base.RemoveItemEvents();
    74     }
    75     /// <summary>
    76     /// Adds event handlers in all children.
    77     /// </summary>
    78     protected override void AddItemEvents() {
    79       base.AddItemEvents();
    80       operatorBaseVariableInfosView.Operator = Operator;
    81       operatorBaseVariablesView.Operator = Operator;
    82       operatorBaseDescriptionView.Operator = Operator;
    83     }
    84 
    85     /// <summary>
    86     /// Updates all controls with the latest data of the model.
    87     /// </summary>
    88     /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
    89     protected override void UpdateControls() {
    90       base.UpdateControls();
    91       if (Operator == null) {
    92         Caption = "Operator";
    93         tabControl.Enabled = false;
     57    protected override void OnObjectChanged() {
     58      base.OnObjectChanged();
     59      if (OperatorBase == null) {
     60        parameterCollectionView.NamedItemCollection = null;
    9461      } else {
    95         Caption = Operator.Name + " (" + Operator.GetType().Name + ")";
    96         tabControl.Enabled = true;
     62        parameterCollectionView.NamedItemCollection = ((IOperator)OperatorBase).Parameters;
    9763      }
    9864    }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.Designer.cs

    r2520 r2655  
    3232    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    3333    protected override void Dispose(bool disposing) {
    34       if (chooseOperatorDialog != null) chooseOperatorDialog.Dispose();
    35       if (graphTreeView.Nodes.Count > 0) {
    36         RemoveTreeNode(graphTreeView.Nodes[0]);
    37         graphTreeView.Nodes.Clear();
    38       }
    39       if (disposing && (components != null)) {
    40         components.Dispose();
     34      if (disposing) {
     35        if (components != null) components.Dispose();
    4136      }
    4237      base.Dispose(disposing);
     
    5146    private void InitializeComponent() {
    5247      this.components = new System.ComponentModel.Container();
    53       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OperatorGraphView));
    54       this.operatorsListView = new System.Windows.Forms.ListView();
    55       this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
    5648      this.operatorsContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    5749      this.initialOperatorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    58       this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    59       this.imageList = new System.Windows.Forms.ImageList(this.components);
    60       this.addOperatorButton = new System.Windows.Forms.Button();
    61       this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    62       this.operatorsGroupBox = new System.Windows.Forms.GroupBox();
     50      this.operatorsView = new HeuristicLab.Core.Views.OperatorSetView();
     51      this.graphView = new HeuristicLab.Core.Views.OperatorTreeView();
     52      this.splitContainer = new System.Windows.Forms.SplitContainer();
    6353      this.graphGroupBox = new System.Windows.Forms.GroupBox();
    64       this.graphTreeView = new System.Windows.Forms.TreeView();
    65       this.graphContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    66       this.breakpointToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    67       this.viewToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
    68       this.removeButton = new System.Windows.Forms.Button();
    69       this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    7054      this.operatorsContextMenuStrip.SuspendLayout();
    71       this.splitContainer1.Panel1.SuspendLayout();
    72       this.splitContainer1.Panel2.SuspendLayout();
    73       this.splitContainer1.SuspendLayout();
    74       this.operatorsGroupBox.SuspendLayout();
     55      this.splitContainer.Panel1.SuspendLayout();
     56      this.splitContainer.Panel2.SuspendLayout();
     57      this.splitContainer.SuspendLayout();
    7558      this.graphGroupBox.SuspendLayout();
    76       this.graphContextMenuStrip.SuspendLayout();
    7759      this.SuspendLayout();
    78       //
    79       // operatorsListView
    80       //
    81       this.operatorsListView.AllowDrop = true;
    82       this.operatorsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
    83             this.columnHeader1});
    84       this.operatorsListView.ContextMenuStrip = this.operatorsContextMenuStrip;
    85       this.operatorsListView.Dock = System.Windows.Forms.DockStyle.Fill;
    86       this.operatorsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
    87       this.operatorsListView.HideSelection = false;
    88       this.operatorsListView.LabelEdit = true;
    89       this.operatorsListView.Location = new System.Drawing.Point(3, 16);
    90       this.operatorsListView.Name = "operatorsListView";
    91       this.operatorsListView.Size = new System.Drawing.Size(169, 243);
    92       this.operatorsListView.SmallImageList = this.imageList;
    93       this.operatorsListView.TabIndex = 0;
    94       this.operatorsListView.UseCompatibleStateImageBehavior = false;
    95       this.operatorsListView.View = System.Windows.Forms.View.Details;
    96       this.operatorsListView.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.operatorsListView_AfterLabelEdit);
    97       this.operatorsListView.SelectedIndexChanged += new System.EventHandler(this.operatorsListView_SelectedIndexChanged);
    98       this.operatorsListView.SizeChanged += new System.EventHandler(this.operatorsListView_SizeChanged);
    99       this.operatorsListView.DoubleClick += new System.EventHandler(this.operatorsListView_DoubleClick);
    100       this.operatorsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.operatorsListView_DragDrop);
    101       this.operatorsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.operatorsListView_DragEnter);
    102       this.operatorsListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.operatorsListView_KeyDown);
    103       this.operatorsListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.operatorsListView_ItemDrag);
    104       this.operatorsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.operatorsListView_DragOver);
    10560      //
    10661      // operatorsContextMenuStrip
    10762      //
    10863      this.operatorsContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    109             this.initialOperatorToolStripMenuItem,
    110             this.viewToolStripMenuItem});
     64            this.initialOperatorToolStripMenuItem});
    11165      this.operatorsContextMenuStrip.Name = "operatorsContextMenuStrip";
    112       this.operatorsContextMenuStrip.Size = new System.Drawing.Size(159, 48);
     66      this.operatorsContextMenuStrip.Size = new System.Drawing.Size(154, 26);
    11367      this.operatorsContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.operatorsContextMenuStrip_Opening);
    11468      //
     
    11771      this.initialOperatorToolStripMenuItem.CheckOnClick = true;
    11872      this.initialOperatorToolStripMenuItem.Name = "initialOperatorToolStripMenuItem";
    119       this.initialOperatorToolStripMenuItem.Size = new System.Drawing.Size(158, 22);
     73      this.initialOperatorToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
    12074      this.initialOperatorToolStripMenuItem.Text = "&Initial Operator";
    12175      this.initialOperatorToolStripMenuItem.ToolTipText = "Set as initial operator";
    12276      this.initialOperatorToolStripMenuItem.Click += new System.EventHandler(this.initialOperatorToolStripMenuItem_Click);
    12377      //
    124       // viewToolStripMenuItem
     78      // operatorsView
    12579      //
    126       this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
    127       this.viewToolStripMenuItem.Size = new System.Drawing.Size(158, 22);
    128       this.viewToolStripMenuItem.Text = "&View...";
    129       this.viewToolStripMenuItem.ToolTipText = "View operator";
    130       this.viewToolStripMenuItem.Click += new System.EventHandler(this.viewToolStripMenuItem_Click);
     80      this.operatorsView.Caption = "Operator Set";
     81      this.operatorsView.Dock = System.Windows.Forms.DockStyle.Fill;
     82      this.operatorsView.ItemCollection = null;
     83      this.operatorsView.ItemSet = null;
     84      this.operatorsView.Location = new System.Drawing.Point(0, 0);
     85      this.operatorsView.Name = "operatorsView";
     86      this.operatorsView.Size = new System.Drawing.Size(608, 316);
     87      this.operatorsView.TabIndex = 0;
     88      this.operatorsView.Load += new System.EventHandler(this.operatorsView_Load);
    13189      //
    132       // imageList
     90      // graphView
    13391      //
    134       this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
    135       this.imageList.TransparentColor = System.Drawing.Color.Magenta;
    136       this.imageList.Images.SetKeyName(0, "Operator.bmp");
    137       this.imageList.Images.SetKeyName(1, "CombinedOperator.bmp");
    138       this.imageList.Images.SetKeyName(2, "ProgrammableOperator.bmp");
     92      this.graphView.Caption = "Operator";
     93      this.graphView.Dock = System.Windows.Forms.DockStyle.Fill;
     94      this.graphView.Item = null;
     95      this.graphView.Location = new System.Drawing.Point(3, 16);
     96      this.graphView.Name = "graphView";
     97      this.graphView.Operator = null;
     98      this.graphView.Size = new System.Drawing.Size(602, 194);
     99      this.graphView.TabIndex = 0;
    139100      //
    140       // addOperatorButton
     101      // splitContainer
    141102      //
    142       this.addOperatorButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    143       this.addOperatorButton.Location = new System.Drawing.Point(0, 268);
    144       this.addOperatorButton.Name = "addOperatorButton";
    145       this.addOperatorButton.Size = new System.Drawing.Size(75, 23);
    146       this.addOperatorButton.TabIndex = 0;
    147       this.addOperatorButton.Text = "&Add...";
    148       this.addOperatorButton.UseVisualStyleBackColor = true;
    149       this.addOperatorButton.Click += new System.EventHandler(this.addOperatorButton_Click);
     103      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     104      this.splitContainer.Location = new System.Drawing.Point(0, 0);
     105      this.splitContainer.Name = "splitContainer";
     106      this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
    150107      //
    151       // splitContainer1
     108      // splitContainer.Panel1
    152109      //
    153       this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    154                   | System.Windows.Forms.AnchorStyles.Left)
    155                   | System.Windows.Forms.AnchorStyles.Right)));
    156       this.splitContainer1.Location = new System.Drawing.Point(0, 0);
    157       this.splitContainer1.Name = "splitContainer1";
     110      this.splitContainer.Panel1.Controls.Add(this.operatorsView);
    158111      //
    159       // splitContainer1.Panel1
     112      // splitContainer.Panel2
    160113      //
    161       this.splitContainer1.Panel1.Controls.Add(this.operatorsGroupBox);
    162       //
    163       // splitContainer1.Panel2
    164       //
    165       this.splitContainer1.Panel2.Controls.Add(this.graphGroupBox);
    166       this.splitContainer1.Size = new System.Drawing.Size(475, 262);
    167       this.splitContainer1.SplitterDistance = 175;
    168       this.splitContainer1.TabIndex = 4;
    169       //
    170       // operatorsGroupBox
    171       //
    172       this.operatorsGroupBox.Controls.Add(this.operatorsListView);
    173       this.operatorsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    174       this.operatorsGroupBox.Location = new System.Drawing.Point(0, 0);
    175       this.operatorsGroupBox.Name = "operatorsGroupBox";
    176       this.operatorsGroupBox.Size = new System.Drawing.Size(175, 262);
    177       this.operatorsGroupBox.TabIndex = 3;
    178       this.operatorsGroupBox.TabStop = false;
    179       this.operatorsGroupBox.Text = "&Operators";
     114      this.splitContainer.Panel2.Controls.Add(this.graphGroupBox);
     115      this.splitContainer.Size = new System.Drawing.Size(608, 533);
     116      this.splitContainer.SplitterDistance = 316;
     117      this.splitContainer.TabIndex = 3;
    180118      //
    181119      // graphGroupBox
    182120      //
    183       this.graphGroupBox.Controls.Add(this.graphTreeView);
     121      this.graphGroupBox.Controls.Add(this.graphView);
    184122      this.graphGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    185123      this.graphGroupBox.Location = new System.Drawing.Point(0, 0);
    186124      this.graphGroupBox.Name = "graphGroupBox";
    187       this.graphGroupBox.Size = new System.Drawing.Size(296, 262);
     125      this.graphGroupBox.Size = new System.Drawing.Size(608, 213);
    188126      this.graphGroupBox.TabIndex = 0;
    189127      this.graphGroupBox.TabStop = false;
    190       this.graphGroupBox.Text = "&Graph";
    191       //
    192       // graphTreeView
    193       //
    194       this.graphTreeView.AllowDrop = true;
    195       this.graphTreeView.ContextMenuStrip = this.graphContextMenuStrip;
    196       this.graphTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
    197       this.graphTreeView.HideSelection = false;
    198       this.graphTreeView.Location = new System.Drawing.Point(3, 16);
    199       this.graphTreeView.Name = "graphTreeView";
    200       this.graphTreeView.ShowNodeToolTips = true;
    201       this.graphTreeView.Size = new System.Drawing.Size(290, 243);
    202       this.graphTreeView.TabIndex = 0;
    203       this.graphTreeView.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.graphTreeView_BeforeExpand);
    204       this.graphTreeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.graphTreeView_DragDrop);
    205       this.graphTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.graphTreeView_AfterSelect);
    206       this.graphTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.graphTreeView_MouseDown);
    207       this.graphTreeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.graphTreeView_DragEnter);
    208       this.graphTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.graphTreeView_KeyDown);
    209       this.graphTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.graphTreeView_ItemDrag);
    210       this.graphTreeView.DragOver += new System.Windows.Forms.DragEventHandler(this.graphTreeView_DragOver);
    211       //
    212       // graphContextMenuStrip
    213       //
    214       this.graphContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    215             this.breakpointToolStripMenuItem,
    216             this.viewToolStripMenuItem1});
    217       this.graphContextMenuStrip.Name = "graphContextMenuStrip";
    218       this.graphContextMenuStrip.Size = new System.Drawing.Size(137, 48);
    219       this.graphContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.graphContextMenuStrip_Opening);
    220       //
    221       // breakpointToolStripMenuItem
    222       //
    223       this.breakpointToolStripMenuItem.CheckOnClick = true;
    224       this.breakpointToolStripMenuItem.Name = "breakpointToolStripMenuItem";
    225       this.breakpointToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
    226       this.breakpointToolStripMenuItem.Text = "&Breakpoint";
    227       this.breakpointToolStripMenuItem.ToolTipText = "Halt engine execution after executing the operator";
    228       this.breakpointToolStripMenuItem.Click += new System.EventHandler(this.breakpointToolStripMenuItem_Click);
    229       //
    230       // viewToolStripMenuItem1
    231       //
    232       this.viewToolStripMenuItem1.Name = "viewToolStripMenuItem1";
    233       this.viewToolStripMenuItem1.Size = new System.Drawing.Size(136, 22);
    234       this.viewToolStripMenuItem1.Text = "&View...";
    235       this.viewToolStripMenuItem1.ToolTipText = "View operator";
    236       this.viewToolStripMenuItem1.Click += new System.EventHandler(this.viewToolStripMenuItem_Click);
    237       //
    238       // removeButton
    239       //
    240       this.removeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    241       this.removeButton.Location = new System.Drawing.Point(81, 268);
    242       this.removeButton.Name = "removeButton";
    243       this.removeButton.Size = new System.Drawing.Size(75, 23);
    244       this.removeButton.TabIndex = 1;
    245       this.removeButton.Text = "&Remove";
    246       this.removeButton.UseVisualStyleBackColor = true;
    247       this.removeButton.Click += new System.EventHandler(this.removeButton_Click);
     128      this.graphGroupBox.Text = "Operator &Graph";
    248129      //
    249130      // OperatorGraphView
     
    251132      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    252133      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    253       this.Controls.Add(this.splitContainer1);
    254       this.Controls.Add(this.addOperatorButton);
    255       this.Controls.Add(this.removeButton);
     134      this.Controls.Add(this.splitContainer);
    256135      this.Name = "OperatorGraphView";
    257       this.Size = new System.Drawing.Size(475, 291);
     136      this.Size = new System.Drawing.Size(608, 533);
    258137      this.operatorsContextMenuStrip.ResumeLayout(false);
    259       this.splitContainer1.Panel1.ResumeLayout(false);
    260       this.splitContainer1.Panel2.ResumeLayout(false);
    261       this.splitContainer1.ResumeLayout(false);
    262       this.operatorsGroupBox.ResumeLayout(false);
     138      this.splitContainer.Panel1.ResumeLayout(false);
     139      this.splitContainer.Panel2.ResumeLayout(false);
     140      this.splitContainer.ResumeLayout(false);
    263141      this.graphGroupBox.ResumeLayout(false);
    264       this.graphContextMenuStrip.ResumeLayout(false);
    265142      this.ResumeLayout(false);
    266143
     
    269146    #endregion
    270147
    271     private System.Windows.Forms.Button addOperatorButton;
    272     private System.Windows.Forms.ListView operatorsListView;
    273     private System.Windows.Forms.SplitContainer splitContainer1;
    274     private System.Windows.Forms.GroupBox operatorsGroupBox;
    275     private System.Windows.Forms.Button removeButton;
    276     private System.Windows.Forms.ColumnHeader columnHeader1;
    277148    private System.Windows.Forms.ContextMenuStrip operatorsContextMenuStrip;
    278     private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
    279149    private System.Windows.Forms.ToolStripMenuItem initialOperatorToolStripMenuItem;
    280     private System.Windows.Forms.ToolTip toolTip;
     150    private OperatorSetView operatorsView;
     151    private OperatorTreeView graphView;
     152    private System.Windows.Forms.SplitContainer splitContainer;
    281153    private System.Windows.Forms.GroupBox graphGroupBox;
    282     private System.Windows.Forms.TreeView graphTreeView;
    283     private System.Windows.Forms.ImageList imageList;
    284     private System.Windows.Forms.ContextMenuStrip graphContextMenuStrip;
    285     private System.Windows.Forms.ToolStripMenuItem breakpointToolStripMenuItem;
    286     private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem1;
    287154  }
    288155}
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.cs

    r2546 r2655  
    3030using HeuristicLab.Common;
    3131using HeuristicLab.MainForm;
     32using HeuristicLab.Collections;
    3233
    3334namespace HeuristicLab.Core.Views {
    3435  /// <summary>
    35   /// The visual representation of an <see cref="IOperatorGraph"/>.
     36  /// The visual representation of an <see cref="OperatorGraph"/>.
    3637  /// </summary>
    3738  [Content(typeof(OperatorGraph), true)]
    3839  public partial class OperatorGraphView : ItemViewBase {
    39     private ChooseOperatorDialog chooseOperatorDialog;
    40     private Dictionary<IOperator, IList<TreeNode>> operatorNodeTable;
    41 
    4240    /// <summary>
    4341    /// Gets or sets the operator graph to represent visually.
     
    4543    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    4644    /// No own data storage present.</remarks>
    47     public IOperatorGraph OperatorGraph {
    48       get { return (IOperatorGraph)Item; }
     45    public OperatorGraph OperatorGraph {
     46      get { return (OperatorGraph)Item; }
    4947      set { base.Item = value; }
    5048    }
     
    5553    public OperatorGraphView() {
    5654      InitializeComponent();
    57       operatorNodeTable = new Dictionary<IOperator, IList<TreeNode>>();
    58       operatorsListView.Columns[0].Width = Math.Max(0, operatorsListView.Width - 25);
    5955      Caption = "Operator Graph";
    6056    }
     
    6561    /// <remarks>Calls <see cref="OperatorGraphView()"/>.</remarks>
    6662    /// <param name="operatorGraph">The operator graph to represent visually.</param>
    67     public OperatorGraphView(IOperatorGraph operatorGraph)
     63    public OperatorGraphView(OperatorGraph operatorGraph)
    6864      : this() {
    6965      OperatorGraph = operatorGraph;
     
    7470    /// </summary>
    7571    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    76     protected override void RemoveItemEvents() {
    77       OperatorGraph.OperatorAdded -= new EventHandler<EventArgs<IOperator>>(OperatorGraph_OperatorAdded);
    78       OperatorGraph.OperatorRemoved -= new EventHandler<EventArgs<IOperator>>(OperatorGraph_OperatorRemoved);
     72    protected override void DeregisterObjectEvents() {
    7973      OperatorGraph.InitialOperatorChanged -= new EventHandler(OperatorGraph_InitialOperatorChanged);
    80       base.RemoveItemEvents();
     74      base.DeregisterObjectEvents();
    8175    }
     76
    8277    /// <summary>
    8378    /// Adds eventhandlers to the underlying <see cref="IOperatorGraph"/>.
    8479    /// </summary>
    8580    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    86     protected override void AddItemEvents() {
    87       base.AddItemEvents();
    88       OperatorGraph.OperatorAdded += new EventHandler<EventArgs<IOperator>>(OperatorGraph_OperatorAdded);
    89       OperatorGraph.OperatorRemoved += new EventHandler<EventArgs<IOperator>>(OperatorGraph_OperatorRemoved);
     81    protected override void RegisterObjectEvents() {
     82      base.RegisterObjectEvents();
    9083      OperatorGraph.InitialOperatorChanged += new EventHandler(OperatorGraph_InitialOperatorChanged);
    9184    }
     
    9588    /// </summary>
    9689    /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
    97     protected override void UpdateControls() {
    98       base.UpdateControls();
    99       if (graphTreeView.Nodes.Count > 0)
    100         RemoveTreeNode(graphTreeView.Nodes[0]);
    101       graphTreeView.SelectedNode = null;
    102       graphTreeView.Nodes.Clear();
    103       graphTreeView.Enabled = false;
    104       operatorsListView.Items.Clear();
    105       removeButton.Enabled = false;
     90    protected override void OnObjectChanged() {
     91      base.OnObjectChanged();
     92      operatorsView.ItemSet = null;
     93      operatorsView.Enabled = false;
     94      graphView.Operator = null;
     95      graphView.Enabled = false;
    10696      if (OperatorGraph == null) {
    10797        Caption = "Operator Graph";
    108         operatorsListView.Enabled = false;
    109         addOperatorButton.Enabled = false;
     98        operatorsView.ItemSet = null;
     99        operatorsView.Enabled = false;
     100        graphView.Operator = null;
     101        graphView.Enabled = false;
    110102      } else {
    111         Caption = "Operator Graph (" + OperatorGraph.GetType().Name + ")";
    112         foreach (IOperator op in OperatorGraph.Operators) {
    113           operatorsListView.Items.Add(CreateListViewItem(op));
    114         }
    115         operatorsListView.Enabled = true;
    116         addOperatorButton.Enabled = true;
    117         if (OperatorGraph.InitialOperator != null) {
    118           graphTreeView.Nodes.Add(CreateTreeNode(OperatorGraph.InitialOperator));
    119           graphTreeView.Enabled = true;
    120         }
     103        Caption = OperatorGraph.ItemName + " (" + OperatorGraph.GetType().Name + ")";
     104        operatorsView.ItemSet = OperatorGraph.Operators;
     105        operatorsView.Enabled = true;
     106        MarkInitialOperator();
     107        graphView.Operator = OperatorGraph.InitialOperator;
     108        graphView.Enabled = true;
    121109      }
    122110    }
    123111
    124     private ListViewItem CreateListViewItem(IOperator op) {
    125       ListViewItem item = new ListViewItem();
    126       item.Text = op.Name;
    127       item.Tag = op;
    128       item.ImageIndex = 0;
    129       if (op.GetType().Name == "CombinedOperator")
    130         item.ImageIndex = 1;
    131       else if (op.GetType().Name == "ProgrammableOperator")
    132         item.ImageIndex = 2;
    133       if (op == OperatorGraph.InitialOperator)
    134         item.Font = new Font(operatorsListView.Font, FontStyle.Bold);
    135       return item;
    136     }
    137 
    138     private TreeNode CreateTreeNode(IOperator op) {
    139       TreeNode node = new TreeNode();
    140       node.Text = op.Name;
    141       node.Tag = op;
    142       if (op.Breakpoint)
    143         node.ForeColor = Color.Red;
    144 
    145       if (!operatorNodeTable.ContainsKey(op)) {
    146         operatorNodeTable.Add(op, new List<TreeNode>());
    147         op.NameChanged += new EventHandler(Operator_NameChanged);
    148         op.BreakpointChanged += new EventHandler(Operator_BreakpointChanged);
    149         op.SubOperatorAdded += new EventHandler<EventArgs<IOperator, int>>(Operator_SubOperatorAdded);
    150         op.SubOperatorRemoved += new EventHandler<EventArgs<IOperator, int>>(Operator_SubOperatorRemoved);
    151       }
    152       operatorNodeTable[op].Add(node);
    153 
    154       for (int i = 0; i < op.SubOperators.Count; i++)
    155         node.Nodes.Add(new TreeNode());
    156       return node;
    157     }
    158 
    159     private void RemoveTreeNode(TreeNode node) {
    160       foreach (TreeNode child in node.Nodes)
    161         RemoveTreeNode(child);
    162 
    163       IOperator op = (IOperator)node.Tag;
    164       if (op != null) {
    165         operatorNodeTable[op].Remove(node);
    166         if (operatorNodeTable[op].Count == 0) {
    167           op.NameChanged -= new EventHandler(Operator_NameChanged);
    168           op.BreakpointChanged -= new EventHandler(Operator_BreakpointChanged);
    169           op.SubOperatorAdded -= new EventHandler<EventArgs<IOperator, int>>(Operator_SubOperatorAdded);
    170           op.SubOperatorRemoved -= new EventHandler<EventArgs<IOperator, int>>(Operator_SubOperatorRemoved);
    171           operatorNodeTable.Remove(op);
    172         }
     112    private void MarkInitialOperator() {
     113      foreach (ListViewItem item in operatorsView.ItemsListView.Items) {
     114        if ((OperatorGraph.InitialOperator != null) && (((IOperator)item.Tag) == OperatorGraph.InitialOperator))
     115          item.Font = new Font(operatorsView.ItemsListView.Font, FontStyle.Bold);
     116        else
     117          item.Font = operatorsView.ItemsListView.Font;
    173118      }
    174119    }
    175120
    176     #region ListView Events
    177     private void operatorsListView_SelectedIndexChanged(object sender, EventArgs e) {
    178       removeButton.Enabled = false;
    179       if (operatorsListView.SelectedItems.Count > 0) {
    180         removeButton.Enabled = true;
    181       }
    182     }
    183     private void operatorsListView_DoubleClick(object sender, EventArgs e) {
    184       if (operatorsListView.SelectedItems.Count == 1) {
    185         IOperator op = (IOperator)operatorsListView.SelectedItems[0].Tag;
    186         IView view = MainFormManager.CreateDefaultView(op);
    187         if (view != null) MainFormManager.MainForm.ShowView(view);
    188       }
    189     }
    190     #endregion
    191 
    192     #region TreeView Events
    193     private void graphTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) {
    194       TreeNode node = e.Node;
    195       IOperator op = (IOperator)node.Tag;
    196       for (int i = 0; i < node.Nodes.Count; i++) {
    197         if (node.Nodes[i].Tag == null) {
    198           node.Nodes[i].Remove();
    199           node.Nodes.Insert(i, CreateTreeNode(op.SubOperators[i]));
    200         }
    201       }
    202     }
    203     private void graphTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
    204       IOperator op = (IOperator)e.Node.Tag;
    205       foreach (ListViewItem item in operatorsListView.Items)
    206         item.Selected = item.Tag == op;
    207     }
    208     #endregion
    209 
    210     #region Size Changed Events
    211     private void operatorsListView_SizeChanged(object sender, EventArgs e) {
    212       if (operatorsListView.Columns.Count > 0)
    213         operatorsListView.Columns[0].Width = Math.Max(0, operatorsListView.Width - 25);
    214     }
    215     #endregion
    216 
    217     #region Key Events
    218     private void operatorsListView_KeyDown(object sender, KeyEventArgs e) {
    219       if (e.KeyCode == Keys.Delete) {
    220         if (operatorsListView.SelectedItems.Count > 0) {
    221           foreach (ListViewItem item in operatorsListView.SelectedItems)
    222             OperatorGraph.RemoveOperator((IOperator)item.Tag);
    223         }
    224       }
    225       if (e.KeyCode == Keys.F2) {
    226         if (operatorsListView.SelectedItems.Count == 1)
    227           operatorsListView.SelectedItems[0].BeginEdit();
    228       }
    229     }
    230     private void graphTreeView_KeyDown(object sender, KeyEventArgs e) {
    231       if (e.KeyCode == Keys.Delete) {
    232         TreeNode node = graphTreeView.SelectedNode;
    233         if ((node != null) && (node.Parent != null)) {
    234           IOperator parent = (IOperator)node.Parent.Tag;
    235           parent.RemoveSubOperator(node.Index);
    236         }
    237       }
    238     }
    239     #endregion
    240 
    241     #region Edit Events
    242     private void operatorsListView_AfterLabelEdit(object sender, LabelEditEventArgs e) {
    243       e.CancelEdit = false;
    244 
    245       string name = e.Label;
    246       if (name != null) {
    247         IOperator op = (IOperator)operatorsListView.Items[e.Item].Tag;
    248         op.Name = name;
    249       }
    250     }
    251     #endregion
    252 
    253     #region Button Events
    254     private void addOperatorButton_Click(object sender, EventArgs e) {
    255       if (chooseOperatorDialog == null) chooseOperatorDialog = new ChooseOperatorDialog();
    256       if (chooseOperatorDialog.ShowDialog(this) == DialogResult.OK)
    257         OperatorGraph.AddOperator(chooseOperatorDialog.Operator);
    258     }
    259     private void removeButton_Click(object sender, EventArgs e) {
    260       if (operatorsListView.SelectedItems.Count > 0) {
    261         foreach (ListViewItem item in operatorsListView.SelectedItems)
    262           OperatorGraph.RemoveOperator((IOperator)item.Tag);
    263       }
    264     }
    265     #endregion
    266 
    267     #region Drag and Drop Events
    268     private void operatorsListView_ItemDrag(object sender, ItemDragEventArgs e) {
    269       ListViewItem item = (ListViewItem)e.Item;
    270       IOperator op = (IOperator)item.Tag;
    271       DataObject data = new DataObject();
    272       data.SetData("IOperator", op);
    273       data.SetData("DragSource", operatorsListView);
    274       DoDragDrop(data, DragDropEffects.Copy);
    275     }
    276     private void operatorsListView_DragEnter(object sender, DragEventArgs e) {
    277       e.Effect = DragDropEffects.None;
    278       if (e.Data.GetDataPresent("IOperator"))
    279         e.Effect = DragDropEffects.Copy;
    280     }
    281     private void operatorsListView_DragOver(object sender, DragEventArgs e) {
    282       e.Effect = DragDropEffects.None;
    283       if (e.Data.GetDataPresent("IOperator"))
    284         e.Effect = DragDropEffects.Copy;
    285     }
    286     private void operatorsListView_DragDrop(object sender, DragEventArgs e) {
    287       if (e.Effect != DragDropEffects.None) {
    288         if (e.Data.GetDataPresent("IOperator")) {
    289           IOperator op = (IOperator)e.Data.GetData("IOperator");
    290           op = (IOperator)op.Clone();
    291           OperatorGraph.AddOperator(op);
    292         }
    293       }
    294     }
    295     private void graphTreeView_ItemDrag(object sender, ItemDragEventArgs e) {
    296       TreeNode node = (TreeNode)e.Item;
    297       if (node.Parent != null) {
    298         IOperator op = (IOperator)node.Tag;
    299         IOperator parent = (IOperator)node.Parent.Tag;
    300         int index = node.Index;
    301         DataObject data = new DataObject();
    302         data.SetData("IOperator", op);
    303         data.SetData("DragSource", graphTreeView);
    304         data.SetData("ParentOperator", parent);
    305         data.SetData("Index", index);
    306         DoDragDrop(data, DragDropEffects.Move);
    307       }
    308     }
    309     private void graphTreeView_DragEnter(object sender, DragEventArgs e) {
    310       e.Effect = DragDropEffects.None;
    311       if (e.Data.GetDataPresent("IOperator")) {
    312         Point p = graphTreeView.PointToClient(new Point(e.X, e.Y));
    313         TreeNode node = graphTreeView.GetNodeAt(p);
    314         if (node != null) {
    315           if ((e.Data.GetDataPresent("ParentOperator")) && (node.Parent != null)) {
    316             if ((e.Data.GetDataPresent("DragSource")) && (e.Data.GetData("DragSource") == graphTreeView))
    317               e.Effect = DragDropEffects.Move;
    318           } else {
    319             if ((e.Data.GetDataPresent("DragSource")) && (e.Data.GetData("DragSource") == operatorsListView))
    320               e.Effect = DragDropEffects.Copy;
    321           }
    322         }
    323       }
    324     }
    325     private void graphTreeView_DragOver(object sender, DragEventArgs e) {
    326       e.Effect = DragDropEffects.None;
    327       if (e.Data.GetDataPresent("IOperator")) {
    328         Point p = graphTreeView.PointToClient(new Point(e.X, e.Y));
    329         TreeNode node = graphTreeView.GetNodeAt(p);
    330         if (node != null) {
    331           if ((e.Data.GetDataPresent("ParentOperator")) && (node.Parent != null)) {
    332             if ((e.Data.GetDataPresent("DragSource")) && (e.Data.GetData("DragSource") == graphTreeView))
    333               e.Effect = DragDropEffects.Move;
    334           } else {
    335             if ((e.Data.GetDataPresent("DragSource")) && (e.Data.GetData("DragSource") == operatorsListView))
    336               e.Effect = DragDropEffects.Copy;
    337           }
    338         }
    339       }
    340     }
    341     private void graphTreeView_DragDrop(object sender, DragEventArgs e) {
    342       if (e.Effect != DragDropEffects.None) {
    343         if (e.Data.GetDataPresent("IOperator")) {
    344           IOperator op = (IOperator)e.Data.GetData("IOperator");
    345           Point p = graphTreeView.PointToClient(new Point(e.X, e.Y));
    346           TreeNode node = graphTreeView.GetNodeAt(p);
    347           if (e.Data.GetDataPresent("ParentOperator")) {
    348             if (node.Parent != null) {
    349               TreeNode parentNode = node.Parent;
    350               IOperator oldParent = (IOperator)e.Data.GetData("ParentOperator");
    351               int oldIndex = (int)e.Data.GetData("Index");
    352               IOperator newParent = (IOperator)node.Parent.Tag;
    353               int newIndex = node.Index;
    354               oldParent.RemoveSubOperator(oldIndex);
    355               newParent.AddSubOperator(op, newIndex);
    356               graphTreeView.SelectedNode = parentNode.Nodes[newIndex];
    357             }
    358           } else {
    359             if (node != null) {
    360               IOperator parent = (IOperator)node.Tag;
    361               parent.AddSubOperator(op);
    362               graphTreeView.SelectedNode = node.Nodes[node.Nodes.Count - 1];
    363             }
    364           }
    365         }
    366       }
    367     }
    368     #endregion
    369 
    370121    #region Context Menu Events
    371122    private void operatorsContextMenuStrip_Opening(object sender, CancelEventArgs e) {
    372       viewToolStripMenuItem.Enabled = false;
    373123      initialOperatorToolStripMenuItem.Enabled = false;
    374124      initialOperatorToolStripMenuItem.Checked = false;
    375       if (operatorsListView.SelectedItems.Count == 1) {
    376         IOperator op = (IOperator)operatorsListView.SelectedItems[0].Tag;
    377         IView view = MainFormManager.CreateDefaultView(op);
    378         if (view != null) {
    379           viewToolStripMenuItem.Enabled = true;
    380           viewToolStripMenuItem.Tag = view;
    381         }
     125      if (operatorsView.ItemsListView.SelectedItems.Count == 1) {
     126        IOperator op = (IOperator)operatorsView.ItemsListView.SelectedItems[0].Tag;
    382127        initialOperatorToolStripMenuItem.Enabled = true;
    383128        initialOperatorToolStripMenuItem.Tag = op;
     
    386131      }
    387132    }
    388     private void viewToolStripMenuItem_Click(object sender, EventArgs e) {
    389       IView view = ((ToolStripMenuItem)sender).Tag as IView;
    390       if (view != null) MainFormManager.MainForm.ShowView(view);
    391     }
    392133    private void initialOperatorToolStripMenuItem_Click(object sender, EventArgs e) {
    393       if (initialOperatorToolStripMenuItem.Checked) {
    394         foreach (ListViewItem item in operatorsListView.Items)
    395           item.Font = operatorsListView.Font;
    396         operatorsListView.SelectedItems[0].Font = new Font(operatorsListView.Font, FontStyle.Bold);
     134      if (initialOperatorToolStripMenuItem.Checked)
    397135        OperatorGraph.InitialOperator = (IOperator)initialOperatorToolStripMenuItem.Tag;
    398       } else {
    399         operatorsListView.SelectedItems[0].Font = operatorsListView.Font;
     136      else
    400137        OperatorGraph.InitialOperator = null;
    401       }
    402     }
    403     private void graphContextMenuStrip_Opening(object sender, CancelEventArgs e) {
    404       viewToolStripMenuItem1.Enabled = false;
    405       breakpointToolStripMenuItem.Enabled = false;
    406       breakpointToolStripMenuItem.Checked = false;
    407       if (graphTreeView.SelectedNode != null) {
    408         IOperator op = (IOperator)graphTreeView.SelectedNode.Tag;
    409         IView view = MainFormManager.CreateDefaultView(op);
    410         if (view != null) {
    411           viewToolStripMenuItem1.Enabled = true;
    412           viewToolStripMenuItem1.Tag = view;
    413         }
    414         breakpointToolStripMenuItem.Enabled = true;
    415         breakpointToolStripMenuItem.Tag = op;
    416         if (op.Breakpoint)
    417           breakpointToolStripMenuItem.Checked = true;
    418       }
    419     }
    420     private void breakpointToolStripMenuItem_Click(object sender, EventArgs e) {
    421       IOperator op = (IOperator)breakpointToolStripMenuItem.Tag;
    422       op.Breakpoint = breakpointToolStripMenuItem.Checked;
    423138    }
    424139    #endregion
    425140
    426141    #region OperatorGraph Events
    427     private void OperatorGraph_OperatorAdded(object sender, EventArgs<IOperator> e) {
    428       operatorsListView.Items.Add(CreateListViewItem(e.Value));
    429     }
    430     private void OperatorGraph_OperatorRemoved(object sender, EventArgs<IOperator> e) {
    431       ListViewItem itemToDelete = null;
    432       foreach (ListViewItem item in operatorsListView.Items) {
    433         if (item.Tag == e.Value)
    434           itemToDelete = item;
    435       }
    436       itemToDelete.Remove();
    437     }
    438142    private void OperatorGraph_InitialOperatorChanged(object sender, EventArgs e) {
    439       Refresh();
    440     }
    441     #endregion
    442 
    443     #region Operator Events
    444     private void Operator_NameChanged(object sender, EventArgs e) {
    445       IOperator op = (IOperator)sender;
    446       foreach (TreeNode node in operatorNodeTable[op])
    447         node.Text = op.Name;
    448     }
    449     private void Operator_BreakpointChanged(object sender, EventArgs e) {
    450       IOperator op = (IOperator)sender;
    451       foreach (TreeNode node in operatorNodeTable[op]) {
    452         if (op.Breakpoint)
    453           node.ForeColor = Color.Red;
    454         else
    455           node.ForeColor = graphTreeView.ForeColor;
    456       }
    457     }
    458     private void Operator_SubOperatorAdded(object sender, EventArgs<IOperator, int> e) {
    459       IOperator op = (IOperator)sender;
    460       if (operatorNodeTable.ContainsKey(op)) {
    461         TreeNode[] nodes = new TreeNode[operatorNodeTable[op].Count];
    462         operatorNodeTable[op].CopyTo(nodes, 0);
    463         foreach (TreeNode node in nodes)
    464           node.Nodes.Insert(e.Value2, CreateTreeNode(e.Value));
    465       }
    466     }
    467     private void Operator_SubOperatorRemoved(object sender, EventArgs<IOperator, int> e) {
    468       IOperator op = (IOperator)sender;
    469       if (operatorNodeTable.ContainsKey(op)) {
    470         TreeNode[] nodes = new TreeNode[operatorNodeTable[op].Count];
    471         operatorNodeTable[op].CopyTo(nodes, 0);
    472         foreach (TreeNode node in nodes) {
    473           RemoveTreeNode(node.Nodes[e.Value2]);
    474           node.Nodes.RemoveAt(e.Value2);
    475         }
     143      if (InvokeRequired)
     144        Invoke(new EventHandler(OperatorGraph_InitialOperatorChanged), sender, e);
     145      else {
     146        MarkInitialOperator();
     147        graphView.Operator = OperatorGraph.InitialOperator;
    476148      }
    477149    }
    478150    #endregion
    479151
    480     #region Mouse Events
    481     private void graphTreeView_MouseDown(object sender, MouseEventArgs e) {
    482       if (e.Button != MouseButtons.Right) return;
    483       TreeNode clickedNode = graphTreeView.GetNodeAt(e.X, e.Y);
    484       if (clickedNode != null) {
    485         graphTreeView.SelectedNode = clickedNode;
    486         graphTreeView.Refresh();
    487       }
     152    private void operatorsView_Load(object sender, EventArgs e) {
     153      operatorsView.ItemsListView.ContextMenuStrip = operatorsContextMenuStrip;
    488154    }
    489     #endregion
    490 
    491155  }
    492156}
  • trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.Designer.cs

    r2520 r2655  
    3232    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    3333    protected override void Dispose(bool disposing) {
    34       if (scopesTreeView.Nodes.Count > 0) {
    35         RemoveTreeNode(scopesTreeView.Nodes[0]);
    36         scopesTreeView.Nodes.Clear();
    37       }
    38       if (disposing && (components != null)) {
    39         components.Dispose();
     34      if (disposing) {
     35        if (scopesTreeView.Nodes.Count > 0) {
     36          RemoveTreeNode(scopesTreeView.Nodes[0]);
     37          scopesTreeView.Nodes.Clear();
     38        }
     39        if (components != null) components.Dispose();
    4040      }
    4141      base.Dispose(disposing);
     
    4949    /// </summary>
    5050    private void InitializeComponent() {
    51       this.components = new System.ComponentModel.Container();
    5251      this.scopesTreeView = new System.Windows.Forms.TreeView();
    53       this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    54       this.automaticUpdatingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    55       this.refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    56       this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
    57       this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    58       this.variablesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    59       this.contextMenuStrip.SuspendLayout();
     52      this.splitContainer = new System.Windows.Forms.SplitContainer();
     53      this.scopesGroupBox = new System.Windows.Forms.GroupBox();
     54      this.variableCollectionView = new HeuristicLab.Core.Views.VariableCollectionView();
     55      this.splitContainer.Panel1.SuspendLayout();
     56      this.splitContainer.Panel2.SuspendLayout();
     57      this.splitContainer.SuspendLayout();
     58      this.scopesGroupBox.SuspendLayout();
    6059      this.SuspendLayout();
    6160      //
    6261      // scopesTreeView
    6362      //
    64       this.scopesTreeView.ContextMenuStrip = this.contextMenuStrip;
    6563      this.scopesTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
    6664      this.scopesTreeView.HideSelection = false;
    67       this.scopesTreeView.Location = new System.Drawing.Point(0, 0);
     65      this.scopesTreeView.Location = new System.Drawing.Point(3, 16);
    6866      this.scopesTreeView.Name = "scopesTreeView";
    6967      this.scopesTreeView.ShowNodeToolTips = true;
    70       this.scopesTreeView.Size = new System.Drawing.Size(400, 400);
     68      this.scopesTreeView.Size = new System.Drawing.Size(394, 181);
    7169      this.scopesTreeView.TabIndex = 0;
    7270      this.scopesTreeView.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.scopesTreeView_AfterCollapse);
    7371      this.scopesTreeView.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.scopesTreeView_BeforeExpand);
    74       this.scopesTreeView.DoubleClick += new System.EventHandler(this.scopesTreeView_DoubleClick);
    7572      this.scopesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.scopesTreeView_MouseDown);
    7673      this.scopesTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.scopesTreeView_ItemDrag);
    7774      //
    78       // contextMenuStrip
     75      // splitContainer
    7976      //
    80       this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    81             this.automaticUpdatingToolStripMenuItem,
    82             this.refreshToolStripMenuItem,
    83             this.toolStripMenuItem1,
    84             this.variablesToolStripMenuItem,
    85             this.viewToolStripMenuItem});
    86       this.contextMenuStrip.Name = "contextMenuStrip";
    87       this.contextMenuStrip.Size = new System.Drawing.Size(180, 98);
    88       this.contextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip_Opening);
     77      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     78      this.splitContainer.Location = new System.Drawing.Point(0, 0);
     79      this.splitContainer.Name = "splitContainer";
     80      this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
    8981      //
    90       // automaticUpdatingToolStripMenuItem
     82      // splitContainer.Panel1
    9183      //
    92       this.automaticUpdatingToolStripMenuItem.CheckOnClick = true;
    93       this.automaticUpdatingToolStripMenuItem.Name = "automaticUpdatingToolStripMenuItem";
    94       this.automaticUpdatingToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
    95       this.automaticUpdatingToolStripMenuItem.Text = "Automatic &Updating";
    96       this.automaticUpdatingToolStripMenuItem.ToolTipText = "Automatically update scope editor during execution";
    97       this.automaticUpdatingToolStripMenuItem.Click += new System.EventHandler(this.automaticUpdatingToolStripMenuItem_Click);
     84      this.splitContainer.Panel1.Controls.Add(this.scopesGroupBox);
    9885      //
    99       // refreshToolStripMenuItem
     86      // splitContainer.Panel2
    10087      //
    101       this.refreshToolStripMenuItem.Name = "refreshToolStripMenuItem";
    102       this.refreshToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
    103       this.refreshToolStripMenuItem.Text = "&Refresh";
    104       this.refreshToolStripMenuItem.Click += new System.EventHandler(this.refreshToolStripMenuItem_Click);
     88      this.splitContainer.Panel2.Controls.Add(this.variableCollectionView);
     89      this.splitContainer.Size = new System.Drawing.Size(400, 400);
     90      this.splitContainer.SplitterDistance = 200;
     91      this.splitContainer.TabIndex = 1;
    10592      //
    106       // toolStripMenuItem1
     93      // scopesGroupBox
    10794      //
    108       this.toolStripMenuItem1.Name = "toolStripMenuItem1";
    109       this.toolStripMenuItem1.Size = new System.Drawing.Size(176, 6);
     95      this.scopesGroupBox.Controls.Add(this.scopesTreeView);
     96      this.scopesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     97      this.scopesGroupBox.Location = new System.Drawing.Point(0, 0);
     98      this.scopesGroupBox.Name = "scopesGroupBox";
     99      this.scopesGroupBox.Size = new System.Drawing.Size(400, 200);
     100      this.scopesGroupBox.TabIndex = 0;
     101      this.scopesGroupBox.TabStop = false;
     102      this.scopesGroupBox.Text = "&Scopes";
    110103      //
    111       // viewToolStripMenuItem
     104      // variableCollectionView
    112105      //
    113       this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
    114       this.viewToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
    115       this.viewToolStripMenuItem.Text = "&View";
    116       //
    117       // variablesToolStripMenuItem
    118       //
    119       this.variablesToolStripMenuItem.Name = "variablesToolStripMenuItem";
    120       this.variablesToolStripMenuItem.Size = new System.Drawing.Size(179, 22);
    121       this.variablesToolStripMenuItem.Text = "&Variables...";
    122       this.variablesToolStripMenuItem.Click += new System.EventHandler(this.variablesToolStripMenuItem_Click);
     106      this.variableCollectionView.Caption = "VariableCollection";
     107      this.variableCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
     108      this.variableCollectionView.ItemCollection = null;
     109      this.variableCollectionView.Location = new System.Drawing.Point(0, 0);
     110      this.variableCollectionView.Name = "variableCollectionView";
     111      this.variableCollectionView.NamedItemCollection = null;
     112      this.variableCollectionView.Size = new System.Drawing.Size(400, 196);
     113      this.variableCollectionView.TabIndex = 0;
    123114      //
    124115      // ScopeView
     
    126117      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    127118      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    128       this.Controls.Add(this.scopesTreeView);
     119      this.Controls.Add(this.splitContainer);
    129120      this.Name = "ScopeView";
    130121      this.Size = new System.Drawing.Size(400, 400);
    131       this.contextMenuStrip.ResumeLayout(false);
     122      this.splitContainer.Panel1.ResumeLayout(false);
     123      this.splitContainer.Panel2.ResumeLayout(false);
     124      this.splitContainer.ResumeLayout(false);
     125      this.scopesGroupBox.ResumeLayout(false);
    132126      this.ResumeLayout(false);
    133127
     
    137131
    138132    private System.Windows.Forms.TreeView scopesTreeView;
    139     private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
    140     private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
    141     private System.Windows.Forms.ToolStripMenuItem automaticUpdatingToolStripMenuItem;
    142     private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem;
    143     private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
    144     private System.Windows.Forms.ToolStripMenuItem variablesToolStripMenuItem;
     133    private System.Windows.Forms.SplitContainer splitContainer;
     134    private System.Windows.Forms.GroupBox scopesGroupBox;
     135    private VariableCollectionView variableCollectionView;
    145136  }
    146137}
  • trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.cs

    r2546 r2655  
    3030using HeuristicLab.Common;
    3131using HeuristicLab.MainForm;
     32using HeuristicLab.Collections;
    3233
    3334namespace HeuristicLab.Core.Views {
    3435  /// <summary>
    35   /// The visual represenation of <see cref="IScope"/>.
     36  /// The visual represenation of <see cref="Scope"/>.
    3637  /// </summary>
    3738  [Content(typeof(Scope), true)]
    3839  public partial class ScopeView : ItemViewBase {
    39     private Dictionary<IScope, TreeNode> scopeNodeTable;
    40     private Dictionary<IScope, bool> scopeExpandedTable;
     40    private Dictionary<Scope, TreeNode> scopeNodeTable;
     41    private Dictionary<ScopeList, Scope> subScopesScopeTable;
    4142
    4243    /// <summary>
     
    4546    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    4647    /// No own data storage present.</remarks>
    47     public IScope Scope {
    48       get { return (IScope)Item; }
     48    public Scope Scope {
     49      get { return (Scope)Item; }
    4950      set { base.Item = value; }
    50     }
    51     private bool myAutomaticUpdating;
    52     /// <summary>
    53     /// Gets information whether the scope is automatically updating.
    54     /// </summary>
    55     public bool AutomaticUpdating {
    56       get { return myAutomaticUpdating; }
    5751    }
    5852
     
    6458      InitializeComponent();
    6559      Caption = "Scope";
    66       scopeNodeTable = new Dictionary<IScope, TreeNode>();
    67       scopeExpandedTable = new Dictionary<IScope, bool>();
    68       myAutomaticUpdating = false;
     60      scopeNodeTable = new Dictionary<Scope, TreeNode>();
     61      subScopesScopeTable = new Dictionary<ScopeList, Scope>();
     62
    6963    }
    7064    /// <summary>
     
    7367    /// <remarks>Calls <see cref="ScopeView()"/>.</remarks>
    7468    /// <param name="scope">The scope to represent visually.</param>
    75     public ScopeView(IScope scope)
     69    public ScopeView(Scope scope)
    7670      : this() {
    7771      Scope = scope;
     
    8276    /// </summary>
    8377    /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
    84     protected override void UpdateControls() {
    85       base.UpdateControls();
    86       if (scopesTreeView.Nodes.Count > 0)
     78    protected override void OnObjectChanged() {
     79      base.OnObjectChanged();
     80      if (scopesTreeView.Nodes.Count > 0) {
    8781        RemoveTreeNode(scopesTreeView.Nodes[0]);
    88       scopesTreeView.SelectedNode = null;
    89       scopesTreeView.Nodes.Clear();
     82        scopesTreeView.Nodes.Clear();
     83      }
     84      variableCollectionView.NamedItemCollection = null;
     85      variableCollectionView.Enabled = false;
    9086      if (Scope == null) {
    9187        Caption = "Scope";
     
    9389      } else {
    9490        Caption = Scope.Name + " (" + Scope.GetType().Name + ")";
     91        scopesTreeView.Enabled = true;
    9592        scopesTreeView.Nodes.Add(CreateTreeNode(Scope));
    96         scopesTreeView.Enabled = true;
    97       }
    98     }
    99 
    100     private TreeNode CreateTreeNode(IScope scope) {
     93      }
     94    }
     95
     96    private TreeNode CreateTreeNode(Scope scope) {
    10197      TreeNode node = new TreeNode();
    10298      node.Text = scope.Name;
     
    104100
    105101      scopeNodeTable.Add(scope, node);
    106       scopeExpandedTable.Add(scope, false);
    107       if (myAutomaticUpdating) {
    108         scope.SubScopeAdded += new EventHandler<EventArgs<IScope, int>>(Scope_SubScopeAdded);
    109         scope.SubScopeRemoved += new EventHandler<EventArgs<IScope, int>>(Scope_SubScopeRemoved);
    110         scope.SubScopesReordered += new EventHandler(Scope_SubScopesReordered);
    111       }
     102      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);
     108      subScopesScopeTable.Add(scope.SubScopes, scope);
    112109      if (scope.SubScopes.Count > 0)
    113110        node.Nodes.Add(new TreeNode());
    114111      return node;
    115112    }
     113
    116114    private void RemoveTreeNode(TreeNode node) {
    117115      foreach (TreeNode child in node.Nodes)
    118116        RemoveTreeNode(child);
    119117
    120       IScope scope = node.Tag as IScope;
    121       if ((scope != null) && (scopeNodeTable.ContainsKey(scope))) {
     118      Scope scope = node.Tag as Scope;
     119      if (scope != null) {
    122120        scopeNodeTable.Remove(scope);
    123         scopeExpandedTable.Remove(scope);
    124         scope.SubScopeAdded -= new EventHandler<EventArgs<IScope, int>>(Scope_SubScopeAdded);
    125         scope.SubScopeRemoved -= new EventHandler<EventArgs<IScope, int>>(Scope_SubScopeRemoved);
    126         scope.SubScopesReordered -= new EventHandler(Scope_SubScopesReordered);
     121        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);
     127        subScopesScopeTable.Remove(scope.SubScopes);
    127128      }
    128129    }
    129130
    130131    #region TreeView Events
    131     private void scopesTreeView_DoubleClick(object sender, EventArgs e) {
    132       // make sure that we can't get NullPointerExceptions
    133       if(scopesTreeView.SelectedNode != null && scopesTreeView.SelectedNode.Tag != null) {
    134         IScope scope = (IScope)scopesTreeView.SelectedNode.Tag;
    135         MainFormManager.MainForm.ShowView(new VariablesScopeView(scope));
     132    private void scopesTreeView_MouseDown(object sender, MouseEventArgs e) {
     133      TreeNode node = scopesTreeView.GetNodeAt(e.X, e.Y);
     134      if ((node != null) && (node.Tag is Scope)) {
     135        variableCollectionView.NamedItemCollection = ((Scope)node.Tag).Variables;
     136        variableCollectionView.Enabled = true;
     137      } else {
     138        variableCollectionView.NamedItemCollection = null;
     139        variableCollectionView.Enabled = false;
     140        if (node == null) scopesTreeView.SelectedNode = null;
    136141      }
    137142    }
    138143    private void scopesTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) {
    139144      TreeNode node = e.Node;
    140       IScope scope = (IScope)node.Tag;
     145      Scope scope = (Scope)node.Tag;
    141146
    142147      node.Nodes.Clear();
    143148      for (int i = 0; i < scope.SubScopes.Count; i++)
    144149        node.Nodes.Add(CreateTreeNode(scope.SubScopes[i]));
    145       scopeExpandedTable[scope] = true;
    146150    }
    147151    private void scopesTreeView_AfterCollapse(object sender, System.Windows.Forms.TreeViewEventArgs e) {
    148152      TreeNode node = e.Node;
    149       IScope scope = (IScope)node.Tag;
     153      Scope scope = (Scope)node.Tag;
    150154
    151155      if (node.Nodes.Count > 0) {
     
    155159        node.Nodes.Add(new TreeNode());
    156160      }
    157       scopeExpandedTable[scope] = false;
    158161    }
    159162    private void scopesTreeView_ItemDrag(object sender, ItemDragEventArgs e) {
    160163      TreeNode node = (TreeNode)e.Item;
    161       IScope scope = node.Tag as IScope;
     164      Scope scope = node.Tag as Scope;
    162165      if (scope != null) {
    163166        DataObject data = new DataObject();
    164         data.SetData("IScope", scope);
     167        data.SetData("Scope", scope);
    165168        data.SetData("DragSource", scopesTreeView);
    166169        DoDragDrop(data, DragDropEffects.Copy);
     
    169172    #endregion
    170173
    171     #region Context Menu Events
    172     private void contextMenuStrip_Opening(object sender, CancelEventArgs e) {
    173       variablesToolStripMenuItem.Enabled = false;
    174       viewToolStripMenuItem.DropDownItems.Clear();
    175       viewToolStripMenuItem.Enabled = false;
    176       if (scopesTreeView.SelectedNode != null) {
    177         variablesToolStripMenuItem.Enabled = true;
    178         IScope scope = (IScope)scopesTreeView.SelectedNode.Tag;
    179         foreach (IVariable variable in scope.Variables) {
    180           if (variable.Value is IVisualizationItem) {
    181             ToolStripMenuItem item = new ToolStripMenuItem();
    182             item.Text = variable.Name + "...";
    183             item.Tag = variable.Value;
    184             item.Click += new EventHandler(showViewToolStripMenuItem_Click);
    185             viewToolStripMenuItem.DropDownItems.Add(item);
    186           }
    187         }
    188         if (viewToolStripMenuItem.DropDownItems.Count > 0)
    189           viewToolStripMenuItem.Enabled = true;
    190       }
    191     }
    192     private void automaticUpdatingToolStripMenuItem_Click(object sender, EventArgs e) {
    193       ToolStripMenuItem item = (ToolStripMenuItem)sender;
    194       myAutomaticUpdating = item.Checked;
    195       if (myAutomaticUpdating)
    196         Refresh();
    197     }
    198     private void refreshToolStripMenuItem_Click(object sender, EventArgs e) {
    199       Refresh();
    200     }
    201     private void variablesToolStripMenuItem_Click(object sender, EventArgs e) {
    202       IScope scope = (IScope)scopesTreeView.SelectedNode.Tag;
    203       MainFormManager.MainForm.ShowView(new VariablesScopeView(scope));
    204     }
    205     private void showViewToolStripMenuItem_Click(object sender, EventArgs e) {
    206       IItem item = (IItem)((ToolStripMenuItem)sender).Tag;
    207       IView view = MainFormManager.CreateDefaultView(item);
    208       if (view != null) MainFormManager.MainForm.ShowView(view);
     174    #region Scope Events
     175    private void Scope_NameChanged(object sender, EventArgs e) {
     176      if (InvokeRequired)
     177        Invoke(new EventHandler(Scope_NameChanged), sender, e);
     178      else {
     179        Scope scope = (Scope)sender;
     180        scopeNodeTable[scope].Text = scope.Name;
     181      }
    209182    }
    210183    #endregion
    211184
    212     #region Scope Events
    213     private delegate void ScopeDelegate(IScope scope);
    214     private delegate void ScopeScopeIndexDelegate(IScope scope, IScope subScope, int index);
    215     private void Scope_SubScopeAdded(object sender, EventArgs<IScope, int> e) {
    216       IScope scope = (IScope)sender;
    217       TreeNode node = scopeNodeTable[scope];
    218       if (scopeExpandedTable[scope] || (scope.SubScopes.Count == 1))
    219         AddSubScope(scope, e.Value, e.Value2);
    220     }
    221     private void AddSubScope(IScope scope, IScope subScope, int index) {
    222       if (InvokeRequired) {
    223         Invoke(new ScopeScopeIndexDelegate(AddSubScope), scope, subScope, index);
    224       } else {
    225         TreeNode parent = scopeNodeTable[scope];
    226         TreeNode child;
    227         if (parent.IsExpanded)
    228           child = CreateTreeNode(subScope);
    229         else
    230           child = new TreeNode();
    231         parent.Nodes.Insert(index, child);
    232       }
    233     }
    234     private void Scope_SubScopeRemoved(object sender, EventArgs<IScope, int> e) {
    235       IScope scope = (IScope)sender;
    236       TreeNode node = scopeNodeTable[scope];
    237       if (scopeExpandedTable[scope] || (scope.SubScopes.Count == 0))
    238         RemoveSubScope(scope, e.Value, e.Value2);
    239     }
    240     private void RemoveSubScope(IScope scope, IScope subScope, int index) {
    241       if (InvokeRequired) {
    242         Invoke(new ScopeScopeIndexDelegate(RemoveSubScope), scope, subScope, index);
    243       } else {
    244         if (scopeNodeTable.ContainsKey(subScope)) {
    245           TreeNode node = scopeNodeTable[subScope];
    246           RemoveTreeNode(scopeNodeTable[subScope]);
    247           node.Remove();
     185    #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) {
     194            TreeNode node = CreateTreeNode(item.Value);
     195            parentNode.Nodes.Insert(item.Index, node);
     196          }
     197        } else if (parentNode.Nodes.Count == 0) {
     198          parentNode.Nodes.Add(new TreeNode());
     199        }
     200      }
     201    }
     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) {
     210            TreeNode node = scopeNodeTable[item.Value];
     211            RemoveTreeNode(node);
     212            node.Remove();
     213          }
     214        } else if (parentScope.SubScopes.Count == 0) {
     215          parentNode.Nodes.Clear();
     216        }
     217      }
     218    }
     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) {
     227            TreeNode node = parentNode.Nodes[item.Index];
     228            RemoveTreeNode(node);
     229            node.Remove();
     230            node = CreateTreeNode(item.Value);
     231            parentNode.Nodes.Insert(item.Index, node);
     232          }
     233        }
     234      }
     235    }
     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)
     245            parentNode.Nodes.Insert(item.Index, scopeNodeTable[item.Value]);
     246        }
     247      }
     248    }
     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];
     254        TreeNode parentNode = scopeNodeTable[parentScope];
     255        if (parentNode.IsExpanded) {
     256          foreach (TreeNode node in parentNode.Nodes)
     257            RemoveTreeNode(node);
     258          parentNode.Nodes.Clear();
     259          foreach (IndexedItem<Scope> item in e.Items) {
     260            TreeNode node = CreateTreeNode(item.Value);
     261            parentNode.Nodes.Insert(item.Index, node);
     262          }
    248263        } else {
    249           TreeNode node = scopeNodeTable[scope];
    250           node.Nodes[0].Remove();
    251         }
    252       }
    253     }
    254     private void Scope_SubScopesReordered(object sender, EventArgs e) {
    255       IScope scope = (IScope)sender;
    256       TreeNode node = scopeNodeTable[scope];
    257       if (scopeExpandedTable[scope])
    258         ReorderSubScopes(scope);
    259     }
    260     private void ReorderSubScopes(IScope scope) {
    261       if (InvokeRequired) {
    262         Invoke(new ScopeDelegate(ReorderSubScopes), scope);
    263       } else {
    264         TreeNode node = scopeNodeTable[scope];
    265         node.Nodes.Clear();
    266         for (int i = 0; i < scope.SubScopes.Count; i++)
    267           node.Nodes.Add(scopeNodeTable[scope.SubScopes[i]]);
    268       }
    269     }
    270     #endregion
    271 
    272     #region Mouse Events
    273     private void scopesTreeView_MouseDown(object sender, MouseEventArgs e) {
    274       if (e.Button != MouseButtons.Right)
    275         return;
    276       TreeNode clickedNode = scopesTreeView.GetNodeAt(e.X, e.Y);
    277       if (clickedNode != null) {
    278         scopesTreeView.SelectedNode = clickedNode;
    279         scopesTreeView.Refresh();
     264          parentNode.Nodes.Clear();
     265          if (parentScope.SubScopes.Count > 0)
     266            parentNode.Nodes.Add(new TreeNode());
     267        }
    280268      }
    281269    }
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.Designer.cs

    r2520 r2655  
    3232    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    3333    protected override void Dispose(bool disposing) {
    34       if (chooseItemDialog != null) chooseItemDialog.Dispose();
    35       if (disposing && (components != null)) {
    36         components.Dispose();
     34      if (disposing) {
     35        if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
     36        if (components != null) components.Dispose();
    3737      }
    3838      base.Dispose(disposing);
     
    4646    /// </summary>
    4747    private void InitializeComponent() {
    48       this.nameLabel = new System.Windows.Forms.Label();
    49       this.nameTextBox = new System.Windows.Forms.TextBox();
    50       this.valueLabel = new System.Windows.Forms.Label();
    51       this.valueTextBox = new System.Windows.Forms.TextBox();
    52       this.editorGroupBox = new System.Windows.Forms.GroupBox();
    53       this.setVariableValueButton = new System.Windows.Forms.Button();
     48      this.components = new System.ComponentModel.Container();
     49      this.dataTypeLabel = new System.Windows.Forms.Label();
     50      this.dataTypeTextBox = new System.Windows.Forms.TextBox();
     51      this.valueGroupBox = new System.Windows.Forms.GroupBox();
     52      this.valuePanel = new System.Windows.Forms.Panel();
     53      this.viewHost = new HeuristicLab.Core.Views.ViewHost();
     54      this.clearValueButton = new System.Windows.Forms.Button();
     55      this.setValueButton = new System.Windows.Forms.Button();
     56      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     57      this.valueGroupBox.SuspendLayout();
     58      this.valuePanel.SuspendLayout();
    5459      this.SuspendLayout();
    55       //
    56       // nameLabel
    57       //
    58       this.nameLabel.AutoSize = true;
    59       this.nameLabel.Location = new System.Drawing.Point(3, 3);
    60       this.nameLabel.Name = "nameLabel";
    61       this.nameLabel.Size = new System.Drawing.Size(38, 13);
    62       this.nameLabel.TabIndex = 0;
    63       this.nameLabel.Text = "&Name:";
    6460      //
    6561      // nameTextBox
    6662      //
    67       this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     63      this.nameTextBox.Size = new System.Drawing.Size(285, 20);
     64      //
     65      // descriptionTextBox
     66      //
     67      this.descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    6868                  | System.Windows.Forms.AnchorStyles.Right)));
    69       this.nameTextBox.Location = new System.Drawing.Point(50, 0);
    70       this.nameTextBox.Name = "nameTextBox";
    71       this.nameTextBox.Size = new System.Drawing.Size(153, 20);
    72       this.nameTextBox.TabIndex = 1;
    73       this.nameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.nameTextBox_Validating);
     69      this.descriptionTextBox.Size = new System.Drawing.Size(285, 62);
    7470      //
    75       // valueLabel
     71      // dataTypeLabel
    7672      //
    77       this.valueLabel.AutoSize = true;
    78       this.valueLabel.Location = new System.Drawing.Point(3, 29);
    79       this.valueLabel.Name = "valueLabel";
    80       this.valueLabel.Size = new System.Drawing.Size(37, 13);
    81       this.valueLabel.TabIndex = 2;
    82       this.valueLabel.Text = "&Value:";
     73      this.dataTypeLabel.AutoSize = true;
     74      this.dataTypeLabel.Location = new System.Drawing.Point(3, 98);
     75      this.dataTypeLabel.Name = "dataTypeLabel";
     76      this.dataTypeLabel.Size = new System.Drawing.Size(60, 13);
     77      this.dataTypeLabel.TabIndex = 4;
     78      this.dataTypeLabel.Text = "Data &Type:";
    8379      //
    84       // valueTextBox
     80      // dataTypeTextBox
    8581      //
    86       this.valueTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     82      this.dataTypeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    8783                  | System.Windows.Forms.AnchorStyles.Right)));
    88       this.valueTextBox.Location = new System.Drawing.Point(50, 26);
    89       this.valueTextBox.Name = "valueTextBox";
    90       this.valueTextBox.ReadOnly = true;
    91       this.valueTextBox.Size = new System.Drawing.Size(99, 20);
    92       this.valueTextBox.TabIndex = 3;
     84      this.dataTypeTextBox.Location = new System.Drawing.Point(72, 94);
     85      this.dataTypeTextBox.Name = "dataTypeTextBox";
     86      this.dataTypeTextBox.ReadOnly = true;
     87      this.dataTypeTextBox.Size = new System.Drawing.Size(285, 20);
     88      this.dataTypeTextBox.TabIndex = 5;
    9389      //
    94       // editorGroupBox
     90      // valueGroupBox
    9591      //
    96       this.editorGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     92      this.valueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    9793                  | System.Windows.Forms.AnchorStyles.Left)
    9894                  | System.Windows.Forms.AnchorStyles.Right)));
    99       this.editorGroupBox.Location = new System.Drawing.Point(0, 52);
    100       this.editorGroupBox.Name = "editorGroupBox";
    101       this.editorGroupBox.Size = new System.Drawing.Size(203, 102);
    102       this.editorGroupBox.TabIndex = 5;
    103       this.editorGroupBox.TabStop = false;
    104       this.editorGroupBox.Text = "&Editor:";
     95      this.valueGroupBox.Controls.Add(this.valuePanel);
     96      this.valueGroupBox.Controls.Add(this.clearValueButton);
     97      this.valueGroupBox.Controls.Add(this.setValueButton);
     98      this.valueGroupBox.Location = new System.Drawing.Point(0, 120);
     99      this.valueGroupBox.Name = "valueGroupBox";
     100      this.valueGroupBox.Size = new System.Drawing.Size(359, 154);
     101      this.valueGroupBox.TabIndex = 7;
     102      this.valueGroupBox.TabStop = false;
     103      this.valueGroupBox.Text = "&Value:";
    105104      //
    106       // setVariableValueButton
     105      // valuePanel
    107106      //
    108       this.setVariableValueButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    109       this.setVariableValueButton.Location = new System.Drawing.Point(155, 26);
    110       this.setVariableValueButton.Name = "setVariableValueButton";
    111       this.setVariableValueButton.Size = new System.Drawing.Size(45, 20);
    112       this.setVariableValueButton.TabIndex = 4;
    113       this.setVariableValueButton.Text = "Set...";
    114       this.setVariableValueButton.UseVisualStyleBackColor = true;
    115       this.setVariableValueButton.Click += new System.EventHandler(this.setVariableValueButton_Click);
     107      this.valuePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     108                  | System.Windows.Forms.AnchorStyles.Left)
     109                  | System.Windows.Forms.AnchorStyles.Right)));
     110      this.valuePanel.Controls.Add(this.viewHost);
     111      this.valuePanel.Location = new System.Drawing.Point(3, 48);
     112      this.valuePanel.Name = "valuePanel";
     113      this.valuePanel.Size = new System.Drawing.Size(353, 103);
     114      this.valuePanel.TabIndex = 2;
     115      this.valuePanel.DragOver += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragEnterOver);
     116      this.valuePanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragDrop);
     117      this.valuePanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragEnterOver);
     118      //
     119      // viewHost
     120      //
     121      this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     122      this.viewHost.Location = new System.Drawing.Point(0, 0);
     123      this.viewHost.Name = "viewHost";
     124      this.viewHost.Object = null;
     125      this.viewHost.Size = new System.Drawing.Size(353, 103);
     126      this.viewHost.TabIndex = 0;
     127      //
     128      // clearValueButton
     129      //
     130      this.clearValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Remove;
     131      this.clearValueButton.Location = new System.Drawing.Point(35, 19);
     132      this.clearValueButton.Name = "clearValueButton";
     133      this.clearValueButton.Size = new System.Drawing.Size(23, 23);
     134      this.clearValueButton.TabIndex = 1;
     135      this.toolTip.SetToolTip(this.clearValueButton, "Clear Value");
     136      this.clearValueButton.UseVisualStyleBackColor = true;
     137      this.clearValueButton.Click += new System.EventHandler(this.clearValueButton_Click);
     138      //
     139      // setValueButton
     140      //
     141      this.setValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Add;
     142      this.setValueButton.Location = new System.Drawing.Point(6, 19);
     143      this.setValueButton.Name = "setValueButton";
     144      this.setValueButton.Size = new System.Drawing.Size(23, 23);
     145      this.setValueButton.TabIndex = 1;
     146      this.toolTip.SetToolTip(this.setValueButton, "Set Value");
     147      this.setValueButton.UseVisualStyleBackColor = true;
     148      this.setValueButton.Click += new System.EventHandler(this.setValueButton_Click);
    116149      //
    117150      // VariableView
     
    119152      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    120153      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    121       this.Controls.Add(this.setVariableValueButton);
    122       this.Controls.Add(this.editorGroupBox);
    123       this.Controls.Add(this.valueTextBox);
    124       this.Controls.Add(this.nameTextBox);
    125       this.Controls.Add(this.valueLabel);
    126       this.Controls.Add(this.nameLabel);
     154      this.Controls.Add(this.valueGroupBox);
     155      this.Controls.Add(this.dataTypeTextBox);
     156      this.Controls.Add(this.dataTypeLabel);
    127157      this.Name = "VariableView";
    128       this.Size = new System.Drawing.Size(203, 154);
     158      this.Size = new System.Drawing.Size(359, 274);
     159      this.Controls.SetChildIndex(this.dataTypeLabel, 0);
     160      this.Controls.SetChildIndex(this.dataTypeTextBox, 0);
     161      this.Controls.SetChildIndex(this.valueGroupBox, 0);
     162      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
     163      this.Controls.SetChildIndex(this.nameLabel, 0);
     164      this.Controls.SetChildIndex(this.descriptionLabel, 0);
     165      this.Controls.SetChildIndex(this.nameTextBox, 0);
     166      this.valueGroupBox.ResumeLayout(false);
     167      this.valuePanel.ResumeLayout(false);
    129168      this.ResumeLayout(false);
    130169      this.PerformLayout();
     
    134173    #endregion
    135174
    136     private System.Windows.Forms.Label nameLabel;
    137     private System.Windows.Forms.TextBox nameTextBox;
    138     private System.Windows.Forms.Label valueLabel;
    139     private System.Windows.Forms.TextBox valueTextBox;
    140     private System.Windows.Forms.GroupBox editorGroupBox;
    141     private System.Windows.Forms.Button setVariableValueButton;
     175    private System.Windows.Forms.Label dataTypeLabel;
     176    private System.Windows.Forms.TextBox dataTypeTextBox;
     177    private System.Windows.Forms.GroupBox valueGroupBox;
     178    private ViewHost viewHost;
     179    private System.Windows.Forms.Button clearValueButton;
     180    private System.Windows.Forms.ToolTip toolTip;
     181    private System.Windows.Forms.Button setValueButton;
     182    private System.Windows.Forms.Panel valuePanel;
    142183  }
    143184}
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs

    r2546 r2655  
    3131namespace HeuristicLab.Core.Views {
    3232  /// <summary>
    33   /// The visual representation of an <see cref="IVariable"/>.
     33  /// The visual representation of a <see cref="Variable"/>.
    3434  /// </summary>
    3535  [Content(typeof(Variable), true)]
    36   public partial class VariableView : ItemViewBase {
    37     private ChooseItemDialog chooseItemDialog;
     36  public partial class VariableView : NamedItemBaseView {
     37    private TypeSelectorDialog typeSelectorDialog;
    3838
    3939    /// <summary>
     
    4242    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    4343    /// No own data storage present.</remarks>
    44     public IVariable Variable {
    45       get { return (IVariable)Item; }
     44    public Variable Variable {
     45      get { return (Variable)Item; }
    4646      set { base.Item = value; }
    4747    }
     
    5959    /// <remarks>Calls <see cref="VariableView()"/>.</remarks>
    6060    /// <param name="variable">The variable to represent visually.</param>
    61     public VariableView(IVariable variable)
     61    public VariableView(Variable variable)
    6262      : this() {
    6363      Variable = variable;
     
    6868    /// </summary>
    6969    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    70     protected override void RemoveItemEvents() {
    71       Variable.NameChanged -= new EventHandler(Variable_NameChanged);
     70    protected override void DeregisterObjectEvents() {
    7271      Variable.ValueChanged -= new EventHandler(Variable_ValueChanged);
    73       base.RemoveItemEvents();
     72      base.DeregisterObjectEvents();
    7473    }
     74
    7575    /// <summary>
    7676    /// Adds eventhandlers to the underlying <see cref="IVariable"/>.
    7777    /// </summary>
    7878    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    79     protected override void AddItemEvents() {
    80       base.AddItemEvents();
    81       Variable.NameChanged += new EventHandler(Variable_NameChanged);
     79    protected override void RegisterObjectEvents() {
     80      base.RegisterObjectEvents();
    8281      Variable.ValueChanged += new EventHandler(Variable_ValueChanged);
    8382    }
    8483
    85     /// <summary>
    86     /// Updates all controls with the latest data of the model.
    87     /// </summary>
    88     /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
    89     protected override void UpdateControls() {
    90       base.UpdateControls();
    91       valueTextBox.Text = "-";
    92       valueTextBox.Enabled = false;
    93       editorGroupBox.Controls.Clear();
    94       editorGroupBox.Enabled = false;
     84    protected override void OnObjectChanged() {
     85      base.OnObjectChanged();
    9586      if (Variable == null) {
    9687        Caption = "Variable";
    97         nameTextBox.Enabled = false;
     88        dataTypeTextBox.Text = "-";
     89        dataTypeTextBox.Enabled = false;
     90        setValueButton.Enabled = false;
     91        clearValueButton.Enabled = false;
     92        valueGroupBox.Enabled = false;
     93        viewHost.Object = null;
    9894      } else {
    9995        Caption = Variable.Name + " (" + Variable.GetType().Name + ")";
    100         nameTextBox.Text = Variable.Name;
    101         nameTextBox.Enabled = true;
    102         if (Variable.Value != null) {
    103           valueTextBox.Text = Variable.Value.GetType().FullName;
    104           valueTextBox.Enabled = true;
    105           Control editor = (Control)MainFormManager.CreateDefaultView(Variable.Value);
    106           if (editor != null) {
    107             editorGroupBox.Controls.Add(editor);
    108             editor.Dock = DockStyle.Fill;
    109             editorGroupBox.Enabled = true;
    110           }
    111         }
     96        dataTypeTextBox.Text = Variable.Value == null ? "-" : Variable.Value.GetType().FullName;
     97        dataTypeTextBox.Enabled = Variable.Value != null;
     98        setValueButton.Enabled = Variable.Value == null;
     99        clearValueButton.Enabled = Variable.Value != null;
     100        valueGroupBox.Enabled = true;
     101        viewHost.Object = Variable.Value;
    112102      }
    113103    }
    114104
    115     private void Variable_NameChanged(object sender, EventArgs e) {
    116       UpdateText();
    117     }
    118     private void UpdateText() {
     105    private void Variable_ValueChanged(object sender, EventArgs e) {
    119106      if (InvokeRequired)
    120         Invoke(new MethodInvoker(UpdateText));
    121       else
    122         nameTextBox.Text = Variable.Name;
    123     }
    124     private void Variable_ValueChanged(object sender, EventArgs e) {
    125       Refresh();
     107        Invoke(new EventHandler(Variable_ValueChanged), sender, e);
     108      else {
     109        dataTypeTextBox.Text = Variable.Value == null ? "-" : Variable.Value.GetType().FullName;
     110        dataTypeTextBox.Enabled = Variable.Value != null;
     111        setValueButton.Enabled = Variable.Value == null;
     112        clearValueButton.Enabled = Variable.Value != null;
     113        viewHost.Object = Variable.Value;
     114      }
    126115    }
    127116
    128     private void nameTextBox_Validating(object sender, CancelEventArgs e) {
    129       Variable.Name = nameTextBox.Text;
    130 
    131       // check if variable name was set successfully
    132       e.Cancel = Variable.Name != nameTextBox.Text;
     117    private void setValueButton_Click(object sender, EventArgs e) {
     118      if (typeSelectorDialog == null) {
     119        typeSelectorDialog = new TypeSelectorDialog();
     120        typeSelectorDialog.Caption = "Select Value Type";
     121        typeSelectorDialog.TypeSelector.Configure(typeof(IItem), false, false);
     122      }
     123      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     124        Variable.Value = (IItem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     125      }
    133126    }
    134 
    135     private void setVariableValueButton_Click(object sender, EventArgs e) {
    136       if (chooseItemDialog == null) {
    137         chooseItemDialog = new ChooseItemDialog();
    138         chooseItemDialog.Caption = "Set Value";
     127    private void clearValueButton_Click(object sender, EventArgs e) {
     128      Variable.Value = null;
     129    }
     130    private void valuePanel_DragEnterOver(object sender, DragEventArgs e) {
     131      e.Effect = DragDropEffects.None;
     132      Type type = e.Data.GetData("Type") as Type;
     133      if ((type != null) && (typeof(IItem).IsAssignableFrom(type))) {
     134        if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy;  // CTRL key
     135        else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Move;  // ALT key
     136        else e.Effect = DragDropEffects.Link;
    139137      }
    140       if (chooseItemDialog.ShowDialog(this) == DialogResult.OK)
    141         Variable.Value = chooseItemDialog.Item;
     138    }
     139    private void valuePanel_DragDrop(object sender, DragEventArgs e) {
     140      if (e.Effect != DragDropEffects.None) {
     141        IItem item = e.Data.GetData("Value") as IItem;
     142        if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (IItem)item.Clone();
     143        Variable.Value = item;
     144      }
    142145    }
    143146  }
Note: See TracChangeset for help on using the changeset viewer.