|
|
|
|
using formula_manage.UserClass;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
|
|
|
namespace SUNLIGHT_CDKEY
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MainWindow.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
|
|
|
|
int d, y, m;
|
|
|
|
|
|
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
T_Y.Text = DateTime.Now.ToString("yyyy");
|
|
|
|
|
T_M.Text = DateTime.Now.ToString("MM");
|
|
|
|
|
T_D.Text = DateTime.Now.ToString("dd");
|
|
|
|
|
}
|
|
|
|
|
private void AlphanumericValidationTextBox(object sender, TextCompositionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Regex regex = new Regex(@"[^a-eA-E0-9]+$");
|
|
|
|
|
e.Handled = regex.IsMatch(e.Text.ToUpper());
|
|
|
|
|
}
|
|
|
|
|
private void validation_PreviewKeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Key == Key.Space) e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Tb_KeyFloating_D(object sender, TextCompositionEventArgs e)//输入事件
|
|
|
|
|
{
|
|
|
|
|
//Regex re = new Regex("[^0-9.-]+");
|
|
|
|
|
Regex re = new Regex(@"^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");// 非负浮点数
|
|
|
|
|
e.Handled = !re.IsMatch(e.Text);
|
|
|
|
|
d = int.Parse(T_D.Text);
|
|
|
|
|
if (d > 30)
|
|
|
|
|
{
|
|
|
|
|
T_D.Text = "30";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Tb_KeyFloating_Y(object sender, TextCompositionEventArgs e)//输入事件
|
|
|
|
|
{
|
|
|
|
|
//Regex re = new Regex("[^0-9.-]+");
|
|
|
|
|
Regex re = new Regex(@"^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");// 非负浮点数
|
|
|
|
|
e.Handled = !re.IsMatch(e.Text);
|
|
|
|
|
y = int.Parse(T_Y.Text);
|
|
|
|
|
if (y > 2099)
|
|
|
|
|
{
|
|
|
|
|
T_Y.Text = "2099";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Tb_KeyFloating_M(object sender, TextCompositionEventArgs e)//输入事件
|
|
|
|
|
{
|
|
|
|
|
//Regex re = new Regex("[^0-9.-]+");
|
|
|
|
|
Regex re = new Regex(@"^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");// 非负浮点数
|
|
|
|
|
e.Handled = !re.IsMatch(e.Text);
|
|
|
|
|
m = int.Parse(T_M.Text);
|
|
|
|
|
if (m > 12)
|
|
|
|
|
{
|
|
|
|
|
T_M.Text = "12";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DURATION_DropDownClosed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
T_Y.Text = DateTime.Now.ToString("yyyy");
|
|
|
|
|
T_M.Text = DateTime.Now.ToString("MM");
|
|
|
|
|
T_D.Text = DateTime.Now.ToString("dd");
|
|
|
|
|
|
|
|
|
|
d = int.Parse(T_D.Text);
|
|
|
|
|
y = int.Parse(T_Y.Text);
|
|
|
|
|
m = int.Parse(T_M.Text);
|
|
|
|
|
|
|
|
|
|
if (DURATION.Text == "1")
|
|
|
|
|
{
|
|
|
|
|
m += 1;
|
|
|
|
|
}
|
|
|
|
|
else if (DURATION.Text == "2")
|
|
|
|
|
{
|
|
|
|
|
m += 2;
|
|
|
|
|
}
|
|
|
|
|
else if (DURATION.Text == "3")
|
|
|
|
|
{
|
|
|
|
|
m += 3;
|
|
|
|
|
}
|
|
|
|
|
else if (DURATION.Text == "6")
|
|
|
|
|
{
|
|
|
|
|
m += 6;
|
|
|
|
|
}
|
|
|
|
|
else if (DURATION.Text == "12")
|
|
|
|
|
{
|
|
|
|
|
y += 1;
|
|
|
|
|
}
|
|
|
|
|
else if (DURATION.Text == "FOREVER")
|
|
|
|
|
{
|
|
|
|
|
y = 2099;
|
|
|
|
|
m = 12;
|
|
|
|
|
d = 30;
|
|
|
|
|
}
|
|
|
|
|
if (m > 12)
|
|
|
|
|
{
|
|
|
|
|
m = m-12;
|
|
|
|
|
y += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
T_Y.Text=y.ToString();
|
|
|
|
|
T_M.Text=m.ToString();
|
|
|
|
|
T_D.Text=d.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string a;
|
|
|
|
|
string b, my, mm, md;
|
|
|
|
|
|
|
|
|
|
d = int.Parse(T_D.Text);
|
|
|
|
|
y = int.Parse(T_Y.Text);
|
|
|
|
|
m = int.Parse(T_M.Text);
|
|
|
|
|
|
|
|
|
|
sn_id.Text = sn_id.Text.ToUpper();
|
|
|
|
|
|
|
|
|
|
if (sn_id.Text.Length < 6)//id字节长度大于6有效
|
|
|
|
|
{
|
|
|
|
|
sn_id.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sn_id.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a= 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);
|
|
|
|
|
|
|
|
|
|
my = Convert.ToString(Convert.ToInt32(2255 - y), 16).ToUpper();
|
|
|
|
|
mm = Convert.ToString(Convert.ToInt32(255 - m), 16).ToUpper();
|
|
|
|
|
md = Convert.ToString(Convert.ToInt32(255 - d), 16).ToUpper();
|
|
|
|
|
b=my+mm+md;
|
|
|
|
|
|
|
|
|
|
cdk.Text = a + b + CRCcheck16.ToCRC16(CRCcheck16.StringToHexByte(a+b), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|