Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/25/14 13:55:01 (10 years ago)
Author:
jkarder
Message:

#2136: applied some of the changes suggested in comment:11:ticket:2136

  • change namespaces to HeuristicLab.Scripting.*
  • added extra compile button and registered F6 as a shortcut
  • changed the order of the output window and the error list
  • tabs (output window and error list) are selected automatically
  • thrown exceptions are shown using the PluginInfrastructure
  • removed namespace declaration in the script
  • names in the VariableStore are now conform to C# property names
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.HLScript/3.3/Script.cs

    r10401 r10506  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.CodeDom;
    324using System.CodeDom.Compiler;
     
    1637using Microsoft.CSharp;
    1738
    18 namespace HeuristicLab.HLScript {
    19   [Item("Script", "A HeuristicLab script.")]
     39namespace HeuristicLab.Scripting {
     40  [Item("Script", "An empty C# script.")]
    2041  [Creatable("Scripts")]
    2142  [StorableClass]
     
    2748
    2849using System;
    29 
    30 namespace UserScripts {
    31   public class UserScript : HeuristicLab.HLScript.UserScriptBase {
    32     public override void Main() {
    33       // type your code here
    34     }
    35 
    36     // further classes and methods
    37 
     50using System.Linq;
     51using System.Collections.Generic;
     52using HeuristicLab.Common;
     53using HeuristicLab.Core;
     54using HeuristicLab.Data;
     55
     56public class UserScript : HeuristicLab.Scripting.UserScriptBase {
     57  public override void Main() {
     58    // type your code here
    3859  }
     60
     61  // further classes and methods
     62
    3963}";
    4064    #endregion
     
    126150        GenerateExecutable = false,
    127151        GenerateInMemory = true,
    128         IncludeDebugInformation = false
     152        IncludeDebugInformation = true,
     153        WarningLevel = 4
    129154      };
    130155      parameters.ReferencedAssemblies.AddRange(
     
    212237      if (executeMethod != null) {
    213238        scriptThread = new Thread(() => {
     239          Exception ex = null;
    214240          try {
    215241            OnScriptExecutionStarted();
    216242            executeMethod.Invoke(compiledScript, new[] { VariableStore });
     243          } catch (ThreadAbortException) {
     244            // the execution was cancelled by the user
     245          } catch (TargetInvocationException e) {
     246            ex = e.InnerException;
    217247          } finally {
    218             OnScriptExecutionFinished();
     248            OnScriptExecutionFinished(ex);
    219249          }
    220250        });
     
    250280    }
    251281
    252     public event EventHandler ScriptExecutionFinished;
    253     private void OnScriptExecutionFinished() {
     282    public event EventHandler<EventArgs<Exception>> ScriptExecutionFinished;
     283    private void OnScriptExecutionFinished(Exception e) {
    254284      var handler = ScriptExecutionFinished;
    255       if (handler != null) handler(this, EventArgs.Empty);
     285      if (handler != null) handler(this, new EventArgs<Exception>(e));
    256286    }
    257287
Note: See TracChangeset for help on using the changeset viewer.