annotate ServerMonitor/Controls/DiskSpaceCheckControl.cs @ 7:8486ab7d2357

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