# HG changeset patch # User Brad Greco # Date 1552180443 18000 # Node ID 052aa62cb42a2a4b79e33a6bc72a979e8643d455 # Parent 8486ab7d2357b3475be9b836de8e0fccfd58dc7c Single instance. Add autorun option. Add icons. General enhancements. diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/App.config --- a/ServerMonitor/App.config Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/App.config Sat Mar 09 20:14:03 2019 -0500 @@ -29,6 +29,9 @@ 30 + + 0, 0 + diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Controls/DiskSpaceCheckControl.Designer.cs --- a/ServerMonitor/Controls/DiskSpaceCheckControl.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Controls/DiskSpaceCheckControl.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -78,7 +78,7 @@ this.FreeSpaceLabel.Name = "FreeSpaceLabel"; this.FreeSpaceLabel.Size = new System.Drawing.Size(110, 13); this.FreeSpaceLabel.TabIndex = 22; - this.FreeSpaceLabel.Text = "Free space is at least:"; + this.FreeSpaceLabel.Text = "Free &space is at least:"; // // FreeSpaceTextBox // @@ -96,7 +96,7 @@ this.DeviceLabel.Name = "DeviceLabel"; this.DeviceLabel.Size = new System.Drawing.Size(69, 13); this.DeviceLabel.TabIndex = 18; - this.DeviceLabel.Text = "File / device:"; + this.DeviceLabel.Text = "&File / device:"; // // DeviceTextBox // diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Controls/FileCheckControl.Designer.cs --- a/ServerMonitor/Controls/FileCheckControl.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Controls/FileCheckControl.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -36,10 +36,10 @@ this.FileLabel = new System.Windows.Forms.Label(); this.FileTextBox = new System.Windows.Forms.TextBox(); this.FileModifiedPanel = new System.Windows.Forms.Panel(); + this.DateModifiedUnitsComboBox = new ServerMonitorApp.TimeUnitsComboBox(); this.DateModifiedComparisonComboBox = new System.Windows.Forms.ComboBox(); this.DateModifiedCheckBox = new System.Windows.Forms.CheckBox(); this.DateModifiedTextBox = new System.Windows.Forms.TextBox(); - this.DateModifiedUnitsComboBox = new ServerMonitorApp.TimeUnitsComboBox(); this.CheckGroupBox.SuspendLayout(); this.FileSizePanel.SuspendLayout(); this.FileModifiedPanel.SuspendLayout(); @@ -73,13 +73,13 @@ this.FileSizeUnitsComboBox.FormattingEnabled = true; this.FileSizeUnitsComboBox.Items.AddRange(new object[] { "B", + "KB", "MB", - "KB", "GB"}); this.FileSizeUnitsComboBox.Location = new System.Drawing.Point(227, 4); this.FileSizeUnitsComboBox.Name = "FileSizeUnitsComboBox"; this.FileSizeUnitsComboBox.Size = new System.Drawing.Size(43, 21); - this.FileSizeUnitsComboBox.TabIndex = 26; + this.FileSizeUnitsComboBox.TabIndex = 27; // // FileSizeComparisonComboBox // @@ -100,7 +100,7 @@ this.FileSizeCheckBox.Name = "FileSizeCheckBox"; this.FileSizeCheckBox.Size = new System.Drawing.Size(63, 17); this.FileSizeCheckBox.TabIndex = 24; - this.FileSizeCheckBox.Text = "File size"; + this.FileSizeCheckBox.Text = "File &size"; this.FileSizeCheckBox.UseVisualStyleBackColor = true; // // FileSizeTextBox @@ -110,7 +110,7 @@ this.FileSizeTextBox.Location = new System.Drawing.Point(152, 4); this.FileSizeTextBox.Name = "FileSizeTextBox"; this.FileSizeTextBox.Size = new System.Drawing.Size(69, 20); - this.FileSizeTextBox.TabIndex = 7; + this.FileSizeTextBox.TabIndex = 26; // // FileLabel // @@ -118,8 +118,8 @@ this.FileLabel.Location = new System.Drawing.Point(6, 25); this.FileLabel.Name = "FileLabel"; this.FileLabel.Size = new System.Drawing.Size(26, 13); - this.FileLabel.TabIndex = 18; - this.FileLabel.Text = "File:"; + this.FileLabel.TabIndex = 17; + this.FileLabel.Text = "&File:"; // // FileTextBox // @@ -128,7 +128,7 @@ this.FileTextBox.Location = new System.Drawing.Point(38, 22); this.FileTextBox.Name = "FileTextBox"; this.FileTextBox.Size = new System.Drawing.Size(482, 20); - this.FileTextBox.TabIndex = 17; + this.FileTextBox.TabIndex = 18; this.FileTextBox.Text = "/"; // // FileModifiedPanel @@ -144,37 +144,6 @@ this.FileModifiedPanel.Size = new System.Drawing.Size(511, 28); this.FileModifiedPanel.TabIndex = 27; // - // DateModifiedComparisonComboBox - // - this.DateModifiedComparisonComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.DateModifiedComparisonComboBox.FormattingEnabled = true; - this.DateModifiedComparisonComboBox.Items.AddRange(new object[] { - "older than", - "newer than"}); - this.DateModifiedComparisonComboBox.Location = new System.Drawing.Point(91, 4); - this.DateModifiedComparisonComboBox.Name = "DateModifiedComparisonComboBox"; - this.DateModifiedComparisonComboBox.Size = new System.Drawing.Size(82, 21); - this.DateModifiedComparisonComboBox.TabIndex = 25; - // - // DateModifiedCheckBox - // - this.DateModifiedCheckBox.AutoSize = true; - this.DateModifiedCheckBox.Location = new System.Drawing.Point(0, 6); - this.DateModifiedCheckBox.Name = "DateModifiedCheckBox"; - this.DateModifiedCheckBox.Size = new System.Drawing.Size(91, 17); - this.DateModifiedCheckBox.TabIndex = 24; - this.DateModifiedCheckBox.Text = "Date modified"; - this.DateModifiedCheckBox.UseVisualStyleBackColor = true; - // - // DateModifiedTextBox - // - this.DateModifiedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.DateModifiedTextBox.Location = new System.Drawing.Point(179, 4); - this.DateModifiedTextBox.Name = "DateModifiedTextBox"; - this.DateModifiedTextBox.Size = new System.Drawing.Size(69, 20); - this.DateModifiedTextBox.TabIndex = 7; - // // DateModifiedUnitsComboBox // this.DateModifiedUnitsComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -186,7 +155,38 @@ this.DateModifiedUnitsComboBox.Location = new System.Drawing.Point(254, 4); this.DateModifiedUnitsComboBox.Name = "DateModifiedUnitsComboBox"; this.DateModifiedUnitsComboBox.Size = new System.Drawing.Size(60, 21); - this.DateModifiedUnitsComboBox.TabIndex = 26; + this.DateModifiedUnitsComboBox.TabIndex = 31; + // + // DateModifiedComparisonComboBox + // + this.DateModifiedComparisonComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.DateModifiedComparisonComboBox.FormattingEnabled = true; + this.DateModifiedComparisonComboBox.Items.AddRange(new object[] { + "older than", + "newer than"}); + this.DateModifiedComparisonComboBox.Location = new System.Drawing.Point(91, 4); + this.DateModifiedComparisonComboBox.Name = "DateModifiedComparisonComboBox"; + this.DateModifiedComparisonComboBox.Size = new System.Drawing.Size(82, 21); + this.DateModifiedComparisonComboBox.TabIndex = 29; + // + // DateModifiedCheckBox + // + this.DateModifiedCheckBox.AutoSize = true; + this.DateModifiedCheckBox.Location = new System.Drawing.Point(0, 6); + this.DateModifiedCheckBox.Name = "DateModifiedCheckBox"; + this.DateModifiedCheckBox.Size = new System.Drawing.Size(91, 17); + this.DateModifiedCheckBox.TabIndex = 28; + this.DateModifiedCheckBox.Text = "Date &modified"; + this.DateModifiedCheckBox.UseVisualStyleBackColor = true; + // + // DateModifiedTextBox + // + this.DateModifiedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.DateModifiedTextBox.Location = new System.Drawing.Point(179, 4); + this.DateModifiedTextBox.Name = "DateModifiedTextBox"; + this.DateModifiedTextBox.Size = new System.Drawing.Size(69, 20); + this.DateModifiedTextBox.TabIndex = 30; // // FileCheckControl // diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Controls/HttpCheckControl.Designer.cs --- a/ServerMonitor/Controls/HttpCheckControl.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Controls/HttpCheckControl.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -80,7 +80,7 @@ this.ResponseBodyRegexCheckBox.Location = new System.Drawing.Point(395, 6); this.ResponseBodyRegexCheckBox.Name = "ResponseBodyRegexCheckBox"; this.ResponseBodyRegexCheckBox.Size = new System.Drawing.Size(116, 17); - this.ResponseBodyRegexCheckBox.TabIndex = 9; + this.ResponseBodyRegexCheckBox.TabIndex = 17; this.ResponseBodyRegexCheckBox.Text = "Regular expression"; this.ResponseBodyRegexCheckBox.UseVisualStyleBackColor = true; // @@ -89,14 +89,16 @@ this.ResponseBodyComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.ResponseBodyComboBox.FormattingEnabled = true; this.ResponseBodyComboBox.Items.AddRange(new object[] { + "equals", + "does not equal", "contains", "does not contain", - "contains", - "does not contain"}); + "is greater than", + "is less than"}); this.ResponseBodyComboBox.Location = new System.Drawing.Point(98, 4); this.ResponseBodyComboBox.Name = "ResponseBodyComboBox"; this.ResponseBodyComboBox.Size = new System.Drawing.Size(110, 21); - this.ResponseBodyComboBox.TabIndex = 8; + this.ResponseBodyComboBox.TabIndex = 14; // // ResponseBodyCheckBox // @@ -104,8 +106,8 @@ this.ResponseBodyCheckBox.Location = new System.Drawing.Point(0, 6); this.ResponseBodyCheckBox.Name = "ResponseBodyCheckBox"; this.ResponseBodyCheckBox.Size = new System.Drawing.Size(100, 17); - this.ResponseBodyCheckBox.TabIndex = 4; - this.ResponseBodyCheckBox.Text = "Response body"; + this.ResponseBodyCheckBox.TabIndex = 13; + this.ResponseBodyCheckBox.Text = "Response &body"; this.ResponseBodyCheckBox.UseVisualStyleBackColor = true; // // ResponseBodyTextBox @@ -115,7 +117,7 @@ this.ResponseBodyTextBox.Location = new System.Drawing.Point(214, 4); this.ResponseBodyTextBox.Name = "ResponseBodyTextBox"; this.ResponseBodyTextBox.Size = new System.Drawing.Size(175, 20); - this.ResponseBodyTextBox.TabIndex = 7; + this.ResponseBodyTextBox.TabIndex = 16; // // ResponseLengthPanel // @@ -137,8 +139,8 @@ this.ResponseLengthCheckbox.Location = new System.Drawing.Point(0, 6); this.ResponseLengthCheckbox.Name = "ResponseLengthCheckbox"; this.ResponseLengthCheckbox.Size = new System.Drawing.Size(150, 17); - this.ResponseLengthCheckbox.TabIndex = 5; - this.ResponseLengthCheckbox.Text = "Response length between"; + this.ResponseLengthCheckbox.TabIndex = 10; + this.ResponseLengthCheckbox.Text = "Response &length between"; this.ResponseLengthCheckbox.UseVisualStyleBackColor = true; // // ResponseLengthMaxTextBox @@ -146,7 +148,7 @@ this.ResponseLengthMaxTextBox.Location = new System.Drawing.Point(228, 4); this.ResponseLengthMaxTextBox.Name = "ResponseLengthMaxTextBox"; this.ResponseLengthMaxTextBox.Size = new System.Drawing.Size(44, 20); - this.ResponseLengthMaxTextBox.TabIndex = 8; + this.ResponseLengthMaxTextBox.TabIndex = 12; this.ResponseLengthMaxTextBox.Text = "200"; // // ResponseLengthKbLabel @@ -163,7 +165,7 @@ this.ResponseLengthMinTextBox.Location = new System.Drawing.Point(151, 4); this.ResponseLengthMinTextBox.Name = "ResponseLengthMinTextBox"; this.ResponseLengthMinTextBox.Size = new System.Drawing.Size(44, 20); - this.ResponseLengthMinTextBox.TabIndex = 9; + this.ResponseLengthMinTextBox.TabIndex = 11; this.ResponseLengthMinTextBox.Text = "100"; // // ResponseLengthAndLabel @@ -190,8 +192,8 @@ this.ResponseCodeCheckBox.Location = new System.Drawing.Point(0, 6); this.ResponseCodeCheckBox.Name = "ResponseCodeCheckBox"; this.ResponseCodeCheckBox.Size = new System.Drawing.Size(135, 17); - this.ResponseCodeCheckBox.TabIndex = 4; - this.ResponseCodeCheckBox.Text = "Response code equals"; + this.ResponseCodeCheckBox.TabIndex = 8; + this.ResponseCodeCheckBox.Text = "Response &code equals"; this.ResponseCodeCheckBox.UseVisualStyleBackColor = true; // // ResponseCodeTextBox @@ -199,7 +201,7 @@ this.ResponseCodeTextBox.Location = new System.Drawing.Point(136, 4); this.ResponseCodeTextBox.Name = "ResponseCodeTextBox"; this.ResponseCodeTextBox.Size = new System.Drawing.Size(39, 20); - this.ResponseCodeTextBox.TabIndex = 7; + this.ResponseCodeTextBox.TabIndex = 9; this.ResponseCodeTextBox.Text = "200"; // // HttpUrlLabel @@ -208,8 +210,8 @@ this.HttpUrlLabel.Location = new System.Drawing.Point(6, 25); this.HttpUrlLabel.Name = "HttpUrlLabel"; this.HttpUrlLabel.Size = new System.Drawing.Size(32, 13); - this.HttpUrlLabel.TabIndex = 18; - this.HttpUrlLabel.Text = "URL:"; + this.HttpUrlLabel.TabIndex = 17; + this.HttpUrlLabel.Text = "&URL:"; // // UrlTextBox // @@ -218,12 +220,13 @@ this.UrlTextBox.Location = new System.Drawing.Point(44, 22); this.UrlTextBox.Name = "UrlTextBox"; this.UrlTextBox.Size = new System.Drawing.Size(476, 20); - this.UrlTextBox.TabIndex = 17; + this.UrlTextBox.TabIndex = 18; // // HttpCheckControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.Control; this.Name = "HttpCheckControl"; this.Size = new System.Drawing.Size(526, 142); this.CheckGroupBox.ResumeLayout(false); diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Controls/ServerSummaryControl.cs --- a/ServerMonitor/Controls/ServerSummaryControl.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Controls/ServerSummaryControl.cs Sat Mar 09 20:14:03 2019 -0500 @@ -27,12 +27,12 @@ Server = server; ServerNameLabel.Text = Server.Name; StatusPictureBox.Parent = ServerPictureBox; - StatusPictureBox.Image = Server.Status.GetIcon(); + StatusPictureBox.Image = Server.Status.GetImage(); } public override void Refresh() { - StatusPictureBox.Image = Server.Status.GetIcon(); + StatusPictureBox.Image = Server.Status.GetImage(); base.Refresh(); } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Controls/SshCheckControl.Designer.cs --- a/ServerMonitor/Controls/SshCheckControl.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Controls/SshCheckControl.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -72,7 +72,7 @@ this.CommandOutputRegexCheckBox.Location = new System.Drawing.Point(395, 6); this.CommandOutputRegexCheckBox.Name = "CommandOutputRegexCheckBox"; this.CommandOutputRegexCheckBox.Size = new System.Drawing.Size(116, 17); - this.CommandOutputRegexCheckBox.TabIndex = 9; + this.CommandOutputRegexCheckBox.TabIndex = 24; this.CommandOutputRegexCheckBox.Text = "Regular expression"; this.CommandOutputRegexCheckBox.UseVisualStyleBackColor = true; // @@ -90,7 +90,7 @@ this.CommandOutputComboBox.Location = new System.Drawing.Point(106, 4); this.CommandOutputComboBox.Name = "CommandOutputComboBox"; this.CommandOutputComboBox.Size = new System.Drawing.Size(110, 21); - this.CommandOutputComboBox.TabIndex = 8; + this.CommandOutputComboBox.TabIndex = 22; this.CommandOutputComboBox.SelectedIndexChanged += new System.EventHandler(this.CommandOutputComboBox_SelectedIndexChanged); // // CommandOutputCheckBox @@ -99,8 +99,8 @@ this.CommandOutputCheckBox.Location = new System.Drawing.Point(0, 6); this.CommandOutputCheckBox.Name = "CommandOutputCheckBox"; this.CommandOutputCheckBox.Size = new System.Drawing.Size(106, 17); - this.CommandOutputCheckBox.TabIndex = 4; - this.CommandOutputCheckBox.Text = "Command output"; + this.CommandOutputCheckBox.TabIndex = 20; + this.CommandOutputCheckBox.Text = "Command &output"; this.CommandOutputCheckBox.UseVisualStyleBackColor = true; // // CommandOutputTextBox @@ -110,7 +110,7 @@ this.CommandOutputTextBox.Location = new System.Drawing.Point(222, 4); this.CommandOutputTextBox.Name = "CommandOutputTextBox"; this.CommandOutputTextBox.Size = new System.Drawing.Size(167, 20); - this.CommandOutputTextBox.TabIndex = 7; + this.CommandOutputTextBox.TabIndex = 23; // // ResponseCodePanel // @@ -127,8 +127,8 @@ this.ExitCodeCheckBox.Location = new System.Drawing.Point(0, 6); this.ExitCodeCheckBox.Name = "ExitCodeCheckBox"; this.ExitCodeCheckBox.Size = new System.Drawing.Size(104, 17); - this.ExitCodeCheckBox.TabIndex = 4; - this.ExitCodeCheckBox.Text = "Exit code equals"; + this.ExitCodeCheckBox.TabIndex = 18; + this.ExitCodeCheckBox.Text = "E&xit code equals"; this.ExitCodeCheckBox.UseVisualStyleBackColor = true; // // ExitCodeTextBox @@ -136,7 +136,7 @@ this.ExitCodeTextBox.Location = new System.Drawing.Point(104, 4); this.ExitCodeTextBox.Name = "ExitCodeTextBox"; this.ExitCodeTextBox.Size = new System.Drawing.Size(39, 20); - this.ExitCodeTextBox.TabIndex = 7; + this.ExitCodeTextBox.TabIndex = 19; this.ExitCodeTextBox.Text = "0"; // // CommandLabel @@ -145,8 +145,8 @@ this.CommandLabel.Location = new System.Drawing.Point(6, 25); this.CommandLabel.Name = "CommandLabel"; this.CommandLabel.Size = new System.Drawing.Size(57, 13); - this.CommandLabel.TabIndex = 18; - this.CommandLabel.Text = "Command:"; + this.CommandLabel.TabIndex = 17; + this.CommandLabel.Text = "&Command:"; // // CommandTextBox // @@ -155,7 +155,7 @@ this.CommandTextBox.Location = new System.Drawing.Point(68, 22); this.CommandTextBox.Name = "CommandTextBox"; this.CommandTextBox.Size = new System.Drawing.Size(452, 20); - this.CommandTextBox.TabIndex = 17; + this.CommandTextBox.TabIndex = 18; // // SshCheckControl // diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/CheckForm.Designer.cs --- a/ServerMonitor/Forms/CheckForm.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/CheckForm.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -33,6 +33,9 @@ this.CheckTypePanel = new System.Windows.Forms.Panel(); this.TypeHelpPictureBox = new System.Windows.Forms.PictureBox(); this.GeneralGroupBox = new System.Windows.Forms.GroupBox(); + this.FailuresLabel = new System.Windows.Forms.Label(); + this.FailuresInput = new System.Windows.Forms.NumericUpDown(); + this.AfterLabel = new System.Windows.Forms.Label(); this.SeverityComboBox = new System.Windows.Forms.ComboBox(); this.SeverityLabel = new System.Windows.Forms.Label(); this.ScheduleAtPanel = new System.Windows.Forms.Panel(); @@ -62,6 +65,7 @@ this.CheckTypePanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.TypeHelpPictureBox)).BeginInit(); this.GeneralGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.FailuresInput)).BeginInit(); this.ScheduleAtPanel.SuspendLayout(); this.ScheduleBetweenPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.FrequencyUpDown)).BeginInit(); @@ -76,7 +80,7 @@ this.CheckTypeLabel.Name = "CheckTypeLabel"; this.CheckTypeLabel.Size = new System.Drawing.Size(64, 13); this.CheckTypeLabel.TabIndex = 0; - this.CheckTypeLabel.Text = "Check type:"; + this.CheckTypeLabel.Text = "Check &type:"; // // CheckTypeComboBox // @@ -95,7 +99,7 @@ this.CheckTypePanel.Controls.Add(this.CheckTypeLabel); this.CheckTypePanel.Controls.Add(this.TypeHelpPictureBox); this.CheckTypePanel.Controls.Add(this.CheckTypeComboBox); - this.CheckTypePanel.Location = new System.Drawing.Point(167, 12); + this.CheckTypePanel.Location = new System.Drawing.Point(162, 12); this.CheckTypePanel.Name = "CheckTypePanel"; this.CheckTypePanel.Size = new System.Drawing.Size(227, 26); this.CheckTypePanel.TabIndex = 1; @@ -116,6 +120,9 @@ // this.GeneralGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.GeneralGroupBox.Controls.Add(this.FailuresLabel); + this.GeneralGroupBox.Controls.Add(this.FailuresInput); + this.GeneralGroupBox.Controls.Add(this.AfterLabel); this.GeneralGroupBox.Controls.Add(this.SeverityComboBox); this.GeneralGroupBox.Controls.Add(this.SeverityLabel); this.GeneralGroupBox.Controls.Add(this.ScheduleAtPanel); @@ -131,11 +138,51 @@ this.GeneralGroupBox.Controls.Add(this.EnabledCheckBox); this.GeneralGroupBox.Location = new System.Drawing.Point(12, 39); this.GeneralGroupBox.Name = "GeneralGroupBox"; - this.GeneralGroupBox.Size = new System.Drawing.Size(537, 135); + this.GeneralGroupBox.Size = new System.Drawing.Size(526, 135); this.GeneralGroupBox.TabIndex = 2; this.GeneralGroupBox.TabStop = false; this.GeneralGroupBox.Text = "General settings"; // + // FailuresLabel + // + this.FailuresLabel.AutoSize = true; + this.FailuresLabel.Location = new System.Drawing.Point(251, 109); + this.FailuresLabel.Name = "FailuresLabel"; + this.FailuresLabel.Size = new System.Drawing.Size(101, 13); + this.FailuresLabel.TabIndex = 37; + this.FailuresLabel.Text = "consecutive failures"; + // + // FailuresInput + // + this.FailuresInput.Location = new System.Drawing.Point(211, 107); + this.FailuresInput.Maximum = new decimal(new int[] { + 99, + 0, + 0, + 0}); + this.FailuresInput.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.FailuresInput.Name = "FailuresInput"; + this.FailuresInput.Size = new System.Drawing.Size(34, 20); + this.FailuresInput.TabIndex = 36; + this.FailuresInput.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // AfterLabel + // + this.AfterLabel.AutoSize = true; + this.AfterLabel.Location = new System.Drawing.Point(180, 109); + this.AfterLabel.Name = "AfterLabel"; + this.AfterLabel.Size = new System.Drawing.Size(28, 13); + this.AfterLabel.TabIndex = 35; + this.AfterLabel.Text = "after"; + // // SeverityComboBox // this.SeverityComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -152,7 +199,7 @@ this.SeverityLabel.Name = "SeverityLabel"; this.SeverityLabel.Size = new System.Drawing.Size(80, 13); this.SeverityLabel.TabIndex = 33; - this.SeverityLabel.Text = "Failure severity:"; + this.SeverityLabel.Text = "Failure se&verity:"; // // ScheduleAtPanel // @@ -160,7 +207,7 @@ this.ScheduleAtPanel.Controls.Add(this.ScheduleAtLabel); this.ScheduleAtPanel.Location = new System.Drawing.Point(258, 76); this.ScheduleAtPanel.Name = "ScheduleAtPanel"; - this.ScheduleAtPanel.Size = new System.Drawing.Size(270, 29); + this.ScheduleAtPanel.Size = new System.Drawing.Size(265, 29); this.ScheduleAtPanel.TabIndex = 32; this.ScheduleAtPanel.Visible = false; // @@ -191,7 +238,7 @@ this.ScheduleBetweenPanel.Controls.Add(this.ScheduleBetweenLabel); this.ScheduleBetweenPanel.Location = new System.Drawing.Point(258, 76); this.ScheduleBetweenPanel.Name = "ScheduleBetweenPanel"; - this.ScheduleBetweenPanel.Size = new System.Drawing.Size(270, 29); + this.ScheduleBetweenPanel.Size = new System.Drawing.Size(265, 29); this.ScheduleBetweenPanel.TabIndex = 31; // // ScheduleBetweenAndLabel @@ -249,8 +296,8 @@ this.ScheduleEveryLabel.Location = new System.Drawing.Point(89, 82); this.ScheduleEveryLabel.Name = "ScheduleEveryLabel"; this.ScheduleEveryLabel.Size = new System.Drawing.Size(34, 13); - this.ScheduleEveryLabel.TabIndex = 29; - this.ScheduleEveryLabel.Text = "Every"; + this.ScheduleEveryLabel.TabIndex = 27; + this.ScheduleEveryLabel.Text = "&Every"; // // FrequencyUpDown // @@ -289,7 +336,7 @@ 0}); this.TimeoutInput.Name = "TimeoutInput"; this.TimeoutInput.Size = new System.Drawing.Size(58, 20); - this.TimeoutInput.TabIndex = 27; + this.TimeoutInput.TabIndex = 25; this.TimeoutInput.Value = new decimal(new int[] { 5000, 0, @@ -302,8 +349,8 @@ this.PingTimeoutLabel.Location = new System.Drawing.Point(6, 56); this.PingTimeoutLabel.Name = "PingTimeoutLabel"; this.PingTimeoutLabel.Size = new System.Drawing.Size(70, 13); - this.PingTimeoutLabel.TabIndex = 26; - this.PingTimeoutLabel.Text = "Timeout (ms):"; + this.PingTimeoutLabel.TabIndex = 24; + this.PingTimeoutLabel.Text = "&Timeout (ms):"; // // ScheduleLabel // @@ -311,7 +358,7 @@ this.ScheduleLabel.Location = new System.Drawing.Point(6, 82); this.ScheduleLabel.Name = "ScheduleLabel"; this.ScheduleLabel.Size = new System.Drawing.Size(55, 13); - this.ScheduleLabel.TabIndex = 25; + this.ScheduleLabel.TabIndex = 26; this.ScheduleLabel.Text = "Schedule:"; // // NameLabel @@ -321,7 +368,7 @@ this.NameLabel.Name = "NameLabel"; this.NameLabel.Size = new System.Drawing.Size(38, 13); this.NameLabel.TabIndex = 21; - this.NameLabel.Text = "Name:"; + this.NameLabel.Text = "&Name:"; // // NameTextBox // @@ -329,6 +376,7 @@ this.NameTextBox.Name = "NameTextBox"; this.NameTextBox.Size = new System.Drawing.Size(181, 20); this.NameTextBox.TabIndex = 22; + this.NameTextBox.TextChanged += new System.EventHandler(this.NameTextBox_TextChanged); // // EnabledCheckBox // @@ -339,17 +387,17 @@ this.EnabledCheckBox.Name = "EnabledCheckBox"; this.EnabledCheckBox.Size = new System.Drawing.Size(65, 17); this.EnabledCheckBox.TabIndex = 23; - this.EnabledCheckBox.Text = "Enabled"; + this.EnabledCheckBox.Text = "&Enabled"; this.EnabledCheckBox.UseVisualStyleBackColor = true; // // OkButton // this.OkButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OkButton.Location = new System.Drawing.Point(393, 397); + this.OkButton.Location = new System.Drawing.Point(382, 334); this.OkButton.Name = "OkButton"; this.OkButton.Size = new System.Drawing.Size(75, 23); - this.OkButton.TabIndex = 20; + this.OkButton.TabIndex = 101; this.OkButton.Text = "OK"; this.OkButton.UseVisualStyleBackColor = true; this.OkButton.Click += new System.EventHandler(this.OkButton_Click); @@ -358,10 +406,10 @@ // this.CancelCheckButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.CancelCheckButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelCheckButton.Location = new System.Drawing.Point(474, 397); + this.CancelCheckButton.Location = new System.Drawing.Point(463, 334); this.CancelCheckButton.Name = "CancelCheckButton"; this.CancelCheckButton.Size = new System.Drawing.Size(75, 23); - this.CancelCheckButton.TabIndex = 19; + this.CancelCheckButton.TabIndex = 102; this.CancelCheckButton.Text = "Cancel"; this.CancelCheckButton.UseVisualStyleBackColor = true; this.CancelCheckButton.Click += new System.EventHandler(this.CancelCheckButton_Click); @@ -371,9 +419,10 @@ this.CheckSettingsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.CheckSettingsPanel.BackColor = System.Drawing.SystemColors.Control; this.CheckSettingsPanel.Location = new System.Drawing.Point(12, 180); this.CheckSettingsPanel.Name = "CheckSettingsPanel"; - this.CheckSettingsPanel.Size = new System.Drawing.Size(537, 211); + this.CheckSettingsPanel.Size = new System.Drawing.Size(526, 148); this.CheckSettingsPanel.TabIndex = 27; // // ResultLabel @@ -381,9 +430,9 @@ this.ResultLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.ResultLabel.AutoEllipsis = true; - this.ResultLabel.Location = new System.Drawing.Point(115, 394); + this.ResultLabel.Location = new System.Drawing.Point(115, 331); this.ResultLabel.Name = "ResultLabel"; - this.ResultLabel.Size = new System.Drawing.Size(272, 29); + this.ResultLabel.Size = new System.Drawing.Size(261, 29); this.ResultLabel.TabIndex = 29; this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.ResultLabel.Visible = false; @@ -391,7 +440,7 @@ // ResultIconPictureBox // this.ResultIconPictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.ResultIconPictureBox.Location = new System.Drawing.Point(93, 399); + this.ResultIconPictureBox.Location = new System.Drawing.Point(93, 336); this.ResultIconPictureBox.Name = "ResultIconPictureBox"; this.ResultIconPictureBox.Size = new System.Drawing.Size(20, 20); this.ResultIconPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -403,7 +452,7 @@ // this.CancelRunButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.CancelRunButton.Image = global::ServerMonitorApp.Properties.Resources.delete; - this.CancelRunButton.Location = new System.Drawing.Point(93, 397); + this.CancelRunButton.Location = new System.Drawing.Point(93, 334); this.CancelRunButton.Name = "CancelRunButton"; this.CancelRunButton.Size = new System.Drawing.Size(75, 23); this.CancelRunButton.TabIndex = 28; @@ -417,10 +466,10 @@ // this.RunButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.RunButton.Image = global::ServerMonitorApp.Properties.Resources.run; - this.RunButton.Location = new System.Drawing.Point(12, 397); + this.RunButton.Location = new System.Drawing.Point(12, 334); this.RunButton.Name = "RunButton"; this.RunButton.Size = new System.Drawing.Size(75, 23); - this.RunButton.TabIndex = 26; + this.RunButton.TabIndex = 100; this.RunButton.Text = "Run"; this.RunButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.RunButton.UseVisualStyleBackColor = true; @@ -432,7 +481,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.CancelCheckButton; - this.ClientSize = new System.Drawing.Size(561, 432); + this.ClientSize = new System.Drawing.Size(550, 369); this.Controls.Add(this.ResultIconPictureBox); this.Controls.Add(this.ResultLabel); this.Controls.Add(this.CancelRunButton); @@ -442,9 +491,11 @@ this.Controls.Add(this.CancelCheckButton); this.Controls.Add(this.GeneralGroupBox); this.Controls.Add(this.CheckTypePanel); - this.MinimumSize = new System.Drawing.Size(550, 38); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimumSize = new System.Drawing.Size(566, 407); this.Name = "CheckForm"; - this.Text = "CheckForm"; + this.Text = "New Check"; this.Load += new System.EventHandler(this.CheckForm_Load); this.Click += new System.EventHandler(this.Control_Click); this.CheckTypePanel.ResumeLayout(false); @@ -452,6 +503,7 @@ ((System.ComponentModel.ISupportInitialize)(this.TypeHelpPictureBox)).EndInit(); this.GeneralGroupBox.ResumeLayout(false); this.GeneralGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.FailuresInput)).EndInit(); this.ScheduleAtPanel.ResumeLayout(false); this.ScheduleAtPanel.PerformLayout(); this.ScheduleBetweenPanel.ResumeLayout(false); @@ -496,5 +548,8 @@ private System.Windows.Forms.Label ScheduleAtLabel; private System.Windows.Forms.ComboBox SeverityComboBox; private System.Windows.Forms.Label SeverityLabel; + private System.Windows.Forms.Label AfterLabel; + private System.Windows.Forms.NumericUpDown FailuresInput; + private System.Windows.Forms.Label FailuresLabel; } } \ No newline at end of file diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/CheckForm.cs --- a/ServerMonitor/Forms/CheckForm.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/CheckForm.cs Sat Mar 09 20:14:03 2019 -0500 @@ -1,4 +1,5 @@ -using System; +using ServerMonitorApp.Properties; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -62,10 +63,18 @@ CheckSettingsPanel.Click += Control_Click; CheckTypeComboBox.SelectedItem = Check?.GetType(); + SetTitle(); + Icon = Resources.icon; if (Check != null) LoadCheck(Check); } + private void SetTitle() + { + string name = NameTextBox.Text.IsNullOrEmpty() ? "New Check" : NameTextBox.Text; + Text = string.Format("{0}: {1}", server.Name, name); + } + private void CheckTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { ShowCheckControl(); @@ -106,7 +115,7 @@ } if (checkControl != null) { - CheckSettingsPanel.Height = checkControl.Height; + //CheckSettingsPanel.Height = checkControl.Height; //Height = 230 + checkControl.Height; checkControl.Show(); } @@ -114,10 +123,12 @@ private void LoadCheck(Check check) { + Icon = Check.LastRunStatus.GetIcon(); NameTextBox.Text = Check.Name; EnabledCheckBox.Checked = check.Enabled; TimeoutInput.Value = check.Timeout; SeverityComboBox.SelectedItem = check.FailStatus; + FailuresInput.Value = check.MaxConsecutiveFailures; FrequencyUnitsComboBox.SelectedItem = check.Schedule.Units; FrequencyUpDown.Value = check.Schedule.Frequency; StartTimePicker.Value = new DateTime(1970, 1, 1) + check.Schedule.StartTime; @@ -140,6 +151,7 @@ check.Enabled = EnabledCheckBox.Checked; check.Timeout = (int)TimeoutInput.Value; check.FailStatus = (CheckStatus)SeverityComboBox.SelectedItem; + check.MaxConsecutiveFailures = (int)FailuresInput.Value; check.Schedule = new Schedule((FrequencyUnits)FrequencyUnitsComboBox.SelectedItem, (int)FrequencyUpDown.Value, StartTimePicker.Value.TimeOfDay, EndTimePicker.Value.TimeOfDay); try { @@ -239,7 +251,7 @@ { ResultLabel.Text = result.Message; //ResultLabel.ForeColor = result.CheckStatus == CheckStatus.Success ? Color.Green : Color.Red; - ResultIconPictureBox.Image = result.CheckStatus.GetIcon(); + ResultIconPictureBox.Image = result.CheckStatus.GetImage(); ResultLabel.Visible = ResultIconPictureBox.Visible = true; } } @@ -333,6 +345,11 @@ { e.Value = e.Value.ToString().ToLower() + 's'; } + + private void NameTextBox_TextChanged(object sender, EventArgs e) + { + SetTitle(); + } } public class HelpLocationChangedEventArgs : EventArgs diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/ServerForm.Designer.cs --- a/ServerMonitor/Forms/ServerForm.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/ServerForm.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -47,12 +47,8 @@ this.KeyBrowseButton = new System.Windows.Forms.Button(); this.PasswordTextBox = new System.Windows.Forms.TextBox(); this.CheckGrid = new System.Windows.Forms.DataGridView(); - this.StatusColumn = new System.Windows.Forms.DataGridViewImageColumn(); - this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ScheduleColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LastRunTimeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.EnabledColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.CheckBindingSource = new System.Windows.Forms.BindingSource(this.components); this.CheckActionsDividerLabel = new System.Windows.Forms.Label(); this.RunAllButton = new System.Windows.Forms.Button(); this.RunButton = new System.Windows.Forms.Button(); @@ -69,27 +65,32 @@ this.LogCheckLabel = new System.Windows.Forms.Label(); this.LogCheckComboBox = new System.Windows.Forms.ComboBox(); this.LogGrid = new System.Windows.Forms.DataGridView(); + this.dataGridViewImageColumn1 = new System.Windows.Forms.DataGridViewImageColumn(); + this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ServerInfoPanel = new System.Windows.Forms.Panel(); + this.EnabledCheckBox = new System.Windows.Forms.CheckBox(); + this.dataGridViewImageColumn2 = new System.Windows.Forms.DataGridViewImageColumn(); + this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.dataGridViewImageColumn3 = new System.Windows.Forms.DataGridViewImageColumn(); + this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.StatusColumn = new System.Windows.Forms.DataGridViewImageColumn(); + this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ScheduleColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.CheckBindingSource = new System.Windows.Forms.BindingSource(this.components); this.LogStatusColumn = new System.Windows.Forms.DataGridViewImageColumn(); this.LogNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LogMessageColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LogStartTimeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LogEndTimeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.CheckResultBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.dataGridViewImageColumn1 = new System.Windows.Forms.DataGridViewImageColumn(); - this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ServerInfoPanel = new System.Windows.Forms.Panel(); - this.dataGridViewImageColumn2 = new System.Windows.Forms.DataGridViewImageColumn(); - this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.dataGridViewImageColumn3 = new System.Windows.Forms.DataGridViewImageColumn(); - this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.CheckGrid)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.CheckBindingSource)).BeginInit(); this.CheckTabControl.SuspendLayout(); this.CheckTabPage.SuspendLayout(); this.LogTabPage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.LogGrid)).BeginInit(); + this.ServerInfoPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.CheckBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CheckResultBindingSource)).BeginInit(); - this.ServerInfoPanel.SuspendLayout(); this.SuspendLayout(); // // TitleLabel @@ -108,7 +109,7 @@ // this.NameTextBox.Location = new System.Drawing.Point(61, 4); this.NameTextBox.Name = "NameTextBox"; - this.NameTextBox.Size = new System.Drawing.Size(354, 20); + this.NameTextBox.Size = new System.Drawing.Size(271, 20); this.NameTextBox.TabIndex = 3; this.NameTextBox.TextChanged += new System.EventHandler(this.NameTextBox_TextChanged); // @@ -119,7 +120,7 @@ this.NameLabel.Name = "NameLabel"; this.NameLabel.Size = new System.Drawing.Size(35, 13); this.NameLabel.TabIndex = 2; - this.NameLabel.Text = "Name"; + this.NameLabel.Text = "Na&me"; this.NameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // HostTextBox @@ -134,7 +135,7 @@ this.PortTextBox.Location = new System.Drawing.Point(61, 56); this.PortTextBox.Name = "PortTextBox"; this.PortTextBox.Size = new System.Drawing.Size(57, 20); - this.PortTextBox.TabIndex = 7; + this.PortTextBox.TabIndex = 8; // // HostLabel // @@ -142,8 +143,8 @@ this.HostLabel.Location = new System.Drawing.Point(6, 33); this.HostLabel.Name = "HostLabel"; this.HostLabel.Size = new System.Drawing.Size(29, 13); - this.HostLabel.TabIndex = 8; - this.HostLabel.Text = "Host"; + this.HostLabel.TabIndex = 5; + this.HostLabel.Text = "&Host"; this.HostLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // PortLabel @@ -152,8 +153,8 @@ this.PortLabel.Location = new System.Drawing.Point(6, 59); this.PortLabel.Name = "PortLabel"; this.PortLabel.Size = new System.Drawing.Size(50, 13); - this.PortLabel.TabIndex = 9; - this.PortLabel.Text = "SSH port"; + this.PortLabel.TabIndex = 7; + this.PortLabel.Text = "SSH &port"; this.PortLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // LoginComboBox @@ -166,7 +167,7 @@ this.LoginComboBox.Location = new System.Drawing.Point(61, 82); this.LoginComboBox.Name = "LoginComboBox"; this.LoginComboBox.Size = new System.Drawing.Size(80, 21); - this.LoginComboBox.TabIndex = 10; + this.LoginComboBox.TabIndex = 12; this.LoginComboBox.SelectedIndexChanged += new System.EventHandler(this.LoginComboBox_SelectedIndexChanged); // // UsernameLabel @@ -175,8 +176,8 @@ this.UsernameLabel.Location = new System.Drawing.Point(144, 59); this.UsernameLabel.Name = "UsernameLabel"; this.UsernameLabel.Size = new System.Drawing.Size(78, 13); - this.UsernameLabel.TabIndex = 11; - this.UsernameLabel.Text = "SSH username"; + this.UsernameLabel.TabIndex = 9; + this.UsernameLabel.Text = "SSH &username"; this.UsernameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // UsernameTextBox @@ -184,7 +185,7 @@ this.UsernameTextBox.Location = new System.Drawing.Point(228, 56); this.UsernameTextBox.Name = "UsernameTextBox"; this.UsernameTextBox.Size = new System.Drawing.Size(187, 20); - this.UsernameTextBox.TabIndex = 8; + this.UsernameTextBox.TabIndex = 10; // // KeyTextBox // @@ -200,8 +201,8 @@ this.LoginLabel.Location = new System.Drawing.Point(6, 85); this.LoginLabel.Name = "LoginLabel"; this.LoginLabel.Size = new System.Drawing.Size(54, 13); - this.LoginLabel.TabIndex = 14; - this.LoginLabel.Text = "SSH login"; + this.LoginLabel.TabIndex = 11; + this.LoginLabel.Text = "SSH &login"; this.LoginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // KeyBrowseButton @@ -210,7 +211,7 @@ this.KeyBrowseButton.Name = "KeyBrowseButton"; this.KeyBrowseButton.Size = new System.Drawing.Size(60, 23); this.KeyBrowseButton.TabIndex = 15; - this.KeyBrowseButton.Text = "Browse..."; + this.KeyBrowseButton.Text = "Br&owse..."; this.KeyBrowseButton.UseVisualStyleBackColor = true; this.KeyBrowseButton.Click += new System.EventHandler(this.KeyBrowseButton_Click); // @@ -249,7 +250,7 @@ this.CheckGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.CheckGrid.ShowEditingIcon = false; this.CheckGrid.Size = new System.Drawing.Size(611, 256); - this.CheckGrid.TabIndex = 19; + this.CheckGrid.TabIndex = 22; this.CheckGrid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckGrid_CellClick); this.CheckGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckGrid_CellContentClick); this.CheckGrid.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.CheckGrid_CellDoubleClick); @@ -259,35 +260,6 @@ this.CheckGrid.SelectionChanged += new System.EventHandler(this.CheckGrid_SelectionChanged); this.CheckGrid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CheckGrid_KeyDown); // - // StatusColumn - // - this.StatusColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.StatusColumn.DataPropertyName = "Status"; - this.StatusColumn.HeaderText = ""; - this.StatusColumn.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom; - this.StatusColumn.Name = "StatusColumn"; - this.StatusColumn.ReadOnly = true; - this.StatusColumn.ToolTipText = "Last Run Status"; - this.StatusColumn.Width = 25; - // - // NameColumn - // - this.NameColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; - this.NameColumn.DataPropertyName = "Name"; - this.NameColumn.HeaderText = "Name"; - this.NameColumn.Name = "NameColumn"; - this.NameColumn.ReadOnly = true; - this.NameColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.NameColumn.Width = 41; - // - // ScheduleColumn - // - this.ScheduleColumn.DataPropertyName = "Schedule"; - this.ScheduleColumn.HeaderText = "Schedule"; - this.ScheduleColumn.Name = "ScheduleColumn"; - this.ScheduleColumn.ReadOnly = true; - this.ScheduleColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - // // LastRunTimeColumn // this.LastRunTimeColumn.DataPropertyName = "LastRunTime"; @@ -305,11 +277,6 @@ this.EnabledColumn.ReadOnly = true; this.EnabledColumn.Width = 50; // - // CheckBindingSource - // - this.CheckBindingSource.DataSource = typeof(ServerMonitorApp.Check); - this.CheckBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(this.CheckBindingSource_ListChanged); - // // CheckActionsDividerLabel // this.CheckActionsDividerLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -328,8 +295,8 @@ this.RunAllButton.Name = "RunAllButton"; this.RunAllButton.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0); this.RunAllButton.Size = new System.Drawing.Size(75, 23); - this.RunAllButton.TabIndex = 25; - this.RunAllButton.Text = "Run All"; + this.RunAllButton.TabIndex = 24; + this.RunAllButton.Text = "Run &All"; this.RunAllButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.RunAllButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.RunAllButton.UseVisualStyleBackColor = true; @@ -344,8 +311,8 @@ this.RunButton.Name = "RunButton"; this.RunButton.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0); this.RunButton.Size = new System.Drawing.Size(75, 23); - this.RunButton.TabIndex = 24; - this.RunButton.Text = "Run"; + this.RunButton.TabIndex = 25; + this.RunButton.Text = "&Run"; this.RunButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.RunButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.RunButton.UseVisualStyleBackColor = true; @@ -361,8 +328,8 @@ this.EditCheckButton.Name = "EditCheckButton"; this.EditCheckButton.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0); this.EditCheckButton.Size = new System.Drawing.Size(75, 23); - this.EditCheckButton.TabIndex = 23; - this.EditCheckButton.Text = "Edit"; + this.EditCheckButton.TabIndex = 26; + this.EditCheckButton.Text = "&Edit"; this.EditCheckButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.EditCheckButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.EditCheckButton.UseVisualStyleBackColor = true; @@ -378,8 +345,8 @@ this.DeleteCheckButton.Name = "DeleteCheckButton"; this.DeleteCheckButton.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0); this.DeleteCheckButton.Size = new System.Drawing.Size(75, 23); - this.DeleteCheckButton.TabIndex = 21; - this.DeleteCheckButton.Text = "Delete"; + this.DeleteCheckButton.TabIndex = 27; + this.DeleteCheckButton.Text = "&Delete"; this.DeleteCheckButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.DeleteCheckButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.DeleteCheckButton.UseVisualStyleBackColor = true; @@ -394,8 +361,8 @@ this.NewCheckButton.Name = "NewCheckButton"; this.NewCheckButton.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0); this.NewCheckButton.Size = new System.Drawing.Size(75, 23); - this.NewCheckButton.TabIndex = 20; - this.NewCheckButton.Text = "New"; + this.NewCheckButton.TabIndex = 23; + this.NewCheckButton.Text = "&New"; this.NewCheckButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.NewCheckButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.NewCheckButton.UseVisualStyleBackColor = true; @@ -469,7 +436,7 @@ this.LogErrorCheckBox.Location = new System.Drawing.Point(414, 8); this.LogErrorCheckBox.Name = "LogErrorCheckBox"; this.LogErrorCheckBox.Size = new System.Drawing.Size(48, 17); - this.LogErrorCheckBox.TabIndex = 33; + this.LogErrorCheckBox.TabIndex = 35; this.LogErrorCheckBox.Text = "Error"; this.LogErrorCheckBox.UseVisualStyleBackColor = true; // @@ -540,9 +507,137 @@ this.LogGrid.ReadOnly = true; this.LogGrid.RowHeadersVisible = false; this.LogGrid.Size = new System.Drawing.Size(693, 223); - this.LogGrid.TabIndex = 28; + this.LogGrid.TabIndex = 40; this.LogGrid.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.LogGrid_CellFormatting); // + // dataGridViewImageColumn1 + // + this.dataGridViewImageColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.dataGridViewImageColumn1.DataPropertyName = "Status"; + this.dataGridViewImageColumn1.HeaderText = ""; + this.dataGridViewImageColumn1.Name = "dataGridViewImageColumn1"; + this.dataGridViewImageColumn1.ReadOnly = true; + this.dataGridViewImageColumn1.ToolTipText = "Last Run Status"; + this.dataGridViewImageColumn1.Width = 25; + // + // dataGridViewTextBoxColumn1 + // + this.dataGridViewTextBoxColumn1.DataPropertyName = "Schedule"; + this.dataGridViewTextBoxColumn1.HeaderText = "Schedule"; + this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; + this.dataGridViewTextBoxColumn1.ReadOnly = true; + this.dataGridViewTextBoxColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.dataGridViewTextBoxColumn1.Width = 192; + // + // ServerInfoPanel + // + this.ServerInfoPanel.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.ServerInfoPanel.Controls.Add(this.EnabledCheckBox); + this.ServerInfoPanel.Controls.Add(this.NameLabel); + this.ServerInfoPanel.Controls.Add(this.NameTextBox); + this.ServerInfoPanel.Controls.Add(this.KeyBrowseButton); + this.ServerInfoPanel.Controls.Add(this.PasswordTextBox); + this.ServerInfoPanel.Controls.Add(this.LoginLabel); + this.ServerInfoPanel.Controls.Add(this.PortTextBox); + this.ServerInfoPanel.Controls.Add(this.KeyTextBox); + this.ServerInfoPanel.Controls.Add(this.HostTextBox); + this.ServerInfoPanel.Controls.Add(this.UsernameTextBox); + this.ServerInfoPanel.Controls.Add(this.HostLabel); + this.ServerInfoPanel.Controls.Add(this.UsernameLabel); + this.ServerInfoPanel.Controls.Add(this.PortLabel); + this.ServerInfoPanel.Controls.Add(this.LoginComboBox); + this.ServerInfoPanel.Location = new System.Drawing.Point(148, 54); + this.ServerInfoPanel.Name = "ServerInfoPanel"; + this.ServerInfoPanel.Size = new System.Drawing.Size(428, 113); + this.ServerInfoPanel.TabIndex = 27; + // + // EnabledCheckBox + // + this.EnabledCheckBox.AutoSize = true; + this.EnabledCheckBox.Checked = true; + this.EnabledCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; + this.EnabledCheckBox.Location = new System.Drawing.Point(350, 6); + this.EnabledCheckBox.Name = "EnabledCheckBox"; + this.EnabledCheckBox.Size = new System.Drawing.Size(65, 17); + this.EnabledCheckBox.TabIndex = 4; + this.EnabledCheckBox.Text = "Ena&bled"; + this.EnabledCheckBox.UseVisualStyleBackColor = true; + this.EnabledCheckBox.Click += new System.EventHandler(this.EnabledCheckBox_Click); + // + // dataGridViewImageColumn2 + // + this.dataGridViewImageColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.dataGridViewImageColumn2.DataPropertyName = "Status"; + this.dataGridViewImageColumn2.HeaderText = ""; + this.dataGridViewImageColumn2.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom; + this.dataGridViewImageColumn2.Name = "dataGridViewImageColumn2"; + this.dataGridViewImageColumn2.ReadOnly = true; + this.dataGridViewImageColumn2.ToolTipText = "Last Run Status"; + this.dataGridViewImageColumn2.Width = 25; + // + // dataGridViewTextBoxColumn2 + // + this.dataGridViewTextBoxColumn2.DataPropertyName = "Schedule"; + this.dataGridViewTextBoxColumn2.HeaderText = "Schedule"; + this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; + this.dataGridViewTextBoxColumn2.ReadOnly = true; + this.dataGridViewTextBoxColumn2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.dataGridViewTextBoxColumn2.Width = 267; + // + // dataGridViewImageColumn3 + // + this.dataGridViewImageColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.dataGridViewImageColumn3.DataPropertyName = "Status"; + this.dataGridViewImageColumn3.HeaderText = ""; + this.dataGridViewImageColumn3.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom; + this.dataGridViewImageColumn3.Name = "dataGridViewImageColumn3"; + this.dataGridViewImageColumn3.ReadOnly = true; + this.dataGridViewImageColumn3.ToolTipText = "Last Run Status"; + this.dataGridViewImageColumn3.Width = 25; + // + // dataGridViewTextBoxColumn3 + // + this.dataGridViewTextBoxColumn3.DataPropertyName = "Schedule"; + this.dataGridViewTextBoxColumn3.HeaderText = "Schedule"; + this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; + this.dataGridViewTextBoxColumn3.ReadOnly = true; + this.dataGridViewTextBoxColumn3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.dataGridViewTextBoxColumn3.Width = 267; + // + // StatusColumn + // + this.StatusColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.StatusColumn.DataPropertyName = "Status"; + this.StatusColumn.HeaderText = ""; + this.StatusColumn.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom; + this.StatusColumn.Name = "StatusColumn"; + this.StatusColumn.ReadOnly = true; + this.StatusColumn.ToolTipText = "Last Run Status"; + this.StatusColumn.Width = 25; + // + // NameColumn + // + this.NameColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.NameColumn.DataPropertyName = "Name"; + this.NameColumn.HeaderText = "Name"; + this.NameColumn.Name = "NameColumn"; + this.NameColumn.ReadOnly = true; + this.NameColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.NameColumn.Width = 41; + // + // ScheduleColumn + // + this.ScheduleColumn.DataPropertyName = "Schedule"; + this.ScheduleColumn.HeaderText = "Schedule"; + this.ScheduleColumn.Name = "ScheduleColumn"; + this.ScheduleColumn.ReadOnly = true; + this.ScheduleColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // CheckBindingSource + // + this.CheckBindingSource.DataSource = typeof(ServerMonitorApp.Check); + this.CheckBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(this.CheckBindingSource_ListChanged); + // // LogStatusColumn // this.LogStatusColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; @@ -594,86 +689,6 @@ // this.CheckResultBindingSource.DataSource = typeof(ServerMonitorApp.CheckResult); // - // dataGridViewImageColumn1 - // - this.dataGridViewImageColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.dataGridViewImageColumn1.DataPropertyName = "Status"; - this.dataGridViewImageColumn1.HeaderText = ""; - this.dataGridViewImageColumn1.Name = "dataGridViewImageColumn1"; - this.dataGridViewImageColumn1.ReadOnly = true; - this.dataGridViewImageColumn1.ToolTipText = "Last Run Status"; - this.dataGridViewImageColumn1.Width = 25; - // - // dataGridViewTextBoxColumn1 - // - this.dataGridViewTextBoxColumn1.DataPropertyName = "Schedule"; - this.dataGridViewTextBoxColumn1.HeaderText = "Schedule"; - this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; - this.dataGridViewTextBoxColumn1.ReadOnly = true; - this.dataGridViewTextBoxColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.dataGridViewTextBoxColumn1.Width = 192; - // - // ServerInfoPanel - // - this.ServerInfoPanel.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.ServerInfoPanel.Controls.Add(this.NameLabel); - this.ServerInfoPanel.Controls.Add(this.NameTextBox); - this.ServerInfoPanel.Controls.Add(this.KeyBrowseButton); - this.ServerInfoPanel.Controls.Add(this.PasswordTextBox); - this.ServerInfoPanel.Controls.Add(this.LoginLabel); - this.ServerInfoPanel.Controls.Add(this.PortTextBox); - this.ServerInfoPanel.Controls.Add(this.KeyTextBox); - this.ServerInfoPanel.Controls.Add(this.HostTextBox); - this.ServerInfoPanel.Controls.Add(this.UsernameTextBox); - this.ServerInfoPanel.Controls.Add(this.HostLabel); - this.ServerInfoPanel.Controls.Add(this.UsernameLabel); - this.ServerInfoPanel.Controls.Add(this.PortLabel); - this.ServerInfoPanel.Controls.Add(this.LoginComboBox); - this.ServerInfoPanel.Location = new System.Drawing.Point(148, 54); - this.ServerInfoPanel.Name = "ServerInfoPanel"; - this.ServerInfoPanel.Size = new System.Drawing.Size(428, 113); - this.ServerInfoPanel.TabIndex = 27; - // - // dataGridViewImageColumn2 - // - this.dataGridViewImageColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.dataGridViewImageColumn2.DataPropertyName = "Status"; - this.dataGridViewImageColumn2.HeaderText = ""; - this.dataGridViewImageColumn2.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom; - this.dataGridViewImageColumn2.Name = "dataGridViewImageColumn2"; - this.dataGridViewImageColumn2.ReadOnly = true; - this.dataGridViewImageColumn2.ToolTipText = "Last Run Status"; - this.dataGridViewImageColumn2.Width = 25; - // - // dataGridViewTextBoxColumn2 - // - this.dataGridViewTextBoxColumn2.DataPropertyName = "Schedule"; - this.dataGridViewTextBoxColumn2.HeaderText = "Schedule"; - this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; - this.dataGridViewTextBoxColumn2.ReadOnly = true; - this.dataGridViewTextBoxColumn2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.dataGridViewTextBoxColumn2.Width = 267; - // - // dataGridViewImageColumn3 - // - this.dataGridViewImageColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.dataGridViewImageColumn3.DataPropertyName = "Status"; - this.dataGridViewImageColumn3.HeaderText = ""; - this.dataGridViewImageColumn3.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom; - this.dataGridViewImageColumn3.Name = "dataGridViewImageColumn3"; - this.dataGridViewImageColumn3.ReadOnly = true; - this.dataGridViewImageColumn3.ToolTipText = "Last Run Status"; - this.dataGridViewImageColumn3.Width = 25; - // - // dataGridViewTextBoxColumn3 - // - this.dataGridViewTextBoxColumn3.DataPropertyName = "Schedule"; - this.dataGridViewTextBoxColumn3.HeaderText = "Schedule"; - this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; - this.dataGridViewTextBoxColumn3.ReadOnly = true; - this.dataGridViewTextBoxColumn3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.dataGridViewTextBoxColumn3.Width = 267; - // // ServerForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -682,22 +697,22 @@ this.Controls.Add(this.ServerInfoPanel); this.Controls.Add(this.CheckTabControl); this.Controls.Add(this.TitleLabel); - this.MinimumSize = new System.Drawing.Size(515, 38); + this.MinimumSize = new System.Drawing.Size(515, 420); this.Name = "ServerForm"; this.Text = "New Server"; this.Activated += new System.EventHandler(this.ServerForm_Activated); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ServerForm_FormClosing); this.Load += new System.EventHandler(this.ServerForm_Load); ((System.ComponentModel.ISupportInitialize)(this.CheckGrid)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.CheckBindingSource)).EndInit(); this.CheckTabControl.ResumeLayout(false); this.CheckTabPage.ResumeLayout(false); this.LogTabPage.ResumeLayout(false); this.LogTabPage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.LogGrid)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.CheckResultBindingSource)).EndInit(); this.ServerInfoPanel.ResumeLayout(false); this.ServerInfoPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.CheckBindingSource)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.CheckResultBindingSource)).EndInit(); this.ResumeLayout(false); } @@ -754,5 +769,6 @@ private System.Windows.Forms.DataGridViewCheckBoxColumn EnabledColumn; private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn3; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; + private System.Windows.Forms.CheckBox EnabledCheckBox; } } \ No newline at end of file diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/ServerForm.cs --- a/ServerMonitor/Forms/ServerForm.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/ServerForm.cs Sat Mar 09 20:14:03 2019 -0500 @@ -54,12 +54,15 @@ if (isNewServer) { LoginComboBox.SelectedIndex = 0; + Icon = CheckStatus.Success.GetIcon(); } else { SetTitle(); + SetIcon(); NameTextBox.Text = Server.Name; HostTextBox.Text = Server.Host; + EnabledCheckBox.Checked = Server.Enabled; PortTextBox.Text = Server.Port.ToString(); UsernameTextBox.Text = Server.Username; PasswordTextBox.Text = "********************"; @@ -71,6 +74,9 @@ BindChangeListeners(); FormatImageButtons(); UpdateCheckButtons(); + + if (NameTextBox.Text == string.Empty) + ActiveControl = NameTextBox; } public void Show(bool activate) @@ -85,6 +91,7 @@ if (e.Check.Server != Server) return; CheckGrid.Refresh(); + SetIcon(); if (e.CheckResult != null && logResults != null) { logResults.Insert(0, e.CheckResult); @@ -102,6 +109,7 @@ { Server.Name = NameTextBox.Text; Server.Host = HostTextBox.Text.Trim(); + Server.Enabled = EnabledCheckBox.Checked; Server.Port = int.TryParse(PortTextBox.Text, out int port) ? port : 0; Server.Username = UsernameTextBox.Text.Trim(); Server.LoginType = (LoginType)LoginComboBox.SelectedIndex; @@ -123,6 +131,12 @@ TitleLabel.Text = title; } + private void SetIcon() + { + if (Server != null) + Icon = Server.Status.GetIcon(); + } + private void NameTextBox_TextChanged(object sender, EventArgs e) { SetTitle(NameTextBox.Text); @@ -296,7 +310,7 @@ { if (e.ColumnIndex == StatusColumn.Index) { - e.Value = ((CheckStatus)e.Value).GetIcon(); + e.Value = ((CheckStatus)e.Value).GetImage(); } } @@ -304,7 +318,7 @@ { if (e.ColumnIndex == LogStatusColumn.Index) { - e.Value = ((CheckStatus)e.Value).GetIcon(); + e.Value = ((CheckStatus)e.Value).GetImage(); } } @@ -312,7 +326,6 @@ { if (Server?.Checks != null) { - //TODO this might result in the selection being reset to all (if a new check is added, for example.) Restore selected index. LogCheckComboBox.Items.Clear(); LogCheckComboBox.Items.Add("(All)"); LogCheckComboBox.Items.AddRange(Server.Checks.ToArray()); @@ -400,7 +413,7 @@ public static void OpenPrivateKey(ServerMonitor monitor, Server server, IWin32Window owner) { - if (server.LoginType != LoginType.PrivateKey) + if (server.LoginType != LoginType.PrivateKey || server.KeyFile.IsNullOrEmpty()) return; KeyStatus keyStatus = monitor.OpenPrivateKey(server.KeyFile); @@ -428,9 +441,27 @@ } } + private void EnabledCheckBox_Click(object sender, EventArgs e) + { + bool enabled = EnabledCheckBox.Checked; + if (enabled) + OpenPrivateKey(monitor, Server, this); + Server.Enabled = enabled; + EnabledCheckBox.Checked = Server.Enabled; + } + + //private void EnabledCheckBox_CheckedChanged(object sender, EventArgs e) + //{ + // bool enabled = EnabledCheckBox.Checked; + // if (enabled) + // OpenPrivateKey(monitor, Server, this); + // EnabledCheckBox.Checked = Server.Enabled; + //} + private void Server_EnabledChanged(object sender, EventArgs e) { SetTitle(); + EnabledCheckBox.Checked = Server.Enabled; } } } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/ServerSummaryForm.Designer.cs --- a/ServerMonitor/Forms/ServerSummaryForm.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/ServerSummaryForm.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -32,11 +32,15 @@ this.ServerPanel = new System.Windows.Forms.FlowLayoutPanel(); this.NotifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.ServerContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.ToggleEnableServerMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.DeleteServerMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SettingsButton = new System.Windows.Forms.Button(); this.NewServerButton = new System.Windows.Forms.Button(); - this.ToggleEnableServerMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.NotificationIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.ShowServerMonitorMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ServerContextMenu.SuspendLayout(); + this.NotificationIconMenu.SuspendLayout(); this.SuspendLayout(); // // ServerPanel @@ -44,16 +48,19 @@ this.ServerPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.ServerPanel.AutoScroll = true; this.ServerPanel.Location = new System.Drawing.Point(12, 12); this.ServerPanel.Name = "ServerPanel"; - this.ServerPanel.Size = new System.Drawing.Size(767, 391); + this.ServerPanel.Size = new System.Drawing.Size(648, 336); this.ServerPanel.TabIndex = 0; // // NotifyIcon // + this.NotifyIcon.ContextMenuStrip = this.NotificationIconMenu; this.NotifyIcon.Text = "Server Monitor"; this.NotifyIcon.Visible = true; this.NotifyIcon.BalloonTipClicked += new System.EventHandler(this.NotifyIcon_BalloonTipClicked); + this.NotifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(this.NotifyIcon_MouseClick); // // ServerContextMenu // @@ -61,59 +68,86 @@ this.ToggleEnableServerMenuItem, this.DeleteServerMenuItem}); this.ServerContextMenu.Name = "ServerContextMenu"; - this.ServerContextMenu.Size = new System.Drawing.Size(181, 70); + this.ServerContextMenu.Size = new System.Drawing.Size(142, 48); this.ServerContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ServerContextMenu_Opening); this.ServerContextMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.ServerContextMenu_ItemClicked); // + // ToggleEnableServerMenuItem + // + this.ToggleEnableServerMenuItem.Name = "ToggleEnableServerMenuItem"; + this.ToggleEnableServerMenuItem.Size = new System.Drawing.Size(141, 22); + this.ToggleEnableServerMenuItem.Text = "Disable"; + // // DeleteServerMenuItem // this.DeleteServerMenuItem.Name = "DeleteServerMenuItem"; - this.DeleteServerMenuItem.Size = new System.Drawing.Size(180, 22); + this.DeleteServerMenuItem.Size = new System.Drawing.Size(141, 22); this.DeleteServerMenuItem.Text = "Delete server"; // // SettingsButton // + this.SettingsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.SettingsButton.Image = global::ServerMonitorApp.Properties.Resources.settings; - this.SettingsButton.Location = new System.Drawing.Point(264, 409); + this.SettingsButton.Location = new System.Drawing.Point(568, 354); this.SettingsButton.Name = "SettingsButton"; this.SettingsButton.Size = new System.Drawing.Size(92, 29); this.SettingsButton.TabIndex = 1; - this.SettingsButton.Text = "Settings"; + this.SettingsButton.Text = "&Settings"; this.SettingsButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.SettingsButton.UseVisualStyleBackColor = true; this.SettingsButton.Click += new System.EventHandler(this.SettingsButton_Click); // // NewServerButton // + this.NewServerButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.NewServerButton.Image = global::ServerMonitorApp.Properties.Resources.add; - this.NewServerButton.Location = new System.Drawing.Point(12, 409); + this.NewServerButton.Location = new System.Drawing.Point(12, 354); this.NewServerButton.Name = "NewServerButton"; this.NewServerButton.Size = new System.Drawing.Size(96, 29); this.NewServerButton.TabIndex = 0; - this.NewServerButton.Text = "New server"; + this.NewServerButton.Text = "&New server"; this.NewServerButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.NewServerButton.UseVisualStyleBackColor = true; this.NewServerButton.Click += new System.EventHandler(this.NewServerButton_Click); // - // ToggleEnableServerMenuItem + // NotificationIconMenu + // + this.NotificationIconMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ShowServerMonitorMenuItem, + this.ExitMenuItem}); + this.NotificationIconMenu.Name = "NotificationIconMenu"; + this.NotificationIconMenu.Size = new System.Drawing.Size(181, 70); + this.NotificationIconMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.NotificationIconMenu_ItemClicked); + // + // ShowServerMonitorMenuItem // - this.ToggleEnableServerMenuItem.Name = "ToggleEnableServerMenuItem"; - this.ToggleEnableServerMenuItem.Size = new System.Drawing.Size(180, 22); - this.ToggleEnableServerMenuItem.Text = "Disable"; + this.ShowServerMonitorMenuItem.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + this.ShowServerMonitorMenuItem.Name = "ShowServerMonitorMenuItem"; + this.ShowServerMonitorMenuItem.Size = new System.Drawing.Size(180, 22); + this.ShowServerMonitorMenuItem.Text = "Server Monitor"; + // + // ExitMenuItem + // + this.ExitMenuItem.Name = "ExitMenuItem"; + this.ExitMenuItem.Size = new System.Drawing.Size(180, 22); + this.ExitMenuItem.Text = "Exit"; // // ServerSummaryForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(672, 395); this.Controls.Add(this.SettingsButton); this.Controls.Add(this.NewServerButton); this.Controls.Add(this.ServerPanel); + this.MinimumSize = new System.Drawing.Size(240, 300); this.Name = "ServerSummaryForm"; - this.Text = "Form1"; + this.Text = "Server Monitor"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ServerSummaryForm_FormClosing); this.Load += new System.EventHandler(this.ServerSummaryForm_Load); + this.ResizeEnd += new System.EventHandler(this.ServerSummaryForm_ResizeEnd); this.ServerContextMenu.ResumeLayout(false); + this.NotificationIconMenu.ResumeLayout(false); this.ResumeLayout(false); } @@ -127,6 +161,9 @@ private System.Windows.Forms.ContextMenuStrip ServerContextMenu; private System.Windows.Forms.ToolStripMenuItem DeleteServerMenuItem; private System.Windows.Forms.ToolStripMenuItem ToggleEnableServerMenuItem; + private System.Windows.Forms.ContextMenuStrip NotificationIconMenu; + private System.Windows.Forms.ToolStripMenuItem ShowServerMonitorMenuItem; + private System.Windows.Forms.ToolStripMenuItem ExitMenuItem; } } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/ServerSummaryForm.cs --- a/ServerMonitor/Forms/ServerSummaryForm.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/ServerSummaryForm.cs Sat Mar 09 20:14:03 2019 -0500 @@ -40,6 +40,10 @@ private void ServerSummaryForm_Load(object sender, EventArgs e) { + Size size = Settings.Default.SummaryFormSize; + if (size.Height > 0 && size.Width > 0) + Size = size; + Helpers.FormatImageButton(NewServerButton); Helpers.FormatImageButton(SettingsButton); monitor = new ServerMonitor(this); @@ -61,7 +65,6 @@ } } } - NotifyIcon.Icon = new Icon(Icon, 16, 16); monitor.CheckStatusChanged += Monitor_CheckStatusChanged; RefreshDisplay(); CollectPrivateKeyPasswords(); @@ -103,11 +106,25 @@ control.Click += ServerSummaryControl_Click; ServerPanel.Controls.Add(control); } + UpdateIcon(); } private void RefreshServer(Server server) { ServerPanel.Controls.Cast().FirstOrDefault(c => c.Server == server).Refresh(); + UpdateIcon(); + } + + private void UpdateIcon() + { + CheckStatus status = monitor.Servers + .Select(s => s.Enabled + ? s.Status + : s.KeyStatus == KeyStatus.NeedPassword ? CheckStatus.Warning : CheckStatus.Success) + .DefaultIfEmpty(CheckStatus.Success) + .Max(); + Icon = status.GetIcon(); + NotifyIcon.Icon = Icon; } private void CollectPrivateKeyPasswords() @@ -130,7 +147,9 @@ private void Monitor_CheckStatusChanged(object sender, CheckStatusChangedEventArgs e) { if (e.CheckResult != null) + { RefreshServer(e.Check.Server); + } } private ToolTipIcon GetToolTipIcon(CheckStatus status) @@ -229,5 +248,44 @@ { return ((ServerSummaryControl)menu.SourceControl).Server; } + + private void ServerSummaryForm_ResizeEnd(object sender, EventArgs e) + { + Settings.Default.SummaryFormSize = Size; + Settings.Default.Save(); + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == Win32Helpers.WM_SHOWMONITOR) + ShowWindow(); + base.WndProc(ref m); + } + + private void NotifyIcon_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + ShowWindow(); + else if (e.Button == MouseButtons.Right) + NotificationIconMenu.Show(); + } + + private void ShowWindow() + { + if (WindowState == FormWindowState.Minimized) + WindowState = FormWindowState.Normal; + Show(); + TopMost = true; + TopMost = false; + Activate(); + } + + private void NotificationIconMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + if (e.ClickedItem == ShowServerMonitorMenuItem) + ShowWindow(); + else if (e.ClickedItem == ExitMenuItem) + Application.Exit(); + } } } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/ServerSummaryForm.resx --- a/ServerMonitor/Forms/ServerSummaryForm.resx Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/ServerSummaryForm.resx Sat Mar 09 20:14:03 2019 -0500 @@ -120,6 +120,9 @@ 17, 17 + + 284, 17 + 125, 17 diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/SettingsForm.Designer.cs --- a/ServerMonitor/Forms/SettingsForm.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/SettingsForm.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -44,6 +44,7 @@ this.KeepLogDaysInput = new System.Windows.Forms.NumericUpDown(); this.DeleteLabel = new System.Windows.Forms.Label(); this.DaysLabel = new System.Windows.Forms.Label(); + this.AutorunCheckBox = new System.Windows.Forms.CheckBox(); this.SeverityOptionsGroupBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.InformationIcon)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.WarningIcon)).BeginInit(); @@ -64,10 +65,10 @@ this.SeverityOptionsGroupBox.Controls.Add(this.WarningIcon); this.SeverityOptionsGroupBox.Controls.Add(this.ErrorLabel); this.SeverityOptionsGroupBox.Controls.Add(this.ErrorIcon); - this.SeverityOptionsGroupBox.Location = new System.Drawing.Point(12, 61); + this.SeverityOptionsGroupBox.Location = new System.Drawing.Point(12, 89); this.SeverityOptionsGroupBox.Name = "SeverityOptionsGroupBox"; this.SeverityOptionsGroupBox.Size = new System.Drawing.Size(337, 104); - this.SeverityOptionsGroupBox.TabIndex = 0; + this.SeverityOptionsGroupBox.TabIndex = 8; this.SeverityOptionsGroupBox.TabStop = false; this.SeverityOptionsGroupBox.Text = "Severity settings"; // @@ -78,7 +79,7 @@ this.ErrorComboBox.Location = new System.Drawing.Point(125, 17); this.ErrorComboBox.Name = "ErrorComboBox"; this.ErrorComboBox.Size = new System.Drawing.Size(121, 21); - this.ErrorComboBox.TabIndex = 8; + this.ErrorComboBox.TabIndex = 9; // // WarningComboBox // @@ -87,7 +88,7 @@ this.WarningComboBox.Location = new System.Drawing.Point(125, 44); this.WarningComboBox.Name = "WarningComboBox"; this.WarningComboBox.Size = new System.Drawing.Size(121, 21); - this.WarningComboBox.TabIndex = 7; + this.WarningComboBox.TabIndex = 11; // // InformationComboBox // @@ -96,7 +97,7 @@ this.InformationComboBox.Location = new System.Drawing.Point(125, 71); this.InformationComboBox.Name = "InformationComboBox"; this.InformationComboBox.Size = new System.Drawing.Size(121, 21); - this.InformationComboBox.TabIndex = 6; + this.InformationComboBox.TabIndex = 13; // // InformationLabel // @@ -104,8 +105,8 @@ this.InformationLabel.Location = new System.Drawing.Point(25, 74); this.InformationLabel.Name = "InformationLabel"; this.InformationLabel.Size = new System.Drawing.Size(94, 13); - this.InformationLabel.TabIndex = 5; - this.InformationLabel.Text = "Information action:"; + this.InformationLabel.TabIndex = 12; + this.InformationLabel.Text = "&Information action:"; // // InformationIcon // @@ -123,8 +124,8 @@ this.WarningLabel.Location = new System.Drawing.Point(25, 47); this.WarningLabel.Name = "WarningLabel"; this.WarningLabel.Size = new System.Drawing.Size(82, 13); - this.WarningLabel.TabIndex = 3; - this.WarningLabel.Text = "Warning action:"; + this.WarningLabel.TabIndex = 10; + this.WarningLabel.Text = "&Warning action:"; // // WarningIcon // @@ -142,8 +143,8 @@ this.ErrorLabel.Location = new System.Drawing.Point(25, 20); this.ErrorLabel.Name = "ErrorLabel"; this.ErrorLabel.Size = new System.Drawing.Size(64, 13); - this.ErrorLabel.TabIndex = 1; - this.ErrorLabel.Text = "Error action:"; + this.ErrorLabel.TabIndex = 8; + this.ErrorLabel.Text = "&Error action:"; // // ErrorIcon // @@ -168,11 +169,11 @@ // OkButton // this.OkButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OkButton.Location = new System.Drawing.Point(193, 176); + this.OkButton.Location = new System.Drawing.Point(193, 204); this.OkButton.Name = "OkButton"; this.OkButton.Size = new System.Drawing.Size(75, 23); - this.OkButton.TabIndex = 2; - this.OkButton.Text = "OK"; + this.OkButton.TabIndex = 50; + this.OkButton.Text = "&OK"; this.OkButton.UseVisualStyleBackColor = true; this.OkButton.Click += new System.EventHandler(this.OkButton_Click); // @@ -180,17 +181,17 @@ // this.CancelSettingsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.CancelSettingsButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelSettingsButton.Location = new System.Drawing.Point(274, 176); + this.CancelSettingsButton.Location = new System.Drawing.Point(274, 204); this.CancelSettingsButton.Name = "CancelSettingsButton"; this.CancelSettingsButton.Size = new System.Drawing.Size(75, 23); - this.CancelSettingsButton.TabIndex = 3; - this.CancelSettingsButton.Text = "Cancel"; + this.CancelSettingsButton.TabIndex = 51; + this.CancelSettingsButton.Text = "&Cancel"; this.CancelSettingsButton.UseVisualStyleBackColor = true; this.CancelSettingsButton.Click += new System.EventHandler(this.CancelSettingsButton_Click); // // KeepLogDaysInput // - this.KeepLogDaysInput.Location = new System.Drawing.Point(130, 31); + this.KeepLogDaysInput.Location = new System.Drawing.Point(130, 59); this.KeepLogDaysInput.Maximum = new decimal(new int[] { 9999, 0, @@ -198,33 +199,44 @@ 0}); this.KeepLogDaysInput.Name = "KeepLogDaysInput"; this.KeepLogDaysInput.Size = new System.Drawing.Size(50, 20); - this.KeepLogDaysInput.TabIndex = 4; + this.KeepLogDaysInput.TabIndex = 6; // // DeleteLabel // this.DeleteLabel.AutoSize = true; - this.DeleteLabel.Location = new System.Drawing.Point(15, 33); + this.DeleteLabel.Location = new System.Drawing.Point(15, 61); this.DeleteLabel.Name = "DeleteLabel"; this.DeleteLabel.Size = new System.Drawing.Size(113, 13); this.DeleteLabel.TabIndex = 5; - this.DeleteLabel.Text = "Delete log entries after"; + this.DeleteLabel.Text = "&Delete log entries after"; // // DaysLabel // this.DaysLabel.AutoSize = true; - this.DaysLabel.Location = new System.Drawing.Point(182, 33); + this.DaysLabel.Location = new System.Drawing.Point(182, 61); this.DaysLabel.Name = "DaysLabel"; this.DaysLabel.Size = new System.Drawing.Size(29, 13); - this.DaysLabel.TabIndex = 6; + this.DaysLabel.TabIndex = 7; this.DaysLabel.Text = "days"; // + // AutorunCheckBox + // + this.AutorunCheckBox.AutoSize = true; + this.AutorunCheckBox.Location = new System.Drawing.Point(18, 36); + this.AutorunCheckBox.Name = "AutorunCheckBox"; + this.AutorunCheckBox.Size = new System.Drawing.Size(117, 17); + this.AutorunCheckBox.TabIndex = 3; + this.AutorunCheckBox.Text = "&Start with Windows"; + this.AutorunCheckBox.UseVisualStyleBackColor = true; + // // SettingsForm // this.AcceptButton = this.OkButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.CancelSettingsButton; - this.ClientSize = new System.Drawing.Size(361, 211); + this.ClientSize = new System.Drawing.Size(361, 239); + this.Controls.Add(this.AutorunCheckBox); this.Controls.Add(this.DaysLabel); this.Controls.Add(this.DeleteLabel); this.Controls.Add(this.KeepLogDaysInput); @@ -266,5 +278,6 @@ private System.Windows.Forms.NumericUpDown KeepLogDaysInput; private System.Windows.Forms.Label DeleteLabel; private System.Windows.Forms.Label DaysLabel; + private System.Windows.Forms.CheckBox AutorunCheckBox; } } \ No newline at end of file diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Forms/SettingsForm.cs --- a/ServerMonitor/Forms/SettingsForm.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Forms/SettingsForm.cs Sat Mar 09 20:14:03 2019 -0500 @@ -1,4 +1,5 @@ -using ServerMonitorApp.Properties; +using Microsoft.Win32; +using ServerMonitorApp.Properties; using System; using System.Collections.Generic; using System.ComponentModel; @@ -14,6 +15,9 @@ { public partial class SettingsForm : Form { + private readonly string autorunKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; + private readonly string autorunName = "ServerMonitor"; + public SettingsForm() { InitializeComponent(); @@ -21,17 +25,35 @@ private void SettingsForm_Load(object sender, EventArgs e) { + Icon = Resources.icon; foreach (ComboBox comboBox in new object[] { ErrorComboBox, WarningComboBox, InformationComboBox }) { comboBox.DataSource = Enum.GetValues(typeof(FailAction)); comboBox.Format += FailActionComboBox_Format; } + AutorunCheckBox.Checked = GetAutorun(); KeepLogDaysInput.Value = Settings.Default.KeepLogDays; ErrorComboBox.SelectedItem = Settings.Default.ErrorAction; WarningComboBox.SelectedItem = Settings.Default.WarningAction; InformationComboBox.SelectedItem = Settings.Default.InformationAction; } + private bool GetAutorun() + { + RegistryKey key = Registry.CurrentUser.OpenSubKey(autorunKey, false); + string value = (string)key.GetValue(autorunName, string.Empty); + return value.StartsWith(Application.ExecutablePath); + } + + private void SetAutorun(bool autorun) + { + RegistryKey key = Registry.CurrentUser.OpenSubKey(autorunKey, true); + if (autorun) + key.SetValue(autorunName, Application.ExecutablePath.ToString()); + else + key.DeleteValue(autorunName, false); + } + private void FailActionComboBox_Format(object sender, ListControlConvertEventArgs e) { e.Value = e.Value.ToString().Substring(0, 1) + Regex.Replace(e.Value.ToString(), "(\\B[A-Z])", " $1").ToLower().Substring(1); @@ -44,6 +66,7 @@ Settings.Default.WarningAction = (FailAction)WarningComboBox.SelectedItem; Settings.Default.InformationAction = (FailAction)InformationComboBox.SelectedItem; Settings.Default.Save(); + SetAutorun(AutorunCheckBox.Checked); Close(); } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Helpers.cs --- a/ServerMonitor/Helpers.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Helpers.cs Sat Mar 09 20:14:03 2019 -0500 @@ -44,7 +44,7 @@ return type.GetCustomAttributes(typeof(T), false).SingleOrDefault() as T; } - public static Image GetIcon(this CheckStatus checkStatus) + public static Image GetImage(this CheckStatus checkStatus) { switch (checkStatus) { @@ -58,6 +58,17 @@ } } + public static Icon GetIcon(this CheckStatus checkStatus) + { + switch (checkStatus) + { + case CheckStatus.Error: return Resources.icon_error; + case CheckStatus.Warning: return Resources.icon_warning; + case CheckStatus.Information: return Resources.icon_info; + default: return Resources.icon; + } + } + public static bool In(this Enum value, params Enum[] values) { return values.Contains(value); } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Objects/CheckResult.cs --- a/ServerMonitor/Objects/CheckResult.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Objects/CheckResult.cs Sat Mar 09 20:14:03 2019 -0500 @@ -18,7 +18,7 @@ public DateTime EndTime { get; set; } - public bool Failed => CheckStatus != CheckStatus.Success; + public bool Failed => CheckStatus.In(CheckStatus.Error, CheckStatus.Warning, CheckStatus.Information); public FailAction FailAction { diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Objects/Checks/Check.cs --- a/ServerMonitor/Objects/Checks/Check.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Objects/Checks/Check.cs Sat Mar 09 20:14:03 2019 -0500 @@ -63,6 +63,11 @@ public CheckStatus FailStatus { get; set; } + public int MaxConsecutiveFailures { get; set; } + + [XmlIgnore] + public int ConsecutiveFailures { get; set; } + [XmlIgnore] public Server Server { get; set; } @@ -84,12 +89,6 @@ return message; } - //public virtual CheckStatus Execute() - //{ - // //TODO - // throw new NotImplementedException(); - //} - public async Task ExecuteAsync(CancellationToken token = default(CancellationToken), bool update = true) { if (token.IsCancellationRequested) diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Objects/Checks/SshCheck.cs --- a/ServerMonitor/Objects/Checks/SshCheck.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Objects/Checks/SshCheck.cs Sat Mar 09 20:14:03 2019 -0500 @@ -32,7 +32,11 @@ try { if (!Server.SshClient.IsConnected) + { + if (Server.LoginType == LoginType.PrivateKey && Server.PrivateKeyFile == null) + return Task.FromResult(Fail(string.Format("Private key '{0}' is locked or not accessible", Server.KeyFile))); Server.SshClient.Connect(); + } } catch (Exception e) { @@ -57,22 +61,6 @@ return Fail(e); } }, token); - //TaskCompletionSource tcs = new TaskCompletionSource(); - - ////TODO timeout - //if (!Server.SshClient.IsConnected) - // Server.SshClient.Connect(); - //using (SshCommand command = Server.SshClient.CreateCommand(Command)) - //{ - // token.Register(command.CancelAsync); - // command.BeginExecute(asyncResult => - // { - // string result = command.EndExecute(asyncResult); - // tcs.SetResult(new CheckResult(this, CheckStatus.Success, result)); - // }); - //} - - //return tcs.Task; } protected virtual List ProcessCommandResult(string output, int exitCode) diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Objects/Schedule.cs --- a/ServerMonitor/Objects/Schedule.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Objects/Schedule.cs Sat Mar 09 20:14:03 2019 -0500 @@ -32,7 +32,6 @@ DateTime nextTime = lastScheduledTime; if (Units == FrequencyUnits.Day) { - //TODO what if nextTime is null or really long ago? while (nextTime < minStartTime) nextTime = nextTime.AddDays(Frequency).Date.Add(StartTime); } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Objects/Server.cs --- a/ServerMonitor/Objects/Server.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Objects/Server.cs Sat Mar 09 20:14:03 2019 -0500 @@ -108,7 +108,7 @@ get { return _enabled; } set { - if (LoginType == LoginType.PrivateKey && PrivateKeyFile == null && value == true) + if ((LoginType == LoginType.PrivateKey && PrivateKeyFile == null && value == true) || value == _enabled) return; _enabled = value; EnabledChanged?.Invoke(this, new EventArgs()); diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Objects/ServerMonitor.cs --- a/ServerMonitor/Objects/ServerMonitor.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Objects/ServerMonitor.cs Sat Mar 09 20:14:03 2019 -0500 @@ -1,4 +1,5 @@ -using Renci.SshNet; +using Microsoft.Win32; +using Renci.SshNet; using Renci.SshNet.Common; using ServerMonitorApp.Properties; using System; @@ -22,7 +23,7 @@ private readonly Dictionary tokens = new Dictionary(); private readonly Dictionary privateKeys = new Dictionary(); private readonly List pausedChecks = new List(); - private bool running, networkAvailable; + private bool running, networkAvailable, suspend; private Dictionary, int> tasks; private ServerSummaryForm mainForm; @@ -60,6 +61,7 @@ public void LoadServers() { + Read: TextReader reader = null; try { @@ -89,14 +91,18 @@ catch (DirectoryNotFoundException) { } catch (InvalidOperationException) { - //TODO log - throw; + reader?.Close(); + File.Copy(ConfigFile, ConfigFile + ".error", true); + File.Copy(ConfigFile + ".bak", ConfigFile, true); + goto Read; } finally { reader?.Close(); } + Application.ApplicationExit += Application_ApplicationExit; NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged; + SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; logger.TrimLog(); Run(); } @@ -108,6 +114,11 @@ XmlSerializer serializer = null; try { + File.Copy(ConfigFile, ConfigFile + ".bak", true); + } + catch { } + try + { writer = new StreamWriter(ConfigFile); serializer = CreateXmlSerializer(); serializer.Serialize(writer, Servers); @@ -119,11 +130,6 @@ serializer = CreateXmlSerializer(); serializer.Serialize(writer, Servers); } - catch (Exception) - { - //TODO log - throw; - } finally { writer?.Close(); @@ -132,7 +138,7 @@ private async void Run() { - if (running) + if (running || suspend) return; running = true; networkAvailable = Helpers.IsNetworkAvailable(); @@ -144,8 +150,6 @@ } pausedChecks.Clear(); } - //TODO subscribe to power events. Find any check's NextExecutionTime is in the past. Cancel waiting task and run immediately (or after short delay). - //tasks = Checks.Select(c => ScheduleExecuteCheckAsync(c)).ToList(); tasks = Checks.ToDictionary(c => ScheduleExecuteCheckAsync(c), c => c.Id); while (tasks.Count > 0) { @@ -171,6 +175,8 @@ check.Status = CheckStatus.Running; OnCheckStatusChanged(check); CheckResult result = await check.ExecuteAsync(token); + if (result.Failed) + check.ConsecutiveFailures++; OnCheckStatusChanged(check, result); HandleResultAsync(result); return result; @@ -179,10 +185,13 @@ private void HandleResultAsync(CheckResult result) { logger.Log(result); - if (result.FailAction == FailAction.FlashTaskbar) - mainForm.AlertServerForm(result.Check); - if (result.FailAction.In(FailAction.FlashTaskbar, FailAction.NotificationBalloon)) - mainForm.ShowBalloon(result); + if (result.Check.ConsecutiveFailures >= result.Check.MaxConsecutiveFailures) + { + if (result.FailAction == FailAction.FlashTaskbar) + mainForm.AlertServerForm(result.Check); + if (result.FailAction.In(FailAction.FlashTaskbar, FailAction.NotificationBalloon)) + mainForm.ShowBalloon(result); + } } public IList GetLog(Server server) @@ -261,10 +270,13 @@ CancellationTokenSource cts = new CancellationTokenSource(); tokens[check.Id] = cts; check.NextRunTime = check.Schedule.GetNextTime(check.LastScheduledRunTime); - await Task.Delay(check.NextRunTime - DateTime.Now, cts.Token); + int delay = Math.Max(0, (int)(check.NextRunTime - DateTime.Now).TotalMilliseconds); + await Task.Delay(delay, cts.Token); check.LastScheduledRunTime = check.NextRunTime; - if (networkAvailable) + if (networkAvailable && !cts.IsCancellationRequested) + { return await ExecuteCheckAsync(check, cts.Token); + } else { if (!pausedChecks.Contains(check.Id)) @@ -280,25 +292,61 @@ mainForm.Invoke((MethodInvoker)(() => Run())); } + private async void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) + { + if (e.Mode == PowerModes.Suspend) + { + foreach (Check check in Checks) + { + CancelCheck(check); + } + suspend = true; + } + else if (e.Mode == PowerModes.Resume) + { + pausedChecks.Clear(); + foreach (Check check in Checks) + { + //CancelCheck(check); + if (check.Enabled && check.Server.Enabled && check.NextRunTime < DateTime.Now) + { + pausedChecks.Add(check.Id); + } + } + await Task.Delay(10000); + suspend = false; + Run(); + } + } + + private void Application_ApplicationExit(object sender, EventArgs e) + { + NetworkChange.NetworkAddressChanged -= NetworkChange_NetworkAddressChanged; + SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged; + } + public KeyStatus OpenPrivateKey(string path, string password = null) { KeyStatus keyStatus; if (path == null) - return KeyStatus.NotAccessible; + keyStatus = KeyStatus.NotAccessible; if (privateKeys.TryGetValue(path, out PrivateKeyFile key) && key != null) - return KeyStatus.Open; - try - { - key = new PrivateKeyFile(path, password); keyStatus = KeyStatus.Open; - } - catch (Exception e) when (e is SshPassPhraseNullOrEmptyException || e is InvalidOperationException) + else { - keyStatus = KeyStatus.NeedPassword; - } - catch (Exception) - { - keyStatus = KeyStatus.NotAccessible; + try + { + key = new PrivateKeyFile(path, password); + keyStatus = KeyStatus.Open; + } + catch (Exception e) when (e is SshPassPhraseNullOrEmptyException || e is InvalidOperationException) + { + keyStatus = KeyStatus.NeedPassword; + } + catch (Exception) + { + keyStatus = KeyStatus.NotAccessible; + } } foreach (Server server in Servers) { diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Program.cs --- a/ServerMonitor/Program.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Program.cs Sat Mar 09 20:14:03 2019 -0500 @@ -8,19 +8,32 @@ { static class Program { + static Mutex mutex = new Mutex(true, "c681570e-dff4-45fa-bdca-d8ca928a0f8a"); + /// /// The main entry point for the application. /// [STAThread] static void Main() { - Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); - Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); - AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + if (mutex.WaitOne(TimeSpan.Zero, true)) + { + Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new ServerSummaryForm()); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new ServerSummaryForm()); + } + else + { + Win32Helpers.PostMessage( + (IntPtr)Win32Helpers.HWND_BROADCAST, + Win32Helpers.WM_SHOWMONITOR, + IntPtr.Zero, + IntPtr.Zero); + } } static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Properties/Resources.Designer.cs --- a/ServerMonitor/Properties/Resources.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Properties/Resources.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -121,6 +121,46 @@ } /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon icon { + get { + object obj = ResourceManager.GetObject("icon", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon icon_error { + get { + object obj = ResourceManager.GetObject("icon_error", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon icon_info { + get { + object obj = ResourceManager.GetObject("icon_info", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon icon_warning { + get { + object obj = ResourceManager.GetObject("icon_warning", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap info { diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Properties/Resources.resx --- a/ServerMonitor/Properties/Resources.resx Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Properties/Resources.resx Sat Mar 09 20:14:03 2019 -0500 @@ -136,6 +136,18 @@ ..\Resources\help.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon_error.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon_info.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon_warning.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\info.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Properties/Settings.Designer.cs --- a/ServerMonitor/Properties/Settings.Designer.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Properties/Settings.Designer.cs Sat Mar 09 20:14:03 2019 -0500 @@ -94,5 +94,17 @@ this["KeepLogDays"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0, 0")] + public global::System.Drawing.Size SummaryFormSize { + get { + return ((global::System.Drawing.Size)(this["SummaryFormSize"])); + } + set { + this["SummaryFormSize"] = value; + } + } } } diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Properties/Settings.settings --- a/ServerMonitor/Properties/Settings.settings Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Properties/Settings.settings Sat Mar 09 20:14:03 2019 -0500 @@ -20,5 +20,8 @@ 30 + + 0, 0 + \ No newline at end of file diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Resources/icon.ico Binary file ServerMonitor/Resources/icon.ico has changed diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Resources/icon_error.ico Binary file ServerMonitor/Resources/icon_error.ico has changed diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Resources/icon_info.ico Binary file ServerMonitor/Resources/icon_info.ico has changed diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Resources/icon_warning.ico Binary file ServerMonitor/Resources/icon_warning.ico has changed diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Resources/monitor.ico Binary file ServerMonitor/Resources/monitor.ico has changed diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/ServerMonitor.csproj --- a/ServerMonitor/ServerMonitor.csproj Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/ServerMonitor.csproj Sat Mar 09 20:14:03 2019 -0500 @@ -268,5 +268,20 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff -r 8486ab7d2357 -r 052aa62cb42a ServerMonitor/Win32Helpers.cs --- a/ServerMonitor/Win32Helpers.cs Fri Mar 01 21:39:22 2019 -0500 +++ b/ServerMonitor/Win32Helpers.cs Sat Mar 09 20:14:03 2019 -0500 @@ -24,6 +24,13 @@ public UInt32 dwTimeout; } + public const int HWND_BROADCAST = 0xffff; + public static readonly int WM_SHOWMONITOR = RegisterWindowMessage("WM_SHOWMONITOR"); + [DllImport("user32")] + public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam); + [DllImport("user32")] + public static extern int RegisterWindowMessage(string message); + public enum FlashWindowFlags : uint { ///