Index: trunk/sources/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.Designer.cs	(revision 10731)
+++ trunk/sources/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.Designer.cs	(revision 10731)
@@ -0,0 +1,162 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Windows.Forms;
+
+namespace HeuristicLab.Scripting.Views {
+  partial class CSharpScriptView {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.components = new System.ComponentModel.Container();
+      this.startStopButton = new System.Windows.Forms.Button();
+      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
+      this.variableStoreView = new HeuristicLab.Scripting.Views.VariableStoreView();
+      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
+      this.splitContainer2.Panel1.SuspendLayout();
+      this.splitContainer2.Panel2.SuspendLayout();
+      this.splitContainer2.SuspendLayout();
+      this.SuspendLayout();
+      // 
+      // nameTextBox
+      // 
+      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
+      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
+      this.nameTextBox.Location = new System.Drawing.Point(60, 0);
+      this.nameTextBox.Size = new System.Drawing.Size(750, 20);
+      // 
+      // infoLabel
+      // 
+      this.infoLabel.Location = new System.Drawing.Point(816, 4);
+      // 
+      // startStopButton
+      // 
+      this.startStopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
+      this.startStopButton.Location = new System.Drawing.Point(36, 26);
+      this.startStopButton.Name = "startStopButton";
+      this.startStopButton.Size = new System.Drawing.Size(24, 24);
+      this.startStopButton.TabIndex = 1;
+      this.startStopButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+      this.toolTip.SetToolTip(this.startStopButton, "Run (F5)");
+      this.startStopButton.UseVisualStyleBackColor = true;
+      this.startStopButton.Click += new System.EventHandler(this.StartStopButtonOnClick);
+      // 
+      // splitContainer2
+      // 
+      this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+            | System.Windows.Forms.AnchorStyles.Left)
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.splitContainer2.Location = new System.Drawing.Point(3, 56);
+      this.splitContainer2.Name = "splitContainer2";
+      // 
+      // splitContainer2.Panel1
+      // 
+      this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
+      // 
+      // splitContainer2.Panel2
+      // 
+      this.splitContainer2.Panel2.Controls.Add(this.variableStoreView);
+      this.splitContainer2.Panel2.Controls.Add(this.viewHost);
+      this.splitContainer2.Size = new System.Drawing.Size(829, 543);
+      this.splitContainer2.SplitterDistance = 637;
+      this.splitContainer2.TabIndex = 7;
+      //
+      // splitContainer1
+      //
+      this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+      this.splitContainer1.Dock = DockStyle.Fill;
+      // 
+      // variableStoreView
+      // 
+      this.variableStoreView.Caption = "ItemCollection View";
+      this.variableStoreView.Content = null;
+      this.variableStoreView.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.variableStoreView.Location = new System.Drawing.Point(0, 0);
+      this.variableStoreView.Name = "variableStoreView";
+      this.variableStoreView.ReadOnly = false;
+      this.variableStoreView.Size = new System.Drawing.Size(188, 543);
+      this.variableStoreView.TabIndex = 0;
+      // 
+      // viewHost
+      // 
+      this.viewHost.Caption = "View";
+      this.viewHost.Content = null;
+      this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.viewHost.Enabled = false;
+      this.viewHost.Location = new System.Drawing.Point(0, 0);
+      this.viewHost.Name = "viewHost";
+      this.viewHost.ReadOnly = false;
+      this.viewHost.Size = new System.Drawing.Size(188, 543);
+      this.viewHost.TabIndex = 0;
+      this.viewHost.ViewsLabelVisible = true;
+      this.viewHost.ViewType = null;
+      // 
+      // ScriptView
+      // 
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+      this.Controls.Add(this.splitContainer2);
+      this.Controls.Add(this.startStopButton);
+      this.Name = "ScriptView";
+      this.Size = new System.Drawing.Size(835, 602);
+      this.Controls.SetChildIndex(this.startStopButton, 0);
+      this.Controls.SetChildIndex(this.splitContainer2, 0);
+      this.Controls.SetChildIndex(this.nameLabel, 0);
+      this.Controls.SetChildIndex(this.nameTextBox, 0);
+      this.Controls.SetChildIndex(this.infoLabel, 0);
+      this.splitContainer2.Panel1.ResumeLayout(false);
+      this.splitContainer2.Panel2.ResumeLayout(false);
+      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
+      this.splitContainer2.ResumeLayout(false);
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    protected System.Windows.Forms.Button startStopButton;
+    protected System.Windows.Forms.SplitContainer splitContainer2;
+    protected MainForm.WindowsForms.ViewHost viewHost;
+    protected VariableStoreView variableStoreView;
+  }
+}
Index: trunk/sources/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.cs
===================================================================
--- trunk/sources/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.cs	(revision 10731)
+++ trunk/sources/HeuristicLab.Scripting.Views/3.3/CSharpScriptView.cs	(revision 10731)
@@ -0,0 +1,158 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using HeuristicLab.Common;
+using HeuristicLab.Common.Resources;
+using HeuristicLab.MainForm;
+
+namespace HeuristicLab.Scripting.Views {
+
+  [View("C# Script View")]
+  [Content(typeof(CSharpScript), true)]
+  public partial class CSharpScriptView : ScriptView {
+    protected bool Running { get; set; }
+
+    public new CSharpScript Content {
+      get { return (CSharpScript)base.Content; }
+      set { base.Content = value; }
+    }
+
+    public CSharpScriptView() {
+      InitializeComponent();
+    }
+
+    protected override void RegisterContentEvents() {
+      base.RegisterContentEvents();
+      Content.ScriptExecutionStarted += ContentOnScriptExecutionStarted;
+      Content.ScriptExecutionFinished += ContentOnScriptExecutionFinished;
+      Content.ConsoleOutputChanged += ContentOnConsoleOutputChanged;
+    }
+
+    protected override void DeregisterContentEvents() {
+      Content.ScriptExecutionStarted -= ContentOnScriptExecutionStarted;
+      Content.ScriptExecutionFinished -= ContentOnScriptExecutionFinished;
+      Content.ConsoleOutputChanged -= ContentOnConsoleOutputChanged;
+      base.DeregisterContentEvents();
+    }
+
+    #region Content event handlers
+    protected virtual void ContentOnScriptExecutionStarted(object sender, EventArgs e) {
+      if (InvokeRequired)
+        Invoke((Action<object, EventArgs>)ContentOnScriptExecutionStarted, sender, e);
+      else {
+        Locked = true;
+        ReadOnly = true;
+        startStopButton.Image = VSImageLibrary.Stop;
+        toolTip.SetToolTip(startStopButton, "Stop (Shift+F5)");
+        infoTabControl.SelectedTab = outputTabPage;
+      }
+    }
+    protected virtual void ContentOnScriptExecutionFinished(object sender, EventArgs<Exception> e) {
+      if (InvokeRequired)
+        Invoke((Action<object, EventArgs<Exception>>)ContentOnScriptExecutionFinished, sender, e);
+      else {
+        Locked = false;
+        ReadOnly = false;
+        startStopButton.Image = VSImageLibrary.Play;
+        toolTip.SetToolTip(startStopButton, "Run (F5)");
+        Running = false;
+        var ex = e.Value;
+        if (ex != null)
+          PluginInfrastructure.ErrorHandling.ShowErrorDialog(this, ex);
+      }
+    }
+    protected virtual void ContentOnConsoleOutputChanged(object sender, EventArgs<string> e) {
+      if (InvokeRequired)
+        Invoke((Action<object, EventArgs<string>>)ContentOnConsoleOutputChanged, sender, e);
+      else {
+        outputTextBox.AppendText(e.Value);
+      }
+    }
+    #endregion
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content == null) {
+        codeEditor.UserCode = string.Empty;
+        variableStoreView.Content = null;
+      } else {
+        codeEditor.UserCode = Content.Code;
+        foreach (var asm in Content.GetAssemblies())
+          codeEditor.AddAssembly(asm);
+        variableStoreView.Content = Content.VariableStore;
+        if (Content.CompileErrors == null) {
+          compilationLabel.ForeColor = SystemColors.ControlDarkDark;
+          compilationLabel.Text = "Not compiled";
+        } else if (Content.CompileErrors.HasErrors) {
+          compilationLabel.ForeColor = Color.DarkRed;
+          compilationLabel.Text = "Compilation failed";
+        } else {
+          compilationLabel.ForeColor = Color.DarkGreen;
+          compilationLabel.Text = "Compilation successful";
+        }
+      }
+    }
+
+    protected override void SetEnabledStateOfControls() {
+      base.SetEnabledStateOfControls();
+      compileButton.Enabled = Content != null && !Locked && !ReadOnly;
+      startStopButton.Enabled = Content != null && (!Locked || Running);
+      codeEditor.Enabled = Content != null && !Locked && !ReadOnly;
+    }
+
+    protected virtual void StartStopButtonOnClick(object sender, EventArgs e) {
+      if (Running) {
+        Content.Kill();
+      } else
+        if (Compile()) {
+          outputTextBox.Clear();
+          Content.Execute();
+          Running = true;
+        }
+    }
+
+    #region global HotKeys
+    protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
+      switch (keyData) {
+        case Keys.F5:
+          if (Content != null && !Locked && !Running) {
+            if (Compile()) {
+              outputTextBox.Clear();
+              Content.Execute();
+              Running = true;
+            }
+          }
+          return true;
+        case Keys.F5 | Keys.Shift:
+          if (Running) Content.Kill();
+          return true;
+        case Keys.F6:
+          if (!Running) Compile();
+          return true;
+      }
+      return base.ProcessCmdKey(ref msg, keyData); ;
+    }
+    #endregion
+  }
+}
Index: trunk/sources/HeuristicLab.Scripting.Views/3.3/HeuristicLab.Scripting.Views-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Scripting.Views/3.3/HeuristicLab.Scripting.Views-3.3.csproj	(revision 10727)
+++ trunk/sources/HeuristicLab.Scripting.Views/3.3/HeuristicLab.Scripting.Views-3.3.csproj	(revision 10731)
@@ -86,4 +86,10 @@
   <ItemGroup>
     <None Include="Plugin.cs.frame" />
