[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[2790] | 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[2520] | 23 | using HeuristicLab.MainForm;
|
---|
[2] | 24 |
|
---|
[2520] | 25 | namespace HeuristicLab.Core.Views {
|
---|
[776] | 26 | /// <summary>
|
---|
| 27 | /// Base class for editors of engines.
|
---|
| 28 | /// </summary>
|
---|
[2917] | 29 | [View("Engine View")]
|
---|
[2664] | 30 | [Content(typeof(Engine), true)]
|
---|
[2727] | 31 | [Content(typeof(IEngine), false)]
|
---|
[2664] | 32 | public partial class EngineView : ItemView {
|
---|
[776] | 33 | /// <summary>
|
---|
| 34 | /// Gets or sets the current engine.
|
---|
| 35 | /// </summary>
|
---|
| 36 | /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="EditorBase"/>.</remarks>
|
---|
[2727] | 37 | public new IEngine Content {
|
---|
| 38 | get { return (IEngine)base.Content; }
|
---|
[2713] | 39 | set { base.Content = value; }
|
---|
[2] | 40 | }
|
---|
| 41 |
|
---|
[776] | 42 | /// <summary>
|
---|
| 43 | /// Initializes a new instance of <see cref="EngineBaseEditor"/>.
|
---|
| 44 | /// </summary>
|
---|
[2664] | 45 | public EngineView() {
|
---|
[2] | 46 | InitializeComponent();
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[776] | 49 | /// <summary>
|
---|
| 50 | /// Removes the event handlers from the underlying <see cref="IEngine"/>.
|
---|
| 51 | /// </summary>
|
---|
| 52 | /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
|
---|
[2713] | 53 | protected override void DeregisterContentEvents() {
|
---|
| 54 | Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
|
---|
| 55 | base.DeregisterContentEvents();
|
---|
[2] | 56 | }
|
---|
[2655] | 57 |
|
---|
[776] | 58 | /// <summary>
|
---|
| 59 | /// Adds event handlers to the underlying <see cref="IEngine"/>.
|
---|
| 60 | /// </summary>
|
---|
| 61 | /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
|
---|
[2713] | 62 | protected override void RegisterContentEvents() {
|
---|
| 63 | base.RegisterContentEvents();
|
---|
| 64 | Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
|
---|
[2] | 65 | }
|
---|
| 66 |
|
---|
[776] | 67 | /// <summary>
|
---|
| 68 | /// Updates all controls with the latest data of the model.
|
---|
| 69 | /// </summary>
|
---|
| 70 | /// <remarks>Calls <see cref="EditorBase.UpdateControls"/> of base class <see cref="EditorBase"/>.</remarks>
|
---|
[2713] | 71 | protected override void OnContentChanged() {
|
---|
| 72 | base.OnContentChanged();
|
---|
| 73 | if (Content == null) {
|
---|
[3289] | 74 | logView.Content = null;
|
---|
[3362] | 75 | executionTimeTextBox.Text = "-";
|
---|
| 76 | } else {
|
---|
| 77 | logView.Content = Content.Log;
|
---|
| 78 | executionTimeTextBox.Text = Content.ExecutionTime.ToString();
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[3904] | 82 | protected override void SetEnabledStateOfControls() {
|
---|
| 83 | base.SetEnabledStateOfControls();
|
---|
[3362] | 84 | if (Content == null) {
|
---|
[3289] | 85 | logView.Enabled = false;
|
---|
[2] | 86 | executionTimeTextBox.Enabled = false;
|
---|
| 87 | } else {
|
---|
[3289] | 88 | logView.Enabled = true;
|
---|
[2] | 89 | executionTimeTextBox.Enabled = true;
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[3262] | 93 | protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
|
---|
[2] | 94 | if (InvokeRequired)
|
---|
[3262] | 95 | Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
|
---|
| 96 | else
|
---|
| 97 | executionTimeTextBox.Text = Content.ExecutionTime.ToString();
|
---|
[2] | 98 | }
|
---|
| 99 | }
|
---|
| 100 | }
|
---|