Mercurial > servermonitor
comparison ServerMonitor/Controls/DiskSpaceCheckControl.cs @ 2:453ecc1ed9ea
Disk space check
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Sun, 06 Jan 2019 20:49:08 -0500 |
parents | |
children | 7127d5b5ac75 |
comparison
equal
deleted
inserted
replaced
1:9e92780ebc0f | 2:453ecc1ed9ea |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.ComponentModel; | |
4 using System.Drawing; | |
5 using System.Data; | |
6 using System.Linq; | |
7 using System.Text; | |
8 using System.Windows.Forms; | |
9 | |
10 namespace ServerMonitorApp | |
11 { | |
12 [CheckType(typeof(DiskSpaceCheck))] | |
13 public partial class DiskSpaceCheckControl : CheckControl | |
14 { | |
15 public DiskSpaceCheckControl() | |
16 { | |
17 InitializeComponent(); | |
18 } | |
19 | |
20 private void DiskSpaceCheckControl_Load(object sender, EventArgs e) | |
21 { | |
22 FreeSpaceUnitsComboBox.SelectedIndex = 1; | |
23 } | |
24 | |
25 public override void LoadCheck(Check check1) | |
26 { | |
27 DiskSpaceCheck check = (DiskSpaceCheck)check1; | |
28 DeviceTextBox.Text = check.Device; | |
29 FreeSpaceTextBox.Text = check.MinFreeSpace.ToString(); | |
30 FreeSpaceUnitsComboBox.SelectedIndex = (int)check.FreeSpaceUnits; | |
31 } | |
32 | |
33 public override void UpdateCheck(Check check1) | |
34 { | |
35 DiskSpaceCheck check = (DiskSpaceCheck)check1; | |
36 check.Device = DeviceTextBox.Text.Trim(); | |
37 check.FreeSpaceUnits = (FreeSpaceUnits)FreeSpaceUnitsComboBox.SelectedIndex; | |
38 try | |
39 { | |
40 check.MinFreeSpace = double.Parse(FreeSpaceTextBox.Text); | |
41 } | |
42 catch | |
43 { | |
44 check.MinFreeSpace = 0; | |
45 throw new UpdateCheckException("Free space must be numeric."); | |
46 } | |
47 } | |
48 } | |
49 } |