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 |
|
---|
22 | using System;
|
---|
23 | using HeuristicLab.Core.Views;
|
---|
24 | using HeuristicLab.MainForm;
|
---|
25 |
|
---|
26 | namespace 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.ExecutionTimeOnHiveChanged -= new EventHandler(Content_ExecutionTimeOnHiveChanged);
|
---|
41 | Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
|
---|
42 | base.DeregisterContentEvents();
|
---|
43 | }
|
---|
44 |
|
---|
45 | protected override void RegisterContentEvents() {
|
---|
46 | base.RegisterContentEvents();
|
---|
47 | Content.ExecutionTimeOnHiveChanged += new EventHandler(Content_ExecutionTimeOnHiveChanged);
|
---|
48 | Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
|
---|
49 | }
|
---|
50 |
|
---|
51 | #region Event Handlers (Content)
|
---|
52 | private void Content_ExecutionTimeChanged(object sender, EventArgs e) {
|
---|
53 | if (InvokeRequired) {
|
---|
54 | Invoke(new EventHandler(Content_ExecutionTimeChanged), 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 | hiveExperimentListView.Content = null;
|
---|
76 | logView.Content = null;
|
---|
77 | } else {
|
---|
78 | resourceIdsTextBox.Text = Content.ResourceNames;
|
---|
79 | priorityTextBox.Text = Content.Priority.ToString();
|
---|
80 | executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
|
---|
81 | hiveExperimentListView.Content = Content.Jobs;
|
---|
82 | logView.Content = Content.Log;
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | protected override void SetEnabledStateOfControls() {
|
---|
87 | base.SetEnabledStateOfControls();
|
---|
88 | // Enable or disable controls based on whether the content is null or the view is set readonly
|
---|
89 | if (Content != null) {
|
---|
90 | resourceIdsTextBox.ReadOnly = this.ReadOnly;
|
---|
91 | priorityTextBox.ReadOnly = this.ReadOnly;
|
---|
92 | } else {
|
---|
93 | resourceIdsTextBox.ReadOnly = false;
|
---|
94 | priorityTextBox.ReadOnly = false;
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | #region Event Handlers (child controls)
|
---|
99 | private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
|
---|
100 | Content.ResourceNames = resourceIdsTextBox.Text;
|
---|
101 | }
|
---|
102 |
|
---|
103 | private void priorityTextBox_Validated(object sender, EventArgs e) {
|
---|
104 | Content.Priority = int.Parse(priorityTextBox.Text);
|
---|
105 | }
|
---|
106 | #endregion
|
---|
107 | }
|
---|
108 | }
|
---|