Changeset 16240 for branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs
- Timestamp:
- 10/18/18 16:16:31 (6 years ago)
- Location:
- branches/2915-AbsoluteSymbol
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2915-AbsoluteSymbol
- Property svn:mergeinfo changed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator
- Property svn:mergeinfo changed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs
r15583 r16240 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Windows.Forms; 24 using HeuristicLab.Clients.Access;25 using HeuristicLab.Core.Views;26 24 using HeuristicLab.MainForm; 27 25 using HeuristicLab.MainForm.WindowsForms; 28 26 29 27 namespace HeuristicLab.Clients.Hive.Administrator.Views { 30 [View("Slave View")]31 [Content(typeof( Resource), IsDefaultView = true)]32 public partial class SlaveView : ItemView {33 public new Resource Content {34 get { return ( Resource)base.Content; }28 [View("Slave View")] 29 [Content(typeof(Slave), IsDefaultView = true)] 30 public sealed partial class SlaveView : ResourceView { 31 public new Slave Content { 32 get { return (Slave)base.Content; } 35 33 set { base.Content = value; } 36 34 } … … 40 38 } 41 39 42 #region Register Content Events 43 protected override void DeregisterContentEvents() { 44 base.DeregisterContentEvents(); 45 } 46 protected override void RegisterContentEvents() { 47 base.RegisterContentEvents(); 48 } 49 #endregion 50 40 #region Overrides 51 41 protected override void OnContentChanged() { 52 42 base.OnContentChanged(); 53 43 if (Content == null) { 54 ShowSlaveUI(true); 55 txtName.Clear(); 56 txtCPU.Clear(); 57 txtDetailsDescription.Clear(); 58 txtMemory.Clear(); 59 txtOS.Clear(); 60 txtSlaveState.Clear(); 61 txtLastHeartbeat.Clear(); 62 txtFreeMemory.Clear(); 63 txtId.Clear(); 64 txtHbIntervall.Clear(); 65 cbxDisposable.Checked = false; 66 cbxPublic.Checked = false; 44 cpuTextBox.Clear(); 45 memoryTextBox.Clear(); 46 operatingSystemTextBox.Clear(); 47 stateTextBox.Clear(); 48 lastHeartbeatTextBox.Clear(); 49 disposableCheckBox.Checked = false; 67 50 } else { 68 if (Content.GetType() == typeof(Slave)) { 69 ShowSlaveUI(true); 70 Slave ct = (Slave)Content; 71 bool authorized = UserInformation.Instance.UserExists && (ct.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions()); 72 txtName.Text = ct.Name; 73 txtHbIntervall.Text = ct.HbInterval.ToString(); 74 cbxPublic.Enabled = authorized; 75 cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged); 76 cbxPublic.Checked = ct.OwnerUserId == null; 77 cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged); 78 txtCPU.Text = string.Format("{0} Cores @ {1} Mhz, Arch.: {2}", ct.Cores.ToString(), ct.CpuSpeed.ToString(), ct.CpuArchitecture.ToString()); 79 txtDetailsDescription.Text = ct.Description; 80 txtMemory.Text = ct.Memory.ToString(); 81 txtOS.Text = ct.OperatingSystem; 82 txtSlaveState.Text = ct.SlaveState.ToString(); 83 txtLastHeartbeat.Text = ct.LastHeartbeat.ToString(); 84 txtFreeMemory.Text = ct.FreeMemory.ToString(); 85 txtId.Text = ct.Id.ToString(); 86 cbxDisposable.Enabled = authorized; 87 cbxDisposable.Checked = ct.IsDisposable.GetValueOrDefault(); 88 } else if (Content.GetType() == typeof(SlaveGroup)) { 89 SlaveGroup ct = (SlaveGroup)Content; 90 txtName.Text = ct.Name; 91 txtHbIntervall.Text = ct.HbInterval.ToString(); 92 cbxPublic.Enabled = ct.Name != "UNGROUPED" && HiveRoles.CheckAdminUserPermissions(); 93 cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged); 94 cbxPublic.Checked = ct.OwnerUserId == null; 95 cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged); 96 ShowSlaveUI(false); 97 } else { 98 throw new Exception("Unknown Resource in SlaveView"); 99 } 51 cpuTextBox.Text = string.Format("{0} Cores @ {1} MHz, Arch.: {2}", Content.Cores, Content.CpuSpeed, Content.CpuArchitecture); 52 memoryTextBox.Text = string.Format("{0} ({1} Free)", Content.Memory, Content.FreeMemory); 53 operatingSystemTextBox.Text = Content.OperatingSystem; 54 stateTextBox.Text = Content.SlaveState.ToString(); 55 lastHeartbeatTextBox.Text = Content.LastHeartbeat.ToString(); 56 disposableCheckBox.Checked = Content.IsDisposable.GetValueOrDefault(); 100 57 } 101 }102 103 private void ShowSlaveUI(bool show) {104 label1.Visible = show;105 label2.Visible = show;106 label4.Visible = show;107 label10.Visible = show;108 label11.Visible = show;109 label12.Visible = show;110 label13.Visible = show;111 label14.Visible = show;112 label15.Visible = show;113 txtCPU.Visible = show;114 txtDetailsDescription.Visible = show;115 txtMemory.Visible = show;116 txtOS.Visible = show;117 txtSlaveState.Visible = show;118 txtLastHeartbeat.Visible = show;119 txtFreeMemory.Visible = show;120 txtId.Visible = show;121 txtName.Enabled = !show;122 cbxDisposable.Visible = show;123 58 } 124 59 125 60 protected override void SetEnabledStateOfControls() { 126 61 base.SetEnabledStateOfControls(); 62 bool enabled = Content != null && !Locked; 63 disposableCheckBox.Enabled = enabled; 127 64 } 65 #endregion 128 66 129 private void txtName_TextChanged(object sender, EventArgs e) {130 if (Content != null && Content is SlaveGroup) {131 Content.Name = txtName.Text;132 }67 #region Event Handlers 68 private void disposableCheckBox_CheckedChanged(object sender, EventArgs e) { 69 if (Content != null) 70 Content.IsDisposable = disposableCheckBox.Checked; 133 71 } 134 135 private void txtHbIntervall_TextChanged(object sender, EventArgs e) { 136 if (Content != null) { 137 if (txtHbIntervall.Text.Length > 0) { 138 try { 139 int interval = int.Parse(txtHbIntervall.Text); 140 Content.HbInterval = interval; 141 } 142 catch (Exception) { 143 MessageBox.Show("Please enter a numeric value for the Heartbeat Interval.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 144 txtHbIntervall.Text = "10"; 145 } 146 } 147 } 148 } 149 150 private void cbxDisposable_CheckedChanged(object sender, EventArgs e) { 151 if (Content != null) { 152 ((Slave)Content).IsDisposable = cbxDisposable.Checked; 153 } 154 } 155 156 private void cbxPublic_CheckedChanged(object sender, EventArgs e) { 157 if (Content != null) { 158 Content.OwnerUserId = cbxPublic.Checked ? null : new Guid?(UserInformation.Instance.User.Id); 159 } 160 } 72 #endregion 161 73 } 162 74 }
Note: See TracChangeset
for help on using the changeset viewer.