251024
This commit is contained in:
79
SLC1-N/Form_Activate.cs
Normal file
79
SLC1-N/Form_Activate.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SLC1_N
|
||||
{
|
||||
public partial class Form_Activate : Form
|
||||
{
|
||||
public delegate void MySignalHandler(bool mode); // 声明信号
|
||||
public event MySignalHandler Signal_LoginResult;
|
||||
|
||||
bool isActivate = false;
|
||||
|
||||
// 激活信息文件 C:\Users\mxl\AppData\Local\mxlSoftware\activation.bin
|
||||
|
||||
public Form_Activate()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form_Activate_Load(object sender, EventArgs e)
|
||||
{
|
||||
tb_ActivateCode.Text = "123"; // 显示记录的激活码
|
||||
|
||||
var (isActivated, expiryTime) = ActivationManager.ReadActivationStatus(); // 读取激活状态
|
||||
if (isActivated)
|
||||
{
|
||||
isActivate = isActivated;
|
||||
this.Close(); // 如果处于激活则关闭激活弹窗
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 验证激活码
|
||||
private void bt_verify_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (tb_ActivateCode.Text == "qwertyuiop")
|
||||
{
|
||||
// 激活60天
|
||||
ActivationManager.WriteActivationStatus(true, 60);
|
||||
|
||||
isActivate = true;
|
||||
Signal_LoginResult.Invoke(true);
|
||||
|
||||
MessageBox.Show("验证通过!");
|
||||
this.Close();
|
||||
}
|
||||
else if (tb_ActivateCode.Text == "qwertyuiop123")
|
||||
{
|
||||
// 写入激活状态
|
||||
ActivationManager.WriteActivationStatus(true);
|
||||
|
||||
isActivate = true;
|
||||
Signal_LoginResult.Invoke(true);
|
||||
|
||||
MessageBox.Show("验证通过!");
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
isActivate = false;
|
||||
MessageBox.Show("验证失败!");
|
||||
Signal_LoginResult.Invoke(isActivate);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void Form_Activate_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
Signal_LoginResult.Invoke(isActivate);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user