You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
276 lines
11 KiB
276 lines
11 KiB
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
|
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Input;
|
|
using System.Windows.Interop;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_
|
|
{
|
|
/// <summary>
|
|
/// MainWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
public static string user_;
|
|
public static DataTable InfData = new DataTable();
|
|
// public static string[] Inf_string ;
|
|
public UserInformation userInformation;
|
|
// public UserInf userInf;
|
|
|
|
public MainWindow()
|
|
{
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
DataContext = new MainWindowViewModel();
|
|
InitializeComponent();
|
|
CountDown();
|
|
CDkey_();
|
|
if (App.USER_Purview != "ENGINEER")
|
|
{
|
|
username.ItemsSource = MainWindowViewModel.USER_data.Select(
|
|
"Groups='" + MainWindowViewModel.USER_data.Select("Name='" + App.USER_Purview + "'").
|
|
First().Field<string>("Groups").ToString() + "'").
|
|
AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();
|
|
}
|
|
user_ = App.USER_Purview;
|
|
username.Text = user_;
|
|
|
|
/**添加提示信息栏**/
|
|
InfData.Columns.Add("Machine", Type.GetType("System.String"));
|
|
InfData.Columns.Add("Information", Type.GetType("System.String"));
|
|
InfData.Columns.Add("Code", Type.GetType("System.String"));
|
|
InfData.Columns.Add("ID", Type.GetType("System.Int32"));
|
|
|
|
InfData.RowChanged += new DataRowChangeEventHandler(InfTable);//
|
|
}
|
|
private void InfTable(object sender, DataRowChangeEventArgs e)//触发行改变事件
|
|
{
|
|
if (userInformation == null || !userInformation.IsLoaded)//窗口不存在及创建
|
|
{
|
|
userInformation = new UserInformation();
|
|
userInformation.Topmost = true;
|
|
userInformation.Show();
|
|
userInformation.Activate();
|
|
}
|
|
else
|
|
{//窗口纯在及置顶
|
|
userInformation.Activate();
|
|
if (userInformation.WindowState == WindowState.Minimized) userInformation.WindowState = WindowState.Normal;
|
|
}
|
|
}
|
|
/* private void UserInfTable(string dat)//触发行改变事件
|
|
{
|
|
userInf.Inf_DAT = dat;
|
|
if (userInf == null || !userInf.IsLoaded)//窗口不存在及创建
|
|
{
|
|
userInf = new UserInf();
|
|
userInf.Topmost = true;
|
|
userInf.Show();
|
|
userInf.Activate();
|
|
}
|
|
else
|
|
{//窗口纯在及置顶
|
|
userInf.Activate();
|
|
if (userInf.WindowState == WindowState.Minimized) userInf.WindowState = WindowState.Normal;
|
|
}
|
|
}*/
|
|
|
|
private void ButtonPopUpLogout_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
System.Windows.Application.Current.Shutdown();
|
|
}
|
|
private void ButtonMaximize_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (WindowState == WindowState.Maximized)
|
|
{ WindowState = WindowState.Normal; }
|
|
else
|
|
{ WindowState = WindowState.Maximized; }
|
|
}
|
|
|
|
private void ButtonMinimize_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (WindowState == WindowState.Minimized)
|
|
{ WindowState = WindowState.Normal; }
|
|
else
|
|
{ WindowState = WindowState.Minimized; }
|
|
}
|
|
|
|
private void ButtonOpenMenu_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
ButtonOpenMenu.Visibility = Visibility.Collapsed;
|
|
ButtonCloseMenu.Visibility = Visibility.Visible;
|
|
}
|
|
|
|
private void ButtonCloseMenu_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
ButtonOpenMenu.Visibility = Visibility.Visible;
|
|
ButtonCloseMenu.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
private void GridTitle_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (e.ChangedButton == MouseButton.Left)
|
|
DragMove();
|
|
}
|
|
|
|
private void GridMenu_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
gdMian.Margin = new Thickness(e.NewSize.Width, 50, 0, 0);
|
|
}
|
|
|
|
private void ListViewItem_ProductionPlanning(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Picture.Content = new View.ProductionPlanningView();
|
|
}
|
|
private void ListViewItem_Whole(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Picture.Content = new View.Whole();
|
|
}
|
|
private void ListViewItem_Monitor(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Picture.Content = new View.MonitorView();
|
|
}
|
|
private void ListViewItem_Machine(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Picture.Content = new View.MachinesView();
|
|
}
|
|
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Picture.Content = new View.CurveView();
|
|
}
|
|
private void ListViewItem_Programgroup(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Picture.Content = new View.ProgramgroupView();
|
|
}
|
|
private void ListViewItem_ConveyorCenters(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Picture.Content = new View.DispenseView();
|
|
}
|
|
private void Buttonhelp_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
WindowsView.Help help_page = new WindowsView.Help();
|
|
help_page.Show();
|
|
}
|
|
private void ButtonSYS_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Picture.Content = new View.SYSSetView();
|
|
}
|
|
private void ButtonUSER_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
WindowsView.User user_ = new WindowsView.User();
|
|
user_.Show();
|
|
}
|
|
private void ButtonPermit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
WindowsView.CDKEY cDKEY = new WindowsView.CDKEY();
|
|
cDKEY.Show();
|
|
}
|
|
|
|
public void CountDown()
|
|
{
|
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环
|
|
{
|
|
Interval = TimeSpan.FromHours(1)
|
|
};
|
|
timer1s.Tick += Tick_Event_1H;
|
|
timer1s.Start();
|
|
}
|
|
void Tick_Event_1H(object sender, EventArgs e)//Tick_Event周期执行事件
|
|
{
|
|
CDkey_();
|
|
}
|
|
|
|
private static UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
|
private void CDkey_()
|
|
{
|
|
try
|
|
{
|
|
string id_1 = MainWindowViewModel.SN_ID.Substring(5, 1) + MainWindowViewModel.SN_ID.Substring(0, 1) +
|
|
MainWindowViewModel.SN_ID.Substring(4, 1) + MainWindowViewModel.SN_ID.Substring(1, 1) +
|
|
MainWindowViewModel.SN_ID.Substring(3, 1) + MainWindowViewModel.SN_ID.Substring(2, 1);
|
|
if ((id_1 == MainWindowViewModel.SN_KEY.Substring(0, 6)) && (MainWindowViewModel.SN_KEY.Length == 16))
|
|
{
|
|
if (CRCcheck16.ToCRC16(CRCcheck16.StringToHexByte(MainWindowViewModel.SN_KEY.Substring(0, 12)), true) == MainWindowViewModel.SN_KEY.Substring(12, 4)) //校验key的crc校验值
|
|
{
|
|
string Y = (2255 - StrToInt.To16Convert10(MainWindowViewModel.SN_KEY.Substring(6, 2))).ToString();
|
|
string M = (255 - StrToInt.To16Convert10(MainWindowViewModel.SN_KEY.Substring(8, 2))).ToString();
|
|
string D = (255 - StrToInt.To16Convert10(MainWindowViewModel.SN_KEY.Substring(10, 2))).ToString();
|
|
|
|
string YY = DateTime.Now.ToString("yyyy");
|
|
string MM = DateTime.Now.ToString("MM");
|
|
string DD = DateTime.Now.ToString("dd");
|
|
|
|
keytext.Text = "注册到期时间: " + Y + "/" + M + "/" + D;
|
|
|
|
if (string.Compare(Y, YY) < 0)
|
|
{
|
|
if (string.Compare(M, MM) < 0)
|
|
{
|
|
if (string.Compare(D, DD) < 0)
|
|
{
|
|
Configini.IniWritevalue("SN", " SN1", "0000000000000000");
|
|
Cdk_page.Visibility = Visibility.Visible; //cdk_pageT_T = -1; //防止触发倒计时
|
|
}
|
|
else if ((int.Parse(D) - int.Parse(DD)) <= 10)//提前10天提醒
|
|
{
|
|
Cdk_page.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Cdk_page.Visibility = Visibility.Visible;
|
|
keytext.Text = "许可证安全校验错误请重新激活";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Cdk_page.Visibility = Visibility.Visible;
|
|
keytext.Text = "计算机信息变更当前许可证失效";
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
keytext.Text = "许可证安全校验错误请重新激活";
|
|
}
|
|
}
|
|
|
|
private void username_DropDownClosed(object sender, EventArgs e)
|
|
{
|
|
MainWindowViewModel.USERCapacity(username.Text);
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)//打开页面
|
|
{
|
|
var windowHandle = new WindowInteropHelper(this).Handle;
|
|
var currentScreen = Screen.FromHandle(windowHandle);
|
|
|
|
System.Drawing.Rectangle rectangle = currentScreen.WorkingArea;
|
|
|
|
this.Left = rectangle.Left;
|
|
this.Top=rectangle.Top;
|
|
this.Width = rectangle.Width;
|
|
this.Height = rectangle.Height;
|
|
}
|
|
|
|
}
|
|
}
|
|
|