annotate ServerMonitor/Forms/CheckForm.cs @ 23:3866c19535fd

Fix NullReferenceException when checks are executed on a brand new server.
author Brad Greco <brad@bgreco.net>
date Thu, 30 May 2019 21:40:27 -0400
parents 48044d9ac000
children e59ec1585616
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
7127d5b5ac75 Code cleanup and comments
Brad Greco <brad@bgreco.net>
parents: 8
diff changeset
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
7127d5b5ac75 Code cleanup and comments
Brad Greco <brad@bgreco.net>
parents: 8
diff changeset
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
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents: 1
diff changeset
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
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents: 1
diff changeset
68 SeverityComboBox.Items.AddRange(new object[] { CheckStatus.Error, CheckStatus.Warning, CheckStatus.Information });
22
48044d9ac000 Change default check interval from 5 seconds to 5 minutes.
Brad Greco <brad@bgreco.net>
parents: 16
diff changeset
69 SeverityComboBox.SelectedIndex = 1;
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));
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
71 Helpers.FormatImageButton(RunButton);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
72 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
73 Icon = Resources.icon;
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
74
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
75 // Bind event listeners.
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
76 Move += CheckForm_Move;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
77 CheckTypePanel.LocationChanged += CheckTypePanel_LocationChanged;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
78 GeneralGroupBox.Click += Control_Click;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
79 CheckSettingsPanel.Click += Control_Click;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
80
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
81 // 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
82 CheckTypeComboBox.SelectedItem = Check?.GetType();
8
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
83 SetTitle();
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
84 if (Check != null)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
85 LoadCheck(Check);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
86 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
87
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
88 /// <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
89 private void SetTitle()
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
90 {
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
91 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
92 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
93 }
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
94
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
95 /// <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
96 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
97 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
98 // 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
99 ShowCheckControl();
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
100 // 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
101 // 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
102 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
103 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
104
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
105 /// <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
106 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
107 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
108 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
109 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
110
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
111 /// <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
112 private void ShowCheckControl()
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
113 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
114 // 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
115 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
116 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
117 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
118 // 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
119 // 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
120 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
121 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
122 if (checkControl == null)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
123 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
124 // 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
125 checkControl = CheckControl.Create(type);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
126 if (checkControl != null)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
127 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
128 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
129 checkControl.Click += Control_Click;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
130 CheckSettingsPanel.Controls.Add(checkControl);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
131 }
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 if (checkControl != null)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
134 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
135 checkControl.Show();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
136 }
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
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
139 /// <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
140 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
141 {
8
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
142 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
143 NameTextBox.Text = Check.Name;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
144 EnabledCheckBox.Checked = check.Enabled;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
145 TimeoutInput.Value = check.Timeout;
4
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents: 1
diff changeset
146 SeverityComboBox.SelectedItem = check.FailStatus;
8
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
147 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
148 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
149 FrequencyUpDown.Value = check.Schedule.Frequency;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
150 StartTimePicker.Value = new DateTime(1970, 1, 1) + check.Schedule.StartTime;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
151 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
152 // 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
153 checkControl?.LoadCheck(check);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
154 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
155
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
156 /// <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
157 /// <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
158 /// <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
159 /// 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
160 /// 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
161 /// 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
162 /// </param>
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
163 /// <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
164 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
165 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
166 // 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
167 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
168 // 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
169 if (CheckTypeComboBox.SelectedIndex == -1)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
170 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
171 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
172 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
173 else
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
174 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
175 check.Id = CheckId;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
176 check.Server = server;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
177 check.Name = NameTextBox.Text;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
178 check.Enabled = EnabledCheckBox.Checked;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
179 check.Timeout = (int)TimeoutInput.Value;
4
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents: 1
diff changeset
180 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
181 check.MaxConsecutiveFailures = (int)FailuresInput.Value;
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
182 check.Schedule = new Schedule((FrequencyUnits)FrequencyUnitsComboBox.SelectedItem, (int)FrequencyUpDown.Value, StartTimePicker.Value.TimeOfDay, EndTimePicker.Value.TimeOfDay);
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
183 // 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
184 try
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
185 {
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
186 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
187 // 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
188 result = check.Validate(saving);
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
189 }
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
190 catch (UpdateCheckException e)
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
191 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
192 // 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
193 result = e.Message;
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
194 }
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
195 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
196 if (!result.IsNullOrEmpty())
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
197 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
198 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
199 return false;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
200 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
201 return true;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
202 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
203
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
204 /// <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
205 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
206 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
207 if (!UpdateCheck(workCheck))
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
208 return;
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
209 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
210 {
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
211 // 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
212 Check = workCheck;
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
213 }
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
214 else
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
215 {
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
216 // 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
217 // 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
218 // 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
219 UpdateCheck(Check);
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
220 }
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
221 UpdateCheck(Check);
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
222 server.UpdateCheck(Check);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
223 monitor.SaveServers();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
224 Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
225 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
226
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
227 /// <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
228 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
229 {
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>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
234 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
235 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
236 // 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
237 if (!UpdateCheck(workCheck, false))
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
238 return;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
239
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
240 // 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
241 RunButton.Enabled = false;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
242 RunButton.Text = "Running";
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
243 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
244 CancelRunButton.Visible = true;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
245
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
246 // 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
247 // 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
248 // 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
249 // 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
250 // again.
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
251 CancellationTokenSource localCancellationTokenSource = new CancellationTokenSource();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
252 cancellationTokenSource = localCancellationTokenSource;
16
7626b099aefd More comments.
Brad Greco <brad@bgreco.net>
parents: 15
diff changeset
253 // Do not update the check status or execution history when the check is run interactively.
7626b099aefd More comments.
Brad Greco <brad@bgreco.net>
parents: 15
diff changeset
254 // No need to pollute the history with manual executions that will likely fail as a
7626b099aefd More comments.
Brad Greco <brad@bgreco.net>
parents: 15
diff changeset
255 // 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
256 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
257 if (!localCancellationTokenSource.IsCancellationRequested)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
258 OnRunFinished(result);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
259 localCancellationTokenSource.Dispose();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
260 localCancellationTokenSource = null;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
261 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
262
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
263 /// <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
264 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
265 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
266 // 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
267 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
268 // 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
269 // 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
270 OnRunFinished();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
271 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
272
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
273 /// <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
274 /// <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
275 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
276 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
277 RunButton.Enabled = true;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
278 RunButton.Text = "Run";
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
279 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
280 // 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
281 if (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 ResultLabel.Text = result.Message;
8
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
284 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
285 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
286 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
287 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
288
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
289 /// <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
290 private string BuildHelpText()
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
291 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
292 // 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
293 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
294 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
295 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
296 // 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
297 // 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
298 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
299 .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
300 .AppendLine(@"\").AppendLine(@"\");
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
301 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
302 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
303 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
304
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
305 /// <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
306 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
307 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
308 if (helpShown)
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 helpForm.Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
311 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
312 else
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 helpForm = new QuickHelpForm(BuildHelpText());
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
315 helpForm.FormClosed += QuickHelpForm_FormClosed;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
316 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
317 // 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
318 Activate();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
319 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
320 // 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
321 OnHelpLocationChanged();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
322 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
323 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
324
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
325 /// <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
326 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
327 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
328 helpShown = false;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
329 helpForm.FormClosed -= QuickHelpForm_FormClosed;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
330 helpForm.Dispose();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
331 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
332
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
333 /// <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
334 private void OnHelpLocationChanged()
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
335 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
336 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
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>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
340 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
341 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
342 OnHelpLocationChanged();
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 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
346 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
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>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
352 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
353 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
354 if (helpShown)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
355 helpForm.Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
356 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
357
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
358 /// <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
359 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
360 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
361 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
362 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
363 helpForm.Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
364 return true;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
365 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
366 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
367 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
368
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
369 /// <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
370 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
371 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
372 // 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
373 // 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
374 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
375 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
376
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
377 /// <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
378 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
379 {
12
d92176c5398a Better display of schedule name.
Brad Greco <brad@bgreco.net>
parents: 9
diff changeset
380 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
381 }
8
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
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>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
384 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
385 {
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
386 SetTitle();
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
387 }
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
388 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
389
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
390 /// <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
391 public class HelpLocationChangedEventArgs : EventArgs
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
392 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
393 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
394
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
395 public HelpLocationChangedEventArgs(Point helpLocation)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
396 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
397 HelpLocation = helpLocation;
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 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
400 }