const string Dir = @"./\Config";//当前目录下的Config文件夹 /// <summary> /// 通用初始化 /// </summary> public void Common_Initial() { //建立配置文件存储目录 if (!Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } //读取系统参数 SysPara = OperatePara.LoadParaXml("Para"); //读取参数 User_DB = new DB_Operate(SysPara.UserDB, SysPara.UserTB, SysPara.UserPath); //指定用户数据库和表 }
/// <summary> /// 保存项目到具体文件 /// </summary> private void SaveProjectToFile() { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "laserpro files (*.laserpro)|*.laserpro"; saveFileDialog.FilterIndex = 2; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { MainLaserProjectpath = saveFileDialog.FileName;//记录保存位置 OperatePara.SaveXmlNoPath <LaserProject>(saveFileDialog.FileName, MainLaserProject); } }
/// <summary> /// 窗口退出关闭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainView_FormClosed(object sender, FormClosedEventArgs e) { IO_Monitor_Timer.Dispose(); //状态监视定时器释放 LW_Refresh_Timer.Dispose(); //激光功率检测定时器关闭 Axis_Handle_Timer.Dispose(); //轴手动操作定时器关闭 Program.SystemContainer.IO.ClearShieldBeepTimer.Dispose(); //蜂鸣器屏蔽取消 if (Program.SystemContainer.SysPara.CamEn) { Program.SystemContainer.T_Client.Send_Data(30); //关闭摄像头软件 } OperatePara.SaveParaXml("Para", Program.SystemContainer.SysPara); Program.SystemContainer.Save_Scissor_Para(); Program.SystemContainer.Save_Material_Storage();//保存材料库 Program.SystemContainer.TimerOFF(); }
/// <summary> /// 系统参数读取 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SyaParaRead_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("确认覆盖当前系统参数?", "系统参数覆盖", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { Program.SystemContainer.SysPara = OperatePara.LoadParaXml("Para"); //更新数据 RefreshSysPara(); // 刷新系统参数页面 RefreshWorkPara(); //刷新WorkPara参数 RefreshAXisPara(); //轴参数页面参数更新 RefreshLaserHandlePara(); //刷新激光页参数数据 RefreshMainContainerPara(); //刷新主页面参数 RefreshMannualGtsPara(); //刷新Gts页面参数值 RefreshRtcPara(); //更新RTC页面参数 } }
/// <summary> /// 保存项目 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveProject_Click(object sender, EventArgs e) { if ((MainLaserProject.ProjectName == "") || (MainLaserProject.ProjectName == null))//项目名为空 { MessageBox.Show("当前项目为空,请先建立项目!"); return; } if (MainLaserProjectpath == null)//未保存过项目 { SaveProjectToFile(); } else//已保存过项目 { if (File.Exists(MainLaserProjectpath)) { OperatePara.SaveXmlNoPath <LaserProject>(MainLaserProjectpath, MainLaserProject); } else { SaveProjectToFile(); } } }
/// <summary> /// 保存材料库 /// </summary> public void Save_Material_Storage() { OperatePara.SaveXml <List <MaterialStorage> >("Material/Material", MaterialStorageList); }
/// <summary> /// 系统参数保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SysParaSave_Click(object sender, EventArgs e) { OperatePara.SaveParaXml("Para", Program.SystemContainer.SysPara); }