Skip to content

Commit 4d4f714

Browse files
committed
添加“管理码”功能
1 parent 59c1f54 commit 4d4f714

File tree

5 files changed

+93
-17
lines changed

5 files changed

+93
-17
lines changed

TimeControl/ControlPanel.Designer.cs

Lines changed: 37 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TimeControl/ControlPanel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,17 @@ public ControlPanel()
116116

117117
private void startButton_Click(object sender, EventArgs e)
118118
{
119+
if (unlockPasswordBox.Text=="")
120+
{
121+
122+
}
119123
IntPtr nowDesktop = GetThreadDesktop(GetCurrentThreadId());
120124
IntPtr newDesktop = CreateDesktop("Lock", null, null, 0, ACCESS_MASK.GENERIC_ALL, IntPtr.Zero);
121125
SwitchDesktop(newDesktop);
122126
System.Threading.Tasks.Task.Factory.StartNew(() =>
123127
{
124128
SetThreadDesktop(newDesktop);
125-
Lock _lock = new Lock(Convert.ToInt32(timeBox.Value));
129+
Lock _lock = new Lock(Convert.ToInt32(timeBox.Value),unlockPasswordBox.Text);
126130
Application.Run(_lock);
127131
}).Wait();
128132
SwitchDesktop(nowDesktop);

TimeControl/ControlPanel.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,4 @@
5757
<resheader name="writer">
5858
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
5959
</resheader>
60-
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
61-
<value>17, 17</value>
62-
</metadata>
6360
</root>

TimeControl/Lock.Designer.cs

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TimeControl/Lock.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ namespace TimeControl
1313
{
1414
public partial class Lock : Form
1515
{
16-
private int minutes;
17-
public Lock(int minutes)
16+
private bool usePassword = true;
17+
private string unlockPassword;
18+
public Lock(int minutes,string unlockPassword)
1819
{
1920
InitializeComponent();
20-
this.minutes = minutes;
2121
progressBar.Maximum = minutes * 60;
22+
if(unlockPassword=="")
23+
{ usePassword = false; }
24+
this.unlockPassword = unlockPassword;
2225
}
2326

24-
private void timer_Tick(object sender, EventArgs e)
27+
private void Timer_Tick(object sender, EventArgs e)
2528
{
2629
progressBar.Value++;
2730
if (progressBar.Value==progressBar.Maximum)
@@ -45,5 +48,21 @@ private void Lock_FormClosing(object sender, FormClosingEventArgs e)
4548
MessageBox.Show("时间还没到呢!再等等吧。(点击继续)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ;
4649
}
4750
}
51+
52+
private void UnlockButton_Click(object sender, EventArgs e)
53+
{
54+
if (usePassword == true)
55+
{
56+
if (unlockPasswordBox.Text == unlockPassword)
57+
{
58+
progressBar.Value = progressBar.Maximum;
59+
Close();
60+
}
61+
else
62+
MessageBox.Show("管理码错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
63+
}
64+
else
65+
MessageBox.Show("你没有设置管理码!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
66+
}
4867
}
4968
}

0 commit comments

Comments
 (0)