+    <Compile Include="CSharpScriptView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="CSharpScriptView.Designer.cs">
+      <DependentUpon>CSharpScriptView.cs</DependentUpon>
+    </Compile>
     <Compile Include="ScriptView.cs">
       <SubType>UserControl</SubType>
Index: trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.Designer.cs	(revision 10727)
+++ trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.Designer.cs	(revision 10731)
@@ -46,6 +46,10 @@
     private void InitializeComponent() {
       this.components = new System.ComponentModel.Container();
+      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScriptView));
       this.compilationLabel = new System.Windows.Forms.Label();
-      this.startStopButton = new System.Windows.Forms.Button();
+      this.imageList = new System.Windows.Forms.ImageList(this.components);
+      this.compileButton = new System.Windows.Forms.Button();
+      this.infoTabControl = new System.Windows.Forms.TabControl();
+      this.errorListTabPage = new System.Windows.Forms.TabPage();
       this.errorListView = new System.Windows.Forms.ListView();
       this.iconColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@@ -55,27 +59,16 @@
       this.columnColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
       this.descriptionColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
-      this.imageList = new System.Windows.Forms.ImageList(this.components);
+      this.outputTabPage = new System.Windows.Forms.TabPage();
+      this.outputTextBox = new System.Windows.Forms.TextBox();
       this.codeEditor = new HeuristicLab.CodeEditor.CodeEditor();
       this.splitContainer1 = new System.Windows.Forms.SplitContainer();
-      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
-      this.infoTabControl = new System.Windows.Forms.TabControl();
-      this.outputTabPage = new System.Windows.Forms.TabPage();
-      this.outputTextBox = new System.Windows.Forms.TextBox();
-      this.errorListTabPage = new System.Windows.Forms.TabPage();
-      this.variableStoreView = new HeuristicLab.Scripting.Views.VariableStoreView();
-      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
-      this.compileButton = new System.Windows.Forms.Button();
       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+      this.infoTabControl.SuspendLayout();
+      this.errorListTabPage.SuspendLayout();
+      this.outputTabPage.SuspendLayout();
       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
       this.splitContainer1.Panel1.SuspendLayout();
       this.splitContainer1.Panel2.SuspendLayout();
       this.splitContainer1.SuspendLayout();
-      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
-      this.splitContainer2.Panel1.SuspendLayout();
-      this.splitContainer2.Panel2.SuspendLayout();
-      this.splitContainer2.SuspendLayout();
-      this.infoTabControl.SuspendLayout();
-      this.outputTabPage.SuspendLayout();
-      this.errorListTabPage.SuspendLayout();
       this.SuspendLayout();
       // 
@@ -84,6 +77,6 @@
       this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
       this.errorProvider.SetIconPadding(this.nameTextBox, 2);
-      this.nameTextBox.Location = new System.Drawing.Point(60, 0);
-      this.nameTextBox.Size = new System.Drawing.Size(750, 20);
+      this.nameTextBox.Location = new System.Drawing.Point(69, 0);
+      this.nameTextBox.Size = new System.Drawing.Size(741, 20);
       // 
       // infoLabel
