private void Logo_Load(object sender, EventArgs e) { base.SetVisibleCore(false);//屏蔽ALT+TAB切换 Process.GetCurrentProcess().PriorityBoostEnabled = true; Common.ProgressCmdKeyChanged += Common_ProgressChanged; if (ProcessCmd.CheckMachineRegistKeyIsValid()) { if (ProcessCmd.CheckMachineRegistValueIsValid()) { timer2.Enabled = true; panel1.Visible = false; Common.SetSystemWorkMode(SysFunState.Load); return; } } DialogResult re = MessageBox.Show(string.Format("系统未进行注册或发生设备环境变更\n点击 '确认' 进行注册\n点击 '取消' 系统将于三分钟后关闭\n"), "系统警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (re == DialogResult.OK) { maskKey.Text = Com.Checksum.GetRegiterKeys(); logoText.Text = "请向厂家技术人员提供注册秘钥"; } else { maskKey.Text = Com.Checksum.GetRegiterKeys(); ProcessCmd.SetSystemShutdown(180); } panel1.Visible = true; panel1.SelectedIndex = 1; timer2.Enabled = false; }
private void MaskCheck_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(superPassword.Text)) { if (Com.Checksum.CheckRegiterKeysIsValid(superPassword.Text)) { ProcessCmd.RegisterSystem(maskKey.Text, superPassword.Text); timer2.Enabled = true; panel1.Visible = false; try { File.Delete(Globals.AppCfg.LogFileFullName);//重新清理生成日志 File.WriteAllBytes(Globals.AppCfg.LogFileFullName, Properties.Resources.FCLOG); } catch { } finally { Common.SetSystemWorkMode(SysFunState.Load); } } else { logoText.Text = "注册密码无效"; } } else { logoText.Text = "请输入厂家提供的注册密码"; } superPassword.Text = string.Empty; }
public static bool SystemExit(bool shutDown, bool isOk = true) { try { Globals.AppCfg.Shutdown = isOk; Globals.AppCfg.SaveDefaultSysConfigFile();//保存当前应用配置 if (X_Axis != null && X_Axis.Enabled) { X_Axis.AxisAotoEscapeLimit(); } if (Y_Axis != null && Y_Axis.Enabled) { Y_Axis.AxisAotoEscapeLimit(); } if (T_Axis != null && T_Axis.Enabled) { T_Axis.AxisAotoEscapeLimit(); } if (Z_Axis != null && Z_Axis.Enabled) { Z_Axis.AxisAotoEscapeLimit(); Z_Axis.AxisGoHomeWork(true); //Z轴回位操作 ReportCmdKeyProgress(CmdKey.S0407); //Z轴回零成功 } if (SPD != null && SPD.IsInit) { SPD.StopSpd(); ReportCmdKeyProgress(CmdKey.S0607); } HwProvider.UnInitHardwareDriver(); //关闭所有硬件 ReportCmdKeyProgress(CmdKey.S0023); //判定是否需要延迟断电 backWorker.CancelAsync(); LogHelper.CloseLogerConnect(); } catch { } if (shutDown) { ProcessCmd.SetSystemShutdown(); } else { //ProcessCmd.ShowWindowDesk();//显示Window桌面 //ProcessCmd.ShowLogicalDriver();//显示硬盘 //ProcessCmd.UsedTaskMgrForm();//使用任务管理器 //ProcessCmd.SetSystytemLoadShell(true);//设置系统默认加载路径并注销系统 } Application.Exit(); return(true); }
public static void ProcessApplication() { try { try { ProcessCmd.InstallFont(); //安装字体 ProcessCmd.HideWindowDesk(); //隐藏桌面 ProcessCmd.HideLogicalDriver(); //隐藏驱动器 ProcessCmd.NoUsedTaskMgrForm(); //关闭任务管理器 if (ProcessCmd.SetSystytemLoadShell()) //设置启动项目 { ProcessCmd.SetProcessAutoStart(false); //删除重启项目 } else { ProcessCmd.SetProcessAutoStart();//如果设置失败就设置自动启动 } } finally { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; Application.ThreadException += Application_ThreadException; Application.ApplicationExit += Application_ApplicationExit; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); keyPad1 = new UI.Ctr.KeyPad(); keyMessage = new KeyMessageFilter(); Application.AddMessageFilter(keyMessage); Common.LoadSysConfigFile(); Application.Run(new MainForm()); Application.RemoveMessageFilter(keyMessage); keyPad1.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Common.SystemExit(true, false); } finally { } }
private void ButtonEx3_Click(object sender, EventArgs e) { ProcessCmd.SetSystytemLoadShell(true); }
// 8AEFE7 private void ExitApplition_Click(object sender, EventArgs e) { Common.SystemExit(true, true); ProcessCmd.SetSystemShutdown(); }
public static bool SystemLoad() { if (!File.Exists(Globals.AppCfg.LogFileFullName)) { File.WriteAllBytes(Globals.AppCfg.LogFileFullName, Properties.Resources.FCLOG); } LogHelper.ConnectLogerDataBase(Globals.AppCfg.LogFileFullName);//连接数据库 if ((SysCfg)ProcessCmd.GetMacConfigRegister() != Globals.SysCfg) { Globals.SysCfg = (SysCfg)ProcessCmd.GetMacConfigRegister(); Globals.AppCfg.SysConfig = Globals.SysCfg; ReportCmdKeyProgress(CmdKey.S0088); } if (!HwProvider.CreateSystemObject(Globals.AppCfg.HardWareFileFullName)) { ReportCmdKeyProgress(CmdKey.S0004); } else { ReportCmdKeyProgress(CmdKey.S0003); } if (File.Exists(Globals.AppCfg.MacFullPathName)) { Globals.MacData = Serialize.XmlDeSerialize <MacData>(File.ReadAllText(Globals.AppCfg.MacFullPathName)); LogHelper.AutoDeleteLogTable(); } else { ReportCmdKeyProgress(CmdKey.S0019); } if (File.Exists(Globals.AppCfg.DevFullPathName)) { Globals.DevData = Serialize.XmlDeSerialize <DevData>(File.ReadAllText(Globals.AppCfg.DevFullPathName)); } else { ReportCmdKeyProgress(CmdKey.S0018); } if (File.Exists(Globals.AppCfg.TabFileFullPath)) { Globals.TabData = Serialize.XmlDeSerialize <TabData>(File.ReadAllText(Globals.AppCfg.TabFileFullPath));//加载工作台信息文件 } else { ReportCmdKeyProgress(CmdKey.S0017); } if (File.Exists(Globals.AppCfg.BladeFileFullName)) { Globals.BldData = Serialize.XmlDeSerialize <BldData>(File.ReadAllText(Globals.AppCfg.BladeFileFullName));//加载刀具信息文件 } else { ReportCmdKeyProgress(CmdKey.S0016); } if (File.Exists(Globals.AppCfg.CutFileFullName)) { Globals.Group = Serialize.XmlDeSerialize <CutGroup>(File.ReadAllText(Globals.AppCfg.CutFileFullName)); //加载划切文件 } else { Globals.Group = new CutGroup(); ReportCmdKeyProgress(CmdKey.S0015); } bool flag = true; if (!HwProvider.InitHardwareDriver()) { flag = false; ReportCmdKeyProgress(CmdKey.S0006); } else { ReportCmdKeyProgress(CmdKey.S0005); } if (!InitAxisSystemParam()) { flag = false; ReportCmdKeyProgress(CmdKey.S0013); } else { ReportCmdKeyProgress(CmdKey.S0012); } if (flag) { ReportCmdKeyProgress(CmdKey.S0001); DO[DoDefine.TAB_AIR] = true; //打开吸台 DO[DoDefine.CUT_WATER] = false; //关闭切割水 Globals.LedCmd.Cmd = Globals.DevData.LoadLedCmd.Cmd; } else { ReportCmdKeyProgress(CmdKey.S0002); } if (!Globals.AppCfg.Shutdown) { ReportCmdKeyProgress(CmdKey.S0089); } Globals.AppCfg.Shutdown = false;//清除上次关机标志 return(flag); }
private static void Application_ApplicationExit(object sender, EventArgs e) { LogHelper.WriteDebugMessage("退出应用程序"); ProcessCmd.ShowWindowDesk(); //System.Diagnostics.Process.Start("shutdown.exe", "-s -t 15"); //1分钟后关机 }