Mercurial > servermonitor
comparison ServerMonitor/Controls/SshCheckControl.cs @ 9:7127d5b5ac75
Code cleanup and comments
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Mon, 08 Apr 2019 21:29:54 -0400 |
parents | 9e92780ebc0f |
children |
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 an SSH space check.</summary> | |
12 [CheckType(typeof(SshCheck))] | 6 [CheckType(typeof(SshCheck))] |
13 public partial class SshCheckControl : CheckControl | 7 public partial class SshCheckControl : CheckControl |
14 { | 8 { |
15 public SshCheckControl() | 9 public SshCheckControl() |
16 { | 10 { |
17 InitializeComponent(); | 11 InitializeComponent(); |
18 } | 12 } |
19 | 13 |
14 /// <summary>Sets the values of the controls from a check's properties.</summary> | |
20 public override void LoadCheck(Check check1) | 15 public override void LoadCheck(Check check1) |
21 { | 16 { |
22 SshCheck check = (SshCheck)check1; | 17 SshCheck check = (SshCheck)check1; |
23 CommandTextBox.Text = check.Command; | 18 CommandTextBox.Text = check.Command; |
24 ExitCodeCheckBox.Checked = check.CheckExitCode; | 19 ExitCodeCheckBox.Checked = check.CheckExitCode; |
27 CommandOutputComboBox.SelectedIndex = (int)check.CommandOutputMatchType; | 22 CommandOutputComboBox.SelectedIndex = (int)check.CommandOutputMatchType; |
28 CommandOutputTextBox.Text = check.CommandOutputPattern; | 23 CommandOutputTextBox.Text = check.CommandOutputPattern; |
29 CommandOutputRegexCheckBox.Checked = check.CommandOutputUseRegex; | 24 CommandOutputRegexCheckBox.Checked = check.CommandOutputUseRegex; |
30 } | 25 } |
31 | 26 |
27 /// <summary>Updates the properties of a check from user input.</summary> | |
32 public override void UpdateCheck(Check check1) | 28 public override void UpdateCheck(Check check1) |
33 { | 29 { |
34 SshCheck check = (SshCheck)check1; | 30 SshCheck check = (SshCheck)check1; |
35 check.Command = CommandTextBox.Text.Trim(); | 31 check.Command = CommandTextBox.Text.Trim(); |
36 check.CheckExitCode = ExitCodeCheckBox.Checked; | 32 check.CheckExitCode = ExitCodeCheckBox.Checked; |
53 } | 49 } |
54 check.CommandOutputPattern = CommandOutputTextBox.Text; | 50 check.CommandOutputPattern = CommandOutputTextBox.Text; |
55 check.CommandOutputUseRegex = CommandOutputRegexCheckBox.Checked; | 51 check.CommandOutputUseRegex = CommandOutputRegexCheckBox.Checked; |
56 } | 52 } |
57 | 53 |
54 /// <summary>Disables the regex checkbox if a numeric comparison is selected.</summary> | |
58 private void CommandOutputComboBox_SelectedIndexChanged(object sender, EventArgs e) | 55 private void CommandOutputComboBox_SelectedIndexChanged(object sender, EventArgs e) |
59 { | 56 { |
60 bool numeric = ((MatchType)CommandOutputComboBox.SelectedIndex).In(MatchType.GreaterThan, MatchType.LessThan); | 57 bool numeric = ((MatchType)CommandOutputComboBox.SelectedIndex).In(MatchType.GreaterThan, MatchType.LessThan); |
61 CommandOutputRegexCheckBox.Enabled = !numeric; | 58 CommandOutputRegexCheckBox.Enabled = !numeric; |
62 if (numeric) | 59 if (numeric) |