Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11721 for trunk/sources


Ignore:
Timestamp:
12/23/14 13:35:06 (10 years ago)
Author:
jkarder
Message:

#2262:

  • fixed SetEnabledStateOfControls in VariableStoreView
  • the code template for a CSharpScript is now read from an embedded resource
Location:
trunk/sources
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Scripting.Views/3.3/VariableStoreView.cs

    r11480 r11721  
    117117        sortDescendingButton.Enabled = false;
    118118        removeButton.Enabled = false;
    119         variableListView.Enabled = false;
     119        variableListView.LabelEdit = false;
    120120      } else {
    121121        bool enabled = !Locked && !ReadOnly;
     
    124124        sortDescendingButton.Enabled = variableListView.Items.Count > 1;
    125125        removeButton.Enabled = enabled && variableListView.SelectedItems.Count > 0;
    126         variableListView.Enabled = enabled;
    127126        variableListView.LabelEdit = enabled;
    128127      }
  • trunk/sources/HeuristicLab.Scripting/3.3/CSharpScript.cs

    r11514 r11721  
    3535    #region Constants
    3636    protected const string ExecuteMethodName = "Execute";
    37     protected override string CodeTemplate {
    38       get {
    39         return @"// use 'vars' to access variables in the script's variable store (e.g. vars.x = 5)
    40 // use 'vars[string]' to access variables via runtime strings (e.g. vars[""x""] = 5)
    41 // use 'vars.Contains(string)' to check if a variable exists
    42 // use 'vars.Clear()' to remove all variables
    43 // use 'foreach (KeyValuePair<string, object> v in vars) { ... }' to iterate over all variables
    44 // use 'variables' to work with IEnumerable<T> extension methods on the script's variable store
    45 
    46 using System;
    47 using System.Linq;
    48 using System.Collections.Generic;
    49 using HeuristicLab.Common;
    50 using HeuristicLab.Core;
    51 using HeuristicLab.Data;
    52 
    53 public class MyScript : HeuristicLab.Scripting.CSharpScriptBase {
    54   public override void Main() {
    55     // type your code here
    56   }
    57 
    58   // implement further classes and methods
    59 
    60 }";
    61       }
    62     }
     37    protected override string CodeTemplate { get { return ReadCodeTemplate("HeuristicLab.Scripting.CSharpScriptCode.cs"); } }
    6338    #endregion
    6439
  • trunk/sources/HeuristicLab.Scripting/3.3/HeuristicLab.Scripting-3.3.csproj

    r11623 r11721  
    9292  <ItemGroup>
    9393    <Compile Include="CSharpScript.cs" />
     94    <EmbeddedResource Include="CSharpScriptCode.cs" />
    9495    <Compile Include="Variables.cs" />
    9596    <Compile Include="VariableStore.cs" />
  • trunk/sources/HeuristicLab.Scripting/3.3/Script.cs

    r11657 r11721  
    157157      if (handler != null) handler(this, EventArgs.Empty);
    158158    }
     159
     160    #region Helpers
     161    protected virtual string ReadCodeTemplate(string templateName) {
     162      using (var stream = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream(templateName))
     163      using (var reader = new StreamReader(stream)) {
     164        return reader.ReadToEnd();
     165      }
     166    }
     167    #endregion
    159168  }
    160169}
Note: See TracChangeset for help on using the changeset viewer.