Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HiveEngineView.cs @ 6212

Last change on this file since 6212 was 6212, checked in by cneumuel, 13 years ago

#1233

  • created HiveEngine.Views plugin
File size: 4.4 KB
RevLine 
[6212]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 HeuristicLab.Core.Views;
24using HeuristicLab.MainForm;
25
26namespace HeuristicLab.HiveEngine.Views {
27  [View("Hive Engine View")]
28  [Content(typeof(HiveEngine), IsDefaultView = true)]
29  public sealed partial class HiveEngineView : ItemView {
30    public new HiveEngine Content {
31      get { return (HiveEngine)base.Content; }
32      set { base.Content = value; }
33    }
34
35    public HiveEngineView() {
36      InitializeComponent();
37    }
38
39    protected override void DeregisterContentEvents() {
40      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
41      Content.ExecutionTimeOnHiveChanged -= new EventHandler(Content_ExecutionTimeOnHiveChanged);
42      base.DeregisterContentEvents();
43    }
44
45    protected override void RegisterContentEvents() {
46      base.RegisterContentEvents();
47      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
48      Content.ExecutionTimeOnHiveChanged += new EventHandler(Content_ExecutionTimeOnHiveChanged);
49    }
50
51    #region Event Handlers (Content)
52    private void Content_ExecutionStateChanged(object sender, EventArgs e) {
53      if (InvokeRequired) {
54        Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
55      } else {
56        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
57      }
58    }
59
60    private void Content_ExecutionTimeOnHiveChanged(object sender, EventArgs e) {
61      if (InvokeRequired) {
62        Invoke(new EventHandler(Content_ExecutionTimeOnHiveChanged), sender, e);
63      } else {
64        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
65      }
66    }
67    #endregion
68
69    protected override void OnContentChanged() {
70      base.OnContentChanged();
71      if (Content == null) {
72        resourceIdsTextBox.Text = string.Empty;
73        priorityTextBox.Text = string.Empty;
74        executionTimeOnHiveTextBox.Text = string.Empty;
75        useLocalPluginsCheckBox.Checked = false;
76        hiveExperimentListView.Content = null;
77        logView.Content = null;
78      } else {
79        resourceIdsTextBox.Text = Content.ResourceNames;
80        priorityTextBox.Text = Content.Priority.ToString();
81        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
82        useLocalPluginsCheckBox.Checked = Content.UseLocalPlugins;
83        hiveExperimentListView.Content = Content.HiveExperiments;
84        logView.Content = Content.Log;
85      }
86    }
87
88    protected override void SetEnabledStateOfControls() {
89      base.SetEnabledStateOfControls();
90      // Enable or disable controls based on whether the content is null or the view is set readonly
91      if (Content != null) {
92        resourceIdsTextBox.ReadOnly = this.ReadOnly;
93        priorityTextBox.ReadOnly = this.ReadOnly;
94        useLocalPluginsCheckBox.Enabled = !this.ReadOnly;
95      } else {
96        resourceIdsTextBox.ReadOnly = false;
97        priorityTextBox.ReadOnly = false;
98        useLocalPluginsCheckBox.Enabled = false;
99      }
100    }
101   
102    #region Event Handlers (child controls)
103    private void resourceIdsTextBox_TextChanged(object sender, EventArgs e) {
104      Content.ResourceNames = resourceIdsTextBox.Text;
105    }
106
107    private void priorityTextBox_TextChanged(object sender, EventArgs e) {
108      Content.Priority = int.Parse(priorityTextBox.Text);
109    }
110
111    private void useLocalPluginsCheckBox_CheckedChanged(object sender, EventArgs e) {
112      Content.UseLocalPlugins = useLocalPluginsCheckBox.Checked;
113    }
114    #endregion
115
116
117  }
118}
Note: See TracBrowser for help on using the repository browser.