@@ -101,15 +94,43 @@
       this.compilationLabel.Text = "Not compiled";
       // 
-      // startStopButton
-      // 
-      this.startStopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
-      this.startStopButton.Location = new System.Drawing.Point(36, 26);
-      this.startStopButton.Name = "startStopButton";
-      this.startStopButton.Size = new System.Drawing.Size(24, 24);
-      this.startStopButton.TabIndex = 1;
-      this.startStopButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
-      this.toolTip.SetToolTip(this.startStopButton, "Run (F5)");
-      this.startStopButton.UseVisualStyleBackColor = true;
-      this.startStopButton.Click += new System.EventHandler(this.startStopButton_Click);
+      // imageList
+      // 
+      this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
+      this.imageList.ImageSize = new System.Drawing.Size(16, 16);
+      this.imageList.TransparentColor = System.Drawing.Color.Transparent;
+      // 
+      // compileButton
+      // 
+      this.compileButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Script;
+      this.compileButton.Location = new System.Drawing.Point(6, 26);
+      this.compileButton.Name = "compileButton";
+      this.compileButton.Size = new System.Drawing.Size(24, 24);
+      this.compileButton.TabIndex = 8;
+      this.compileButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+      this.toolTip.SetToolTip(this.compileButton, "Compile (F6)");
+      this.compileButton.UseVisualStyleBackColor = true;
+      this.compileButton.Click += new System.EventHandler(this.CompileButtonOnClick);
+      // 
+      // infoTabControl
+      // 
+      this.infoTabControl.Controls.Add(this.outputTabPage);
+      this.infoTabControl.Controls.Add(this.errorListTabPage);
+      this.infoTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.infoTabControl.Location = new System.Drawing.Point(0, 0);
+      this.infoTabControl.Name = "infoTabControl";
+      this.infoTabControl.SelectedIndex = 0;
+      this.infoTabControl.Size = new System.Drawing.Size(832, 112);
+      this.infoTabControl.TabIndex = 1;
+      // 
+      // errorListTabPage
+      // 
+      this.errorListTabPage.Controls.Add(this.errorListView);
+      this.errorListTabPage.Location = new System.Drawing.Point(4, 22);
+      this.errorListTabPage.Name = "errorListTabPage";
+      this.errorListTabPage.Padding = new System.Windows.Forms.Padding(3);
+      this.errorListTabPage.Size = new System.Drawing.Size(824, 86);
+      this.errorListTabPage.TabIndex = 0;
+      this.errorListTabPage.Text = "Error List";
+      this.errorListTabPage.UseVisualStyleBackColor = true;
       // 
       // errorListView
@@ -128,5 +149,5 @@
       this.errorListView.Location = new System.Drawing.Point(3, 3);
       this.errorListView.Name = "errorListView";
-      this.errorListView.Size = new System.Drawing.Size(623, 79);
+      this.errorListView.Size = new System.Drawing.Size(818, 80);
       this.errorListView.SmallImageList = this.imageList;
       this.errorListView.TabIndex = 0;
@@ -158,71 +179,4 @@
       this.descriptionColumnHeader.Text = "Description";
       // 
-      // imageList
-      // 
-      this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
-      this.imageList.ImageSize = new System.Drawing.Size(16, 16);
-      this.imageList.TransparentColor = System.Drawing.Color.Transparent;
-      // 
-      // codeEditor
-      // 
-      this.codeEditor.Dock = System.Windows.Forms.DockStyle.Fill;
-      this.codeEditor.Location = new System.Drawing.Point(0, 0);
-      this.codeEditor.Name = "codeEditor";
-      this.codeEditor.Prefix = "";
-      this.codeEditor.Size = new System.Drawing.Size(637, 428);
-      this.codeEditor.Suffix = "";
-      this.codeEditor.TabIndex = 0;
-      this.codeEditor.UserCode = "";
-      this.codeEditor.TextEditorTextChanged += new System.EventHandler(this.codeEditor_TextEditorTextChanged);
-      // 
-      // splitContainer1
-      // 
-      this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-            | System.Windows.Forms.AnchorStyles.Left)
-            | System.Windows.Forms.AnchorStyles.Right)));
-      this.splitContainer1.Location = new System.Drawing.Point(3, 56);
-      this.splitContainer1.Name = "splitContainer1";
-      // 
-      // splitContainer1.Panel1
-      // 
-      this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
-      // 
-      // splitContainer1.Panel2
-      // 
-      this.splitContainer1.Panel2.Controls.Add(this.variableStoreView);
-      this.splitContainer1.Panel2.Controls.Add(this.viewHost);
-      this.splitContainer1.Size = new System.Drawing.Size(829, 543);
-      this.splitContainer1.SplitterDistance = 637;
-      this.splitContainer1.TabIndex = 7;
-      // 
-      // splitContainer2
-      // 
-      this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
-      this.splitContainer2.Location = new System.Drawing.Point(0, 0);
-      this.splitContainer2.Name = "splitContainer2";
-      this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
-      // 
-      // splitContainer2.Panel1
-      // 
-      this.splitContainer2.Panel1.Controls.Add(this.codeEditor);
-      // 
-      // splitContainer2.Panel2
-      // 
-      this.splitContainer2.Panel2.Controls.Add(this.infoTabControl);
-      this.splitContainer2.Size = new System.Drawing.Size(637, 543);
-      this.splitContainer2.SplitterDistance = 428;
-      this.splitContainer2.TabIndex = 5;
-      // 
-      // infoTabControl
-      // 
-      this.infoTabControl.Controls.Add(this.outputTabPage);
-      this.infoTabControl.Controls.Add(this.errorListTabPage);
-      this.infoTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
-      this.infoTabControl.Location = new System.Drawing.Point(0, 0);
-      this.infoTabControl.Name = "infoTabControl";
-      this.infoTabControl.SelectedIndex = 0;
-      this.infoTabControl.Size = new System.Drawing.Size(637, 111);
-      this.infoTabControl.TabIndex = 1;
-      // 
       // outputTabPage
       // 
@@ -231,5 +185,5 @@
       this.outputTabPage.Name = "outputTabPage";
       this.outputTabPage.Padding = new System.Windows.Forms.Padding(3);
-      this.outputTabPage.Size = new System.Drawing.Size(629, 85);
+      this.outputTabPage.Size = new System.Drawing.Size(824, 86);
       this.outputTabPage.TabIndex = 1;
       this.outputTabPage.Text = "Output";
@@ -245,85 +199,60 @@
       this.outputTextBox.ReadOnly = true;
       this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
