#region License Information
/* HeuristicLab
* Copyright (C) 2002-2018 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 HeuristicLab.MainForm;
namespace HeuristicLab.Core.Views {
///
/// Base class for editors of engines.
///
[View("Engine View")]
[Content(typeof(Engine), true)]
[Content(typeof(IEngine), false)]
public partial class EngineView : ItemView {
///
/// Gets or sets the current engine.
///
/// Uses property of base class .
public new IEngine Content {
get { return (IEngine)base.Content; }
set { base.Content = value; }
}
///
/// Initializes a new instance of .
///
public EngineView() {
InitializeComponent();
}
///
/// Removes the event handlers from the underlying .
///
/// Calls of base class .
protected override void DeregisterContentEvents() {
Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
base.DeregisterContentEvents();
}
///
/// Adds event handlers to the underlying .
///
/// Calls of base class .
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
}
///
/// Updates all controls with the latest data of the model.
///
/// Calls of base class .
protected override void OnContentChanged() {
base.OnContentChanged();
if (Content == null) {
logView.Content = null;
executionTimeTextBox.Text = "-";
} else {
logView.Content = Content.Log;
executionTimeTextBox.Text = Content.ExecutionTime.ToString();
}
}
protected override void SetEnabledStateOfControls() {
base.SetEnabledStateOfControls();
if (Content == null) {
logView.Enabled = false;
executionTimeTextBox.Enabled = false;
} else {
logView.Enabled = true;
executionTimeTextBox.Enabled = true;
}
}
protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
if (InvokeRequired)
Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
else
executionTimeTextBox.Text = Content == null ? "-" : Content.ExecutionTime.ToString();
}
}
}