-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsWindow.cs
47 lines (43 loc) · 1.43 KB
/
SettingsWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Text.RegularExpressions;
using KPreisser.UI;
using TaskDialog = KPreisser.UI.TaskDialog;
namespace VRCWMT;
public partial class SettingsWindow : Form
{
public bool Canceled = true;
public SettingsWindow()
{
InitializeComponent();
}
private void SettingsWindow_Load(object sender, EventArgs e)
{
FastGC.Checked = Config.FastGC;
AllowMultipleWindows.Checked = Config.AllowMultipleWindows;
WarnBeforeClose.Checked = Config.WarnBeforeClose;
AutoCloseInstance.Checked = Config.AutoCloseInstance;
UpdateTime.Text = Config.UpdateTime.ToString();
}
private void SaveSettings(object sender, FormClosingEventArgs e)
{
Config.FastGC = FastGC.Checked;
Config.AllowMultipleWindows = AllowMultipleWindows.Checked;
Config.WarnBeforeClose = WarnBeforeClose.Checked;
Config.AutoCloseInstance = AutoCloseInstance.Checked;
ushort time;
if (!ushort.TryParse(UpdateTime.Text.Trim(), out time))
{
e.Cancel = true;
TaskDialog.Show(text: "Failed To Save Update Time",
title: "Settings Window",
buttons: TaskDialogButtons.OK,
icon: TaskDialogStandardIcon.Error);
return;
}
if (time < 5)
time = 10;
if (time > 300)
time = 300;
Config.UpdateTime = time;
Config.WriteConfig();
}
}