-      this.outputTextBox.Size = new System.Drawing.Size(623, 79);
+      this.outputTextBox.Size = new System.Drawing.Size(818, 80);
       this.outputTextBox.TabIndex = 0;
       this.outputTextBox.WordWrap = false;
       // 
-      // errorListTabPage
-      // 
-      this.errorListTabPage.Controls.Add(this.errorListView);
-      this.errorListTabPage.Location = new System.Drawing.Point(4, 22);
-      this.errorListTabPage.Name = "errorListTabPage";
-      this.errorListTabPage.Padding = new System.Windows.Forms.Padding(3);
-      this.errorListTabPage.Size = new System.Drawing.Size(629, 85);
-      this.errorListTabPage.TabIndex = 0;
-      this.errorListTabPage.Text = "Error List";
-      this.errorListTabPage.UseVisualStyleBackColor = true;
-      // 
-      // variableStoreView
-      // 
-      this.variableStoreView.Caption = "ItemCollection View";
-      this.variableStoreView.Content = null;
-      this.variableStoreView.Dock = System.Windows.Forms.DockStyle.Fill;
-      this.variableStoreView.Location = new System.Drawing.Point(0, 0);
-      this.variableStoreView.Name = "variableStoreView";
-      this.variableStoreView.ReadOnly = false;
-      this.variableStoreView.Size = new System.Drawing.Size(188, 543);
-      this.variableStoreView.TabIndex = 0;
-      // 
-      // viewHost
-      // 
-      this.viewHost.Caption = "View";
-      this.viewHost.Content = null;
-      this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
-      this.viewHost.Enabled = false;
-      this.viewHost.Location = new System.Drawing.Point(0, 0);
-      this.viewHost.Name = "viewHost";
-      this.viewHost.ReadOnly = false;
-      this.viewHost.Size = new System.Drawing.Size(188, 543);
-      this.viewHost.TabIndex = 0;
-      this.viewHost.ViewsLabelVisible = true;
-      this.viewHost.ViewType = null;
-      // 
-      // compileButton
-      // 
-      this.compileButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Script;
-      this.compileButton.Location = new System.Drawing.Point(6, 26);
-      this.compileButton.Name = "compileButton";
-      this.compileButton.Size = new System.Drawing.Size(24, 24);
-      this.compileButton.TabIndex = 8;
-      this.compileButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
-      this.toolTip.SetToolTip(this.compileButton, "Compile (F6)");
-      this.compileButton.UseVisualStyleBackColor = true;
-      this.compileButton.Click += new System.EventHandler(this.compileButton_Click);
+      // codeEditor
+      // 
+      this.codeEditor.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.codeEditor.Location = new System.Drawing.Point(0, 0);
+      this.codeEditor.Name = "codeEditor";
+      this.codeEditor.Prefix = "";
+      this.codeEditor.Size = new System.Drawing.Size(832, 430);
+      this.codeEditor.Suffix = "";
+      this.codeEditor.TabIndex = 0;
+      this.codeEditor.UserCode = "";
+      this.codeEditor.TextEditorTextChanged += new System.EventHandler(this.CodeEditorOnTextEditorTextChanged);
+      // 
+      // splitContainer1
+      // 
+      this.splitContainer1.Location = new System.Drawing.Point(0, 56);
+      this.splitContainer1.Name = "splitContainer1";
+      this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
+      // 
+      // splitContainer1.Panel1
+      // 
+      this.splitContainer1.Panel1.Controls.Add(this.codeEditor);
+      // 
+      // splitContainer1.Panel2
+      // 
+      this.splitContainer1.Panel2.Controls.Add(this.infoTabControl);
+      this.splitContainer1.Size = new System.Drawing.Size(832, 546);
+      this.splitContainer1.SplitterDistance = 430;
+      this.splitContainer1.TabIndex = 9;
       // 
       // ScriptView
       // 
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+      this.Controls.Add(this.splitContainer1);
       this.Controls.Add(this.compileButton);
-      this.Controls.Add(this.splitContainer1);
-      this.Controls.Add(this.startStopButton);
       this.Controls.Add(this.compilationLabel);
       this.Name = "ScriptView";
       this.Size = new System.Drawing.Size(835, 602);
       this.Controls.SetChildIndex(this.compilationLabel, 0);
-      this.Controls.SetChildIndex(this.startStopButton, 0);
+      this.Controls.SetChildIndex(this.compileButton, 0);
       this.Controls.SetChildIndex(this.splitContainer1, 0);
       this.Controls.SetChildIndex(this.nameLabel, 0);
       this.Controls.SetChildIndex(this.nameTextBox, 0);
       this.Controls.SetChildIndex(this.infoLabel, 0);
-      this.Controls.SetChildIndex(this.compileButton, 0);
       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+      this.infoTabControl.ResumeLayout(false);
+      this.errorListTabPage.ResumeLayout(false);
+      this.outputTabPage.ResumeLayout(false);
+      this.outputTabPage.PerformLayout();
       this.splitContainer1.Panel1.ResumeLayout(false);
       this.splitContainer1.Panel2.ResumeLayout(false);
       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
       this.splitContainer1.ResumeLayout(false);
-      this.splitContainer2.Panel1.ResumeLayout(false);
-      this.splitContainer2.Panel2.ResumeLayout(false);
-      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
-      this.splitContainer2.ResumeLayout(false);
-      this.infoTabControl.ResumeLayout(false);
-      this.outputTabPage.ResumeLayout(false);
-      this.outputTabPage.PerformLayout();
-      this.errorListTabPage.ResumeLayout(false);
       this.ResumeLayout(false);
       this.PerformLayout();
@@ -333,24 +262,20 @@
     #endregion
 
