Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 5676 was 5676, checked in by ascheibe, 14 years ago

#1233 worked on Administration UI

File size: 3.9 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.Views.Administration {
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 = ct.Cores.ToString() + " Cores @ " + ct.CpuSpeed.ToString() + " Mhz, Arch.: " + 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    void txtName_TextChanged(object sender, EventArgs e) {
87      throw new NotImplementedException();
88    }
89
90    private void ShowSlaveUI(bool show) {
91      label2.Visible = show;
92      label1.Visible = show;
93      label10.Visible = show;
94      label11.Visible = show;
95      label12.Visible = show;
96      label13.Visible = show;
97      label14.Visible = show;
98      label15.Visible = show;
99      txtCPU.Visible = show;
100      txtDetailsDescription.Visible = show;
101      txtMemory.Visible = show;
102      txtOS.Visible = show;
103      txtSlaveState.Visible = show;
104      txtLastHeartbeat.Visible = show;
105      txtFreeMemory.Visible = show;
106      txtId.Visible = show;
107    }
108
109    protected override void SetEnabledStateOfControls() {
110      base.SetEnabledStateOfControls();
111    }
112
113    private void txtName_TextChanged_1(object sender, EventArgs e) {
114      if (Content != null && Content is SlaveGroup) {
115        Content.Name = txtName.Text;
116      }
117    }
118  }
119}
Note: See TracBrowser for help on using the repository browser.