#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.Drawing;
using System.Windows.Forms;
using HeuristicLab.Common;
using HeuristicLab.Common.Resources;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.Scripting.Python.Views {
[View("Python-Script View")]
[Content(typeof(PythonScript), true)]
public partial class PythonScriptView : NamedItemView {
private bool running;
private bool suppressEvents;
public new PythonScript Content {
get { return (PythonScript)base.Content; }
set { base.Content = value; }
}
public PythonScriptView() {
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) {
try {
suppressEvents = true;
codeTextBox.Text = Content.Code;
} finally { suppressEvents = false; }
}
private void Content_ScriptExecutionStarted(object sender, EventArgs e) {
if (InvokeRequired)
Invoke((Action