-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminVerify.cs
69 lines (63 loc) · 2.34 KB
/
AdminVerify.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
using Microsoft.Win32;
using Sunny.UI;
using System;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Windows.Forms;
namespace TDesktop
{
public partial class AdminVerify : UIForm
{
public string FontFilePath = @".\Resources\HarmonyOS_Sans.ttf";
public AdminVerify()
{
InitializeComponent();
}
private void AdminVerify_button_Click(object sender, EventArgs e)
{
var a = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TeacherDesktop", true);
a.GetValue("AdminPassword");
if (AdminVerify_Input.Text == a.GetValue("AdminPassword").ToString())
{
AdminVerify_Label.ForeColor = Color.Green;
AdminVerify_Label.Text = "密码正确";
this.DialogResult = DialogResult.OK;
this.Hide();
}
else
{
AdminVerify_Label.ForeColor = Color.Red;
AdminVerify_Label.Text = "密码错误";
AdminVerify_Input.Text = "";
}
}
private void AdminVerify_Load(object sender, EventArgs e)
{
if (File.Exists(FontFilePath))
{
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile(FontFilePath);
Font TitleFont = new Font(pfc.Families[0].Name, 14F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134)));
Font Font = new Font(pfc.Families[0].Name, 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134)));
this.TitleFont = TitleFont;
AdminVerify_Label.Font = Font;
AdminVerify_Input.Font = Font;
AdminVerify_button.Font = Font;
}
var a = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TeacherDesktop", true);
a.GetValue("AdminPassword");
if (a == null)
{
MessageBox.Show("⚠请设置管理员密码");
}
}
private void AdminVerify_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
this.DialogResult = DialogResult.Cancel;
}
}
}
}