#region License Information
/* HeuristicLab
* Copyright (C) 2002-2008 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.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using HeuristicLab.Core;
namespace HeuristicLab.Hive.Engine {
///
/// Visual representation of a .
///
public partial class HiveEngineEditor : EngineBaseEditor {
///
/// Gets or set the engine to represent visually.
///
/// Uses property of base class
/// . No own data storage present.
public HiveEngine HiveEngine {
get { return (HiveEngine)Engine; }
set {
if (base.Engine != null) RemoveItemEvents();
base.Engine = value;
AddItemEvents();
SetDataBinding();
}
}
///
/// Initializes a new instance of .
///
public HiveEngineEditor() {
InitializeComponent();
}
///
/// Initializes a new instance of with the given
/// .
///
/// The engine to display.
public HiveEngineEditor(HiveEngine hiveEngine)
: this() {
HiveEngine = hiveEngine;
base.executeButton.Click += new EventHandler(executeButton_Click);
}
void executeButton_Click(object sender, EventArgs e) {
snapshotButton.Enabled = true;
}
private void SetDataBinding() {
urlTextBox.DataBindings.Add("Text", HiveEngine, "HiveServerUrl");
}
protected override void RemoveItemEvents() {
Engine.Initialized -= new EventHandler(Engine_Initialized);
Engine.Finished -= new EventHandler(Engine_Finished);
base.RemoveItemEvents();
}
protected override void AddItemEvents() {
base.AddItemEvents();
Engine.Finished += new EventHandler(Engine_Finished);
Engine.Initialized += new EventHandler(Engine_Initialized);
}
void Engine_Initialized(object sender, EventArgs e) {
snapshotButton.Enabled = false;
}
void Engine_Finished(object sender, EventArgs e) {
snapshotButton.Enabled = false;
}
private void snapshotButton_Click(object sender, EventArgs e) {
HiveEngine.RequestSnapshot();
}
}
}