Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core.Views/3.3/EngineView.cs @ 3332

Last change on this file since 3332 was 3289, checked in by swagner, 15 years ago

Implemented logs of engines (#963).

File size: 3.5 KB
RevLine 
[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
22using System;
[2520]23using HeuristicLab.MainForm;
[2]24
[2520]25namespace 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    }
[2727]48    public EngineView(IEngine content)
[2655]49      : this() {
[2727]50      Content = content;
[2655]51    }
[2]52
[776]53    /// <summary>
54    /// Removes the event handlers from the underlying <see cref="IEngine"/>.
55    /// </summary>
56    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
[2713]57    protected override void DeregisterContentEvents() {
58      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
59      base.DeregisterContentEvents();
[2]60    }
[2655]61
[776]62    /// <summary>
63    /// Adds event handlers to the underlying <see cref="IEngine"/>.
64    /// </summary>
65    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
[2713]66    protected override void RegisterContentEvents() {
67      base.RegisterContentEvents();
68      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
[2]69    }
70
[776]71    /// <summary>
72    /// Updates all controls with the latest data of the model.
73    /// </summary>
74    /// <remarks>Calls <see cref="EditorBase.UpdateControls"/> of base class <see cref="EditorBase"/>.</remarks>
[2713]75    protected override void OnContentChanged() {
76      base.OnContentChanged();
77      if (Content == null) {
[3289]78        logView.Content = null;
79        logView.Enabled = false;
[3262]80        executionTimeTextBox.Text = "-";
[2]81        executionTimeTextBox.Enabled = false;
82      } else {
[3289]83        logView.Content = Content.Log;
84        logView.Enabled = true;
[3262]85        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
[2]86        executionTimeTextBox.Enabled = true;
87      }
88    }
89
[3262]90    protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
[2]91      if (InvokeRequired)
[3262]92        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
93      else
94        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
[2]95    }
96  }
97}
Note: See TracBrowser for help on using the repository browser.