annotate ServerMonitor/Controls/DiskSpaceCheckControl.cs @ 19:b3128fe10d57

Add About form and license.
author Brad Greco <brad@bgreco.net>
date Wed, 29 May 2019 20:18:37 -0400
parents 7127d5b5ac75
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
1 using System;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
2
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
3 namespace ServerMonitorApp
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
4 {
9
7127d5b5ac75 Code cleanup and comments
Brad Greco <brad@bgreco.net>
parents: 2
diff changeset
5 /// <summary>Control for editing a disk space check.</summary>
2
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
6 [CheckType(typeof(DiskSpaceCheck))]
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
7 public partial class DiskSpaceCheckControl : CheckControl
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
8 {
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
9 public DiskSpaceCheckControl()
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
10 {
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
11 InitializeComponent();
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
12 }
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
13
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
14 private void DiskSpaceCheckControl_Load(object sender, EventArgs e)
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
15 {
9
7127d5b5ac75 Code cleanup and comments
Brad Greco <brad@bgreco.net>
parents: 2
diff changeset
16 // Initialize the free space units to a non-empty value.
2
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
17 FreeSpaceUnitsComboBox.SelectedIndex = 1;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
18 }
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
19
9
7127d5b5ac75 Code cleanup and comments
Brad Greco <brad@bgreco.net>
parents: 2
diff changeset
20 /// <summary>Sets the values of the controls from a check's properties.</summary>
2
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
21 public override void LoadCheck(Check check1)
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
22 {
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
23 DiskSpaceCheck check = (DiskSpaceCheck)check1;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
24 DeviceTextBox.Text = check.Device;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
25 FreeSpaceTextBox.Text = check.MinFreeSpace.ToString();
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
26 FreeSpaceUnitsComboBox.SelectedIndex = (int)check.FreeSpaceUnits;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
27 }
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
28
9
7127d5b5ac75 Code cleanup and comments
Brad Greco <brad@bgreco.net>
parents: 2
diff changeset
29 /// <summary>Updates the properties of a check from user input.</summary>
2
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
30 public override void UpdateCheck(Check check1)
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
31 {
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
32 DiskSpaceCheck check = (DiskSpaceCheck)check1;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
33 check.Device = DeviceTextBox.Text.Trim();
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
34 check.FreeSpaceUnits = (FreeSpaceUnits)FreeSpaceUnitsComboBox.SelectedIndex;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
35 try
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
36 {
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
37 check.MinFreeSpace = double.Parse(FreeSpaceTextBox.Text);
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
38 }
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
39 catch
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
40 {
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
41 check.MinFreeSpace = 0;
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
42 throw new UpdateCheckException("Free space must be numeric.");
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
43 }
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
44 }
453ecc1ed9ea Disk space check
Brad Greco <brad@bgreco.net>
parents:
diff changeset
45 }
9
7127d5b5ac75 Code cleanup and comments
Brad Greco <brad@bgreco.net>
parents: 2
diff changeset
46 }