Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ParallelEngine.Views/3.3/ParallelEngineView.cs @ 14498

Last change on this file since 14498 was 14186, checked in by swagner, 8 years ago

#2526: Updated year of copyrights in license headers

File size: 3.2 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#endregion
23
24using System;
25using System.Windows.Forms;
26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
28
29namespace HeuristicLab.ParallelEngine.Views {
30  [View("Parallel Engine View")]
31  [Content(typeof(ParallelEngine), true)]
32  public partial class ParallelEngineView : EngineView {
33    public ParallelEngineView() {
34      InitializeComponent();
35    }
36
37    public new ParallelEngine Content {
38      get { return (ParallelEngine)base.Content; }
39      set { base.Content = value; }
40    }
41
42    protected override void SetEnabledStateOfControls() {
43      base.SetEnabledStateOfControls();
44      degreeOfParallelizationNumericUpDown.Enabled = Content != null && !Locked;
45    }
46
47    protected override void RegisterContentEvents() {
48      base.RegisterContentEvents();
49      Content.DegreeOfParallelismChanged += Content_DegreeOfParallelismChanged;
50    }
51    protected override void DeregisterContentEvents() {
52      Content.DegreeOfParallelismChanged -= Content_DegreeOfParallelismChanged;
53      base.DeregisterContentEvents();
54    }
55
56    private void Content_DegreeOfParallelismChanged(object sender, EventArgs e) {
57      degreeOfParallelizationNumericUpDown.Value = Content.DegreeOfParallelism;
58    }
59
60    protected override void OnContentChanged() {
61      base.OnContentChanged();
62      if (Content != null) degreeOfParallelizationNumericUpDown.Value = Content.DegreeOfParallelism;
63      else degreeOfParallelizationNumericUpDown.Value = -1;
64    }
65
66    private void degreeOfParallelizationNumericUpDown_ValueChanged(object sender, EventArgs e) {
67      if (Content == null) return;
68      if (degreeOfParallelizationNumericUpDown.Value == 0) {
69        degreeOfParallelizationNumericUpDown.Value = 1;
70        return;
71      }
72      Content.DegreeOfParallelism = (int)degreeOfParallelizationNumericUpDown.Value;
73    }
74
75    protected virtual void infoLabel_DoubleClick(object sender, EventArgs e) {
76      const string caption = "Degree of Parallelism Description";
77      const string description = @"Specifies the maximum degree of parallelization (-1 no limit given) to balance the maximum processor load. For further information see http://msdn.microsoft.com/en-us/library/system.threading.tasks.paralleloptions.maxdegreeofparallelism.aspx";
78      using (TextDialog dialog = new TextDialog(caption, description, true)) {
79        dialog.ShowDialog(this);
80      }
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.