annotate ServerMonitor/Forms/CheckForm.cs @ 27:e59ec1585616

Fix bad commit intending to change default frequency that actually changed default severity.
author Brad Greco <brad@bgreco.net>
date Sun, 02 Jun 2019 17:51:30 -0400
parents 48044d9ac000
children 69e8ecdbbdd3
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 });
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
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents: 1
diff changeset
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;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
151 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
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
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents: 1
diff changeset
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;
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
183 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
184 // 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
185 try
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
186 {
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
187 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
188 // 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
189 result = check.Validate(saving);
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
190 }
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
191 catch (UpdateCheckException e)
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
192 {
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 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
194 result = e.Message;
9e92780ebc0f Additional validation for SSH check
Brad Greco <brad@bgreco.net>
parents: 0
diff changeset
195 }
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
196 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
197 if (!result.IsNullOrEmpty())
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
198 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
199 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
200 return false;
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 return true;
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
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
205 /// <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
206 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
207 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
208 if (!UpdateCheck(workCheck))
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
209 return;
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
210 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
211 {
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
212 // 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
213 Check = workCheck;
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
214 }
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
215 else
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 // 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
218 // 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
219 // 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
220 UpdateCheck(Check);
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 UpdateCheck(Check);
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
223 server.UpdateCheck(Check);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
224 monitor.SaveServers();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
225 Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
226 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
227
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
228 /// <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
229 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
230 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
231 Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
232 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
233
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
234 /// <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
235 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
236 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
237 // 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
238 if (!UpdateCheck(workCheck, false))
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
239 return;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
240
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
241 // 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
242 RunButton.Enabled = false;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
243 RunButton.Text = "Running";
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
244 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
245 CancelRunButton.Visible = true;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
246
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
247 // 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
248 // 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
249 // 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
250 // 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
251 // again.
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
252 CancellationTokenSource localCancellationTokenSource = new CancellationTokenSource();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
253 cancellationTokenSource = localCancellationTokenSource;
16
7626b099aefd More comments.
Brad Greco <brad@bgreco.net>
parents: 15
diff changeset
254 // 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
255 // 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
256 // 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
257 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
258 if (!localCancellationTokenSource.IsCancellationRequested)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
259 OnRunFinished(result);
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
260 localCancellationTokenSource.Dispose();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
261 localCancellationTokenSource = null;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
262 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
263
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
264 /// <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
265 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
266 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
267 // 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
268 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
269 // 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
270 // 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
271 OnRunFinished();
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
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
274 /// <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
275 /// <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
276 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
277 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
278 RunButton.Enabled = true;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
279 RunButton.Text = "Run";
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
280 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
281 // 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
282 if (result != null)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
283 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
284 ResultLabel.Text = result.Message;
8
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
285 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
286 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
287 }
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
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
290 /// <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
291 private string BuildHelpText()
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
292 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
293 // 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
294 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
295 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
296 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
297 // 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
298 // 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
299 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
300 .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
301 .AppendLine(@"\").AppendLine(@"\");
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
302 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
303 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
304 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
305
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
306 /// <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
307 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
308 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
309 if (helpShown)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
310 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
311 helpForm.Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
312 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
313 else
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
314 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
315 helpForm = new QuickHelpForm(BuildHelpText());
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
316 helpForm.FormClosed += QuickHelpForm_FormClosed;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
317 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
318 // 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
319 Activate();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
320 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
321 // 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
322 OnHelpLocationChanged();
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 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
325
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
326 /// <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
327 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
328 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
329 helpShown = false;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
330 helpForm.FormClosed -= QuickHelpForm_FormClosed;
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
331 helpForm.Dispose();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
332 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
333
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
334 /// <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
335 private void OnHelpLocationChanged()
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
336 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
337 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
338 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
339
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
340 /// <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
341 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
342 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
343 OnHelpLocationChanged();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
344 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
345
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
346 /// <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
347 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
348 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
349 OnHelpLocationChanged();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
350 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
351
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
352 /// <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
353 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
354 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
355 if (helpShown)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
356 helpForm.Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
357 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
358
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
359 /// <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
360 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
361 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
362 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
363 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
364 helpForm.Close();
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
365 return true;
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 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
368 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
369
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
370 /// <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
371 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
372 {
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
373 // 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
374 // 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
375 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
376 }
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 /// <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
379 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
380 {
12
d92176c5398a Better display of schedule name.
Brad Greco <brad@bgreco.net>
parents: 9
diff changeset
381 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
382 }
8
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
383
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
384 /// <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
385 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
386 {
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
387 SetTitle();
052aa62cb42a Single instance. Add autorun option. Add icons. General enhancements.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
388 }
0
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
389 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
390
15
23f2e0da1094 - Fix the last execution status being lost after a check is edited.
Brad Greco <brad@bgreco.net>
parents: 12
diff changeset
391 /// <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
392 public class HelpLocationChangedEventArgs : EventArgs
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
393 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
394 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
395
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
396 public HelpLocationChangedEventArgs(Point helpLocation)
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
397 {
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
398 HelpLocation = helpLocation;
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 }
3e1a2131f897 Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
Brad Greco <brad@bgreco.net>
parents:
diff changeset
401 }