diff ServerMonitor/Forms/SettingsForm.cs @ 4:3142e52cbe69

Lots more progress
author Brad Greco <brad@bgreco.net>
date Sun, 10 Feb 2019 20:51:26 -0500
parents
children c1dffaac66fa
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ServerMonitor/Forms/SettingsForm.cs	Sun Feb 10 20:51:26 2019 -0500
@@ -0,0 +1,53 @@
+using ServerMonitorApp.Properties;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ServerMonitorApp
+{
+    public partial class SettingsForm : Form
+    {
+        public SettingsForm()
+        {
+            InitializeComponent();
+        }
+
+        private void SettingsForm_Load(object sender, EventArgs e)
+        {
+            foreach (ComboBox comboBox in new object[] { ErrorComboBox, WarningComboBox, InformationComboBox })
+            {
+                comboBox.DataSource = Enum.GetValues(typeof(FailAction));
+                comboBox.Format += FailActionComboBox_Format;
+            }
+            ErrorComboBox.SelectedItem = Settings.Default.ErrorAction;
+            WarningComboBox.SelectedItem = Settings.Default.WarningAction;
+            InformationComboBox.SelectedItem = Settings.Default.InformationAction;
+        }
+
+        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);
+        }
+
+        private void OkButton_Click(object sender, EventArgs e)
+        {
+            Settings.Default.ErrorAction = (FailAction)ErrorComboBox.SelectedItem;
+            Settings.Default.WarningAction = (FailAction)WarningComboBox.SelectedItem;
+            Settings.Default.InformationAction = (FailAction)InformationComboBox.SelectedItem;
+            Settings.Default.Save();
+            Close();
+        }
+
+        private void CancelSettingsButton_Click(object sender, EventArgs e)
+        {
+            Close();
+        }
+    }
+}