Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administration/3.4/Views/SlaveView.cs @ 6688

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

#1233 some renaming to be more consistent with OKB

File size: 3.8 KB
Line 
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 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      } else {
64        if (Content.GetType() == typeof(Slave)) {
65          ShowSlaveUI(true);
66          Slave ct = (Slave)Content;
67          txtName.Text = ct.Name;
68          txtCPU.Text = string.Format("{0} Cores @ {1} Mhz, Arch.: {2}", ct.Cores.ToString(), ct.CpuSpeed.ToString(), ct.CpuArchitecture.ToString());
69          txtDetailsDescription.Text = ct.Description;
70          txtMemory.Text = ct.Memory.ToString();
71          txtOS.Text = ct.OperatingSystem;
72          txtSlaveState.Text = ct.SlaveState.ToString();
73          txtLastHeartbeat.Text = ct.LastHeartbeat.ToString();
74          txtFreeMemory.Text = ct.FreeMemory.ToString();
75          txtId.Text = ct.Id.ToString();
76        } else if (Content.GetType() == typeof(SlaveGroup)) {
77          SlaveGroup ct = (SlaveGroup)Content;
78          txtName.Text = ct.Name;
79          ShowSlaveUI(false);
80        } else {
81          throw new Exception("Unknown Resource in SlaveView");
82        }
83      }
84    }
85
86    private void ShowSlaveUI(bool show) {
87      label2.Visible = show;
88      label1.Visible = show;
89      label10.Visible = show;
90      label11.Visible = show;
91      label12.Visible = show;
92      label13.Visible = show;
93      label14.Visible = show;
94      label15.Visible = show;
95      txtCPU.Visible = show;
96      txtDetailsDescription.Visible = show;
97      txtMemory.Visible = show;
98      txtOS.Visible = show;
99      txtSlaveState.Visible = show;
100      txtLastHeartbeat.Visible = show;
101      txtFreeMemory.Visible = show;
102      txtId.Visible = show;
103      txtName.Enabled = !show;
104    }
105
106    protected override void SetEnabledStateOfControls() {
107      base.SetEnabledStateOfControls();
108    }
109
110    private void txtName_TextChanged(object sender, EventArgs e) {
111      if (Content != null && Content is SlaveGroup) {
112        Content.Name = txtName.Text;
113      }
114    }
115  }
116}
Note: See TracBrowser for help on using the repository browser.