Changeset 5042 for trunk/sources
- Timestamp:
- 12/06/10 18:17:09 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Operators.Programmable/3.3
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Programmable/3.3/HeuristicLab.Operators.Programmable-3.3.csproj
r4828 r5042 191 191 </ItemGroup> 192 192 <ItemGroup> 193 <EmbeddedResource Include="ProgrammableOperatorView.resx">194 <DependentUpon>ProgrammableOperatorView.cs</DependentUpon>195 <SubType>Designer</SubType>196 </EmbeddedResource>197 193 <EmbeddedResource Include="Properties\Resources.resx"> 198 194 <Generator>ResXFileCodeGenerator</Generator> -
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs
r5011 r5042 31 31 using HeuristicLab.Collections; 32 32 using HeuristicLab.Common; 33 using HeuristicLab.Common.Resources; 33 34 using HeuristicLab.Core; 34 35 using HeuristicLab.Persistence.Auxiliary; … … 50 51 get { return base.Parameters; } 51 52 } 53 54 public override System.Drawing.Image ItemImage { get { return VS2008ImageLibrary.Script; } } 52 55 53 56 private MethodInfo executeMethod; … … 342 345 var results = DoCompile(); 343 346 executeMethod = null; 347 CompileErrors = results.Errors; 344 348 if (results.Errors.HasErrors) { 345 CompileErrors = results.Errors;346 349 StringBuilder sb = new StringBuilder(); 347 350 foreach (CompilerError error in results.Errors) { … … 355 358 sb.ToString())); 356 359 } else { 357 CompileErrors = null;358 360 Assembly assembly = results.CompiledAssembly; 359 361 Type[] types = assembly.GetTypes(); -
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.Designer.cs
r4477 r5042 59 59 this.tabPage1 = new System.Windows.Forms.TabPage(); 60 60 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 61 this.breakpointCheckBox = new System.Windows.Forms.CheckBox(); 62 this.breakpointLabel = new System.Windows.Forms.Label(); 63 this.compilationLabel = new System.Windows.Forms.Label(); 61 64 tabPage2 = new System.Windows.Forms.TabPage(); 62 65 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); … … 90 93 tabPage2.Name = "tabPage2"; 91 94 tabPage2.Padding = new System.Windows.Forms.Padding(3); 92 tabPage2.Size = new System.Drawing.Size(977, 619);95 tabPage2.Size = new System.Drawing.Size(977, 596); 93 96 tabPage2.TabIndex = 1; 94 97 tabPage2.Text = "Code"; … … 103 106 // splitContainer1.Panel1 104 107 // 108 this.splitContainer1.Panel1.Controls.Add(this.compilationLabel); 105 109 this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); 106 110 this.splitContainer1.Panel1.Controls.Add(this.showCodeButton); … … 110 114 // 111 115 this.splitContainer1.Panel2.Controls.Add(this.codeEditor); 112 this.splitContainer1.Size = new System.Drawing.Size(971, 613);116 this.splitContainer1.Size = new System.Drawing.Size(971, 590); 113 117 this.splitContainer1.SplitterDistance = 244; 114 118 this.splitContainer1.TabIndex = 0; … … 116 120 // splitContainer2 117 121 // 118 this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 119 | System.Windows.Forms.AnchorStyles.Left)120 122 this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 123 | System.Windows.Forms.AnchorStyles.Left) 124 | System.Windows.Forms.AnchorStyles.Right))); 121 125 this.splitContainer2.Location = new System.Drawing.Point(0, 33); 122 126 this.splitContainer2.Name = "splitContainer2"; … … 130 134 // 131 135 this.splitContainer2.Panel2.Controls.Add(this.namespacesBox); 132 this.splitContainer2.Size = new System.Drawing.Size(242, 5 83);133 this.splitContainer2.SplitterDistance = 2 90;136 this.splitContainer2.Size = new System.Drawing.Size(242, 560); 137 this.splitContainer2.SplitterDistance = 278; 134 138 this.splitContainer2.TabIndex = 2; 135 139 // … … 140 144 this.assembliesBox.Location = new System.Drawing.Point(0, 0); 141 145 this.assembliesBox.Name = "assembliesBox"; 142 this.assembliesBox.Size = new System.Drawing.Size(242, 2 90);146 this.assembliesBox.Size = new System.Drawing.Size(242, 278); 143 147 this.assembliesBox.TabIndex = 1; 144 148 this.assembliesBox.TabStop = false; … … 151 155 this.assembliesTreeView.Location = new System.Drawing.Point(3, 16); 152 156 this.assembliesTreeView.Name = "assembliesTreeView"; 153 this.assembliesTreeView.Size = new System.Drawing.Size(236, 2 71);157 this.assembliesTreeView.Size = new System.Drawing.Size(236, 259); 154 158 this.assembliesTreeView.TabIndex = 0; 155 159 this.assembliesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.assembliesTreeView_AfterCheck); … … 161 165 this.namespacesBox.Location = new System.Drawing.Point(0, 0); 162 166 this.namespacesBox.Name = "namespacesBox"; 163 this.namespacesBox.Size = new System.Drawing.Size(242, 2 89);167 this.namespacesBox.Size = new System.Drawing.Size(242, 278); 164 168 this.namespacesBox.TabIndex = 1; 165 169 this.namespacesBox.TabStop = false; … … 173 177 this.namespacesTreeView.Name = "namespacesTreeView"; 174 178 this.namespacesTreeView.PathSeparator = "."; 175 this.namespacesTreeView.Size = new System.Drawing.Size(236, 2 70);179 this.namespacesTreeView.Size = new System.Drawing.Size(236, 259); 176 180 this.namespacesTreeView.TabIndex = 0; 177 181 this.namespacesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.namespacesTreeView_AfterCheck); … … 179 183 // showCodeButton 180 184 // 181 this.showCodeButton.Image = ((System.Drawing.Image)(resources.GetObject("showCodeButton.Image")));185 this.showCodeButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.PrintPreview; 182 186 this.showCodeButton.Location = new System.Drawing.Point(33, 3); 183 187 this.showCodeButton.Name = "showCodeButton"; … … 191 195 // compileButton 192 196 // 193 this.compileButton.Image = ((System.Drawing.Image)(resources.GetObject("compileButton.Image")));197 this.compileButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Script; 194 198 this.compileButton.Location = new System.Drawing.Point(3, 3); 195 199 this.compileButton.Name = "compileButton"; … … 207 211 this.codeEditor.Name = "codeEditor"; 208 212 this.codeEditor.Prefix = ""; 209 this.codeEditor.Size = new System.Drawing.Size(723, 613);213 this.codeEditor.Size = new System.Drawing.Size(723, 590); 210 214 this.codeEditor.Suffix = ""; 211 215 this.codeEditor.TabIndex = 0; … … 215 219 // tabControl1 216 220 // 217 this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 218 | System.Windows.Forms.AnchorStyles.Left)219 221 this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 222 | System.Windows.Forms.AnchorStyles.Left) 223 | System.Windows.Forms.AnchorStyles.Right))); 220 224 this.tabControl1.Controls.Add(this.tabPage1); 221 225 this.tabControl1.Controls.Add(tabPage2); 222 this.tabControl1.Location = new System.Drawing.Point(0, 52);226 this.tabControl1.Location = new System.Drawing.Point(0, 75); 223 227 this.tabControl1.Name = "tabControl1"; 224 228 this.tabControl1.SelectedIndex = 0; 225 this.tabControl1.Size = new System.Drawing.Size(985, 6 45);229 this.tabControl1.Size = new System.Drawing.Size(985, 622); 226 230 this.tabControl1.TabIndex = 7; 227 231 // … … 232 236 this.tabPage1.Name = "tabPage1"; 233 237 this.tabPage1.Padding = new System.Windows.Forms.Padding(3); 234 this.tabPage1.Size = new System.Drawing.Size(977, 619);238 this.tabPage1.Size = new System.Drawing.Size(977, 596); 235 239 this.tabPage1.TabIndex = 0; 236 240 this.tabPage1.Text = "Parameters"; … … 245 249 this.parameterCollectionView.Name = "parameterCollectionView"; 246 250 this.parameterCollectionView.ReadOnly = false; 247 this.parameterCollectionView.Size = new System.Drawing.Size(971, 613);251 this.parameterCollectionView.Size = new System.Drawing.Size(971, 590); 248 252 this.parameterCollectionView.TabIndex = 0; 253 // 254 // breakpointCheckBox 255 // 256 this.breakpointCheckBox.AutoSize = true; 257 this.breakpointCheckBox.Location = new System.Drawing.Point(72, 52); 258 this.breakpointCheckBox.Name = "breakpointCheckBox"; 259 this.breakpointCheckBox.Size = new System.Drawing.Size(15, 14); 260 this.breakpointCheckBox.TabIndex = 8; 261 this.breakpointCheckBox.UseVisualStyleBackColor = true; 262 this.breakpointCheckBox.CheckedChanged += new System.EventHandler(this.breakpointCheckBox_CheckedChanged); 263 // 264 // breakpointLabel 265 // 266 this.breakpointLabel.AutoSize = true; 267 this.breakpointLabel.Location = new System.Drawing.Point(3, 52); 268 this.breakpointLabel.Name = "breakpointLabel"; 269 this.breakpointLabel.Size = new System.Drawing.Size(61, 13); 270 this.breakpointLabel.TabIndex = 9; 271 this.breakpointLabel.Text = "Breakpoint:"; 272 // 273 // compilationLabel 274 // 275 this.compilationLabel.AutoSize = true; 276 this.compilationLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 277 this.compilationLabel.Location = new System.Drawing.Point(63, 9); 278 this.compilationLabel.Name = "compilationLabel"; 279 this.compilationLabel.Size = new System.Drawing.Size(67, 13); 280 this.compilationLabel.TabIndex = 3; 281 this.compilationLabel.Text = "not compiled"; 249 282 // 250 283 // ProgrammableOperatorView … … 253 286 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 254 287 this.Controls.Add(this.tabControl1); 288 this.Controls.Add(this.breakpointCheckBox); 289 this.Controls.Add(this.breakpointLabel); 255 290 this.Name = "ProgrammableOperatorView"; 256 291 this.Size = new System.Drawing.Size(985, 697); 292 this.Controls.SetChildIndex(this.breakpointLabel, 0); 293 this.Controls.SetChildIndex(this.breakpointCheckBox, 0); 257 294 this.Controls.SetChildIndex(this.tabControl1, 0); 258 295 this.Controls.SetChildIndex(this.nameTextBox, 0); … … 263 300 tabPage2.ResumeLayout(false); 264 301 this.splitContainer1.Panel1.ResumeLayout(false); 302 this.splitContainer1.Panel1.PerformLayout(); 265 303 this.splitContainer1.Panel2.ResumeLayout(false); 266 304 this.splitContainer1.ResumeLayout(false); … … 291 329 private System.Windows.Forms.GroupBox assembliesBox; 292 330 private System.Windows.Forms.GroupBox namespacesBox; 331 private System.Windows.Forms.CheckBox breakpointCheckBox; 332 private System.Windows.Forms.Label compilationLabel; 333 private System.Windows.Forms.Label breakpointLabel; 293 334 } 294 335 } -
trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.cs
r4838 r5042 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Reflection; … … 33 34 34 35 namespace HeuristicLab.Operators.Programmable { 36 35 37 [View("ProgrammableOperator View")] 36 38 [Content(typeof(ProgrammableOperator), true)] … … 55 57 ProgrammableOperator.CodeChanged += ProgrammableOperator_CodeChanged; 56 58 ProgrammableOperator.SignatureChanged += ProgrammableOperator_SignatureChanged; 59 ProgrammableOperator.BreakpointChanged += ProgrammableOperator_BreakpointChanged; 57 60 } 58 61 … … 60 63 ProgrammableOperator.CodeChanged -= ProgrammableOperator_CodeChanged; 61 64 ProgrammableOperator.SignatureChanged -= ProgrammableOperator_SignatureChanged; 65 ProgrammableOperator.BreakpointChanged -= ProgrammableOperator_BreakpointChanged; 62 66 base.DeregisterContentEvents(); 63 67 } 68 69 #region Content event handlers 70 void ProgrammableOperator_BreakpointChanged(object sender, EventArgs e) { 71 breakpointCheckBox.Checked = ProgrammableOperator.Breakpoint; 72 } 73 private void ProgrammableOperator_CodeChanged(object sender, EventArgs e) { 74 codeEditor.Text = ProgrammableOperator.Code; 75 } 76 private void ProgrammableOperator_SignatureChanged(object sender, EventArgs args) { 77 codeEditor.Prefix = GetGeneratedPrefix(); 78 } 79 #endregion 64 80 65 81 protected override void OnContentChanged() { … … 86 102 ProgrammableOperator.CompilationUnitCode.Length > 0; 87 103 parameterCollectionView.Content = ProgrammableOperator.Parameters; 104 if (ProgrammableOperator.CompileErrors == null) { 105 compilationLabel.ForeColor = SystemColors.ControlDarkDark; 106 compilationLabel.Text = "not compiled"; 107 } else if (ProgrammableOperator.CompileErrors.HasErrors) { 108 compilationLabel.ForeColor = Color.DarkRed; 109 compilationLabel.Text = "compilation failed"; 110 } else { 111 compilationLabel.ForeColor = Color.DarkGreen; 112 compilationLabel.Text = "compilation successful"; 113 } 114 88 115 } 89 116 } … … 96 123 compileButton.Enabled = Content != null && !ReadOnly; 97 124 codeEditor.Enabled = Content != null && !ReadOnly; 98 } 99 100 101 private string GetGeneratedPrefix() { 102 StringBuilder prefix = new StringBuilder(); 103 foreach (var ns in ProgrammableOperator.GetSelectedAndValidNamespaces()) { 104 prefix.Append("using ").Append(ns).AppendLine(";"); 105 } 106 prefix.AppendLine(); 107 prefix.Append("public class ").Append(ProgrammableOperator.CompiledTypeName).AppendLine(" {"); 108 prefix.Append(" ").Append(ProgrammableOperator.Signature).AppendLine(" {"); 109 return prefix.ToString(); 110 } 111 125 showCodeButton.Enabled = Content != null && !string.IsNullOrEmpty(ProgrammableOperator.CompilationUnitCode) && !ReadOnly; 126 } 127 128 #region Child Control event handlers 129 private void compileButton_Click(object sender, EventArgs e) { 130 Recompile(); 131 } 132 private void breakpointCheckBox_CheckedChanged(object sender, EventArgs e) { 133 if (ProgrammableOperator != null) ProgrammableOperator.Breakpoint = breakpointCheckBox.Checked; 134 } 135 private void showCodeButton_Click(object sender, EventArgs e) { 136 new CodeViewer(ProgrammableOperator.CompilationUnitCode).ShowDialog(this); 137 } 112 138 private void codeEditor_Validated(object sender, EventArgs e) { 113 139 ProgrammableOperator.Code = codeEditor.UserCode; 114 140 } 115 116 private void Recompile() {117 this.Enabled = false;118 try {119 ProgrammableOperator.Compile();120 MessageBox.Show("Compilation successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);121 } catch (Exception ex) {122 ErrorHandling.ShowErrorDialog(this, ex);123 }124 OnContentChanged();125 this.Enabled = true;126 }127 128 private void compileButton_Click(object sender, EventArgs e) {129 Recompile();130 }131 132 #region ProgrammableOperator Events133 private void ProgrammableOperator_CodeChanged(object sender, EventArgs e) {134 codeEditor.Text = ProgrammableOperator.Code;135 }136 private void ProgrammableOperator_SignatureChanged(object sender, EventArgs args) {137 codeEditor.Prefix = GetGeneratedPrefix();138 }139 #endregion140 141 141 private void assembliesTreeView_AfterCheck(object sender, TreeViewEventArgs e) { 142 142 if (initializing) … … 158 158 InitializeNamespacesList(); 159 159 codeEditor.Prefix = GetGeneratedPrefix(); 160 } 161 private void namespacesTreeView_AfterCheck(object sender, TreeViewEventArgs e) { 162 if (initializing) 163 return; 164 if (e.Node.Checked) { 165 ProgrammableOperator.SelectNamespace(e.Node.FullPath); 166 } else { 167 ProgrammableOperator.UnselectNamespace(e.Node.FullPath); 168 } 169 codeEditor.Prefix = GetGeneratedPrefix(); 170 } 171 #endregion 172 173 #region global HotKeys 174 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { 175 if (keyData == Keys.F6) { 176 Control activeControl = ActiveControl; 177 compileButton.Focus(); 178 Recompile(); 179 if (activeControl != null) 180 activeControl.Focus(); 181 return true; 182 } 183 return base.ProcessCmdKey(ref msg, keyData); 184 } 185 #endregion 186 187 #region Auxiliary functions 188 189 private string GetGeneratedPrefix() { 190 StringBuilder prefix = new StringBuilder(); 191 foreach (var ns in ProgrammableOperator.GetSelectedAndValidNamespaces()) { 192 prefix.Append("using ").Append(ns).AppendLine(";"); 193 } 194 prefix.AppendLine(); 195 prefix.Append("public class ").Append(ProgrammableOperator.CompiledTypeName).AppendLine(" {"); 196 prefix.Append(" ").Append(ProgrammableOperator.Signature).AppendLine(" {"); 197 return prefix.ToString(); 198 } 199 200 private void Recompile() { 201 this.Enabled = false; 202 try { 203 ProgrammableOperator.Compile(); 204 } catch (Exception ex) { 205 ErrorHandling.ShowErrorDialog(this, ex); 206 } 207 OnContentChanged(); 208 this.Enabled = true; 160 209 } 161 210 … … 265 314 } 266 315 267 private void namespacesTreeView_AfterCheck(object sender, TreeViewEventArgs e) { 268 if (initializing) 269 return; 270 if (e.Node.Checked) { 271 ProgrammableOperator.SelectNamespace(e.Node.FullPath); 272 } else { 273 ProgrammableOperator.UnselectNamespace(e.Node.FullPath); 274 } 275 codeEditor.Prefix = GetGeneratedPrefix(); 276 } 277 278 private void showCodeButton_Click(object sender, EventArgs e) { 279 new CodeViewer(ProgrammableOperator.CompilationUnitCode).ShowDialog(this); 280 } 316 #endregion 281 317 } 282 318 }
Note: See TracChangeset
for help on using the changeset viewer.