- Timestamp:
- 01/20/10 05:04:31 (15 years ago)
- 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 32 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 33 protected override void Dispose(bool disposing) { 34 if (disposing && (components != null)) {35 components.Dispose();34 if (disposing) { 35 if (components != null) components.Dispose(); 36 36 } 37 37 base.Dispose(disposing); … … 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container(); 47 48 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 48 49 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(); 51 51 this.operatorGraphView = new HeuristicLab.Core.Views.OperatorGraphView(); 52 this.globalScopeGroupBox = new System.Windows.Forms.GroupBox();53 52 this.scopeView = new HeuristicLab.Core.Views.ScopeView(); 54 53 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(); 62 60 this.SuspendLayout(); 63 61 // … … 65 63 // 66 64 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); 68 66 this.executionTimeTextBox.Name = "executionTimeTextBox"; 69 67 this.executionTimeTextBox.ReadOnly = true; 70 68 this.executionTimeTextBox.Size = new System.Drawing.Size(141, 20); 71 this.executionTimeTextBox.TabIndex = 5;69 this.executionTimeTextBox.TabIndex = 4; 72 70 // 73 71 // executionTimeLabel … … 75 73 this.executionTimeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 76 74 this.executionTimeLabel.AutoSize = true; 77 this.executionTimeLabel.Location = new System.Drawing.Point( 496, 444);75 this.executionTimeLabel.Location = new System.Drawing.Point(572, 623); 78 76 this.executionTimeLabel.Name = "executionTimeLabel"; 79 77 this.executionTimeLabel.Size = new System.Drawing.Size(83, 13); 80 this.executionTimeLabel.TabIndex = 4;78 this.executionTimeLabel.TabIndex = 3; 81 79 this.executionTimeLabel.Text = "&Execution Time:"; 82 80 // 83 // splitContainer 181 // splitContainer 84 82 // 85 this.splitContainer 1.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) 86 84 | System.Windows.Forms.AnchorStyles.Left) 87 85 | System.Windows.Forms.AnchorStyles.Right))); 88 this.splitContainer 1.Location = new System.Drawing.Point(0, 0);89 this.splitContainer 1.Name = "splitContainer1";86 this.splitContainer.Location = new System.Drawing.Point(0, 0); 87 this.splitContainer.Name = "splitContainer"; 90 88 // 91 // splitContainer 1.Panel189 // splitContainer.Panel1 92 90 // 93 this.splitContainer 1.Panel1.Controls.Add(this.operatorGraphGroupBox);91 this.splitContainer.Panel1.Controls.Add(this.operatorGraphView); 94 92 // 95 // splitContainer 1.Panel293 // splitContainer.Panel2 96 94 // 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; 112 99 // 113 100 // operatorGraphView … … 115 102 this.operatorGraphView.Caption = "Operator Graph"; 116 103 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); 118 106 this.operatorGraphView.Name = "operatorGraphView"; 119 107 this.operatorGraphView.OperatorGraph = null; 120 this.operatorGraphView.Size = new System.Drawing.Size( 314, 422);108 this.operatorGraphView.Size = new System.Drawing.Size(401, 611); 121 109 this.operatorGraphView.TabIndex = 0; 122 //123 // globalScopeGroupBox124 //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";133 110 // 134 111 // scopeView … … 136 113 this.scopeView.Caption = "Scope"; 137 114 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); 139 117 this.scopeView.Name = "scopeView"; 140 118 this.scopeView.Scope = null; 141 this.scopeView.Size = new System.Drawing.Size(3 10, 422);119 this.scopeView.Size = new System.Drawing.Size(397, 611); 142 120 this.scopeView.TabIndex = 0; 143 121 // … … 145 123 // 146 124 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); 148 127 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"); 152 131 this.resetButton.UseVisualStyleBackColor = true; 153 132 this.resetButton.Click += new System.EventHandler(this.resetButton_Click); 154 133 // 155 // abortButton134 // stopButton 156 135 // 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); 166 146 // 167 // executeButton147 // startButton 168 148 // 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); 177 158 // 178 // EngineBase Editor159 // EngineBaseView 179 160 // 180 161 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); … … 182 163 this.Controls.Add(this.executionTimeTextBox); 183 164 this.Controls.Add(this.executionTimeLabel); 184 this.Controls.Add(this.splitContainer 1);165 this.Controls.Add(this.splitContainer); 185 166 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); 195 174 this.ResumeLayout(false); 196 175 this.PerformLayout(); … … 202 181 protected System.Windows.Forms.TextBox executionTimeTextBox; 203 182 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; 207 184 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; 210 187 protected HeuristicLab.Core.Views.OperatorGraphView operatorGraphView; 211 188 protected HeuristicLab.Core.Views.ScopeView scopeView; 189 private System.Windows.Forms.ToolTip toolTip; 212 190 213 191 } -
trunk/sources/HeuristicLab.Core.Views/3.3/EngineBaseView.cs
r2546 r2655 43 43 /// </summary> 44 44 /// <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; } 47 47 set { base.Item = value; } 48 48 } … … 54 54 InitializeComponent(); 55 55 } 56 public EngineBaseView(EngineBase engine) 57 : this() { 58 Engine = engine; 59 } 56 60 57 61 /// <summary> … … 59 63 /// </summary> 60 64 /// <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); 62 67 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); 63 71 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(); 69 73 } 74 70 75 /// <summary> 71 76 /// Adds event handlers to the underlying <see cref="IEngine"/>. 72 77 /// </summary> 73 78 /// <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); 76 82 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); 77 86 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;82 87 } 83 88 … … 86 91 /// </summary> 87 92 /// <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; 91 96 if (Engine == null) { 92 executeButton.Enabled = false; 97 operatorGraphView.Enabled = false; 98 scopeView.Enabled = false; 99 startButton.Enabled = false; 93 100 resetButton.Enabled = false; 94 101 executionTimeTextBox.Enabled = false; 95 102 } else { 96 executeButton.Enabled = true; 103 operatorGraphView.OperatorGraph = Engine.OperatorGraph; 104 scopeView.Scope = Engine.GlobalScope; 105 startButton.Enabled = !Engine.Finished; 97 106 resetButton.Enabled = true; 98 executionTimeCounter = 0;99 107 executionTimeTextBox.Text = Engine.ExecutionTime.ToString(); 100 108 executionTimeTextBox.Enabled = true; … … 103 111 104 112 #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 } 105 119 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 } 107 130 } 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; 110 133 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 } 114 155 } 115 156 private void Engine_ExecutionTimeChanged(object sender, EventArgs e) { 116 157 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) { 133 159 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(); 135 164 } 136 165 } 137 private void En ableDisableControls() {166 private void Engine_ExceptionOccurred(object sender, EventArgs<Exception> e) { 138 167 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); 147 171 } 148 172 #endregion 149 173 150 174 #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(); 158 177 } 159 private void abortButton_Click(object sender, EventArgs e) {160 Engine. Abort();178 private void stopButton_Click(object sender, EventArgs e) { 179 Engine.Stop(); 161 180 } 162 181 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(); 170 183 } 171 184 #endregion -
trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj
r2546 r2655 39 39 <RequiredTargetFramework>3.5</RequiredTargetFramework> 40 40 </Reference> 41 <Reference Include="System.Design" /> 41 42 <Reference Include="System.Drawing" /> 42 43 <Reference Include="System.Windows.Forms" /> … … 51 52 </ItemGroup> 52 53 <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> 53 60 <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>72 61 <Compile Include="EngineBaseView.cs"> 73 62 <SubType>UserControl</SubType> … … 76 65 <DependentUpon>EngineBaseView.cs</DependentUpon> 77 66 </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> 78 206 <Compile Include="HeuristicLabCoreViewsPlugin.cs" /> 79 <Compile Include="IItemView.cs" />80 207 <Compile Include="ItemBaseView.cs"> 81 208 <SubType>UserControl</SubType> … … 90 217 <DependentUpon>ItemViewBase.cs</DependentUpon> 91 218 </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>128 219 <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>147 220 <Compile Include="VariableView.cs"> 148 221 <SubType>UserControl</SubType> … … 157 230 </ItemGroup> 158 231 <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> 159 236 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.2\HeuristicLab.Common.Resources-3.2.csproj"> 160 237 <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project> … … 177 254 <Name>HeuristicLab.MainForm-3.2</Name> 178 255 </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> 179 260 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 180 261 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 181 262 <Name>HeuristicLab.PluginInfrastructure</Name> 182 263 </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>236 264 </ItemGroup> 237 265 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLabCoreViewsPlugin.cs
r2520 r2655 29 29 /// Plugin class for HeuristicLab.Core.Views plugin. 30 30 /// </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")] 38 40 public class HeuristicLabCoreViewsPlugin : PluginBase { 39 41 } -
trunk/sources/HeuristicLab.Core.Views/3.3/IObjectView.cs
r2617 r2655 30 30 /// An interface for all kinds visual representations of items (objects, operators...). 31 31 /// </summary> 32 public interface I ItemView : IView {32 public interface IObjectView : IView { 33 33 /// <summary> 34 34 /// Gets the current item instance. 35 35 /// </summary> 36 IItem Item{ get; }36 object Object { get; } 37 37 38 38 /// <summary> 39 /// Occurs when the item was changed.39 /// Occurs when the current item was changed. 40 40 /// </summary> 41 event EventHandler ItemChanged;41 event EventHandler ObjectChanged; 42 42 } 43 43 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemBaseView.Designer.cs
r2520 r2655 32 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 33 protected override void Dispose(bool disposing) { 34 if (disposing && (components != null)) {35 components.Dispose();34 if (disposing) { 35 if (components != null) components.Dispose(); 36 36 } 37 37 base.Dispose(disposing); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemBaseView.cs
r2546 r2655 45 45 /// </summary> 46 46 /// <param name="item">The item that should be displayed.</param> 47 public ItemBaseView(I Itemitem)47 public ItemBaseView(ItemBase item) 48 48 : this() { 49 49 Item = item; -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemViewBase.Designer.cs
r2546 r2655 34 34 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 35 35 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(); 40 38 } 41 39 base.Dispose(disposing); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemViewBase.cs
r2555 r2655 34 34 /// Base class for all visual representations. 35 35 /// </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 { 44 37 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; } 57 40 } 58 41 … … 65 48 } 66 49 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"; 86 53 } else { 87 UpdateControls(); 88 base.Refresh(); 54 Caption = Item.ItemName; 89 55 } 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 else98 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 time120 System.Threading.Thread.Sleep(0);121 122 // prevent blocking of worker thread in Invoke, if the control is disposed123 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 time134 System.Threading.Thread.Sleep(0);135 136 // prevent blocking of worker thread in Invoke, if the control is disposed137 IAsyncResult result = BeginInvoke(method, args);138 while ((!result.AsyncWaitHandle.WaitOne(100, false)) && (!IsDisposed)) { }139 if (!IsDisposed) EndInvoke(result);140 56 } 141 57 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorBaseView.Designer.cs
r2524 r2655 20 20 #endregion 21 21 22 using System;23 using System.Windows.Forms;24 25 22 namespace HeuristicLab.Core.Views { 26 23 partial class OperatorBaseView { … … 35 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 36 33 protected override void Dispose(bool disposing) { 37 if (disposing && (components != null)) {38 components.Dispose();34 if (disposing) { 35 if (components != null) components.Dispose(); 39 36 } 40 37 base.Dispose(disposing); … … 48 45 /// </summary> 49 46 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(); 61 48 this.SuspendLayout(); 62 49 // 63 // tabControl50 // nameTextBox 64 51 // 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); 74 53 // 75 // variableInfosTabPage54 // descriptionTextBox 76 55 // 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); 85 59 // 86 // operatorBaseVariableInfosView60 // parameterCollectionView 87 61 // 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; 138 72 // 139 73 // OperatorBaseView … … 141 75 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 142 76 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 143 this.Controls.Add(this. tabControl);77 this.Controls.Add(this.parameterCollectionView); 144 78 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); 150 85 this.ResumeLayout(false); 86 this.PerformLayout(); 151 87 152 88 } … … 154 90 #endregion 155 91 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; 163 93 164 94 -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorBaseView.cs
r2546 r2655 29 29 using HeuristicLab.MainForm; 30 30 31 namespace HeuristicLab.Core.Views { 31 namespace HeuristicLab.Core.Views { 32 32 /// <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. 35 34 /// </summary> 36 35 [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; } 46 40 } 47 41 48 42 /// <summary> 49 /// Initializes a new instance of <see cref=" OperatorBaseView"/> with caption "Operator".43 /// Initializes a new instance of <see cref="ItemBaseView"/>. 50 44 /// </summary> 51 45 public OperatorBaseView() { 52 46 InitializeComponent(); 53 Caption = "Operator";54 47 } 55 48 /// <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"/>. 58 50 /// </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) 62 53 : this() { 63 Operator = op;54 OperatorBase = operatorBase; 64 55 } 65 56 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; 94 61 } else { 95 Caption = Operator.Name + " (" + Operator.GetType().Name + ")"; 96 tabControl.Enabled = true; 62 parameterCollectionView.NamedItemCollection = ((IOperator)OperatorBase).Parameters; 97 63 } 98 64 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.Designer.cs
r2520 r2655 32 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 33 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(); 41 36 } 42 37 base.Dispose(disposing); … … 51 46 private void InitializeComponent() { 52 47 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();56 48 this.operatorsContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 57 49 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(); 63 53 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);70 54 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(); 75 58 this.graphGroupBox.SuspendLayout(); 76 this.graphContextMenuStrip.SuspendLayout();77 59 this.SuspendLayout(); 78 //79 // operatorsListView80 //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);105 60 // 106 61 // operatorsContextMenuStrip 107 62 // 108 63 this.operatorsContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 109 this.initialOperatorToolStripMenuItem, 110 this.viewToolStripMenuItem}); 64 this.initialOperatorToolStripMenuItem}); 111 65 this.operatorsContextMenuStrip.Name = "operatorsContextMenuStrip"; 112 this.operatorsContextMenuStrip.Size = new System.Drawing.Size(15 9, 48);66 this.operatorsContextMenuStrip.Size = new System.Drawing.Size(154, 26); 113 67 this.operatorsContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.operatorsContextMenuStrip_Opening); 114 68 // … … 117 71 this.initialOperatorToolStripMenuItem.CheckOnClick = true; 118 72 this.initialOperatorToolStripMenuItem.Name = "initialOperatorToolStripMenuItem"; 119 this.initialOperatorToolStripMenuItem.Size = new System.Drawing.Size(15 8, 22);73 this.initialOperatorToolStripMenuItem.Size = new System.Drawing.Size(153, 22); 120 74 this.initialOperatorToolStripMenuItem.Text = "&Initial Operator"; 121 75 this.initialOperatorToolStripMenuItem.ToolTipText = "Set as initial operator"; 122 76 this.initialOperatorToolStripMenuItem.Click += new System.EventHandler(this.initialOperatorToolStripMenuItem_Click); 123 77 // 124 // viewToolStripMenuItem78 // operatorsView 125 79 // 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); 131 89 // 132 // imageList90 // graphView 133 91 // 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; 139 100 // 140 // addOperatorButton101 // splitContainer 141 102 // 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; 150 107 // 151 // splitContainer 1108 // splitContainer.Panel1 152 109 // 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); 158 111 // 159 // splitContainer 1.Panel1112 // splitContainer.Panel2 160 113 // 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; 180 118 // 181 119 // graphGroupBox 182 120 // 183 this.graphGroupBox.Controls.Add(this.graph TreeView);121 this.graphGroupBox.Controls.Add(this.graphView); 184 122 this.graphGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 185 123 this.graphGroupBox.Location = new System.Drawing.Point(0, 0); 186 124 this.graphGroupBox.Name = "graphGroupBox"; 187 this.graphGroupBox.Size = new System.Drawing.Size( 296, 262);125 this.graphGroupBox.Size = new System.Drawing.Size(608, 213); 188 126 this.graphGroupBox.TabIndex = 0; 189 127 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"; 248 129 // 249 130 // OperatorGraphView … … 251 132 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 252 133 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); 256 135 this.Name = "OperatorGraphView"; 257 this.Size = new System.Drawing.Size( 475, 291);136 this.Size = new System.Drawing.Size(608, 533); 258 137 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); 263 141 this.graphGroupBox.ResumeLayout(false); 264 this.graphContextMenuStrip.ResumeLayout(false);265 142 this.ResumeLayout(false); 266 143 … … 269 146 #endregion 270 147 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;277 148 private System.Windows.Forms.ContextMenuStrip operatorsContextMenuStrip; 278 private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;279 149 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; 281 153 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;287 154 } 288 155 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.cs
r2546 r2655 30 30 using HeuristicLab.Common; 31 31 using HeuristicLab.MainForm; 32 using HeuristicLab.Collections; 32 33 33 34 namespace HeuristicLab.Core.Views { 34 35 /// <summary> 35 /// The visual representation of an <see cref=" IOperatorGraph"/>.36 /// The visual representation of an <see cref="OperatorGraph"/>. 36 37 /// </summary> 37 38 [Content(typeof(OperatorGraph), true)] 38 39 public partial class OperatorGraphView : ItemViewBase { 39 private ChooseOperatorDialog chooseOperatorDialog;40 private Dictionary<IOperator, IList<TreeNode>> operatorNodeTable;41 42 40 /// <summary> 43 41 /// Gets or sets the operator graph to represent visually. … … 45 43 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 46 44 /// No own data storage present.</remarks> 47 public IOperatorGraph OperatorGraph {48 get { return ( IOperatorGraph)Item; }45 public OperatorGraph OperatorGraph { 46 get { return (OperatorGraph)Item; } 49 47 set { base.Item = value; } 50 48 } … … 55 53 public OperatorGraphView() { 56 54 InitializeComponent(); 57 operatorNodeTable = new Dictionary<IOperator, IList<TreeNode>>();58 operatorsListView.Columns[0].Width = Math.Max(0, operatorsListView.Width - 25);59 55 Caption = "Operator Graph"; 60 56 } … … 65 61 /// <remarks>Calls <see cref="OperatorGraphView()"/>.</remarks> 66 62 /// <param name="operatorGraph">The operator graph to represent visually.</param> 67 public OperatorGraphView( IOperatorGraph operatorGraph)63 public OperatorGraphView(OperatorGraph operatorGraph) 68 64 : this() { 69 65 OperatorGraph = operatorGraph; … … 74 70 /// </summary> 75 71 /// <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() { 79 73 OperatorGraph.InitialOperatorChanged -= new EventHandler(OperatorGraph_InitialOperatorChanged); 80 base. RemoveItemEvents();74 base.DeregisterObjectEvents(); 81 75 } 76 82 77 /// <summary> 83 78 /// Adds eventhandlers to the underlying <see cref="IOperatorGraph"/>. 84 79 /// </summary> 85 80 /// <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(); 90 83 OperatorGraph.InitialOperatorChanged += new EventHandler(OperatorGraph_InitialOperatorChanged); 91 84 } … … 95 88 /// </summary> 96 89 /// <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; 106 96 if (OperatorGraph == null) { 107 97 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; 110 102 } 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; 121 109 } 122 110 } 123 111 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; 173 118 } 174 119 } 175 120 176 #region ListView Events177 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 #endregion191 192 #region TreeView Events193 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 #endregion209 210 #region Size Changed Events211 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 #endregion216 217 #region Key Events218 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 #endregion240 241 #region Edit Events242 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 #endregion252 253 #region Button Events254 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 #endregion266 267 #region Drag and Drop Events268 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 #endregion369 370 121 #region Context Menu Events 371 122 private void operatorsContextMenuStrip_Opening(object sender, CancelEventArgs e) { 372 viewToolStripMenuItem.Enabled = false;373 123 initialOperatorToolStripMenuItem.Enabled = false; 374 124 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; 382 127 initialOperatorToolStripMenuItem.Enabled = true; 383 128 initialOperatorToolStripMenuItem.Tag = op; … … 386 131 } 387 132 } 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 }392 133 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) 397 135 OperatorGraph.InitialOperator = (IOperator)initialOperatorToolStripMenuItem.Tag; 398 } else { 399 operatorsListView.SelectedItems[0].Font = operatorsListView.Font; 136 else 400 137 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;423 138 } 424 139 #endregion 425 140 426 141 #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 }438 142 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; 476 148 } 477 149 } 478 150 #endregion 479 151 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; 488 154 } 489 #endregion490 491 155 } 492 156 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.Designer.cs
r2520 r2655 32 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 33 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(); 40 40 } 41 41 base.Dispose(disposing); … … 49 49 /// </summary> 50 50 private void InitializeComponent() { 51 this.components = new System.ComponentModel.Container();52 51 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(); 60 59 this.SuspendLayout(); 61 60 // 62 61 // scopesTreeView 63 62 // 64 this.scopesTreeView.ContextMenuStrip = this.contextMenuStrip;65 63 this.scopesTreeView.Dock = System.Windows.Forms.DockStyle.Fill; 66 64 this.scopesTreeView.HideSelection = false; 67 this.scopesTreeView.Location = new System.Drawing.Point( 0, 0);65 this.scopesTreeView.Location = new System.Drawing.Point(3, 16); 68 66 this.scopesTreeView.Name = "scopesTreeView"; 69 67 this.scopesTreeView.ShowNodeToolTips = true; 70 this.scopesTreeView.Size = new System.Drawing.Size( 400, 400);68 this.scopesTreeView.Size = new System.Drawing.Size(394, 181); 71 69 this.scopesTreeView.TabIndex = 0; 72 70 this.scopesTreeView.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.scopesTreeView_AfterCollapse); 73 71 this.scopesTreeView.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.scopesTreeView_BeforeExpand); 74 this.scopesTreeView.DoubleClick += new System.EventHandler(this.scopesTreeView_DoubleClick);75 72 this.scopesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.scopesTreeView_MouseDown); 76 73 this.scopesTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.scopesTreeView_ItemDrag); 77 74 // 78 // contextMenuStrip75 // splitContainer 79 76 // 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; 89 81 // 90 // automaticUpdatingToolStripMenuItem82 // splitContainer.Panel1 91 83 // 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); 98 85 // 99 // refreshToolStripMenuItem86 // splitContainer.Panel2 100 87 // 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; 105 92 // 106 // toolStripMenuItem193 // scopesGroupBox 107 94 // 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"; 110 103 // 111 // v iewToolStripMenuItem104 // variableCollectionView 112 105 // 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; 123 114 // 124 115 // ScopeView … … 126 117 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 127 118 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 128 this.Controls.Add(this.s copesTreeView);119 this.Controls.Add(this.splitContainer); 129 120 this.Name = "ScopeView"; 130 121 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); 132 126 this.ResumeLayout(false); 133 127 … … 137 131 138 132 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; 145 136 } 146 137 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.cs
r2546 r2655 30 30 using HeuristicLab.Common; 31 31 using HeuristicLab.MainForm; 32 using HeuristicLab.Collections; 32 33 33 34 namespace HeuristicLab.Core.Views { 34 35 /// <summary> 35 /// The visual represenation of <see cref=" IScope"/>.36 /// The visual represenation of <see cref="Scope"/>. 36 37 /// </summary> 37 38 [Content(typeof(Scope), true)] 38 39 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; 41 42 42 43 /// <summary> … … 45 46 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 46 47 /// No own data storage present.</remarks> 47 public IScope Scope {48 get { return ( IScope)Item; }48 public Scope Scope { 49 get { return (Scope)Item; } 49 50 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; }57 51 } 58 52 … … 64 58 InitializeComponent(); 65 59 Caption = "Scope"; 66 scopeNodeTable = new Dictionary< IScope, TreeNode>();67 s copeExpandedTable = new Dictionary<IScope, bool>();68 myAutomaticUpdating = false; 60 scopeNodeTable = new Dictionary<Scope, TreeNode>(); 61 subScopesScopeTable = new Dictionary<ScopeList, Scope>(); 62 69 63 } 70 64 /// <summary> … … 73 67 /// <remarks>Calls <see cref="ScopeView()"/>.</remarks> 74 68 /// <param name="scope">The scope to represent visually.</param> 75 public ScopeView( IScope scope)69 public ScopeView(Scope scope) 76 70 : this() { 77 71 Scope = scope; … … 82 76 /// </summary> 83 77 /// <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) { 87 81 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; 90 86 if (Scope == null) { 91 87 Caption = "Scope"; … … 93 89 } else { 94 90 Caption = Scope.Name + " (" + Scope.GetType().Name + ")"; 91 scopesTreeView.Enabled = true; 95 92 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) { 101 97 TreeNode node = new TreeNode(); 102 98 node.Text = scope.Name; … … 104 100 105 101 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); 112 109 if (scope.SubScopes.Count > 0) 113 110 node.Nodes.Add(new TreeNode()); 114 111 return node; 115 112 } 113 116 114 private void RemoveTreeNode(TreeNode node) { 117 115 foreach (TreeNode child in node.Nodes) 118 116 RemoveTreeNode(child); 119 117 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) { 122 120 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); 127 128 } 128 129 } 129 130 130 131 #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; 136 141 } 137 142 } 138 143 private void scopesTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) { 139 144 TreeNode node = e.Node; 140 IScope scope = (IScope)node.Tag;145 Scope scope = (Scope)node.Tag; 141 146 142 147 node.Nodes.Clear(); 143 148 for (int i = 0; i < scope.SubScopes.Count; i++) 144 149 node.Nodes.Add(CreateTreeNode(scope.SubScopes[i])); 145 scopeExpandedTable[scope] = true;146 150 } 147 151 private void scopesTreeView_AfterCollapse(object sender, System.Windows.Forms.TreeViewEventArgs e) { 148 152 TreeNode node = e.Node; 149 IScope scope = (IScope)node.Tag;153 Scope scope = (Scope)node.Tag; 150 154 151 155 if (node.Nodes.Count > 0) { … … 155 159 node.Nodes.Add(new TreeNode()); 156 160 } 157 scopeExpandedTable[scope] = false;158 161 } 159 162 private void scopesTreeView_ItemDrag(object sender, ItemDragEventArgs e) { 160 163 TreeNode node = (TreeNode)e.Item; 161 IScope scope = node.Tag as IScope;164 Scope scope = node.Tag as Scope; 162 165 if (scope != null) { 163 166 DataObject data = new DataObject(); 164 data.SetData(" IScope", scope);167 data.SetData("Scope", scope); 165 168 data.SetData("DragSource", scopesTreeView); 166 169 DoDragDrop(data, DragDropEffects.Copy); … … 169 172 #endregion 170 173 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 } 209 182 } 210 183 #endregion 211 184 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 } 248 263 } 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 } 280 268 } 281 269 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.Designer.cs
r2520 r2655 32 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 33 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(); 37 37 } 38 38 base.Dispose(disposing); … … 46 46 /// </summary> 47 47 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(); 54 59 this.SuspendLayout(); 55 //56 // nameLabel57 //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:";64 60 // 65 61 // nameTextBox 66 62 // 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) 68 68 | 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); 74 70 // 75 // valueLabel71 // dataTypeLabel 76 72 // 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:"; 83 79 // 84 // valueTextBox80 // dataTypeTextBox 85 81 // 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) 87 83 | 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; 93 89 // 94 // editorGroupBox90 // valueGroupBox 95 91 // 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) 97 93 | System.Windows.Forms.AnchorStyles.Left) 98 94 | 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:"; 105 104 // 106 // setVariableValueButton105 // valuePanel 107 106 // 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); 116 149 // 117 150 // VariableView … … 119 152 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 120 153 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); 127 157 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); 129 168 this.ResumeLayout(false); 130 169 this.PerformLayout(); … … 134 173 #endregion 135 174 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; 142 183 } 143 184 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs
r2546 r2655 31 31 namespace HeuristicLab.Core.Views { 32 32 /// <summary> 33 /// The visual representation of a n <see cref="IVariable"/>.33 /// The visual representation of a <see cref="Variable"/>. 34 34 /// </summary> 35 35 [Content(typeof(Variable), true)] 36 public partial class VariableView : ItemViewBase{37 private ChooseItemDialog chooseItemDialog;36 public partial class VariableView : NamedItemBaseView { 37 private TypeSelectorDialog typeSelectorDialog; 38 38 39 39 /// <summary> … … 42 42 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 43 43 /// No own data storage present.</remarks> 44 public IVariable Variable {45 get { return ( IVariable)Item; }44 public Variable Variable { 45 get { return (Variable)Item; } 46 46 set { base.Item = value; } 47 47 } … … 59 59 /// <remarks>Calls <see cref="VariableView()"/>.</remarks> 60 60 /// <param name="variable">The variable to represent visually.</param> 61 public VariableView( IVariable variable)61 public VariableView(Variable variable) 62 62 : this() { 63 63 Variable = variable; … … 68 68 /// </summary> 69 69 /// <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() { 72 71 Variable.ValueChanged -= new EventHandler(Variable_ValueChanged); 73 base. RemoveItemEvents();72 base.DeregisterObjectEvents(); 74 73 } 74 75 75 /// <summary> 76 76 /// Adds eventhandlers to the underlying <see cref="IVariable"/>. 77 77 /// </summary> 78 78 /// <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(); 82 81 Variable.ValueChanged += new EventHandler(Variable_ValueChanged); 83 82 } 84 83 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(); 95 86 if (Variable == null) { 96 87 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; 98 94 } else { 99 95 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; 112 102 } 113 103 } 114 104 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) { 119 106 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 } 126 115 } 127 116 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 } 133 126 } 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; 139 137 } 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 } 142 145 } 143 146 }
Note: See TracChangeset
for help on using the changeset viewer.