Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveHiveEngine/HeuristicLab.Core.Views/3.3/EngineView.cs @ 13279

Last change on this file since 13279 was 7259, checked in by swagner, 13 years ago

Updated year of copyrights to 2012 (#1716)

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
22using System;
23using HeuristicLab.MainForm;
24
25namespace HeuristicLab.Core.Views {
26  /// <summary>
27  /// Base class for editors of engines.
28  /// </summary>
29  [View("Engine View")]
30  [Content(typeof(Engine), true)]
31  [Content(typeof(IEngine), false)]
32  public partial class EngineView : ItemView {
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>
37    public new IEngine Content {
38      get { return (IEngine)base.Content; }
39      set { base.Content = value; }
40    }
41
42    /// <summary>
43    /// Initializes a new instance of <see cref="EngineBaseEditor"/>.
44    /// </summary>
45    public EngineView() {
46      InitializeComponent();
47    }
48
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>
53    protected override void DeregisterContentEvents() {
54      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
55      base.DeregisterContentEvents();
56    }
57
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>
62    protected override void RegisterContentEvents() {
63      base.RegisterContentEvents();
64      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
65    }
66
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>
71    protected override void OnContentChanged() {
72      base.OnContentChanged();
73      if (Content == null) {
74        logView.Content = null;
75        executionTimeTextBox.Text = "-";
76      } else {
77        logView.Content = Content.Log;
78        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
79      }
80    }
81
82    protected override void SetEnabledStateOfControls() {
83      base.SetEnabledStateOfControls();
84      if (Content == null) {
85        logView.Enabled = false;
86        executionTimeTextBox.Enabled = false;
87      } else {
88        logView.Enabled = true;
89        executionTimeTextBox.Enabled = true;
90      }
91    }
92
93    protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
94      if (InvokeRequired)
95        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
96      else
97        executionTimeTextBox.Text = Content == null ? "-" : Content.ExecutionTime.ToString();
98    }
99  }
100}
Note: See TracBrowser for help on using the repository browser.