diff ServerMonitor/Forms/CheckForm.cs @ 8:052aa62cb42a

Single instance. Add autorun option. Add icons. General enhancements.
author Brad Greco <brad@bgreco.net>
date Sat, 09 Mar 2019 20:14:03 -0500
parents 3142e52cbe69
children 7127d5b5ac75
line wrap: on
line diff
--- 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