版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

535 строки
28 KiB

  1. using MaiMuAOI.SysCtrl;
  2. using MaiMuAOI.SysUI;
  3. using System;
  4. using System.CodeDom.Compiler;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.IO;
  10. using System.IO.Ports;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. namespace MaiMuAOI.UI.SysSet
  16. {
  17. public partial class SysSetFrm : Form
  18. {
  19. public SysSetFrm()
  20. {
  21. InitializeComponent();
  22. UIStyle.SetUIStyle(this);
  23. this.uiTitel1.FatherForm = this;
  24. }
  25. private void tsbtnExit_Click(object sender, EventArgs e)
  26. {
  27. this.Close();
  28. }
  29. private void tsbtnSave_Click(object sender, EventArgs e)
  30. {
  31. try
  32. {
  33. GetParamsSave();
  34. SysMgr.Instance.CheckWebLog();
  35. MessageBox.Show("保存成功,修改硬件参数之后需重启生效!", "保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  36. }
  37. catch (Exception ex)
  38. {
  39. MessageBox.Show(ex.Message,"保存出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
  40. }
  41. }
  42. private void SysSetFrm_Load(object sender, EventArgs e)
  43. {
  44. skinTabControl1.SelectedIndex = 0;
  45. var comNameList = SerialPort.GetPortNames().ToList();
  46. comNameList.ForEach(comName =>
  47. {
  48. this.cobLightPortNum.Items.Add(comName);
  49. this.coLensPortNum.Items.Add(comName);
  50. this.coTensorPortNum.Items.Add(comName);
  51. });
  52. //显示所有打印机
  53. if (SysMgr.Instance.PrintControl != null)
  54. {
  55. List<string> list = SysMgr.Instance.PrintControl.GetPrintersName();
  56. foreach (string printer in list)
  57. {
  58. cboPrinters.Items.Add(printer);
  59. cboPrinters2.Items.Add(printer);
  60. }
  61. }
  62. RefeshParams();
  63. }
  64. #region 界面刷新&保存
  65. private void RefeshParams()
  66. {
  67. ckSkipSizeFailed.Checked = ConfMgr.Instance.SysConfigParams.OpenMarkErrorStop;
  68. chkBuzzer.Checked = ConfMgr.Instance.SysConfigParams.OpenBuzzer;
  69. chkDoorSensor.Checked = ConfMgr.Instance.SysConfigParams.OpenDoor;
  70. chkHttpLog.Checked = ConfMgr.Instance.SysConfigParams.OpenHttpLog;
  71. cbOpenAutoAxisGoHome.Checked = ConfMgr.Instance.SysConfigParams.OpenAutoGoHome;
  72. cbOpenFlawDistribution.Checked = ConfMgr.Instance.SysConfigParams.OpenFlawDistribution;
  73. cbOpenAxisXCal.Checked = ConfMgr.Instance.SysConfigParams.OpenAxisXCalibration;
  74. cbPdtPut.Checked = ConfMgr.Instance.SysConfigParams.OpenPdtIsHave;
  75. cbSnapDefect.Checked = ConfMgr.Instance.SysConfigParams.OpenDefectSanp;
  76. cbAsideDefect.Checked = ConfMgr.Instance.SysConfigParams.OpenAsideDefect;
  77. cbOrdercheck.Checked = ConfMgr.Instance.SysConfigParams.OpenOredrCheck;
  78. cbOrderCntcheck.Checked = ConfMgr.Instance.SysConfigParams.OpenOredrCntCheck;
  79. cobLightPortNum.Text = ConfMgr.Instance.SysConfigParams.LightCom;
  80. numCamBaud.Value = ConfMgr.Instance.SysConfigParams.LightComBaud;
  81. coTensorPortNum.Text = ConfMgr.Instance.SysConfigParams.TensionCom;
  82. numTensorBaud.Value = ConfMgr.Instance.SysConfigParams.TensionComBaud;
  83. numOffset.Value = (decimal)ConfMgr.Instance.SysConfigParams.Tension_Offset;
  84. coLensPortNum.Text = ConfMgr.Instance.SysConfigParams.LensMotorCom;
  85. numLensBaud.Value = ConfMgr.Instance.SysConfigParams.LensMotorComBaud;
  86. tbThicknessIP.Text = ConfMgr.Instance.SysConfigParams.ThicknessIP;
  87. numThicknessPort.Value = ConfMgr.Instance.SysConfigParams.ThicknessPort;
  88. tbIODevNum.Text = ConfMgr.Instance.SysConfigParams.IODevName;
  89. tbIOCfgPath.Text = ConfMgr.Instance.SysConfigParams.IOCfgPath;
  90. tbMotionCfgPath.Text = ConfMgr.Instance.SysConfigParams.MotionCfgPath;
  91. tbCamCfgPath.Text = ConfMgr.Instance.SysConfigParams.FrontCamCfgPath;
  92. tbCamSN.Text = ConfMgr.Instance.SysConfigParams.FrontCamName;
  93. tbCamCfgPath2.Text = ConfMgr.Instance.SysConfigParams.BackCamCfgPath;
  94. tbCamSN2.Text = ConfMgr.Instance.SysConfigParams.BackCamName;
  95. chkSaveAllDefectImg.Checked = ConfMgr.Instance.SysConfigParams.SaveAllImg;
  96. tbDefectPath.Text = ConfMgr.Instance.SysConfigParams.DefectBigImag.SavePath;
  97. chkDefect_Path_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.DefectBigImag.AutoDelete;
  98. numDefect_Path_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectBigImag.AutoDeleteDays;
  99. tbDefectSrcSmallPath.Text = ConfMgr.Instance.SysConfigParams.DefectSrcSmallImag.SavePath;
  100. chkDefect_SrcSmall_Path_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.DefectSrcSmallImag.AutoDelete;
  101. numDefect_SrcSmall_Path_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectSrcSmallImag.AutoDeleteDays;
  102. numThres.Value = (decimal)ConfMgr.Instance.SysConfigParams.Defect_SrcSmall_Thres;
  103. tbDefectSmallPath.Text = ConfMgr.Instance.SysConfigParams.DefectSmallImag.SavePath;
  104. chkDefect_Small_Path_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.DefectSmallImag.AutoDelete;
  105. numDefect_Small_Path_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectSmallImag.AutoDeleteDays;
  106. tbDefectCompressSavePath.Text = ConfMgr.Instance.SysConfigParams.DefectRepairImag.SavePath;
  107. chkDefect_Compress_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.DefectRepairImag.AutoDelete;
  108. numDefect_Compress_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectRepairImag.AutoDeleteDays;
  109. tbSizeBmpSavePath.Text = ConfMgr.Instance.SysConfigParams.SizeBigImag.SavePath;
  110. chkSizeBmp_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.SizeBigImag.AutoDelete;
  111. numSizeBmp_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.SizeBigImag.AutoDeleteDays;
  112. tbSizeBmpCompareSavePath.Text = ConfMgr.Instance.SysConfigParams.SizeNGImag.SavePath;
  113. chkSizeBmp_Compare_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.SizeNGImag.AutoDelete;
  114. numSizeBmp_Compare_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.SizeNGImag.AutoDeleteDays;
  115. tbSizeBmpZoomImageSavePath.Text = ConfMgr.Instance.SysConfigParams.SizeRepairImag.SavePath;
  116. chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked = ConfMgr.Instance.SysConfigParams.SizeRepairImag.AutoDelete;
  117. numSizeBmp_Zoom_Image_SavePath_AutoClear.Value = (decimal)ConfMgr.Instance.SysConfigParams.SizeRepairImag.AutoDeleteDays;
  118. chkSkipAxis0.Checked = ConfMgr.Instance.SysConfigParams.DisableX1;
  119. chkSkipAxis1.Checked = ConfMgr.Instance.SysConfigParams.DisableX2;
  120. chkSkipAxis2.Checked = ConfMgr.Instance.SysConfigParams.DisableY;
  121. chkSkipAxis3.Checked = ConfMgr.Instance.SysConfigParams.DisableZ;
  122. chkSkipLight.Checked = ConfMgr.Instance.SysConfigParams.DisableLight;
  123. chkSkipTensor.Checked = ConfMgr.Instance.SysConfigParams.DisableTensor;
  124. chkSkipHeight.Checked = ConfMgr.Instance.SysConfigParams.DisableThickness;
  125. chkSkipLens.Checked = ConfMgr.Instance.SysConfigParams.DisableLensMotor;
  126. chkSkipScannerCC.Checked = ConfMgr.Instance.SysConfigParams.DisableFrontCam;
  127. chkSkipScannerGL.Checked = ConfMgr.Instance.SysConfigParams.DisableBackCam;
  128. tbSizeEnginePath.Text = ConfMgr.Instance.SysConfigParams.ImageProcessPath;
  129. tbMatDataPath.Text = ConfMgr.Instance.SysConfigParams.ImageProcessDataPath;
  130. tbModelPath.Text = ConfMgr.Instance.SysConfigParams.AIModelPath;
  131. tbPdtPath.Text = ConfMgr.Instance.ProjectDir;
  132. tbLocalIp.Text = ConfMgr.Instance.SysConfigParams.HttpServerIP;
  133. numHttpPort.Value = ConfMgr.Instance.SysConfigParams.HttpServerPort;
  134. tbLogPath.Text = ConfMgr.Instance.SysConfigParams.LogPath;
  135. ckbAutoClear.Checked = ConfMgr.Instance.SysConfigParams.AutoDeleteLog;
  136. numLogDays.Value = (decimal)ConfMgr.Instance.SysConfigParams.AutoDeleteLogData;
  137. cbResetBtn.Checked = ConfMgr.Instance.SysConfigParams.ShowResetBtn;
  138. cbBuzzShow.Checked = ConfMgr.Instance.SysConfigParams.ShowBuzz;
  139. cbDoorAlm.Checked = ConfMgr.Instance.SysConfigParams.ShowDoorAlm;
  140. cbShowBtn.Checked = ConfMgr.Instance.SysConfigParams.ShowDistribution;
  141. cbSizeEnabel.Checked = ConfMgr.Instance.SysConfigParams.ShowSizeBtn;
  142. cbDefectEnable.Checked = ConfMgr.Instance.SysConfigParams.ShowDefectBtn;
  143. numViewX.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectCamViewX;
  144. numViewY.Value = (decimal)ConfMgr.Instance.SysConfigParams.DefectCamViewY;
  145. cbEnableHttp.Checked = ConfMgr.Instance.SysConfigParams.EnableHttp;
  146. tbHttpUrl.Text = ConfMgr.Instance.SysConfigParams.HttpUrl;
  147. tbTempPath.Text = ConfMgr.Instance.SysConfigParams.HttpTempPath;
  148. tbKey.Text = ConfMgr.Instance.SysConfigParams.HttpReturnKey;
  149. tbValue.Text = ConfMgr.Instance.SysConfigParams.HttpReturnValue;
  150. numAxisZ1.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_0_58X;
  151. //numAxisZ2.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_0_6X;
  152. numAxisZ3.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_1_0X;
  153. numAxisZ4.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_1_5X;
  154. numAxisZ5.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_2_0X;
  155. numAxisZ6.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_2_5X;
  156. numAxisZ7.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_3_0X;
  157. numAxisZ8.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_3_5X;
  158. numAxisZ9.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_4_0X;
  159. numAxisZ10.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_4_5X;
  160. numAxisZ11.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_5_0X;
  161. numAxisZ12.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_5_5X;
  162. numAxisZ13.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_6_0X;
  163. numAxisZ14.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_6_5X;
  164. numAxisZ15.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_7_0X;
  165. numAxisZ16.Value = (decimal)ConfMgr.Instance.SysConfigParams.LensAxisZPos.Z_7_5X;
  166. /////////////Print////////////////
  167. this.cbOpenBarTenderPrint.Checked = ConfMgr.Instance.SysConfigParams.EnableLabelPrint;
  168. this.cboPrinters.SelectedItem = ConfMgr.Instance.SysConfigParams.LabelPrinterName;
  169. this.cbOpenExcelPrint.Checked = ConfMgr.Instance.SysConfigParams.EnableExcelPrint;
  170. this.cboPrinters2.SelectedItem = ConfMgr.Instance.SysConfigParams.ExcelPrinterName;
  171. ////////////////////////////////
  172. ////////////////本地云端////////////////
  173. cbOpenCloud.Checked = ConfMgr.Instance.SysConfigParams.OpenCloud;
  174. tbCloudName.Text = ConfMgr.Instance.SysConfigParams.CloudThisName;
  175. tbCloudIP.Text = ConfMgr.Instance.SysConfigParams.CloudServerIP;
  176. numCloudPort.Value = (decimal)ConfMgr.Instance.SysConfigParams.CloudServerPort;
  177. tbCloudUser.Text = ConfMgr.Instance.SysConfigParams.CloudUser;
  178. tbCloudPassword.Text = ConfMgr.Instance.SysConfigParams.CloudPassword;
  179. cbOpenPdtServer.Checked = ConfMgr.Instance.SysConfigParams.OpenPdtServer;
  180. rbServer.Checked = ConfMgr.Instance.SysConfigParams.IsPdtServer;
  181. rbClient.Checked = !ConfMgr.Instance.SysConfigParams.IsPdtServer;
  182. tbPdtServerIP.Text = ConfMgr.Instance.SysConfigParams.PdtServerIP;
  183. numPdtServerPort.Value = (decimal)ConfMgr.Instance.SysConfigParams.PdtServerPort;
  184. ////////////////////////////////////////
  185. }
  186. private void GetParamsSave()
  187. {
  188. SysConfigParams configParams = new SysConfigParams();
  189. configParams = ConfMgr.Instance.SysConfigParams;
  190. configParams.OpenMarkErrorStop = ckSkipSizeFailed.Checked;
  191. configParams.OpenBuzzer = chkBuzzer.Checked;
  192. configParams.OpenDoor = chkDoorSensor.Checked;
  193. configParams.OpenHttpLog = chkHttpLog.Checked;
  194. configParams.OpenAutoGoHome = cbOpenAutoAxisGoHome.Checked;
  195. configParams.OpenFlawDistribution = cbOpenFlawDistribution.Checked;
  196. configParams.OpenAxisXCalibration = cbOpenAxisXCal.Checked;
  197. configParams.OpenPdtIsHave = cbPdtPut.Checked;
  198. configParams.OpenDefectSanp = cbSnapDefect.Checked;
  199. configParams.OpenAsideDefect = cbAsideDefect.Checked;
  200. configParams.OpenOredrCheck = cbOrdercheck.Checked;
  201. configParams.OpenOredrCntCheck = cbOrderCntcheck.Checked;
  202. configParams.LightCom = cobLightPortNum.Text;
  203. configParams.LightComBaud = (int)numCamBaud.Value;
  204. configParams.TensionCom = coTensorPortNum.Text;
  205. configParams.TensionComBaud = (int)numTensorBaud.Value;
  206. configParams.Tension_Offset = (double)numOffset.Value;
  207. configParams.LensMotorCom = coLensPortNum.Text;
  208. configParams.LensMotorComBaud = (int)numLensBaud.Value;
  209. configParams.ThicknessIP = tbThicknessIP.Text;
  210. configParams.ThicknessPort = (int)numThicknessPort.Value;
  211. configParams.IODevName = tbIODevNum.Text;
  212. configParams.IOCfgPath = tbIOCfgPath.Text;
  213. configParams.MotionCfgPath = tbMotionCfgPath.Text;
  214. configParams.FrontCamName = tbCamSN.Text;
  215. configParams.FrontCamCfgPath = tbCamCfgPath.Text;
  216. configParams.BackCamName = tbCamSN2.Text;
  217. configParams.BackCamCfgPath = tbCamCfgPath2.Text;
  218. configParams.SaveAllImg = chkSaveAllDefectImg.Checked;
  219. configParams.DefectBigImag.SavePath = tbDefectPath.Text;
  220. configParams.DefectBigImag.AutoDelete = chkDefect_Path_AutoClear.Checked;
  221. configParams.DefectBigImag.AutoDeleteDays = (double)numDefect_Path_AutoClear.Value;
  222. configParams.DefectSrcSmallImag.SavePath = tbDefectSrcSmallPath.Text;
  223. configParams.DefectSrcSmallImag.AutoDelete = chkDefect_SrcSmall_Path_AutoClear.Checked;
  224. configParams.DefectSrcSmallImag.AutoDeleteDays = (double)numDefect_SrcSmall_Path_AutoClear.Value;
  225. configParams.Defect_SrcSmall_Thres = (double)numThres.Value;
  226. configParams.DefectSmallImag.SavePath = tbDefectSmallPath.Text;
  227. configParams.DefectSmallImag.AutoDelete = chkDefect_Small_Path_AutoClear.Checked;
  228. configParams.DefectSmallImag.AutoDeleteDays = (double)numDefect_Small_Path_AutoClear.Value;
  229. configParams.DefectRepairImag.SavePath = tbDefectCompressSavePath.Text;
  230. configParams.DefectRepairImag.AutoDelete = chkDefect_Compress_SavePath_AutoClear.Checked;
  231. configParams.DefectRepairImag.AutoDeleteDays = (double)numDefect_Compress_SavePath_AutoClear.Value;
  232. configParams.SizeBigImag.SavePath = tbSizeBmpSavePath.Text;
  233. configParams.SizeBigImag.AutoDelete = chkSizeBmp_SavePath_AutoClear.Checked;
  234. configParams.SizeBigImag.AutoDeleteDays = (double)numSizeBmp_SavePath_AutoClear.Value;
  235. configParams.SizeNGImag.SavePath = tbSizeBmpCompareSavePath.Text;
  236. configParams.SizeNGImag.AutoDelete = chkSizeBmp_Compare_SavePath_AutoClear.Checked;
  237. configParams.SizeNGImag.AutoDeleteDays = (double)numSizeBmp_Compare_SavePath_AutoClear.Value;
  238. configParams.SizeRepairImag.SavePath = tbSizeBmpZoomImageSavePath.Text;
  239. configParams.SizeRepairImag.AutoDelete = chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked;
  240. configParams.SizeRepairImag.AutoDeleteDays = (double)numSizeBmp_Zoom_Image_SavePath_AutoClear.Value;
  241. configParams.DisableX1 = chkSkipAxis0.Checked;
  242. configParams.DisableX2 = chkSkipAxis1.Checked;
  243. configParams.DisableY = chkSkipAxis2.Checked;
  244. configParams.DisableZ = chkSkipAxis3.Checked;
  245. configParams.DisableLight = chkSkipLight.Checked;
  246. configParams.DisableTensor = chkSkipTensor.Checked;
  247. configParams.DisableThickness = chkSkipHeight.Checked;
  248. configParams.DisableLensMotor = chkSkipLens.Checked;
  249. configParams.DisableFrontCam = chkSkipScannerCC.Checked;
  250. configParams.DisableBackCam = chkSkipScannerGL.Checked;
  251. configParams.ImageProcessPath = tbSizeEnginePath.Text;
  252. configParams.ImageProcessDataPath = tbMatDataPath.Text;
  253. configParams.AIModelPath = tbModelPath.Text;
  254. configParams.ProductPath = tbPdtPath.Text;
  255. configParams.HttpServerIP = tbLocalIp.Text;
  256. configParams.HttpServerPort = (int)numHttpPort.Value;
  257. configParams.LogPath = tbLogPath.Text;
  258. configParams.AutoDeleteLog = ckbAutoClear.Checked;
  259. configParams.AutoDeleteLogData = (double)numLogDays.Value;
  260. configParams.ShowResetBtn = cbResetBtn.Checked;
  261. configParams.ShowBuzz = cbBuzzShow.Checked;
  262. configParams.ShowDoorAlm = cbDoorAlm.Checked;
  263. configParams.ShowDistribution = cbShowBtn.Checked;
  264. configParams.ShowSizeBtn = cbSizeEnabel.Checked;
  265. configParams.ShowDefectBtn = cbDefectEnable.Checked;
  266. configParams.DefectCamViewX = (double)numViewX.Value;
  267. configParams.DefectCamViewY = (double)numViewY.Value;
  268. configParams.EnableHttp = cbEnableHttp.Checked;
  269. configParams.HttpUrl = tbHttpUrl.Text;
  270. configParams.HttpTempPath = tbTempPath.Text;
  271. configParams.HttpReturnKey = tbKey.Text;
  272. configParams.HttpReturnValue = tbValue.Text;
  273. configParams.LensAxisZPos.Z_0_58X = (double)numAxisZ1.Value;
  274. //configParams.LensAxisZPos.Z_0_6X = (double)numAxisZ2.Value;
  275. configParams.LensAxisZPos.Z_1_0X = (double)numAxisZ3.Value;
  276. configParams.LensAxisZPos.Z_1_5X = (double)numAxisZ4.Value;
  277. configParams.LensAxisZPos.Z_2_0X = (double)numAxisZ5.Value;
  278. configParams.LensAxisZPos.Z_2_5X = (double)numAxisZ6.Value;
  279. configParams.LensAxisZPos.Z_3_0X = (double)numAxisZ7.Value;
  280. configParams.LensAxisZPos.Z_3_5X = (double)numAxisZ8.Value;
  281. configParams.LensAxisZPos.Z_4_0X = (double)numAxisZ9.Value;
  282. configParams.LensAxisZPos.Z_4_5X = (double)numAxisZ10.Value;
  283. configParams.LensAxisZPos.Z_5_0X = (double)numAxisZ11.Value;
  284. configParams.LensAxisZPos.Z_5_5X = (double)numAxisZ12.Value;
  285. configParams.LensAxisZPos.Z_6_0X = (double)numAxisZ13.Value;
  286. configParams.LensAxisZPos.Z_6_5X = (double)numAxisZ14.Value;
  287. configParams.LensAxisZPos.Z_7_0X = (double)numAxisZ15.Value;
  288. configParams.LensAxisZPos.Z_7_5X = (double)numAxisZ16.Value;
  289. ////////////////////Print//////////////////////////
  290. configParams.EnableLabelPrint = this.cbOpenBarTenderPrint.Checked;
  291. if(this.cboPrinters.SelectedItem != null)
  292. configParams.LabelPrinterName = this.cboPrinters.SelectedItem.ToString();
  293. configParams.EnableExcelPrint = this.cbOpenExcelPrint.Checked;
  294. if (this.cboPrinters2.SelectedItem != null)
  295. configParams.ExcelPrinterName = this.cboPrinters2.SelectedItem.ToString();
  296. /////////////////////////////////////////////////
  297. ///////本地云端////////////////////////////
  298. configParams.OpenCloud = this.cbOpenCloud.Checked;
  299. configParams.CloudThisName = this.tbCloudName.Text;
  300. configParams.CloudServerIP = this.tbCloudIP.Text;
  301. configParams.CloudServerPort = (int)this.numCloudPort.Value;
  302. configParams.CloudUser = this.tbCloudUser.Text;
  303. configParams.CloudPassword = this.tbCloudPassword.Text;
  304. configParams.OpenPdtServer = this.cbOpenPdtServer.Checked;
  305. configParams.IsPdtServer = this.rbServer.Checked;
  306. configParams.PdtServerIP = this.tbPdtServerIP.Text;
  307. configParams.PdtServerPort = (int)this.numPdtServerPort.Value;
  308. ///////////////////////////////////////////
  309. ConfMgr.Instance.WriteSysConfParams(configParams);
  310. }
  311. #endregion
  312. private void tbPath_Click(object sender, EventArgs e)
  313. {
  314. TextBox tb = (TextBox)sender;
  315. string path = ConfMgr.SelectFolder(Application.StartupPath);
  316. if (!string.IsNullOrWhiteSpace(path))
  317. {
  318. if(tb.Name == tbIOCfgPath.Name)
  319. this.tbIOCfgPath.Text = path;
  320. else if (tb.Name == tbCamCfgPath.Name)
  321. this.tbCamCfgPath.Text = path;
  322. else if (tb.Name == tbMotionCfgPath.Name)
  323. this.tbMotionCfgPath.Text = path;
  324. else if (tb.Name == tbSizeEnginePath.Name)
  325. this.tbSizeEnginePath.Text = path;
  326. else if (tb.Name == tbMatDataPath.Name)
  327. this.tbMatDataPath.Text = path;
  328. else if (tb.Name == tbModelPath.Name)
  329. this.tbModelPath.Text = path;
  330. else if (tb.Name == tbPdtPath.Name)
  331. this.tbPdtPath.Text = path;
  332. else if (tb.Name == tbLogPath.Name)
  333. this.tbLogPath.Text = path;
  334. else if (tb.Name == tbDefectCompressSavePath.Name)
  335. this.tbDefectCompressSavePath.Text = path;
  336. else if (tb.Name == tbDefectPath.Name)
  337. this.tbDefectPath.Text = path;
  338. else if (tb.Name == tbDefectSmallPath.Name)
  339. this.tbDefectSmallPath.Text = path;
  340. else if (tb.Name == tbDefectSrcSmallPath.Name)
  341. this.tbDefectSrcSmallPath.Text = path;
  342. else if (tb.Name == tbSizeBmpCompareSavePath.Name)
  343. this.tbSizeBmpCompareSavePath.Text = path;
  344. else if (tb.Name == tbSizeBmpSavePath.Name)
  345. this.tbSizeBmpSavePath.Text = path;
  346. else if (tb.Name == tbSizeBmpZoomImageSavePath.Name)
  347. this.tbSizeBmpZoomImageSavePath.Text = path;
  348. }
  349. }
  350. private void btnClearPathClick(object sender, EventArgs e)
  351. {
  352. PictureBox pb = (PictureBox)sender;
  353. string path = "";
  354. if (pb.Name == btnClearDefect_Compress_SavePath.Name)
  355. this.tbDefectCompressSavePath.Text = path;
  356. else if (pb.Name == btnClearDefect_Path.Name)
  357. this.tbDefectPath.Text = path;
  358. else if (pb.Name == btnClearDefect_Small_Path.Name)
  359. this.tbDefectSmallPath.Text = path;
  360. else if (pb.Name == btnClearSizeBmp_Compare_SavePath.Name)
  361. this.tbSizeBmpCompareSavePath.Text = path;
  362. else if (pb.Name == btnClearSizeBmp_Path.Name)
  363. this.tbSizeBmpSavePath.Text = path;
  364. else if (pb.Name == btnSizeBmp_Zoom_Image_SavePath.Name)
  365. this.tbSizeBmpZoomImageSavePath.Text = path;
  366. else if (pb.Name == btnClearDefect_SrcSmall_Path.Name)
  367. this.tbDefectSrcSmallPath.Text = path;
  368. }
  369. private void tsbtnDatSave_Click(object sender, EventArgs e)
  370. {
  371. try
  372. {
  373. string lsPath = ConfMgr.SelectFolder();
  374. if (string.IsNullOrWhiteSpace(lsPath))
  375. return;
  376. //lsPath += "\\DB" + DateTime.Now.ToString("yyyyMMddHHmm") + ".bak";
  377. lsPath += "\\backup_" + DateTime.Now.ToString("yyyyMMddHHmm") + ".sql";
  378. Service.InitDB.BackupDataBase(lsPath);
  379. MessageBox.Show("备份成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  380. }
  381. catch (Exception ex)
  382. {
  383. MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
  384. }
  385. }
  386. private void tsbtnDatImport_Click(object sender, EventArgs e)
  387. {
  388. try
  389. {
  390. string dbPath = ConfMgr.SelectFile();
  391. if (string.IsNullOrWhiteSpace(dbPath))
  392. return;
  393. if (MessageBox.Show($"是否导入{dbPath}?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
  394. {
  395. bool rel = Service.InitDB.RestoreDB(dbPath);
  396. if (rel)
  397. {
  398. MessageBox.Show("导入成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  399. }
  400. else
  401. MessageBox.Show("导入失败!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
  402. }
  403. }
  404. catch (Exception ex)
  405. {
  406. MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
  407. }
  408. }
  409. private void tbPathFile_Click(object sender, EventArgs e)
  410. {
  411. TextBox tb = (TextBox)sender;
  412. string path = ConfMgr.SelectFile("所有文件|*.*", Application.StartupPath);
  413. if (!string.IsNullOrWhiteSpace(path))
  414. {
  415. if (tb.Name == tbIOCfgPath.Name)
  416. this.tbIOCfgPath.Text = path;
  417. else if (tb.Name == tbCamCfgPath.Name)
  418. this.tbCamCfgPath.Text = path;
  419. else if (tb.Name == tbMotionCfgPath.Name)
  420. this.tbMotionCfgPath.Text = path;
  421. else if (tb.Name == tbCamCfgPath2.Name)
  422. this.tbCamCfgPath2.Text = path;
  423. else if (tb.Name == tbMatDataPath.Name)
  424. this.tbMatDataPath.Text = path;
  425. }
  426. }
  427. #region 打印测试
  428. private void btnPrint_Click(object sender, EventArgs e)
  429. {
  430. //Button btn = (Button)sender;
  431. //bool ret = true;
  432. //if (btn.Name == "btnPrint")
  433. //{
  434. // ret = SysMgr.Instance.PrintFileData(PrinterType.Label, cboPrinters.SelectedItem.ToString(), "", null, null);
  435. //}
  436. //else
  437. //{
  438. // ret = SysMgr.Instance.PrintFileData(PrinterType.Excel, cboPrinters2.SelectedItem.ToString(), "", null, null);
  439. //}
  440. //if (ret)
  441. //{
  442. // MessageBox.Show("打印任务发生成功!", "提示");
  443. //}
  444. //else
  445. // MessageBox.Show("打印任务发生失败!", "提示");
  446. }
  447. #endregion
  448. private void tbBarTenderTempPath_DoubleClick(object sender, EventArgs e)
  449. {
  450. TextBox bt = (TextBox)sender;
  451. OpenFileDialog openFileDialog1 = new OpenFileDialog();
  452. DialogResult result = openFileDialog1.ShowDialog();
  453. if (result == DialogResult.OK)
  454. {
  455. bt.Text = openFileDialog1.FileName;
  456. }
  457. }
  458. private void tbTempPath_DoubleClick(object sender, EventArgs e)
  459. {
  460. TextBox bt = (TextBox)sender;
  461. OpenFileDialog openFileDialog1 = new OpenFileDialog();
  462. DialogResult result = openFileDialog1.ShowDialog();
  463. if (result == DialogResult.OK)
  464. {
  465. bt.Text = openFileDialog1.FileName;
  466. }
  467. }
  468. }
  469. }