Free cookie consent management tool by TermsFeed Policy Generator

source: branches/MPI/HeuristicLab.MPIEngine/3.3/MPIEngineView.cs @ 9584

Last change on this file since 9584 was 6398, checked in by svonolfe, 14 years ago

Added MPIEngine view (#1542)

File size: 3.7 KB
RevLine 
[6398]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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 System.Windows.Forms;
24using HeuristicLab.Core;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27using System.ComponentModel;
28
29namespace HeuristicLab.MPIEngine {
30
31  /// <summary>
32  /// Engine for MPI
33  /// </summary>
34  [View("MPIEngine View")]
35  [Content(typeof(MPIEngine), true)]
36  public partial class MPIEngineView : ItemView {
37    #region Basics
38
39    /// <summary>
40    /// Gets or sets the current engine.
41    /// </summary>
42    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="EditorBase"/>.</remarks>
43    public new MPIEngine Content {
44      get { return (MPIEngine)base.Content; }
45      set { base.Content = value; }
46    }
47
48    /// <summary>
49    /// Initializes a new instance of <see cref="DebugEngineView"/>.
50    /// </summary>
51    public MPIEngineView() {
52      InitializeComponent();
53    }
54
55    /// <summary>
56    /// Removes the event handlers from the underlying <see cref="IEngine"/>.
57    /// </summary>
58    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
59    protected override void DeregisterContentEvents() {
60      if (Content != null) {
61        Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
62        Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
63      }
64     
65      base.DeregisterContentEvents();   
66    }
67
68    /// <summary>
69    /// Adds event handlers to the underlying <see cref="IEngine"/>.
70    /// </summary>
71    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
72    protected override void RegisterContentEvents() {
73      base.RegisterContentEvents();
74
75      if (Content != null) {
76        Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
77        Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
78      }
79    }
80
81    void Content_ExecutionTimeChanged(object sender, EventArgs e) {
82      if (InvokeRequired) {
83        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
84      } else {
85        propertyGrid.Refresh();
86      }
87    }
88
89    void Content_ExecutionStateChanged(object sender, EventArgs e) {
90      if (InvokeRequired) {
91        Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
92      } else {
93        propertyGrid.Refresh();
94      }
95    }
96
97    /// <summary>
98    /// Updates all controls with the latest data of the model.
99    /// </summary>
100    /// <remarks>Calls <see cref="EditorBase.UpdateControls"/> of base class <see cref="EditorBase"/>.</remarks>
101    protected override void OnContentChanged() {
102      this.propertyGrid.SelectedObject = Content;
103
104      base.OnContentChanged();
105    }
106
107    protected override void SetEnabledStateOfControls() {
108      base.SetEnabledStateOfControls();
109    }
110
111    #endregion
112
113  }
114}
Note: See TracBrowser for help on using the repository browser.