Mercurial > servermonitor
annotate ServerMonitor/Forms/CheckForm.cs @ 40:c4fc74593a78 default tip
Mono fix
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Sat, 13 Jun 2020 13:28:20 -0400 |
parents | 69e8ecdbbdd3 |
children |
rev | line source |
---|---|
9 | 1 using System; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
2 using System.Collections.Generic; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
3 using System.ComponentModel; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
4 using System.Drawing; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
5 using System.Linq; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
6 using System.Text; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
7 using System.Threading; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
8 using System.Windows.Forms; |
9 | 9 using ServerMonitorApp.Properties; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
10 |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
11 namespace ServerMonitorApp |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
12 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
13 /// <summary>Form for creating and editing a check.</summary> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
14 /// <remarks> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
15 /// This form contains controls common to editing all types of checks. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
16 /// Additional controls for specific check types may be shown in a panel below. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
17 /// </remarks> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
18 public partial class CheckForm : Form |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
19 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
20 private bool helpShown; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
21 private CancellationTokenSource cancellationTokenSource; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
22 private Check workCheck; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
23 private CheckControl checkControl; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
24 private QuickHelpForm helpForm; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
25 private Server server; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
26 private ServerMonitor monitor; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
27 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
28 /// <summary>Raised when the Help button's location on the screen changes.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
29 public event EventHandler<HelpLocationChangedEventArgs> HelpLocationChanged; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
30 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
31 /// <summary>The check being edited by the form.</summary> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
32 /// <remarks>This check object is not updated with the form values until the OK button is clicked.</remarks> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
33 public Check Check { get; private set; } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
34 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
35 /// <summary>The ID of the check being edited.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
36 public int CheckId { get; private set; } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
37 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
38 /// <summary>The Help button's location on the screen.</summary> |
4 | 39 public Point HelpLocation => TypeHelpPictureBox.PointToScreen(Point.Empty); |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
40 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
41 /// <summary>Creates a check form to edit an existing check.</summary> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
42 /// <param name="monitor">The server monitor.</param> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
43 /// <param name="check">The check to edit.</param> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
44 public CheckForm(ServerMonitor monitor, Check check) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
45 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
46 InitializeComponent(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
47 |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
48 Check = check; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
49 CheckId = Check.Id; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
50 server = Check.Server; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
51 this.monitor = monitor; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
52 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
53 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
54 /// <summary>Creates a check form for creating a new check.</summary> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
55 /// <param name="monitor">The server monitor.</param> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
56 /// <param name="server">The server the new check will run on.</param> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
57 public CheckForm(ServerMonitor monitor, Server server) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
58 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
59 InitializeComponent(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
60 this.server = server; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
61 this.monitor = monitor; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
62 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
63 |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
64 private void CheckForm_Load(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
65 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
66 // Set up control default values. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
67 CheckTypeComboBox.Items.AddRange(Check.CheckTypes); |
4 | 68 SeverityComboBox.Items.AddRange(new object[] { CheckStatus.Error, CheckStatus.Warning, CheckStatus.Information }); |
27
e59ec1585616
Fix bad commit intending to change default frequency that actually changed default severity.
Brad Greco <brad@bgreco.net>
parents:
22
diff
changeset
|
69 SeverityComboBox.SelectedIndex = 0; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
70 FrequencyUnitsComboBox.DataSource = Enum.GetValues(typeof(FrequencyUnits)); |
27
e59ec1585616
Fix bad commit intending to change default frequency that actually changed default severity.
Brad Greco <brad@bgreco.net>
parents:
22
diff
changeset
|
71 FrequencyUnitsComboBox.SelectedIndex = 1; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
72 Helpers.FormatImageButton(RunButton); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
73 Helpers.FormatImageButton(CancelRunButton); |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
74 Icon = Resources.icon; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
75 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
76 // Bind event listeners. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
77 Move += CheckForm_Move; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
78 CheckTypePanel.LocationChanged += CheckTypePanel_LocationChanged; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
79 GeneralGroupBox.Click += Control_Click; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
80 CheckSettingsPanel.Click += Control_Click; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
81 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
82 // Set control values from the check. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
83 CheckTypeComboBox.SelectedItem = Check?.GetType(); |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
84 SetTitle(); |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
85 if (Check != null) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
86 LoadCheck(Check); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
87 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
88 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
89 /// <summary>Sets the form title from the check, or a default value for a new check.</summary> |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
90 private void SetTitle() |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
91 { |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
92 string name = NameTextBox.Text.IsNullOrEmpty() ? "New Check" : NameTextBox.Text; |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
93 Text = string.Format("{0}: {1}", server.Name, name); |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
94 } |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
95 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
96 /// <summary>Handles the check type combo box changing.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
97 private void CheckTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
98 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
99 // Show the check control for the selected check type. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
100 ShowCheckControl(); |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
101 // Create a temporary instance of the selected check type that will be used for validation |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
102 // and execution that can be discarded if the Cancel button is clicked. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
103 workCheck = (Check)Activator.CreateInstance((Type)CheckTypeComboBox.SelectedItem); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
104 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
105 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
106 /// <summary>Shows the display name of each check type in the combo box.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
107 private void CheckTypeComboBox_Format(object sender, ListControlConvertEventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
108 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
109 e.Value = Helpers.GetDisplayName((Type)e.ListItem); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
110 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
111 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
112 /// <summary>Shows a check control containing settings for the selected check type.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
113 private void ShowCheckControl() |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
114 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
115 // Hide the existing check control. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
116 IEnumerable<CheckControl> checkControls = CheckSettingsPanel.Controls.OfType<CheckControl>(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
117 foreach (CheckControl control in checkControls) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
118 control.Hide(); |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
119 // Show the check control for the selected check type if it has already been created. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
120 // Allows switching check types without losing data. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
121 Type type = (Type)CheckTypeComboBox.SelectedItem; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
122 checkControl = checkControls.FirstOrDefault(c => c.CheckType == type); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
123 if (checkControl == null) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
124 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
125 // Create a new check control if one has not been created yet for this check type. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
126 checkControl = CheckControl.Create(type); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
127 if (checkControl != null) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
128 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
129 checkControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
130 checkControl.Click += Control_Click; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
131 CheckSettingsPanel.Controls.Add(checkControl); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
132 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
133 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
134 if (checkControl != null) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
135 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
136 checkControl.Show(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
137 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
138 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
139 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
140 /// <summary>Populates common check controls from a check.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
141 private void LoadCheck(Check check) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
142 { |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
143 Icon = Check.LastRunStatus.GetIcon(); |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
144 NameTextBox.Text = Check.Name; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
145 EnabledCheckBox.Checked = check.Enabled; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
146 TimeoutInput.Value = check.Timeout; |
4 | 147 SeverityComboBox.SelectedItem = check.FailStatus; |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
148 FailuresInput.Value = check.MaxConsecutiveFailures; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
149 FrequencyUnitsComboBox.SelectedItem = check.Schedule.Units; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
150 FrequencyUpDown.Value = check.Schedule.Frequency; |
33
69e8ecdbbdd3
Fix schedule time not being saved on daily schedules.
Brad Greco <brad@bgreco.net>
parents:
27
diff
changeset
|
151 StartTimePicker.Value = AtTimePicker.Value = new DateTime(1970, 1, 1) + check.Schedule.StartTime; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
152 EndTimePicker.Value = new DateTime(1970, 1, 1) + check.Schedule.EndTime; |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
153 // Populate the controls specific to this check type. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
154 checkControl?.LoadCheck(check); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
155 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
156 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
157 /// <summary>Updates a check with user inputs.</summary> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
158 /// <param name="check">The check to be updated.</param> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
159 /// <param name="saving"> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
160 /// Whether the check is being saved. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
161 /// Checks are validated before being saved and before being executed. This parameter allows |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
162 /// them to distinguish between these cases. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
163 /// </param> |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
164 /// <returns>Whether the check was updated successfully.</returns> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
165 private bool UpdateCheck(Check check, bool saving = true) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
166 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
167 // The validation result message. An empty value indicates that validation succeeded. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
168 string result; |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
169 // Make sure we have a valid check type before doing anything else. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
170 if (CheckTypeComboBox.SelectedIndex == -1) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
171 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
172 result = "Check type cannot be blank."; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
173 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
174 else |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
175 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
176 check.Id = CheckId; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
177 check.Server = server; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
178 check.Name = NameTextBox.Text; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
179 check.Enabled = EnabledCheckBox.Checked; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
180 check.Timeout = (int)TimeoutInput.Value; |
4 | 181 check.FailStatus = (CheckStatus)SeverityComboBox.SelectedItem; |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
182 check.MaxConsecutiveFailures = (int)FailuresInput.Value; |
33
69e8ecdbbdd3
Fix schedule time not being saved on daily schedules.
Brad Greco <brad@bgreco.net>
parents:
27
diff
changeset
|
183 check.Schedule = new Schedule( |
69e8ecdbbdd3
Fix schedule time not being saved on daily schedules.
Brad Greco <brad@bgreco.net>
parents:
27
diff
changeset
|
184 (FrequencyUnits)FrequencyUnitsComboBox.SelectedItem, |
69e8ecdbbdd3
Fix schedule time not being saved on daily schedules.
Brad Greco <brad@bgreco.net>
parents:
27
diff
changeset
|
185 (int)FrequencyUpDown.Value, |
69e8ecdbbdd3
Fix schedule time not being saved on daily schedules.
Brad Greco <brad@bgreco.net>
parents:
27
diff
changeset
|
186 (FrequencyUnits)FrequencyUnitsComboBox.SelectedItem == FrequencyUnits.Day ? AtTimePicker.Value.TimeOfDay : StartTimePicker.Value.TimeOfDay, |
69e8ecdbbdd3
Fix schedule time not being saved on daily schedules.
Brad Greco <brad@bgreco.net>
parents:
27
diff
changeset
|
187 EndTimePicker.Value.TimeOfDay |
69e8ecdbbdd3
Fix schedule time not being saved on daily schedules.
Brad Greco <brad@bgreco.net>
parents:
27
diff
changeset
|
188 ); |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
189 // Attempt to update the check from the check control inputs. |
1
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
190 try |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
191 { |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
192 checkControl?.UpdateCheck(check); |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
193 // If the update succeeded, run the check's own validation. |
1
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
194 result = check.Validate(saving); |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
195 } |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
196 catch (UpdateCheckException e) |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
197 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
198 // If the update failed, set the validation message to the error message. |
1
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
199 result = e.Message; |
9e92780ebc0f
Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents:
0
diff
changeset
|
200 } |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
201 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
202 if (!result.IsNullOrEmpty()) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
203 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
204 MessageBox.Show(result, "Error validating check", MessageBoxButtons.OK, MessageBoxIcon.Error); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
205 return false; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
206 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
207 return true; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
208 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
209 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
210 /// <summary>Saves the check and closes the form.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
211 private void OkButton_Click(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
212 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
213 if (!UpdateCheck(workCheck)) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
214 return; |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
215 if (Check == null) |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
216 { |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
217 // If this is a new check, just use the check object created by this form. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
218 Check = workCheck; |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
219 } |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
220 else |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
221 { |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
222 // When editing an existing check, update it now that we know the validation will succeed. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
223 // Don't replace it with the temporary check object because the temporary check |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
224 // is not a complete copy; some properties are missing such as LastRunStatus. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
225 UpdateCheck(Check); |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
226 } |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
227 UpdateCheck(Check); |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
228 server.UpdateCheck(Check); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
229 monitor.SaveServers(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
230 Close(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
231 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
232 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
233 /// <summary>Cancels the form.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
234 private void CancelCheckButton_Click(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
235 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
236 Close(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
237 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
238 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
239 /// <summary>Executes the check with the current user inputs.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
240 private async void RunButton_Click(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
241 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
242 // If the the inputs are invalid, show the error and return. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
243 if (!UpdateCheck(workCheck, false)) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
244 return; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
245 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
246 // Update controls with the running status. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
247 RunButton.Enabled = false; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
248 RunButton.Text = "Running"; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
249 ResultLabel.Visible = ResultIconPictureBox.Visible = false; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
250 CancelRunButton.Visible = true; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
251 |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
252 // Create a CancellationTokenSource for this execution, and set it to both variables. |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
253 // localCancellationTokenSource will mantain a reference to the token for this execution, |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
254 // while cancellationTokenSource might end up referencing a different token if the Cancel |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
255 // button is clicked (but the Task itself is unable to be cancelled), then Run is clicked |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
256 // again. |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
257 CancellationTokenSource localCancellationTokenSource = new CancellationTokenSource(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
258 cancellationTokenSource = localCancellationTokenSource; |
16 | 259 // Do not update the check status or execution history when the check is run interactively. |
260 // No need to pollute the history with manual executions that will likely fail as a | |
261 // check is being configured. | |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
262 CheckResult result = await workCheck.ExecuteAsync(cancellationTokenSource.Token, false); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
263 if (!localCancellationTokenSource.IsCancellationRequested) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
264 OnRunFinished(result); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
265 localCancellationTokenSource.Dispose(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
266 localCancellationTokenSource = null; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
267 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
268 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
269 /// <summary>Cancels a check execution.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
270 private void CancelRunButton_Click(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
271 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
272 // Request the check to cancel. Some check types are not cancellable. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
273 cancellationTokenSource.Cancel(); |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
274 // Immediately update the UI so the user doesn't have to wait |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
275 // if a check is uncancellable. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
276 OnRunFinished(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
277 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
278 |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
279 /// <summary>Updates the UI after a check is finished running.</summary> |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
280 /// <param name="result">Result of the check execution. If null, the check was cancelled before it completed.</param> |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
281 private void OnRunFinished(CheckResult result = null) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
282 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
283 RunButton.Enabled = true; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
284 RunButton.Text = "Run"; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
285 CancelRunButton.Visible = false; |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
286 // If the check was not cancelled, show the results. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
287 if (result != null) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
288 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
289 ResultLabel.Text = result.Message; |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
290 ResultIconPictureBox.Image = result.CheckStatus.GetImage(); |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
291 ResultLabel.Visible = ResultIconPictureBox.Visible = true; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
292 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
293 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
294 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
295 /// <summary>Gathers the descriptions of all check types to show in the Help window.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
296 private string BuildHelpText() |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
297 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
298 // Build the string as RTF to allow bold text. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
299 StringBuilder rtf = new StringBuilder(@"{\rtf1\ansi "); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
300 foreach (Type checkType in Check.CheckTypes) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
301 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
302 // Show the check type name in bold, and the check type description. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
303 // Arguments to AppendLine() must end with a \ for the RichTextBox to render the newline character. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
304 rtf.Append(@"\b ").Append(Helpers.GetDisplayName(checkType)).AppendLine(@"\b0 \") |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
305 .Append(checkType.GetAttribute<DescriptionAttribute>()?.Description ?? "No description provided.") |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
306 .AppendLine(@"\").AppendLine(@"\"); |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
307 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
308 return rtf.ToString().TrimEnd(' ', '\r', '\n', '\\'); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
309 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
310 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
311 /// <summary>Shows or hides the Help popup window when the Help button is clicked.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
312 private void TypeHelpPictureBox_Click(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
313 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
314 if (helpShown) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
315 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
316 helpForm.Close(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
317 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
318 else |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
319 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
320 helpForm = new QuickHelpForm(BuildHelpText()); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
321 helpForm.FormClosed += QuickHelpForm_FormClosed; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
322 helpForm.Show(this); |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
323 // Keep focus on this form. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
324 Activate(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
325 helpShown = true; |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
326 // Trigger the location changed event so the popup will appear in the correct location. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
327 OnHelpLocationChanged(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
328 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
329 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
330 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
331 /// <summary>Handles the closing of the Help popup.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
332 private void QuickHelpForm_FormClosed(object sender, FormClosedEventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
333 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
334 helpShown = false; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
335 helpForm.FormClosed -= QuickHelpForm_FormClosed; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
336 helpForm.Dispose(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
337 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
338 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
339 /// <summary>Notifies event subscribers that the location of the Help button on the screen changed.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
340 private void OnHelpLocationChanged() |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
341 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
342 HelpLocationChanged?.Invoke(this, new HelpLocationChangedEventArgs(HelpLocation)); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
343 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
344 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
345 /// <summary>The Help button location changes if its panel location changes (such as when the window is resized).</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
346 private void CheckTypePanel_LocationChanged(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
347 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
348 OnHelpLocationChanged(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
349 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
350 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
351 /// <summary>The Help button location changes if the window is moved.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
352 private void CheckForm_Move(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
353 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
354 OnHelpLocationChanged(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
355 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
356 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
357 /// <summary>Closes the Help popup when another control is clicked.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
358 private void Control_Click(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
359 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
360 if (helpShown) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
361 helpForm.Close(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
362 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
363 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
364 /// <summary>Hides the Help popup when ESC is pressed.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
365 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
366 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
367 if (keyData == Keys.Escape && helpShown) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
368 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
369 helpForm.Close(); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
370 return true; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
371 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
372 return base.ProcessCmdKey(ref msg, keyData); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
373 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
374 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
375 /// <summary>Shows appropriate schedule controls depending on the time interval selected.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
376 private void FrequencyUnitsComboBox_SelectedIndexChanged(object sender, EventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
377 { |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
378 // Show a single time input for daily schedules. |
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
379 // For more frequent schedules, show a time range. |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
380 ScheduleBetweenPanel.Visible = !(ScheduleAtPanel.Visible = FrequencyUnitsComboBox.SelectedIndex == 3); |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
381 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
382 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
383 /// <summary>Formats the FrequencyUnits enum as a string.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
384 private void FrequencyUnitsComboBox_Format(object sender, ListControlConvertEventArgs e) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
385 { |
12
d92176c5398a
Better display of schedule name.
Brad Greco <brad@bgreco.net>
parents:
9
diff
changeset
|
386 e.Value = e.Value.ToString().ToLower() + "s"; |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
387 } |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
388 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
389 /// <summary>Updates the form title when the check's name is changed..</summary> |
8
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
390 private void NameTextBox_TextChanged(object sender, EventArgs e) |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
391 { |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
392 SetTitle(); |
052aa62cb42a
Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents:
4
diff
changeset
|
393 } |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
394 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
395 |
15
23f2e0da1094
- Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents:
12
diff
changeset
|
396 /// <summary>Event arguments containing the location of the Help button.</summary> |
0
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
397 public class HelpLocationChangedEventArgs : EventArgs |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
398 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
399 public Point HelpLocation { get; private set; } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
400 |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
401 public HelpLocationChangedEventArgs(Point helpLocation) |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
402 { |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
403 HelpLocation = helpLocation; |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
404 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
405 } |
3e1a2131f897
Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
406 } |