comparison ServerMonitor/Controls/FileCheckControl.cs @ 9:7127d5b5ac75

Code cleanup and comments
author Brad Greco <brad@bgreco.net>
date Mon, 08 Apr 2019 21:29:54 -0400
parents 96f0b028176d
children 832a07de0f90
comparison
equal deleted inserted replaced
8:052aa62cb42a 9:7127d5b5ac75
1 ´╗┐using System; 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 2
10 namespace ServerMonitorApp 3 namespace ServerMonitorApp
11 { 4 {
5 /// <summary>Control for editing a file check.</summary>
12 [CheckType(typeof(FileCheck))] 6 [CheckType(typeof(FileCheck))]
13 public partial class FileCheckControl : CheckControl 7 public partial class FileCheckControl : CheckControl
14 { 8 {
15 public FileCheckControl() 9 public FileCheckControl()
16 { 10 {
17 InitializeComponent(); 11 InitializeComponent();
18 } 12 }
19 13
20 private void DiskSpaceCheckControl_Load(object sender, EventArgs e) 14 private void DiskSpaceCheckControl_Load(object sender, EventArgs e)
21 { 15 {
16 // Initialize the combo boxes to non-empty values.
22 FileSizeComparisonComboBox.SelectedIndex = 0; 17 FileSizeComparisonComboBox.SelectedIndex = 0;
23 DateModifiedComparisonComboBox.SelectedIndex = 0; 18 DateModifiedComparisonComboBox.SelectedIndex = 0;
24 } 19 }
25 20
21 /// <summary>Sets the values of the controls from a check's properties.</summary>
26 public override void LoadCheck(Check check1) 22 public override void LoadCheck(Check check1)
27 { 23 {
28 FileCheck check = (FileCheck)check1; 24 FileCheck check = (FileCheck)check1;
29 FileTextBox.Text = check.File; 25 FileTextBox.Text = check.File;
30 FileSizeCheckBox.Checked = check.CheckFileSize; 26 FileSizeCheckBox.Checked = check.CheckFileSize;
34 DateModifiedCheckBox.Checked = check.CheckDateModified; 30 DateModifiedCheckBox.Checked = check.CheckDateModified;
35 DateModifiedComparisonComboBox.SelectedIndex = check.DateModifiedOlderThan ? 0 : 1; 31 DateModifiedComparisonComboBox.SelectedIndex = check.DateModifiedOlderThan ? 0 : 1;
36 DateModifiedTextBox.Text = check.DateModified.ToString(); 32 DateModifiedTextBox.Text = check.DateModified.ToString();
37 DateModifiedUnitsComboBox.SelectedIndex = (int)check.DateModifiedUnits; 33 DateModifiedUnitsComboBox.SelectedIndex = (int)check.DateModifiedUnits;
38 34
39 if (FileSizeTextBox.Text == "0") 35 // Blank out text boxes that are disabled and have a blank-looking value.
36 if (FileSizeTextBox.Text == "0" && !check.CheckFileSize)
40 FileSizeTextBox.Clear(); 37 FileSizeTextBox.Clear();
41 if (DateModifiedTextBox.Text == "0") 38 if (DateModifiedTextBox.Text == "0" && !check.CheckDateModified)
42 DateModifiedTextBox.Clear(); 39 DateModifiedTextBox.Clear();
43 } 40 }
44 41
42 /// <summary>Updates the properties of a check from user input.</summary>
45 public override void UpdateCheck(Check check1) 43 public override void UpdateCheck(Check check1)
46 { 44 {
47 FileCheck check = (FileCheck)check1; 45 FileCheck check = (FileCheck)check1;
48 check.File = FileTextBox.Text; 46 check.File = FileTextBox.Text;
49 check.CheckFileSize = FileSizeCheckBox.Checked; 47 check.CheckFileSize = FileSizeCheckBox.Checked;