#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 .
*/
#endregion
using System;
using System.CodeDom.Compiler;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Windows.Forms;
using HeuristicLab.Common;
using HeuristicLab.Common.Resources;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.Scripting.Views {
[View("Script View")]
[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; }
}
public ScriptView() {
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;
}
protected override void DeregisterContentEvents() {
Content.CodeChanged -= Content_CodeChanged;
Content.ScriptExecutionStarted -= Content_ScriptExecutionStarted;
Content.ScriptExecutionFinished -= Content_ScriptExecutionFinished;
Content.ConsoleOutputChanged -= Content_ConsoleOutputChanged;
base.DeregisterContentEvents();
}
#region Content event handlers
private void Content_CodeChanged(object sender, EventArgs e) {
codeEditor.UserCode = Content.Code;
}
private void Content_ScriptExecutionStarted(object sender, EventArgs e) {
if (InvokeRequired)
Invoke((Action