using MaiMuAOI.SysCtrl; using MaiMuAOI.SysUI; using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.IO.Ports; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MaiMuAOI.UI.SysSet { public partial class SysSetFrm : Form { public SysSetFrm() { InitializeComponent(); UIStyle.SetUIStyle(this); this.uiTitel1.FatherForm = this; dataGridView1.DefaultCellStyle.ForeColor = Color.Black; dataGridView2.DefaultCellStyle.ForeColor = Color.Black; } private void tsbtnExit_Click(object sender, EventArgs e) { this.Close(); } private void tsbtnSave_Click(object sender, EventArgs e) { try { GetParamsSave(); SysMgr.Instance.CheckWebLog(); MessageBox.Show("保存成功,修改硬件参数之后需重启生效!", "保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message,"保存出错", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void SysSetFrm_Load(object sender, EventArgs e) { skinTabControl1.SelectedIndex = 0; var comNameList = SerialPort.GetPortNames().ToList(); comNameList.ForEach(comName => { this.cobLightPortNum.Items.Add(comName); this.coLensPortNum.Items.Add(comName); this.coTensorPortNum.Items.Add(comName); }); //显示所有打印机 if (SysMgr.Instance.PrintControl != null) { List list = SysMgr.Instance.PrintControl.GetPrintersName(); foreach (string printer in list) { cboPrinters.Items.Add(printer); cboPrinters2.Items.Add(printer); } } //显示打印内容 DataGridViewComboBoxColumn cbxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns["DataType"]; DataGridViewComboBoxColumn cbxColumn2 = (DataGridViewComboBoxColumn)dataGridView2.Columns["DataType2"]; foreach (var s in System.Enum.GetValues(typeof(PrintDataEnum))) { PrintDataEnum dataEnum = (PrintDataEnum)s; cbxColumn.Items.Add(dataEnum.GetDescription()); cbxColumn2.Items.Add(dataEnum.GetDescription()); } RefeshParams(); } #region 界面刷新&保存 private void RefeshParams() { ckSkipSizeFailed.Checked = ConfMgr.Instance.SysConfigParams.OpenMarkErrorStop; chkBuzzer.Checked = ConfMgr.Instance.SysConfigParams.OpenBuzzer; chkDoorSensor.Checked = ConfMgr.Instance.SysConfigParams.OpenDoor; chkHttpLog.Checked = ConfMgr.Instance.SysConfigParams.OpenHttpLog; cbOpenAutoAxisGoHome.Checked = ConfMgr.Instance.SysConfigParams.OpenAutoGoHome; cbOpenFlawDistribution.Checked = ConfMgr.Instance.SysConfigParams.OpenFlawDistribution; cbOpenAxisXCal.Checked = ConfMgr.Instance.SysConfigParams.OpenAxisXCalibration; cbPdtPut.Checked = ConfMgr.Instance.SysConfigParams.OpenPdtIsHave; cbSnapDefect.Checked = ConfMgr.Instance.SysConfigParams.OpenDefectSanp; cbAsideDefect.Checked = ConfMgr.Instance.SysConfigParams.OpenAsideDefect; cobLightPortNum.Text = ConfMgr.Instance.SysConfigParams.LightCom; numCamBaud.Value = ConfMgr.Instance.SysConfigParams.LightComBaud; coTensorPortNum.Text = ConfMgr.Instance.SysConfigParams.TensionCom; numTensorBaud.Value = ConfMgr.Instance.SysConfigParams.TensionComBaud; numOffset.Value = (decimal)ConfMgr.Instance.SysConfigParams.Tension_Offset; coLensPortNum.Text = ConfMgr.Instance.SysConfigParams.LensMotorCom; numLensBaud.Value = ConfMgr.Instance.SysConfigParams.LensMotorComBaud; tbThicknessIP.Text = ConfMgr.Instance.SysConfigParams.ThicknessIP; numThicknessPort.Value = ConfMgr.Instance.SysConfigParams.ThicknessPort; tbIODevNum.Text = ConfMgr.Instance.SysConfigParams.IODevName; tbIOCfgPath.Text = ConfMgr.Instance.SysConfigParams.IOCfgPath; tbMotionCfgPath.Text = ConfMgr.Instance.SysConfigParams.MotionCfgPath; tbCamCfgPath.Text = ConfMgr.Instance.SysConfigParams.FrontCamCfgPath; tbCamSN.Text = ConfMgr.Instance.SysConfigParams.FrontCamName; tbCamCfgPath2.Text = ConfMgr.Instance.SysConfigParams.BackCamCfgPath; tbCamSN2.Text = ConfMgr.Instance.SysConfigParams.BackCamName; chkSaveAllDefectImg.Checked = ConfMgr.Instance.SysConfigParams.SaveAllImg; tbDefectPath.Text = ConfMgr.Instance.SysConfigParams.DefectBigImag.SavePath; chkDefect_Path_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.DefectBigImag.AutoDelete; numDefect_Path_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectBigImag.AutoDeleteDays; tbDefectSmallPath.Text = ConfMgr.Instance.SysConfigParams.DefectSmallImag.SavePath; chkDefect_Small_Path_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.DefectSmallImag.AutoDelete; numDefect_Small_Path_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectSmallImag.AutoDeleteDays; tbDefectCompressSavePath.Text = ConfMgr.Instance.SysConfigParams.DefectRepairImag.SavePath; chkDefect_Compress_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.DefectRepairImag.AutoDelete; numDefect_Compress_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectRepairImag.AutoDeleteDays; tbSizeBmpSavePath.Text = ConfMgr.Instance.SysConfigParams.SizeBigImag.SavePath; chkSizeBmp_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.SizeBigImag.AutoDelete; numSizeBmp_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.SizeBigImag.AutoDeleteDays; tbSizeBmpCompareSavePath.Text = ConfMgr.Instance.SysConfigParams.SizeNGImag.SavePath; chkSizeBmp_Compare_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.SizeNGImag.AutoDelete; numSizeBmp_Compare_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.SizeNGImag.AutoDeleteDays; tbSizeBmpZoomImageSavePath.Text = ConfMgr.Instance.SysConfigParams.SizeRepairImag.SavePath; chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.SizeRepairImag.AutoDelete; numSizeBmp_Zoom_Image_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.SizeRepairImag.AutoDeleteDays; chkSkipAxis0.Checked = ConfMgr.Instance.SysConfigParams.DisableX1; chkSkipAxis1.Checked = ConfMgr.Instance.SysConfigParams.DisableX2; chkSkipAxis2.Checked = ConfMgr.Instance.SysConfigParams.DisableY; chkSkipAxis3.Checked = ConfMgr.Instance.SysConfigParams.DisableZ; chkSkipLight.Checked = ConfMgr.Instance.SysConfigParams.DisableLight; chkSkipTensor.Checked = ConfMgr.Instance.SysConfigParams.DisableTensor; chkSkipHeight.Checked = ConfMgr.Instance.SysConfigParams.DisableThickness; chkSkipLens.Checked = ConfMgr.Instance.SysConfigParams.DisableLensMotor; chkSkipScannerCC.Checked = ConfMgr.Instance.SysConfigParams.DisableFrontCam; chkSkipScannerGL.Checked = ConfMgr.Instance.SysConfigParams.DisableBackCam; tbSizeEnginePath.Text = ConfMgr.Instance.SysConfigParams.ImageProcessPath; tbMatDataPath.Text = ConfMgr.Instance.SysConfigParams.ImageProcessDataPath; tbModelPath.Text = ConfMgr.Instance.SysConfigParams.AIModelPath; tbPdtPath.Text = ConfMgr.Instance.ProjectDir; tbLocalIp.Text = ConfMgr.Instance.SysConfigParams.HttpServerIP; numHttpPort.Value = ConfMgr.Instance.SysConfigParams.HttpServerPort; tbLogPath.Text = ConfMgr.Instance.SysConfigParams.LogPath; ckbAutoClear.Checked = ConfMgr.Instance.SysConfigParams.AutoDeleteLog; numLogDays.Value = (decimal)ConfMgr.Instance.SysConfigParams.AutoDeleteLogData; cbResetBtn.Checked = ConfMgr.Instance.SysConfigParams.ShowResetBtn; cbBuzzShow.Checked = ConfMgr.Instance.SysConfigParams.ShowBuzz; cbDoorAlm.Checked = ConfMgr.Instance.SysConfigParams.ShowDoorAlm; cbShowBtn.Checked = ConfMgr.Instance.SysConfigParams.ShowDistribution; numViewX.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectCamViewX; numViewY.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectCamViewY; cbEnableHttp.Checked = ConfMgr.Instance.SysConfigParams.EnableHttp; tbHttpUrl.Text = ConfMgr.Instance.SysConfigParams.HttpUrl; tbTempPath.Text = ConfMgr.Instance.SysConfigParams.HttpTempPath; tbKey.Text = ConfMgr.Instance.SysConfigParams.HttpReturnKey; tbValue.Text = ConfMgr.Instance.SysConfigParams.HttpReturnValue; numAxisZ1.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_0_58X; //numAxisZ2.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_0_6X; numAxisZ3.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_1_0X; numAxisZ4.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_1_5X; numAxisZ5.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_2_0X; numAxisZ6.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_2_5X; numAxisZ7.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_3_0X; numAxisZ8.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_3_5X; numAxisZ9.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_4_0X; numAxisZ10.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_4_5X; numAxisZ11.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_5_0X; numAxisZ12.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_5_5X; numAxisZ13.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_6_0X; numAxisZ14.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_6_5X; numAxisZ15.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_7_0X; numAxisZ16.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_7_5X; /////////////Print//////////////// this.cbOpenBarTenderPrint.Checked = ConfMgr.Instance.SysConfigParams.EnableLabelPrint; this.cboPrinters.SelectedItem = ConfMgr.Instance.SysConfigParams.LabelPrinterName; this.tbBarTenderTempPath.Text = ConfMgr.Instance.SysConfigParams.LabelTempPath; foreach (var item in ConfMgr.Instance.SysConfigParams.LabelData) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = item.Key; this.dataGridView1.Rows[index].Cells[1].Value = item.Value; } this.cbOpenExcelPrint.Checked = ConfMgr.Instance.SysConfigParams.EnableExcelPrint; this.cboPrinters2.SelectedItem = ConfMgr.Instance.SysConfigParams.ExcelPrinterName; this.tbExcelTempPath.Text = ConfMgr.Instance.SysConfigParams.ExcelTempPath; foreach (var item in ConfMgr.Instance.SysConfigParams.ExcelData) { int index = this.dataGridView2.Rows.Add(); this.dataGridView2.Rows[index].Cells[0].Value = item.Key; this.dataGridView2.Rows[index].Cells[1].Value = item.Value; } //////////////////////////////// ////////////////本地云端//////////////// cbOpenCloud.Checked = ConfMgr.Instance.SysConfigParams.OpenCloud; tbCloudName.Text = ConfMgr.Instance.SysConfigParams.CloudThisName; tbCloudIP.Text = ConfMgr.Instance.SysConfigParams.CloudServerIP; numCloudPort.Value = (decimal)ConfMgr.Instance.SysConfigParams.CloudServerPort; tbCloudUser.Text = ConfMgr.Instance.SysConfigParams.CloudUser; tbCloudPassword.Text = ConfMgr.Instance.SysConfigParams.CloudPassword; cbOpenPdtServer.Checked = ConfMgr.Instance.SysConfigParams.OpenPdtServer; rbServer.Checked = ConfMgr.Instance.SysConfigParams.IsPdtServer; rbClient.Checked = !ConfMgr.Instance.SysConfigParams.IsPdtServer; tbPdtServerIP.Text = ConfMgr.Instance.SysConfigParams.PdtServerIP; numPdtServerPort.Value = (decimal)ConfMgr.Instance.SysConfigParams.PdtServerPort; //////////////////////////////////////// } private void GetParamsSave() { SysConfigParams configParams = new SysConfigParams(); configParams = ConfMgr.Instance.SysConfigParams; configParams.OpenMarkErrorStop = ckSkipSizeFailed.Checked; configParams.OpenBuzzer = chkBuzzer.Checked; configParams.OpenDoor = chkDoorSensor.Checked; configParams.OpenHttpLog = chkHttpLog.Checked; configParams.OpenAutoGoHome = cbOpenAutoAxisGoHome.Checked; configParams.OpenFlawDistribution = cbOpenFlawDistribution.Checked; configParams.OpenAxisXCalibration = cbOpenAxisXCal.Checked; configParams.OpenPdtIsHave = cbPdtPut.Checked; configParams.OpenDefectSanp = cbSnapDefect.Checked; configParams.OpenAsideDefect = cbAsideDefect.Checked; configParams.LightCom = cobLightPortNum.Text; configParams.LightComBaud = (int)numCamBaud.Value; configParams.TensionCom = coTensorPortNum.Text; configParams.TensionComBaud = (int)numTensorBaud.Value; configParams.Tension_Offset = (double)numOffset.Value; configParams.LensMotorCom = coLensPortNum.Text; configParams.LensMotorComBaud = (int)numLensBaud.Value; configParams.ThicknessIP = tbThicknessIP.Text; configParams.ThicknessPort = (int)numThicknessPort.Value; configParams.IODevName = tbIODevNum.Text; configParams.IOCfgPath = tbIOCfgPath.Text; configParams.MotionCfgPath = tbMotionCfgPath.Text; configParams.FrontCamName = tbCamSN.Text; configParams.FrontCamCfgPath = tbCamCfgPath.Text; configParams.BackCamName = tbCamSN2.Text; configParams.BackCamCfgPath = tbCamCfgPath2.Text; configParams.SaveAllImg = chkSaveAllDefectImg.Checked; configParams.DefectBigImag.SavePath = tbDefectPath.Text; configParams.DefectBigImag.AutoDelete = chkDefect_Path_AutoClear.Checked; configParams.DefectBigImag.AutoDeleteDays = (double)numDefect_Path_AutoClear.Value; configParams.DefectSmallImag.SavePath = tbDefectSmallPath.Text; configParams.DefectSmallImag.AutoDelete = chkDefect_Small_Path_AutoClear.Checked; configParams.DefectSmallImag.AutoDeleteDays = (double)numDefect_Small_Path_AutoClear.Value; configParams.DefectRepairImag.SavePath = tbDefectCompressSavePath.Text; configParams.DefectRepairImag.AutoDelete = chkDefect_Compress_SavePath_AutoClear.Checked; configParams.DefectRepairImag.AutoDeleteDays = (double)numDefect_Compress_SavePath_AutoClear.Value; configParams.SizeBigImag.SavePath = tbSizeBmpSavePath.Text; configParams.SizeBigImag.AutoDelete = chkSizeBmp_SavePath_AutoClear.Checked; configParams.SizeBigImag.AutoDeleteDays = (double)numSizeBmp_SavePath_AutoClear.Value; configParams.SizeNGImag.SavePath = tbSizeBmpCompareSavePath.Text; configParams.SizeNGImag.AutoDelete = chkSizeBmp_Compare_SavePath_AutoClear.Checked; configParams.SizeNGImag.AutoDeleteDays = (double)numSizeBmp_Compare_SavePath_AutoClear.Value; configParams.SizeRepairImag.SavePath = tbSizeBmpZoomImageSavePath.Text; configParams.SizeRepairImag.AutoDelete = chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked; configParams.SizeRepairImag.AutoDeleteDays = (double)numSizeBmp_Zoom_Image_SavePath_AutoClear.Value; configParams.DisableX1 = chkSkipAxis0.Checked; configParams.DisableX2 = chkSkipAxis1.Checked; configParams.DisableY = chkSkipAxis2.Checked; configParams.DisableZ = chkSkipAxis3.Checked; configParams.DisableLight = chkSkipLight.Checked; configParams.DisableTensor = chkSkipTensor.Checked; configParams.DisableThickness = chkSkipHeight.Checked; configParams.DisableLensMotor = chkSkipLens.Checked; configParams.DisableFrontCam = chkSkipScannerCC.Checked; configParams.DisableBackCam = chkSkipScannerGL.Checked; configParams.ImageProcessPath = tbSizeEnginePath.Text; configParams.ImageProcessDataPath = tbMatDataPath.Text; configParams.AIModelPath = tbModelPath.Text; configParams.ProductPath = tbPdtPath.Text; configParams.HttpServerIP = tbLocalIp.Text; configParams.HttpServerPort = (int)numHttpPort.Value; configParams.LogPath = tbLogPath.Text; configParams.AutoDeleteLog = ckbAutoClear.Checked; configParams.AutoDeleteLogData = (double)numLogDays.Value; configParams.ShowResetBtn = cbResetBtn.Checked; configParams.ShowBuzz = cbBuzzShow.Checked; configParams.ShowDoorAlm = cbDoorAlm.Checked; configParams.ShowDistribution = cbShowBtn.Checked; configParams.DefectCamViewX = (double)numViewX.Value; configParams.DefectCamViewY = (double)numViewY.Value; configParams.EnableHttp = cbEnableHttp.Checked; configParams.HttpUrl = tbHttpUrl.Text; configParams.HttpTempPath = tbTempPath.Text; configParams.HttpReturnKey = tbKey.Text; configParams.HttpReturnValue = tbValue.Text; configParams.LensAxisZPos.Z_0_58X = (double)numAxisZ1.Value; //configParams.LensAxisZPos.Z_0_6X = (double)numAxisZ2.Value; configParams.LensAxisZPos.Z_1_0X = (double)numAxisZ3.Value; configParams.LensAxisZPos.Z_1_5X = (double)numAxisZ4.Value; configParams.LensAxisZPos.Z_2_0X = (double)numAxisZ5.Value; configParams.LensAxisZPos.Z_2_5X = (double)numAxisZ6.Value; configParams.LensAxisZPos.Z_3_0X = (double)numAxisZ7.Value; configParams.LensAxisZPos.Z_3_5X = (double)numAxisZ8.Value; configParams.LensAxisZPos.Z_4_0X = (double)numAxisZ9.Value; configParams.LensAxisZPos.Z_4_5X = (double)numAxisZ10.Value; configParams.LensAxisZPos.Z_5_0X = (double)numAxisZ11.Value; configParams.LensAxisZPos.Z_5_5X = (double)numAxisZ12.Value; configParams.LensAxisZPos.Z_6_0X = (double)numAxisZ13.Value; configParams.LensAxisZPos.Z_6_5X = (double)numAxisZ14.Value; configParams.LensAxisZPos.Z_7_0X = (double)numAxisZ15.Value; configParams.LensAxisZPos.Z_7_5X = (double)numAxisZ16.Value; ////////////////////Print////////////////////////// configParams.EnableLabelPrint = this.cbOpenBarTenderPrint.Checked; if(this.cboPrinters.SelectedItem != null) configParams.LabelPrinterName = this.cboPrinters.SelectedItem.ToString(); configParams.LabelTempPath = this.tbBarTenderTempPath.Text; Dictionary labeldata = new Dictionary(); for (int i = 0; i < this.dataGridView1.RowCount; i++) { if (this.dataGridView1.Rows[i].Cells[0].Value != null) labeldata.Add(this.dataGridView1.Rows[i].Cells[0].Value.ToString(), this.dataGridView1.Rows[i].Cells[1].Value.ToString()); } configParams.LabelData = labeldata; configParams.EnableExcelPrint = this.cbOpenExcelPrint.Checked; if (this.cboPrinters2.SelectedItem != null) configParams.ExcelPrinterName = this.cboPrinters2.SelectedItem.ToString(); configParams.ExcelTempPath = this.tbExcelTempPath.Text; labeldata = new Dictionary(); for (int i = 0; i < this.dataGridView2.RowCount; i++) { if (this.dataGridView2.Rows[i].Cells[0].Value != null) labeldata.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString(), this.dataGridView2.Rows[i].Cells[1].Value.ToString()); } configParams.ExcelData = labeldata; ///////////////////////////////////////////////// ///////本地云端//////////////////////////// configParams.OpenCloud = this.cbOpenCloud.Checked; configParams.CloudThisName = this.tbCloudName.Text; configParams.CloudServerIP = this.tbCloudIP.Text; configParams.CloudServerPort = (int)this.numCloudPort.Value; configParams.CloudUser = this.tbCloudUser.Text; configParams.CloudPassword = this.tbCloudPassword.Text; configParams.OpenPdtServer = this.cbOpenPdtServer.Checked; configParams.IsPdtServer = this.rbServer.Checked; configParams.PdtServerIP = this.tbPdtServerIP.Text; configParams.PdtServerPort = (int)this.numPdtServerPort.Value; /////////////////////////////////////////// ConfMgr.Instance.WriteSysConfParams(configParams); } #endregion private void tbPath_Click(object sender, EventArgs e) { TextBox tb = (TextBox)sender; string path = ConfMgr.SelectFolder(Application.StartupPath); if (!string.IsNullOrWhiteSpace(path)) { if(tb.Name == tbIOCfgPath.Name) this.tbIOCfgPath.Text = path; else if (tb.Name == tbCamCfgPath.Name) this.tbCamCfgPath.Text = path; else if (tb.Name == tbMotionCfgPath.Name) this.tbMotionCfgPath.Text = path; else if (tb.Name == tbSizeEnginePath.Name) this.tbSizeEnginePath.Text = path; else if (tb.Name == tbMatDataPath.Name) this.tbMatDataPath.Text = path; else if (tb.Name == tbModelPath.Name) this.tbModelPath.Text = path; else if (tb.Name == tbPdtPath.Name) this.tbPdtPath.Text = path; else if (tb.Name == tbLogPath.Name) this.tbLogPath.Text = path; else if (tb.Name == tbDefectCompressSavePath.Name) this.tbDefectCompressSavePath.Text = path; else if (tb.Name == tbDefectPath.Name) this.tbDefectPath.Text = path; else if (tb.Name == tbDefectSmallPath.Name) this.tbDefectSmallPath.Text = path; else if (tb.Name == tbSizeBmpCompareSavePath.Name) this.tbSizeBmpCompareSavePath.Text = path; else if (tb.Name == tbSizeBmpSavePath.Name) this.tbSizeBmpSavePath.Text = path; else if (tb.Name == tbSizeBmpZoomImageSavePath.Name) this.tbSizeBmpZoomImageSavePath.Text = path; } } private void btnClearPathClick(object sender, EventArgs e) { PictureBox pb = (PictureBox)sender; string path = ""; if (pb.Name == btnClearDefect_Compress_SavePath.Name) this.tbDefectCompressSavePath.Text = path; else if (pb.Name == btnClearDefect_Path.Name) this.tbDefectPath.Text = path; else if (pb.Name == btnClearDefect_Small_Path.Name) this.tbDefectSmallPath.Text = path; else if (pb.Name == btnClearSizeBmp_Compare_SavePath.Name) this.tbSizeBmpCompareSavePath.Text = path; else if (pb.Name == btnClearSizeBmp_Path.Name) this.tbSizeBmpSavePath.Text = path; else if (pb.Name == btnSizeBmp_Zoom_Image_SavePath.Name) this.tbSizeBmpZoomImageSavePath.Text = path; } private void tsbtnDatSave_Click(object sender, EventArgs e) { try { string lsPath = ConfMgr.SelectFolder(); if (string.IsNullOrWhiteSpace(lsPath)) return; //lsPath += "\\DB" + DateTime.Now.ToString("yyyyMMddHHmm") + ".bak"; lsPath += "\\backup_" + DateTime.Now.ToString("yyyyMMddHHmm") + ".sql"; Service.InitDB.BackupDataBase(lsPath); MessageBox.Show("备份成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void tsbtnDatImport_Click(object sender, EventArgs e) { try { string dbPath = ConfMgr.SelectFile(); if (string.IsNullOrWhiteSpace(dbPath)) return; if (MessageBox.Show($"是否导入{dbPath}?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { bool rel = Service.InitDB.RestoreDB(dbPath); if (rel) { MessageBox.Show("导入成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else MessageBox.Show("导入失败!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void tbPathFile_Click(object sender, EventArgs e) { TextBox tb = (TextBox)sender; string path = ConfMgr.SelectFile("所有文件|*.*", Application.StartupPath); if (!string.IsNullOrWhiteSpace(path)) { if (tb.Name == tbIOCfgPath.Name) this.tbIOCfgPath.Text = path; else if (tb.Name == tbCamCfgPath.Name) this.tbCamCfgPath.Text = path; else if (tb.Name == tbMotionCfgPath.Name) this.tbMotionCfgPath.Text = path; else if (tb.Name == tbCamCfgPath2.Name) this.tbCamCfgPath2.Text = path; else if (tb.Name == tbMatDataPath.Name) this.tbMatDataPath.Text = path; } } #region 打印测试 private void btnPrint_Click(object sender, EventArgs e) { //Button btn = (Button)sender; //bool ret = true; //if (btn.Name == "btnPrint") //{ // ret = SysMgr.Instance.PrintFileData(PrinterType.Label, cboPrinters.SelectedItem.ToString(), "", null, null); //} //else //{ // ret = SysMgr.Instance.PrintFileData(PrinterType.Excel, cboPrinters2.SelectedItem.ToString(), "", null, null); //} //if (ret) //{ // MessageBox.Show("打印任务发生成功!", "提示"); //} //else // MessageBox.Show("打印任务发生失败!", "提示"); } #endregion private void tbBarTenderTempPath_DoubleClick(object sender, EventArgs e) { TextBox bt = (TextBox)sender; OpenFileDialog openFileDialog1 = new OpenFileDialog(); DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { bt.Text = openFileDialog1.FileName; } } private void tbTempPath_DoubleClick(object sender, EventArgs e) { TextBox bt = (TextBox)sender; OpenFileDialog openFileDialog1 = new OpenFileDialog(); DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { bt.Text = openFileDialog1.FileName; } } } }