Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/HeuristicLab.ThreadParallelEngine/3.2/ThreadParallelEngineEditor.cs @ 3199

Last change on this file since 3199 was 1530, checked in by gkronber, 16 years ago

Moved source files of plugins Hive ... Visualization.Test into version-specific sub-folders. #576

File size: 4.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Text;
28using System.Windows.Forms;
29using HeuristicLab.Core;
30
31namespace HeuristicLab.ThreadParallelEngine {
32  /// <summary>
33  /// Visual representation of a <see cref="ThreadParallelEngine"/>.
34  /// </summary>
35  public partial class ThreadParallelEngineEditor : EngineBaseEditor {
36    /// <summary>
37    /// Gets or sets the ThreadParallelEngine to display.
38    /// </summary>
39    /// <remarks>Uses property <see cref="EngineBaseEditor.Engine"/> of base class
40    /// <see cref="EngineBaseEditor"/>. No own data storage present.</remarks>
41    public ThreadParallelEngine ThreadParallelEngine {
42      get { return (ThreadParallelEngine)Engine; }
43      set { base.Engine = value; }
44    }
45
46    /// <summary>
47    /// Initializes a new instance of <see cref="ThreadParallelEngineEditor"/>.
48    /// </summary>
49    public ThreadParallelEngineEditor() {
50      InitializeComponent();
51    }
52    /// <summary>
53    /// Initializes a new instance of <see cref="ThreadParallelEngineEditor"/> with the given
54    /// <paramref name="threadParallelEngine"/> to display.
55    /// </summary>
56    /// <param name="threadParallelEngine">The engine to represent visually.</param>
57    public ThreadParallelEngineEditor(ThreadParallelEngine threadParallelEngine)
58      : this() {
59      ThreadParallelEngine = threadParallelEngine;
60    }
61
62    /// <summary>
63    /// Removes the eventhandlers from the underlying <see cref="ThreadParallelEngine"/>.
64    /// </summary>
65    /// <remarks>Calls <see cref="EngineBaseEditor.RemoveItemEvents"/> of base class
66    /// <see cref="EngineBaseEditor"/>.
67    /// </remarks>
68    protected override void RemoveItemEvents() {
69      ThreadParallelEngine.WorkersChanged -= new EventHandler(ThreadParallelEngine_WorkersChanged);
70      base.RemoveItemEvents();
71    }
72
73    /// <summary>
74    /// Adds eventhandlers to the underlying <see cref="ThreadParallelEngine"/>.
75    /// </summary>
76    /// <remarks>Calls <see cref="EngineBaseEditor.AddItemEvents"/> of base class
77    /// <see cref="EngineBaseEditor"/>.
78    /// </remarks>
79    protected override void AddItemEvents() {
80      base.AddItemEvents();
81      ThreadParallelEngine.WorkersChanged += new EventHandler(ThreadParallelEngine_WorkersChanged);
82    }
83
84    /// <summary>
85    /// Updates the controls with the latest data.
86    /// </summary>
87    /// <remarks>Calls <see cref="EngineBaseEditor.UpdateControls"/> of base class
88    /// <see cref="EngineBaseEditor"/>.</remarks>
89    protected override void UpdateControls() {
90      base.UpdateControls();
91      if (ThreadParallelEngine == null) {
92        workersNumericUpDown.Value = 1;
93        workersNumericUpDown.Enabled = false;
94      } else {
95        workersNumericUpDown.Value = ThreadParallelEngine.Workers;
96        workersNumericUpDown.Enabled = true;
97      }
98    }
99
100    #region ThreadParallelEngine Events
101    private void ThreadParallelEngine_WorkersChanged(object sender, EventArgs e) {
102      workersNumericUpDown.Value = ThreadParallelEngine.Workers;
103    }
104    #endregion
105
106    #region NumericUpDown Events
107    private void workersNumericUpDown_ValueChanged(object sender, EventArgs e) {
108      ThreadParallelEngine.Workers = (int)workersNumericUpDown.Value;
109    }
110    #endregion
111  }
112}
Note: See TracBrowser for help on using the repository browser.