This repository was archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKeyInput.xaml.cs
83 lines (74 loc) · 2.44 KB
/
KeyInput.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Windows;
using System.Windows.Controls;
namespace CopyPlusPlus
{
/// <summary>
/// Interaction logic for KeyInput.xaml
/// </summary>
public partial class KeyInput : Window
{
// Holds a value determining if this is the first time the box has been clicked
// So that the text value is not always wiped out.
private bool hasBeenClicked1 = false;
private bool hasBeenClicked2 = false;
public KeyInput()
{
InitializeComponent();
if (Properties.Settings.Default.AppID == "none")
{
textBox1.Text = "点击这里输入";
}
else
{
textBox1.Text = Properties.Settings.Default.AppID;
}
if (Properties.Settings.Default.SecretKey == "none")
{
textBox2.Text = "关闭窗口自动保存";
}
else
{
textBox2.Text = Properties.Settings.Default.SecretKey;
}
}
private void ClearText(object sender, RoutedEventArgs e)
{
TextBox box = sender as TextBox;
if (box.Name == "textBox1")
{
if (!hasBeenClicked1)
{
box.Text = String.Empty;
hasBeenClicked1 = true;
}
}
if (box.Name == "textBox2")
{
if (!hasBeenClicked2)
{
box.Text = String.Empty;
hasBeenClicked2 = true;
}
}
}
private void WriteKey(object sender, EventArgs e)
{
if (textBox1.Text != "点击这里输入" && textBox1.Text != "" && textBox1.Text != " ")
{
Properties.Settings.Default.AppID = textBox1.Text;
}
if (textBox2.Text != "关闭窗口自动保存" && textBox2.Text != "" && textBox2.Text != " ")
{
Properties.Settings.Default.SecretKey = textBox2.Text;
}
Properties.Settings.Default.Save();
if (Properties.Settings.Default.AppID == "none" || Properties.Settings.Default.SecretKey == "none")
{
//MainWindow.Switch3Uncheck();
//this.Owner.switch3.Ischecked = false;
}
MainWindow.changeStatus = false;
}
}
}