Browse Source

加入注册页面

master
sc 9 months ago
parent
commit
82360f9ac2
  1. 2
      MainWindow.xaml
  2. 6
      MainWindow.xaml.cs
  3. 45
      Properties/Resources.Designer.cs
  4. 15
      Properties/Resources.en-US.resx
  5. 15
      Properties/Resources.resx
  6. 15
      Properties/Resources.zh-CN.resx
  7. 18
      Properties/Resources.zh-TW.resx
  8. 7
      SunlightCentralizedControlManagement_SCCM_.csproj
  9. 2
      UserClass/CRCcheck16.cs
  10. 2
      UserClass/MD5check.cs
  11. 20
      WindowsView/CDKEY.xaml
  12. 149
      WindowsView/CDKEY.xaml.cs

2
MainWindow.xaml

@ -46,6 +46,8 @@
<StackPanel Width="150">
<Button Content="{x:Static lang:Resources.USER}"/>
<Button Content="{x:Static lang:Resources.SysSet}" Click="ButtonSYS_Click"/>
<Separator/>
<Button Content="{x:Static lang:Resources.Permit}" Click="ButtonPermit_Click"/>
<Button Content="{x:Static lang:Resources.Help}" Click="Buttonhelp_Click"/>
<Separator/>
<Button x:Name="ButtonMinimize" Content="{x:Static lang:Resources.Minimize}" Click="ButtonMinimize_Click"/>

6
MainWindow.xaml.cs

@ -112,5 +112,11 @@ namespace SunlightCentralizedControlManagement_SCCM_
{
Picture.Content = new View.SYSSetView();
}
private void ButtonPermit_Click(object sender, RoutedEventArgs e)
{
WindowsView.CDKEY cDKEY = new WindowsView.CDKEY();
cDKEY.Show();
}
}
}

45
Properties/Resources.Designer.cs

@ -1563,6 +1563,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 Permit 的本地化字符串。
/// </summary>
public static string Permit {
get {
return ResourceManager.GetString("Permit", resourceCulture);
}
}
/// <summary>
/// 查找类似 PHControl 的本地化字符串。
/// </summary>
@ -2049,6 +2058,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 Registration is successful 的本地化字符串。
/// </summary>
public static string RIS {
get {
return ResourceManager.GetString("RIS", resourceCulture);
}
}
/// <summary>
/// 查找类似 RunningTime 的本地化字符串。
/// </summary>
@ -2400,6 +2418,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 trce 的本地化字符串。
/// </summary>
public static string TRCE {
get {
return ResourceManager.GetString("TRCE", resourceCulture);
}
}
/// <summary>
/// 查找类似 Type 的本地化字符串。
/// </summary>
@ -2427,6 +2454,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 Valid time 的本地化字符串。
/// </summary>
public static string Validtime {
get {
return ResourceManager.GetString("Validtime", resourceCulture);
}
}
/// <summary>
/// 查找类似 View 的本地化字符串。
/// </summary>
@ -2436,6 +2472,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 void 的本地化字符串。
/// </summary>
public static string void_ {
get {
return ResourceManager.GetString("void_", resourceCulture);
}
}
/// <summary>
/// 查找类似 Washing 的本地化字符串。
/// </summary>

15
Properties/Resources.en-US.resx

@ -954,4 +954,19 @@
<data name="NPERR" xml:space="preserve">
<value>The account number or password is incorrect</value>
</data>
<data name="Permit" xml:space="preserve">
<value>Permit</value>
</data>
<data name="Validtime" xml:space="preserve">
<value>Valid Time</value>
</data>
<data name="RIS" xml:space="preserve">
<value>Registration is successful</value>
</data>
<data name="TRCE" xml:space="preserve">
<value>The registration code has expired</value>
</data>
<data name="void_" xml:space="preserve">
<value>Void</value>
</data>
</root>

15
Properties/Resources.resx

@ -954,4 +954,19 @@
<data name="NPERR" xml:space="preserve">
<value>The account number or password is incorrect</value>
</data>
<data name="Permit" xml:space="preserve">
<value>Permit</value>
</data>
<data name="Validtime" xml:space="preserve">
<value>Valid time</value>
</data>
<data name="RIS" xml:space="preserve">
<value>Registration is successful</value>
</data>
<data name="TRCE" xml:space="preserve">
<value>trce</value>
</data>
<data name="void_" xml:space="preserve">
<value>void</value>
</data>
</root>

15
Properties/Resources.zh-CN.resx

