forked from CopyPlusPlus/CopyPlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemainOriginal.xaml.cs
56 lines (46 loc) · 1.53 KB
/
RemainOriginal.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.Linq;
using System.Windows;
using CopyPlusPlus.Properties;
namespace CopyPlusPlus
{
/// <summary>
/// Interaction logic for RemainOriginal.xaml
/// </summary>
public partial class RemainOriginal : Window
{
//Get MainWindow
private readonly MainWindow _mainWindow =
Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;
// 防止窗口初始化时执行 toggled
private bool _first1 = true;
private bool _first2 = true;
public RemainOriginal()
{
InitializeComponent();
SwitchChineseOriginal.IsOn = _mainWindow.RemainChinese;
SwitchEnglishOriginal.IsOn = _mainWindow.RemainEnglish;
}
private void OnChineseToggled(object sender, RoutedEventArgs e)
{
if (_first1)
{
_first1 = false;
return;
}
_mainWindow.RemainChinese = SwitchChineseOriginal.IsOn;
Settings.Default.RemainChinese = SwitchChineseOriginal.IsOn;
Settings.Default.Save();
}
private void OnEnglishToggled(object sender, RoutedEventArgs e)
{
if (_first2)
{
_first2 = false;
return;
}
_mainWindow.RemainEnglish = SwitchEnglishOriginal.IsOn;
Settings.Default.RemainEnglish = SwitchEnglishOriginal.IsOn;
Settings.Default.Save();
}
}
}