-    private System.Windows.Forms.Label compilationLabel;
-    private System.Windows.Forms.Button startStopButton;
-    private System.Windows.Forms.ListView errorListView;
-    private System.Windows.Forms.ColumnHeader descriptionColumnHeader;
-    private System.Windows.Forms.ColumnHeader lineColumnHeader;
-    private System.Windows.Forms.ColumnHeader columnColumnHeader;
-    private CodeEditor.CodeEditor codeEditor;
-    private System.Windows.Forms.SplitContainer splitContainer1;
-    private System.Windows.Forms.SplitContainer splitContainer2;
-    private MainForm.WindowsForms.ViewHost viewHost;
-    private VariableStoreView variableStoreView;
-    private System.Windows.Forms.ColumnHeader errorNumberColumnHeader;
-    private System.Windows.Forms.ColumnHeader categoryColumnHeader;
-    private System.Windows.Forms.TabControl infoTabControl;
-    private System.Windows.Forms.TabPage errorListTabPage;
-    private System.Windows.Forms.TabPage outputTabPage;
-    private System.Windows.Forms.TextBox outputTextBox;
-    private System.Windows.Forms.Button compileButton;
-    private System.Windows.Forms.ColumnHeader iconColumnHeader;
-    private System.Windows.Forms.ImageList imageList;
+    protected System.Windows.Forms.Label compilationLabel;
+    protected System.Windows.Forms.Button compileButton;
+    protected System.Windows.Forms.ImageList imageList;
+    protected System.Windows.Forms.TabControl infoTabControl;
+    protected System.Windows.Forms.TabPage outputTabPage;
+    protected System.Windows.Forms.TextBox outputTextBox;
+    protected System.Windows.Forms.TabPage errorListTabPage;
+    protected System.Windows.Forms.ListView errorListView;
+    protected System.Windows.Forms.ColumnHeader iconColumnHeader;
+    protected System.Windows.Forms.ColumnHeader categoryColumnHeader;
+    protected System.Windows.Forms.ColumnHeader errorNumberColumnHeader;
+    protected System.Windows.Forms.ColumnHeader lineColumnHeader;
+    protected System.Windows.Forms.ColumnHeader columnColumnHeader;
+    protected System.Windows.Forms.ColumnHeader descriptionColumnHeader;
+    protected CodeEditor.CodeEditor codeEditor;
+    protected System.Windows.Forms.SplitContainer splitContainer1;
   }
 }
Index: trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.cs
===================================================================
--- trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.cs	(revision 10727)
+++ trunk/sources/HeuristicLab.Scripting.Views/3.3/ScriptView.cs	(revision 10731)
@@ -26,5 +26,4 @@
 using System.Linq;
 using System.Windows.Forms;
-using HeuristicLab.Common;
 using HeuristicLab.Common.Resources;
 using HeuristicLab.Core.Views;
@@ -36,9 +35,7 @@
   [Content(typeof(Script), true)]
   public partial class ScriptView : NamedItemView {
-    private bool running;
-
     public new Script Content {
       get { return (Script)base.Content; }
-      set { base.Content = (Script)value; }
+      set { base.Content = value; }
     }
 
@@ -46,60 +43,19 @@
       InitializeComponent();
       errorListView.SmallImageList.Images.AddRange(new Image[] { VSImageLibrary.Warning, VSImageLibrary.Error });
-      AdjustErrorListViewColumnSizes();
     }
 
     protected override void RegisterContentEvents() {
       base.RegisterContentEvents();
-      Content.CodeChanged += Content_CodeChanged;
-      Content.ScriptExecutionStarted += Content_ScriptExecutionStarted;
-      Content.ScriptExecutionFinished += Content_ScriptExecutionFinished;
-      Content.ConsoleOutputChanged += Content_ConsoleOutputChanged;
+      Content.CodeChanged += ContentOnCodeChanged;
     }
 
     protected override void DeregisterContentEvents() {
-      Content.CodeChanged -= Content_CodeChanged;
-      Content.ScriptExecutionStarted -= Content_ScriptExecutionStarted;
-      Content.ScriptExecutionFinished -= Content_ScriptExecutionFinished;
-      Content.ConsoleOutputChanged -= Content_ConsoleOutputChanged;
+      Content.CodeChanged -= ContentOnCodeChanged;
       base.DeregisterContentEvents();
     }
 
