-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsWindow.xaml.cs
40 lines (33 loc) · 1.17 KB
/
SettingsWindow.xaml.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
using System.Windows;
namespace Timer
{
public partial class SettingsWindow : Window
{
static Window instance; // Singleton
public SettingsWindow()
{
if (instance != null)
{
instance.Focus();
}
else
{
this.Closing += RemoveInstance;
instance = this;
InitializeComponent();
this.Show();
CB_Theme.IsChecked = Properties.Settings.Default.DarkTheme;
CB_UnitInSeconds.IsChecked = Properties.Settings.Default.UnitInSeconds;
}
}
private void Bt_Save_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.DarkTheme = CB_Theme.IsChecked ?? false;
Properties.Settings.Default.UnitInSeconds = CB_UnitInSeconds.IsChecked ?? false;
Properties.Settings.Default.Save();
MainWindow.UpdateTheme();
MainWindow.UnitInSeconds = CB_UnitInSeconds.IsChecked ?? false;
}
void RemoveInstance(object sender, System.ComponentModel.CancelEventArgs e) => instance = null;
}
}