4
|
1 using ServerMonitorApp.Properties;
|
|
2 using System;
|
|
3 using System.Collections.Generic;
|
|
4 using System.ComponentModel;
|
|
5 using System.Data;
|
|
6 using System.Drawing;
|
|
7 using System.Linq;
|
|
8 using System.Text;
|
|
9 using System.Text.RegularExpressions;
|
|
10 using System.Threading.Tasks;
|
|
11 using System.Windows.Forms;
|
|
12
|
|
13 namespace ServerMonitorApp
|
|
14 {
|
|
15 public partial class SettingsForm : Form
|
|
16 {
|
|
17 public SettingsForm()
|
|
18 {
|
|
19 InitializeComponent();
|
|
20 }
|
|
21
|
|
22 private void SettingsForm_Load(object sender, EventArgs e)
|
|
23 {
|
|
24 foreach (ComboBox comboBox in new object[] { ErrorComboBox, WarningComboBox, InformationComboBox })
|
|
25 {
|
|
26 comboBox.DataSource = Enum.GetValues(typeof(FailAction));
|
|
27 comboBox.Format += FailActionComboBox_Format;
|
|
28 }
|
|
29 ErrorComboBox.SelectedItem = Settings.Default.ErrorAction;
|
|
30 WarningComboBox.SelectedItem = Settings.Default.WarningAction;
|
|
31 InformationComboBox.SelectedItem = Settings.Default.InformationAction;
|
|
32 }
|
|
33
|
|
34 private void FailActionComboBox_Format(object sender, ListControlConvertEventArgs e)
|
|
35 {
|
|
36 e.Value = e.Value.ToString().Substring(0, 1) + Regex.Replace(e.Value.ToString(), "(\\B[A-Z])", " $1").ToLower().Substring(1);
|
|
37 }
|
|
38
|
|
39 private void OkButton_Click(object sender, EventArgs e)
|
|
40 {
|
|
41 Settings.Default.ErrorAction = (FailAction)ErrorComboBox.SelectedItem;
|
|
42 Settings.Default.WarningAction = (FailAction)WarningComboBox.SelectedItem;
|
|
43 Settings.Default.InformationAction = (FailAction)InformationComboBox.SelectedItem;
|
|
44 Settings.Default.Save();
|
|
45 Close();
|
|
46 }
|
|
47
|
|
48 private void CancelSettingsButton_Click(object sender, EventArgs e)
|
|
49 {
|
|
50 Close();
|
|
51 }
|
|
52 }
|
|
53 }
|