@ -954,4 +954,19 @@
<data name="NPERR" xml:space="preserve">
<value>账号或密码错误</value>
</data>
<data name="Permit" xml:space="preserve">
<value>许可证</value>
</data>
<data name="Validtime" xml:space="preserve">
<value>有效时间</value>
</data>
<data name="RIS" xml:space="preserve">
<value>注册成功</value>
</data>
<data name="TRCE" xml:space="preserve">
<value>注册码过期</value>
</data>
<data name="void_" xml:space="preserve">
<value>无效</value>
</data>
</root>

18
Properties/Resources.zh-TW.resx

@ -951,4 +951,22 @@
<data name="log" xml:space="preserve">
<value>日誌</value>
</data>
<data name="NPERR" xml:space="preserve">
<value>帳戶號碼或密碼不正確</value>
</data>
<data name="Permit" xml:space="preserve">
<value>許可</value>
</data>
<data name="Validtime" xml:space="preserve">
<value>有效的</value>
</data>
<data name="RIS" xml:space="preserve">
<value>注冊成功</value>
</data>
<data name="void_" xml:space="preserve">
<value>無效</value>
</data>
<data name="TRCE" xml:space="preserve">
<value>注冊無效</value>
</data>
</root>

7
SunlightCentralizedControlManagement_SCCM_.csproj

@ -172,6 +172,9 @@
<Compile Include="View\Whole.xaml.cs">
<DependentUpon>Whole.xaml</DependentUpon>
</Compile>
<Compile Include="WindowsView\CDKEY.xaml.cs">
<DependentUpon>CDKEY.xaml</DependentUpon>
</Compile>
<Compile Include="WindowsView\Help.xaml.cs">
<DependentUpon>Help.xaml</DependentUpon>
</Compile>
@ -269,6 +272,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WindowsView\CDKEY.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WindowsView\Help.xaml">
<SubType>Designer</SubType>
<Generator>XamlIntelliSenseFileGenerator</Generator>

2
UserClass/CRCcheck16.cs

@ -1,7 +1,7 @@
using System;
using System.Text;
namespace DyeingComputer.UserClass
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
/// <summary>
/// CRC校验

2
UserClass/MD5check.cs

@ -2,7 +2,7 @@
using System.Security.Cryptography;
using System.Text;
namespace DyeingComputer.UserClass
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
/// <summary>
/// MD5加密

20
WindowsView/CDKEY.xaml

@ -0,0 +1,20 @@
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.CDKEY"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.WindowsView"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" Loaded="Window_CDKEY" BorderBrush="White" Background="#FFEFEFEF"
Title="CDKEY" Height="190" Width="500" MaxHeight="190" MaxWidth="500" ResizeMode="NoResize">
<Grid>
<TextBlock HorizontalAlignment="Left" Height="20" Margin="20,55,0,0" TextWrapping="Wrap" Text="CDKEY:" VerticalAlignment="Top" Width="70" FontSize="16"/>
<TextBlock HorizontalAlignment="Left" Height="20" Margin="20,25,0,0" Text="SN:" VerticalAlignment="Top" Width="70" FontSize="16"/>
<TextBox x:Name="sn_id" HorizontalAlignment="Left" Height="30" Margin="90,20,0,0" VerticalAlignment="Top" Width="360" Background="#FFE6E6E6" IsReadOnly="True" IsTabStop="False" Focusable="False"/>
<TextBox x:Name="cdk" HorizontalAlignment="Left" Height="30" Margin="90,55,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="360"/>
<Button Content="OK" HorizontalAlignment="Right" Height="30" Margin="0,90,50,0" VerticalAlignment="Top" Width="85" Background="#7F673AB7" Click="Button_Click_2"/>
<TextBox x:Name="sn_time" HorizontalAlignment="Left" Height="30" Margin="90,90,0,0" VerticalAlignment="Top" Width="250" Background="{x:Null}" IsReadOnly="True" IsTabStop="False" Focusable="False" BorderBrush="{x:Null}"/>
</Grid>
</Window>

149
WindowsView/CDKEY.xaml.cs

