Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs @ 7908

Last change on this file since 7908 was 7862, checked in by ascheibe, 13 years ago

#1854 fixed compatibility issue with 3.3.6

File size: 4.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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.Views;
25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27
28namespace HeuristicLab.Clients.Hive.Administrator.Views {
29  [View("SlaveView")]
30  [Content(typeof(Resource), IsDefaultView = true)]
31  public partial class SlaveView : ItemView {
32    public new Resource Content {
33      get { return (Resource)base.Content; }
34      set { base.Content = value; }
35    }
36
37    public SlaveView() {
38      InitializeComponent();
39    }
40
41    #region Register Content Events
42    protected override void DeregisterContentEvents() {
43      base.DeregisterContentEvents();
44    }
45    protected override void RegisterContentEvents() {
46      base.RegisterContentEvents();
47    }
48    #endregion
49
50    protected override void OnContentChanged() {
51      base.OnContentChanged();
52      if (Content == null) {
53        ShowSlaveUI(true);
54        txtName.Clear();
55        txtCPU.Clear();
56        txtDetailsDescription.Clear();
57        txtMemory.Clear();
58        txtOS.Clear();
59        txtSlaveState.Clear();
60        txtLastHeartbeat.Clear();
61        txtFreeMemory.Clear();
62        txtId.Clear();
63        txtHbIntervall.Clear();
64        cbxDisposable.Checked = false;
65      } else {
66        if (Content.GetType() == typeof(Slave)) {
67          ShowSlaveUI(true);
68          Slave ct = (Slave)Content;
69          txtName.Text = ct.Name;
70          txtHbIntervall.Text = ct.HbInterval.ToString();
71          cbxDisposable.Checked = ct.IsDisposable.GetValueOrDefault();
72          txtCPU.Text = string.Format("{0} Cores @ {1} Mhz, Arch.: {2}", ct.Cores.ToString(), ct.CpuSpeed.ToString(), ct.CpuArchitecture.ToString());
73          txtDetailsDescription.Text = ct.Description;
74          txtMemory.Text = ct.Memory.ToString();
75          txtOS.Text = ct.OperatingSystem;
76          txtSlaveState.Text = ct.SlaveState.ToString();
77          txtLastHeartbeat.Text = ct.LastHeartbeat.ToString();
78          txtFreeMemory.Text = ct.FreeMemory.ToString();
79          txtId.Text = ct.Id.ToString();
80        } else if (Content.GetType() == typeof(SlaveGroup)) {
81          SlaveGroup ct = (SlaveGroup)Content;
82          txtName.Text = ct.Name;
83          txtHbIntervall.Text = ct.HbInterval.ToString();
84          ShowSlaveUI(false);
85        } else {
86          throw new Exception("Unknown Resource in SlaveView");
87        }
88      }
89    }
90
91    private void ShowSlaveUI(bool show) {
92      label1.Visible = show;
93      label2.Visible = show;
94      label4.Visible = show;
95      label10.Visible = show;
96      label11.Visible = show;
97      label12.Visible = show;
98      label13.Visible = show;
99      label14.Visible = show;
100      label15.Visible = show;
101      txtCPU.Visible = show;
102      txtDetailsDescription.Visible = show;
103      txtMemory.Visible = show;
104      txtOS.Visible = show;
105      txtSlaveState.Visible = show;
106      txtLastHeartbeat.Visible = show;
107      txtFreeMemory.Visible = show;
108      txtId.Visible = show;
109      txtName.Enabled = !show;
110      cbxDisposable.Visible = show;
111    }
112
113    protected override void SetEnabledStateOfControls() {
114      base.SetEnabledStateOfControls();
115    }
116
117    private void txtName_TextChanged(object sender, EventArgs e) {
118      if (Content != null && Content is SlaveGroup) {
119        Content.Name = txtName.Text;
120      }
121    }
122
123    private void txtHbIntervall_TextChanged(object sender, EventArgs e) {
124      if (Content != null) {
125        if (txtHbIntervall.Text.Length > 0) {
126          try {
127            int interval = int.Parse(txtHbIntervall.Text);
128            Content.HbInterval = interval;
129          }
130          catch (Exception) {
131            MessageBox.Show("Please enter a numeric value for the Heartbeat Interval.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
132            txtHbIntervall.Text = "10";
133          }
134        }
135      }
136    }
137
138    private void checkBox1_CheckedChanged(object sender, EventArgs e) {
139      if (Content != null) {
140        ((Slave)Content).IsDisposable = cbxDisposable.Checked;
141      }
142    }
143  }
144}
Note: See TracBrowser for help on using the repository browser.