2
|
1 using System;
|
|
2
|
|
3 namespace ServerMonitorApp
|
|
4 {
|
9
|
5 /// <summary>Control for editing a disk space check.</summary>
|
2
|
6 [CheckType(typeof(DiskSpaceCheck))]
|
|
7 public partial class DiskSpaceCheckControl : CheckControl
|
|
8 {
|
|
9 public DiskSpaceCheckControl()
|
|
10 {
|
|
11 InitializeComponent();
|
|
12 }
|
|
13
|
|
14 private void DiskSpaceCheckControl_Load(object sender, EventArgs e)
|
|
15 {
|
9
|
16 // Initialize the free space units to a non-empty value.
|
2
|
17 FreeSpaceUnitsComboBox.SelectedIndex = 1;
|
|
18 }
|
|
19
|
9
|
20 /// <summary>Sets the values of the controls from a check's properties.</summary>
|
2
|
21 public override void LoadCheck(Check check1)
|
|
22 {
|
|
23 DiskSpaceCheck check = (DiskSpaceCheck)check1;
|
|
24 DeviceTextBox.Text = check.Device;
|
|
25 FreeSpaceTextBox.Text = check.MinFreeSpace.ToString();
|
|
26 FreeSpaceUnitsComboBox.SelectedIndex = (int)check.FreeSpaceUnits;
|
|
27 }
|
|
28
|
9
|
29 /// <summary>Updates the properties of a check from user input.</summary>
|
2
|
30 public override void UpdateCheck(Check check1)
|
|
31 {
|
|
32 DiskSpaceCheck check = (DiskSpaceCheck)check1;
|
|
33 check.Device = DeviceTextBox.Text.Trim();
|
|
34 check.FreeSpaceUnits = (FreeSpaceUnits)FreeSpaceUnitsComboBox.SelectedIndex;
|
|
35 try
|
|
36 {
|
|
37 check.MinFreeSpace = double.Parse(FreeSpaceTextBox.Text);
|
|
38 }
|
|
39 catch
|
|
40 {
|
|
41 check.MinFreeSpace = 0;
|
|
42 throw new UpdateCheckException("Free space must be numeric.");
|
|
43 }
|
|
44 }
|
|
45 }
|
9
|
46 }
|