@ -0,0 +1,149 @@
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using System;
using System.Diagnostics;
using System.Windows;
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
{
/// <summary>
/// CDKEY.xaml 的交互逻辑
/// </summary>
public partial class CDKEY : Window
{
public CDKEY()
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent();
}
string cpuSerialNumber;
string biosSerialNumber;
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini";
private void Window_CDKEY(object sender, RoutedEventArgs e) //打开页面
{
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取
string cdk = Configini.IniReadvalue("SN", "SN1"); //读配置文件
if (cdk.Length == 16)
{
if (CRCcheck16.ToCRC16(CRCcheck16.StringToHexByte(cdk.Substring(0, 12)), true) == cdk.Substring(12, 4)) //校验key的crc校验值
{
try
{
string Y = (2255 - StrToInt.To16Convert10(cdk.Substring(6, 2))).ToString();
string M = (255 - StrToInt.To16Convert10(cdk.Substring(8, 2))).ToString();
string D = (255 - StrToInt.To16Convert10(cdk.Substring(10, 2))).ToString();
sn_time.Text = Properties.Resources.Validtime+ ": " + Y + "-" + M + "-" + D;
}
catch (Exception)
{
sn_time.Text = Properties.Resources.Validtime + ": --------";
}
}
else
{
sn_time.Text = Properties.Resources.Validtime + ": --------";
}
}
else
{
sn_time.Text = Properties.Resources.Validtime + ": --------";
}
// 获取CPU序列号
cpuSerialNumber = HardwareSN.GetCPUSerialNumber();
// 获取主板序列号
biosSerialNumber = HardwareSN.GetBIOSSerialNumber();
// 获取硬盘序列号
//string hardDiskSerialNumber = HardwareSN.GetHardDiskSerialNumber();
// 获取网卡地址
//string netCardMACAddress = HardwareSN.GetNetCardMACAddress();
sn_id.Text = MD5check.MD5Encrypt16(cpuSerialNumber + biosSerialNumber);//生成id基于硬件值的md5校验
}
private void Button_Click_2(object sender, RoutedEventArgs e) //cdk确认按钮
{
string id_1;
id_1 = sn_id.Text.Substring(5, 1) + sn_id.Text.Substring(0, 1) + sn_id.Text.Substring(4, 1) + sn_id.Text.Substring(1, 1) + sn_id.Text.Substring(3, 1) + sn_id.Text.Substring(2, 1);
if (cdk.Text.Length != 16)
{
System.Windows.MessageBox.Show("CDKEY: 无效注册码", "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (id_1 == cdk.Text.Substring(0, 6))
{
if (CRCcheck16.ToCRC16(CRCcheck16.StringToHexByte(cdk.Text.Substring(0, 12)), true) == cdk.Text.Substring(12, 4)) //校验key的crc校验值
{
string Y = (2255 - StrToInt.To16Convert10(cdk.Text.Substring(6, 2))).ToString();
string M = (255 - StrToInt.To16Convert10(cdk.Text.Substring(8, 2))).ToString();
string D = (255 - StrToInt.To16Convert10(cdk.Text.Substring(10, 2))).ToString();
string YY = DateTime.Now.ToString("yyyy");
string MM = DateTime.Now.ToString("MM");
string DD = DateTime.Now.ToString("dd");
if (string.Compare(Y, YY) == 0)
{
if (string.Compare(M, MM) == 0)
{
if (string.Compare(D, DD) >= 0)
{
System.Windows.MessageBox.Show("CDKEY: "+Properties.Resources.RIS, "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
sn_time.Text = Properties.Resources.Validtime + ": " + Y + "-" + M + "-" + D;
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
Configini.IniWritevalue("SN", " SN1", cdk.Text);
Configini.IniWritevalue("SN", " SN2", MD5check.MD5Encrypt16(cpuSerialNumber + biosSerialNumber));
}
else if (string.Compare(M, MM) > 0)
{
System.Windows.MessageBox.Show("CDKEY: " + Properties.Resources.RIS, "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
sn_time.Text = Properties.Resources.Validtime + ": " + Y + "-" + M + "-" + D;
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
Configini.IniWritevalue("SN", " SN1", cdk.Text);
Configini.IniWritevalue("SN", " SN2", MD5check.MD5Encrypt16(cpuSerialNumber + biosSerialNumber));
}
else
{
System.Windows.MessageBox.Show("CDKEY:" + Properties.Resources.TRCE, "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
else
{
System.Windows.MessageBox.Show("CDKEY:" + Properties.Resources.TRCE, "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
else if (string.Compare(Y, YY) > 0)
{
System.Windows.MessageBox.Show("CDKEY:"+Properties.Resources.RIS, "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
sn_time.Text = Properties.Resources.Validtime + ": " + Y + "-" + M + "-" + D;
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
Configini.IniWritevalue("SN", " SN1", cdk.Text);
Configini.IniWritevalue("SN", " SN2", MD5check.MD5Encrypt16(cpuSerialNumber + biosSerialNumber));
}
else
{
System.Windows.MessageBox.Show("CDKEY:" + Properties.Resources.TRCE, "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
else
{
System.Windows.MessageBox.Show("CDKEY:" + Properties.Resources.void_, "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
else
{
System.Windows.MessageBox.Show("CDKEY:" + Properties.Resources.void_, "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
Loading…
Cancel
Save