Mercurial > servermonitor
comparison ServerMonitor/Controls/FileCheckControl.cs @ 3:96f0b028176d
File check
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Fri, 11 Jan 2019 22:34:18 -0500 |
parents | |
children | 7127d5b5ac75 |
comparison
equal
deleted
inserted
replaced
2:453ecc1ed9ea | 3:96f0b028176d |
---|---|
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(FileCheck))] | |
13 public partial class FileCheckControl : CheckControl | |
14 { | |
15 public FileCheckControl() | |
16 { | |
17 InitializeComponent(); | |
18 } | |
19 | |
20 private void DiskSpaceCheckControl_Load(object sender, EventArgs e) | |
21 { | |
22 FileSizeComparisonComboBox.SelectedIndex = 0; | |
23 DateModifiedComparisonComboBox.SelectedIndex = 0; | |
24 } | |
25 | |
26 public override void LoadCheck(Check check1) | |
27 { | |
28 FileCheck check = (FileCheck)check1; | |
29 FileTextBox.Text = check.File; | |
30 FileSizeCheckBox.Checked = check.CheckFileSize; | |
31 FileSizeComparisonComboBox.SelectedIndex = check.FileSizeLessThan ? 0 : 1; | |
32 FileSizeTextBox.Text = check.FileSizeInSelectedUnits.ToString(); | |
33 FileSizeUnitsComboBox.SelectedIndex = (int)check.FileSizeUnits; | |
34 DateModifiedCheckBox.Checked = check.CheckDateModified; | |
35 DateModifiedComparisonComboBox.SelectedIndex = check.DateModifiedOlderThan ? 0 : 1; | |
36 DateModifiedTextBox.Text = check.DateModified.ToString(); | |
37 DateModifiedUnitsComboBox.SelectedIndex = (int)check.DateModifiedUnits; | |
38 | |
39 if (FileSizeTextBox.Text == "0") | |
40 FileSizeTextBox.Clear(); | |
41 if (DateModifiedTextBox.Text == "0") | |
42 DateModifiedTextBox.Clear(); | |
43 } | |
44 | |
45 public override void UpdateCheck(Check check1) | |
46 { | |
47 FileCheck check = (FileCheck)check1; | |
48 check.File = FileTextBox.Text; | |
49 check.CheckFileSize = FileSizeCheckBox.Checked; | |
50 check.FileSizeLessThan = FileSizeComparisonComboBox.SelectedIndex == 0; | |
51 try | |
52 { | |
53 check.FileSizeInSelectedUnits = double.Parse(FileSizeTextBox.Text); | |
54 } | |
55 catch | |
56 { | |
57 if (check.CheckFileSize) | |
58 throw new UpdateCheckException("File size must be numeric."); | |
59 else | |
60 check.FileSizeInSelectedUnits = 0; | |
61 } | |
62 check.FileSizeUnits = (SizeUnits)FileSizeUnitsComboBox.SelectedIndex; | |
63 check.CheckDateModified = DateModifiedCheckBox.Checked; | |
64 check.DateModifiedOlderThan = DateModifiedComparisonComboBox.SelectedIndex == 0; | |
65 try | |
66 { | |
67 check.DateModified = double.Parse(DateModifiedTextBox.Text); | |
68 } | |
69 catch | |
70 { | |
71 if (check.CheckDateModified) | |
72 throw new UpdateCheckException("Date modified must be numeric."); | |
73 else | |
74 check.DateModified = 0; | |
75 } | |
76 check.DateModifiedUnits = (TimeUnits)DateModifiedUnitsComboBox.SelectedIndex; | |
77 } | |
78 } | |
79 } |