-    #region Content event handlers
-    private void Content_CodeChanged(object sender, EventArgs e) {
+    protected virtual void ContentOnCodeChanged(object sender, EventArgs e) {
       codeEditor.UserCode = Content.Code;
     }
-    private void Content_ScriptExecutionStarted(object sender, EventArgs e) {
-      if (InvokeRequired)
-        Invoke((Action<object, EventArgs>)Content_ScriptExecutionStarted, sender, e);
-      else {
-        Locked = true;
-        ReadOnly = true;
-        startStopButton.Image = VSImageLibrary.Stop;
-        toolTip.SetToolTip(startStopButton, "Stop (Shift+F5)");
-        infoTabControl.SelectedTab = outputTabPage;
-      }
-    }
-    private void Content_ScriptExecutionFinished(object sender, EventArgs<Exception> e) {
-      if (InvokeRequired)
-        Invoke((Action<object, EventArgs<Exception>>)Content_ScriptExecutionFinished, sender, e);
-      else {
-        Locked = false;
-        ReadOnly = false;
-        startStopButton.Image = VSImageLibrary.Play;
-        toolTip.SetToolTip(startStopButton, "Run (F5)");
-        running = false;
-        var ex = e.Value;
-        if (ex != null)
-          PluginInfrastructure.ErrorHandling.ShowErrorDialog(this, ex);
-      }
-    }
-    private void Content_ConsoleOutputChanged(object sender, EventArgs<string> e) {
-      if (InvokeRequired)
-        Invoke((Action<object, EventArgs<string>>)Content_ConsoleOutputChanged, sender, e);
-      else {
-        outputTextBox.AppendText(e.Value);
-      }
-    }
-    #endregion
 
     protected override void OnContentChanged() {
@@ -107,10 +63,8 @@
       if (Content == null) {
         codeEditor.UserCode = string.Empty;
-        variableStoreView.Content = null;
       } else {
         codeEditor.UserCode = Content.Code;
         foreach (var asm in Content.GetAssemblies())
           codeEditor.AddAssembly(asm);
-        variableStoreView.Content = Content.VariableStore;
         if (Content.CompileErrors == null) {
           compilationLabel.ForeColor = SystemColors.ControlDarkDark;
@@ -129,54 +83,25 @@
       base.SetEnabledStateOfControls();
       compileButton.Enabled = Content != null && !Locked && !ReadOnly;
-      startStopButton.Enabled = Content != null && (!Locked || running);
       codeEditor.Enabled = Content != null && !Locked && !ReadOnly;
     }
 
-    #region Child Control event handlers
-    private void compileButton_Click(object sender, EventArgs e) {
+    protected virtual void CompileButtonOnClick(object sender, EventArgs e) {
       Compile();
     }
 
-    private void startStopButton_Click(object sender, EventArgs e) {
-      if (running) {
-        Content.Kill();
-      } else
-        if (Compile()) {
-          outputTextBox.Clear();
-          Content.Execute();
-          running = true;
-        }
-    }
-
-    private void codeEditor_TextEditorTextChanged(object sender, EventArgs e) {
+    protected virtual void CodeEditorOnTextEditorTextChanged(object sender, EventArgs e) {
       Content.Code = codeEditor.UserCode;
     }
-    #endregion
-
-    #region global HotKeys
     protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
       switch (keyData) {
-        case Keys.F5:
-          if (Content != null && !Locked && !running) {
-            if (Compile()) {
-              outputTextBox.Clear();
-              Content.Execute();
-              running = true;
-            }
-          }
-          break;
-        case Keys.F5 | Keys.Shift:
-          if (running) Content.Kill();
-          break;
         case Keys.F6:
-          if (!running) Compile();
-          break;
+          if (Content != null && !Locked)
+            Compile();
+          return true;
       }
       return base.ProcessCmdKey(ref msg, keyData);
     }
-    #endregion
 
-    #region Auxiliary functions
-    private bool Compile() {
+    public virtual bool Compile() {
       ReadOnly = true;
       Locked = true;
@@ -199,7 +124,6 @@
       }
     }
-    #endregion
 
-    private void ShowCompilationResults() {
+    protected virtual void ShowCompilationResults() {
       if (Content.CompileErrors.Count == 0) return;
       var msgs = Content.CompileErrors.OfType<CompilerError>()
@@ -222,5 +146,5 @@
     }
 
-    private void AdjustErrorListViewColumnSizes() {
+    protected virtual void AdjustErrorListViewColumnSizes() {
       foreach (ColumnHeader ch in errorListView.Columns)
         // adjusts the column width to the width of the column
Index: trunk/sources/HeuristicLab.Scripting/3.3/CSharpScript.cs
===================================================================
--- trunk/sources/HeuristicLab.Scripting/3.3/CSharpScript.cs	(revision 10731)
+++ trunk/sources/HeuristicLab.Scripting/3.3/CSharpScript.cs	(revision 10731)
@@ -0,0 +1,167 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Threading;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Scripting {
+  [Item("C# Script", "An empty C# script.")]
+  [Creatable("Scripts")]
+  [StorableClass]
+  public class CSharpScript : Script, IStorableContent {
+    #region Constants
+    protected const string ExecuteMethodName = "Execute";
+    protected override string CodeTemplate {
+      get {
+        return @"// use 'vars' to access variables in the script's variable store (e.g. vars.x = 5)
+// use 'vars.Contains(string)' to check if a variable exists
+// use 'vars.Clear()' to remove all variables
+// use 'foreach (KeyValuePair<string, object> v in vars) { ... }' to iterate over all variables
+
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+
+public class MyScript : HeuristicLab.Scripting.CSharpScriptBase {
+  public override void Main() {
+    // type your code here
+  }
+
+  // implement further classes and methods
+
+}";
+      }
+    }
+    #endregion
+
+    #region Fields & Properties
+    protected CSharpScriptBase CompiledScript;
+
+    public string Filename { get; set; }
+
+    [Storable]
+    private VariableStore variableStore;
+    public VariableStore VariableStore {
+      get { return variableStore; }
+    }
+    #endregion
+
+    #region Construction & Initialization
+    [StorableConstructor]
+    protected CSharpScript(bool deserializing) : base(deserializing) { }
+    protected CSharpScript(CSharpScript original, Cloner cloner)
+      : base(original, cloner) {
+      variableStore = new VariableStore();
+    }
+    public CSharpScript() {
+      variableStore = new VariableStore();
+    }
+    public CSharpScript(string code)
+      : base(code) {
+      variableStore = new VariableStore();
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new CSharpScript(this, cloner);
+    }
+    #endregion
+
+    protected virtual void RegisterScriptEvents() {
+      if (CompiledScript != null)
+        CompiledScript.ConsoleOutputChanged += CompiledScriptOnConsoleOutputChanged;
+    }
+
+    protected virtual void DeregisterScriptEvents() {
+      if (CompiledScript != null)
+        CompiledScript.ConsoleOutputChanged -= CompiledScriptOnConsoleOutputChanged;
+    }
+
+    #region Compilation
+
+    public override Assembly Compile() {
+      CompiledScript = null;
+      var assembly = base.Compile();
+      var types = assembly.GetTypes();
+      DeregisterScriptEvents();
+      CompiledScript = (CSharpScriptBase)Activator.CreateInstance(types.First(x => typeof(CSharpScriptBase).IsAssignableFrom(x)));
+      RegisterScriptEvents();
+      return assembly;
+    }
+    #endregion
+
+    protected Thread ScriptThread;
+    public virtual void Execute() {
+      if (CompiledScript == null) return;
+      var executeMethod = typeof(CSharpScriptBase).GetMethod(ExecuteMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
+      if (executeMethod != null) {
+        ScriptThread = new Thread(() => {
+          Exception ex = null;
+          try {
+            OnScriptExecutionStarted();
+            executeMethod.Invoke(CompiledScript, new object[] { VariableStore });
+          } catch (ThreadAbortException) {
+            // the execution was cancelled by the user
+          } catch (TargetInvocationException e) {
+            ex = e.InnerException;
+          } finally {
+            OnScriptExecutionFinished(ex);
+          }
+        });
+        ScriptThread.Start();
+      }
+    }
+
+    public virtual void Kill() {
+      if (ScriptThread.IsAlive)
+        ScriptThread.Abort();
+    }
+
+    protected virtual void CompiledScriptOnConsoleOutputChanged(object sender, EventArgs<string> e) {
+      OnConsoleOutputChanged(e.Value);
+    }
+
+    public event EventHandler ScriptExecutionStarted;
+    protected virtual void OnScriptExecutionStarted() {
+      var handler = ScriptExecutionStarted;
+      if (handler != null) handler(this, EventArgs.Empty);
+    }
+
+    public event EventHandler<EventArgs<Exception>> ScriptExecutionFinished;
+    protected virtual void OnScriptExecutionFinished(Exception e) {
+      var handler = ScriptExecutionFinished;
+      if (handler != null) handler(this, new EventArgs<Exception>(e));
+    }
+
+    public event EventHandler<EventArgs<string>> ConsoleOutputChanged;
+    protected virtual void OnConsoleOutputChanged(string args) {
+      var handler = ConsoleOutputChanged;
+      if (handler != null) handler(this, new EventArgs<string>(args));
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Scripting/3.3/CSharpScriptBase.cs
===================================================================
--- trunk/sources/HeuristicLab.Scripting/3.3/CSharpScriptBase.cs	(revision 10731)
+++ trunk/sources/HeuristicLab.Scripting/3.3/CSharpScriptBase.cs	(revision 10731)
@@ -0,0 +1,108 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.IO;
+using System.Text;
+using HeuristicLab.Common;
+
+namespace HeuristicLab.Scripting {
+  public abstract class CSharpScriptBase {
+    protected dynamic vars;
+
+    private readonly EventWriter console;
+    protected EventWriter Console {
+      get { return console; }
+    }
+
+    protected CSharpScriptBase() {
+      console = new EventWriter(this);
+    }
+
+    public abstract void Main();
+
+    internal void Execute(VariableStore variableStore) {
+      vars = new Variables(variableStore);
+      Main();
+    }
+
+    protected internal event EventHandler<EventArgs<string>> ConsoleOutputChanged;
+    private void OnConsoleOutputChanged(string args) {
+      var handler = ConsoleOutputChanged;
+      if (handler != null) handler(null, new EventArgs<string>(args));
+    }
+
+    protected class EventWriter : TextWriter {
+      private readonly CSharpScriptBase usb;
+
+      public EventWriter(CSharpScriptBase usb) {
+        this.usb = usb;
+      }
+
+      public override Encoding Encoding {
+        get { return Encoding.UTF8; }
+      }
+
+      #region Write/WriteLine Overrides
+      #region Write
+      public override void Write(bool value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(char value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(char[] buffer) { usb.OnConsoleOutputChanged(new string(buffer)); }
+      public override void Write(char[] buffer, int index, int count) { usb.OnConsoleOutputChanged(new string(buffer, index, count)); }
+      public override void Write(decimal value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(double value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(float value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(int value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(long value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(object value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(string value) { usb.OnConsoleOutputChanged(value); }
+      public override void Write(string format, object arg0) { usb.OnConsoleOutputChanged(string.Format(format, arg0)); }
+      public override void Write(string format, object arg0, object arg1) { usb.OnConsoleOutputChanged(string.Format(format, arg0, arg0)); }
+      public override void Write(string format, object arg0, object arg1, object arg2) { usb.OnConsoleOutputChanged(string.Format(format, arg0, arg1, arg2)); }
+      public override void Write(string format, params object[] arg) { usb.OnConsoleOutputChanged(string.Format(format, arg)); }
+      public override void Write(uint value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      public override void Write(ulong value) { usb.OnConsoleOutputChanged(value.ToString()); }
+      #endregion
+
+      #region WriteLine
+      public override void WriteLine() { usb.OnConsoleOutputChanged(Environment.NewLine); }
+      public override void WriteLine(bool value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(char value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(char[] buffer) { usb.OnConsoleOutputChanged(new string(buffer) + Environment.NewLine); }
+      public override void WriteLine(char[] buffer, int index, int count) { usb.OnConsoleOutputChanged(new string(buffer, index, count) + Environment.NewLine); }
+      public override void WriteLine(decimal value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(double value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(float value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(int value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(long value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(object value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(string value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(string format, object arg0) { usb.OnConsoleOutputChanged(string.Format(format, arg0) + Environment.NewLine); }
+      public override void WriteLine(string format, object arg0, object arg1) { usb.OnConsoleOutputChanged(string.Format(format, arg0, arg1) + Environment.NewLine); }
+      public override void WriteLine(string format, object arg0, object arg1, object arg2) { usb.OnConsoleOutputChanged(string.Format(format, arg0, arg1, arg2) + Environment.NewLine); }
+      public override void WriteLine(string format, params object[] arg) { usb.OnConsoleOutputChanged(string.Format(format, arg) + Environment.NewLine); }
+      public override void WriteLine(uint value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      public override void WriteLine(ulong value) { usb.OnConsoleOutputChanged(value + Environment.NewLine); }
+      #endregion
+      #endregion
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Scripting/3.3/HeuristicLab.Scripting-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Scripting/3.3/HeuristicLab.Scripting-3.3.csproj	(revision 10727)
+++ trunk/sources/HeuristicLab.Scripting/3.3/HeuristicLab.Scripting-3.3.csproj	(revision 10731)
@@ -85,9 +85,10 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="CSharpScript.cs" />
     <Compile Include="Variables.cs" />
     <Compile Include="VariableStore.cs" />
     <None Include="Plugin.cs.frame" />
     <Compile Include="Script.cs" />
-    <Compile Include="UserScriptBase.cs" />
+    <Compile Include="CSharpScriptBase.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
Index: trunk/sources/HeuristicLab.Scripting/3.3/Script.cs
===================================================================
--- trunk/sources/HeuristicLab.Scripting/3.3/Script.cs	(revision 10727)
+++ trunk/sources/HeuristicLab.Scripting/3.3/Script.cs	(revision 10731)
@@ -29,6 +29,4 @@
 using System.Reflection;
 using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading;
 using HeuristicLab.Common;
 using HeuristicLab.Common.Resources;
@@ -38,38 +36,11 @@
 
 namespace HeuristicLab.Scripting {
-  [Item("C# Script", "An empty C# script.")]
-  [Creatable("Scripts")]
   [StorableClass]
-  public sealed class Script : NamedItem, IStorableContent {
-    #region Constants
-    private const string ExecuteMethodName = "Execute";
-    private const string CodeTemplate =
-@"// use 'vars' to access variables in the script's variable store (e.g. vars.x = 5)
-// use 'vars.Contains(string)' to check if a variable exists
-// use 'vars.Clear()' to remove all variables
-// use 'foreach (KeyValuePair<string, object> v in vars) { ... }' to iterate over all variables
-
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-
-public class UserScript : HeuristicLab.Scripting.UserScriptBase {
-  public override void Main() {
-    // type your code here
-  }
-
-  // implement further classes and methods
-
-}";
-    #endregion
+  public class Script : NamedItem {
+    protected virtual string CodeTemplate {
+      get { return string.Empty; }
+    }
 
     #region Fields & Properties
-    private UserScriptBase compiledScript;
-
-    public string Filename { get; set; }
-
     public static new Image StaticItemImage {
       get { return VSImageLibrary.Script; }
@@ -77,17 +48,10 @@
 
     [Storable]
-    private VariableStore variableStore;
-    public VariableStore VariableStore {
-      get { return variableStore; }
-    }
-
-    [Storable]
     private string code;
-    public string Code {
+    public virtual string Code {
       get { return code; }
       set {
         if (value == code) return;
         code = value;
-        compiledScript = null;
         OnCodeChanged();
       }
@@ -95,10 +59,10 @@
 
     private string compilationUnitCode;
-    public string CompilationUnitCode {
+    public virtual string CompilationUnitCode {
       get { return compilationUnitCode; }
     }
 
     private CompilerErrorCollection compileErrors;
-    public CompilerErrorCollection CompileErrors {
+    public virtual CompilerErrorCollection CompileErrors {
       get { return compileErrors; }
       private set {
@@ -111,9 +75,8 @@
     #region Construction & Initialization
     [StorableConstructor]
-    private Script(bool deserializing) : base(deserializing) { }
-    private Script(Script original, Cloner cloner)
+    protected Script(bool deserializing) : base(deserializing) { }
+    protected Script(Script original, Cloner cloner)
       : base(original, cloner) {
       code = original.code;
-      variableStore = new VariableStore();
       compilationUnitCode = original.compilationUnitCode;
       if (original.compileErrors != null)
@@ -124,5 +87,4 @@
       description = ItemDescription;
       code = CodeTemplate;
-      variableStore = new VariableStore();
     }
     public Script(string code)
@@ -136,22 +98,15 @@
     #endregion
 
-    private void RegisterScriptEvents() {
-      if (compiledScript == null) return;
-      compiledScript.ConsoleOutputChanged += compiledScript_ConsoleOutputChanged;
+    #region Compilation
+    protected virtual CSharpCodeProvider CodeProvider {
+      get {
+        return new CSharpCodeProvider(
+          new Dictionary<string, string> {
+                {"CompilerVersion", "v4.0"}, // support C# 4.0 syntax
+              });
+      }
     }
 
-    private void DeregisterScriptEvents() {
-      if (compiledScript == null) return;
-      compiledScript.ConsoleOutputChanged -= compiledScript_ConsoleOutputChanged;
-    }
-
-    #region Compilation
-    private CSharpCodeProvider codeProvider =
-      new CSharpCodeProvider(
-        new Dictionary<string, string> {
-          { "CompilerVersion", "v4.0" },  // support C# 4.0 syntax
-        });
-
-    private CompilerResults DoCompile() {
+    protected virtual CompilerResults DoCompile() {
       var parameters = new CompilerParameters {
         GenerateExecutable = false,
@@ -166,5 +121,5 @@
       var unit = CreateCompilationUnit();
       var writer = new StringWriter();
-      codeProvider.GenerateCodeFromCompileUnit(
+      CodeProvider.GenerateCodeFromCompileUnit(
         unit,
         writer,
@@ -174,10 +129,9 @@
         });
       compilationUnitCode = writer.ToString();
-      return codeProvider.CompileAssemblyFromDom(parameters, unit);
+      return CodeProvider.CompileAssemblyFromDom(parameters, unit);
     }
 
-    public void Compile() {
+    public virtual Assembly Compile() {
       var results = DoCompile();
-      compiledScript = null;
       CompileErrors = results.Errors;
       if (results.Errors.HasErrors) {
@@ -188,18 +142,12 @@
             .AppendLine(error.ErrorText);
         }
-        throw new Exception(string.Format(
-          "Compilation of \"{0}\" failed:{1}{2}",
-          Name, Environment.NewLine,
-          sb.ToString()));
+        throw new Exception(string.Format("Compilation of \"{0}\" failed:{1}{2}",
+          Name, Environment.NewLine, sb.ToString()));
       } else {
-        var assembly = results.CompiledAssembly;
-        var types = assembly.GetTypes();
-        DeregisterScriptEvents();
-        compiledScript = (UserScriptBase)Activator.CreateInstance(types[0]);
-        RegisterScriptEvents();
+        return results.CompiledAssembly;
       }
     }
 
-    public IEnumerable<Assembly> GetAssemblies() {
+    public virtual IEnumerable<Assembly> GetAssemblies() {
       var assemblies = new List<Assembly>();
       foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) {
@@ -217,58 +165,12 @@
     }
 
-    private readonly Regex SafeTypeNameCharRegex = new Regex("[_a-zA-Z0-9]+");
-    private readonly Regex SafeTypeNameRegex = new Regex("[_a-zA-Z][_a-zA-Z0-9]*");
-
-    private CodeCompileUnit CreateCompilationUnit() {
+    protected virtual CodeCompileUnit CreateCompilationUnit() {
       var unit = new CodeSnippetCompileUnit(code);
       return unit;
     }
-
-    public string CompiledTypeName {
-      get {
-        var sb = new StringBuilder();
-        var strings = SafeTypeNameCharRegex.Matches(Name)
-                                           .Cast<Match>()
-                                           .Select(m => m.Value);
-        foreach (string s in strings)
-          sb.Append(s);
-        return SafeTypeNameRegex.Match(sb.ToString()).Value;
-      }
-    }
     #endregion
 
-    private Thread scriptThread;
-    public void Execute() {
-      if (compiledScript == null) return;
-      var executeMethod = typeof(UserScriptBase).GetMethod(ExecuteMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
-      if (executeMethod != null) {
-        scriptThread = new Thread(() => {
-          Exception ex = null;
-          try {
-            OnScriptExecutionStarted();
-            executeMethod.Invoke(compiledScript, new[] { VariableStore });
-          } catch (ThreadAbortException) {
-            // the execution was cancelled by the user
-          } catch (TargetInvocationException e) {
-            ex = e.InnerException;
-          } finally {
-            OnScriptExecutionFinished(ex);
-          }
-        });
-        scriptThread.Start();
-      }
-    }
-
-    public void Kill() {
-      if (scriptThread.IsAlive)
-        scriptThread.Abort();
-    }
-
-    private void compiledScript_ConsoleOutputChanged(object sender, EventArgs<string> e) {
-      OnConsoleOutputChanged(e.Value);
-    }
-
     public event EventHandler CodeChanged;
-    private void OnCodeChanged() {
+    protected virtual void OnCodeChanged() {
       var handler = CodeChanged;
       if (handler != null) handler(this, EventArgs.Empty);
@@ -276,26 +178,8 @@
 
     public event EventHandler CompileErrorsChanged;
-    private void OnCompileErrorsChanged() {
+    protected virtual void OnCompileErrorsChanged() {
       var handler = CompileErrorsChanged;
       if (handler != null) handler(this, EventArgs.Empty);
     }
-
-    public event EventHandler ScriptExecutionStarted;
-    private void OnScriptExecutionStarted() {
-      var handler = ScriptExecutionStarted;
-      if (handler != null) handler(this, EventArgs.Empty);
-    }
-
-    public event EventHandler<EventArgs<Exception>> ScriptExecutionFinished;
-    private void OnScriptExecutionFinished(Exception e) {
-      var handler = ScriptExecutionFinished;
-      if (handler != null) handler(this, new EventArgs<Exception>(e));
-    }
-
-    public event EventHandler<EventArgs<string>> ConsoleOutputChanged;
-    private void OnConsoleOutputChanged(string args) {
-      var handler = ConsoleOutputChanged;
-      if (handler != null) handler(this, new EventArgs<string>(args));
-    }
   }
 }
