annotate ServerMonitor/Forms/SettingsForm.cs @ 6:c1dffaac66fa

- Don't show multiple password dialogs for the same key if the first one was cancelled. - Add option to trim log files.
author Brad Greco <brad@bgreco.net>
date Fri, 01 Mar 2019 21:38:22 -0500
parents 3142e52cbe69
children 052aa62cb42a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
1 using ServerMonitorApp.Properties;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
2 using System;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
3 using System.Collections.Generic;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
4 using System.ComponentModel;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
5 using System.Data;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
6 using System.Drawing;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
7 using System.Linq;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
8 using System.Text;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
9 using System.Text.RegularExpressions;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
10 using System.Threading.Tasks;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
11 using System.Windows.Forms;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
12
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
13 namespace ServerMonitorApp
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
14 {
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
15 public partial class SettingsForm : Form
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
16 {
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
17 public SettingsForm()
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
18 {
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
19 InitializeComponent();
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
20 }
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
21
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
22 private void SettingsForm_Load(object sender, EventArgs e)
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
23 {
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
24 foreach (ComboBox comboBox in new object[] { ErrorComboBox, WarningComboBox, InformationComboBox })
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
25 {
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
26 comboBox.DataSource = Enum.GetValues(typeof(FailAction));
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
27 comboBox.Format += FailActionComboBox_Format;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
28 }
6
c1dffaac66fa - Don't show multiple password dialogs for the same key if the first one was cancelled.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
29 KeepLogDaysInput.Value = Settings.Default.KeepLogDays;
4
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
30 ErrorComboBox.SelectedItem = Settings.Default.ErrorAction;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
31 WarningComboBox.SelectedItem = Settings.Default.WarningAction;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
32 InformationComboBox.SelectedItem = Settings.Default.InformationAction;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
33 }
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
34
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
35 private void FailActionComboBox_Format(object sender, ListControlConvertEventArgs e)
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
36 {
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
37 e.Value = e.Value.ToString().Substring(0, 1) + Regex.Replace(e.Value.ToString(), "(\\B[A-Z])", " $1").ToLower().Substring(1);
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
38 }
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
39
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
40 private void OkButton_Click(object sender, EventArgs e)
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
41 {
6
c1dffaac66fa - Don't show multiple password dialogs for the same key if the first one was cancelled.
Brad Greco <brad@bgreco.net>
parents: 4
diff changeset
42 Settings.Default.KeepLogDays = (int)KeepLogDaysInput.Value;
4
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
43 Settings.Default.ErrorAction = (FailAction)ErrorComboBox.SelectedItem;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
44 Settings.Default.WarningAction = (FailAction)WarningComboBox.SelectedItem;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
45 Settings.Default.InformationAction = (FailAction)InformationComboBox.SelectedItem;
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
46 Settings.Default.Save();
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
47 Close();
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
48 }
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
49
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
50 private void CancelSettingsButton_Click(object sender, EventArgs e)
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
51 {
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
52 Close();
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
53 }
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
54 }
3142e52cbe69 Lots more progress
Brad Greco <brad@bgreco.net>
parents:
diff changeset
55 }