UControl_Init.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MeasureData;
  11. using System.Configuration;
  12. using FileManager;
  13. using System.IO;
  14. namespace HOZProject
  15. {
  16. public partial class UControl_Init : UserControl
  17. {
  18. #region 全局变量
  19. String[] sT;
  20. String[] firms;
  21. String[] WPZD;
  22. String[] WPZF;
  23. String[] WQGD;
  24. String[] WQGF;
  25. String[] WLZ;
  26. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  27. private FormHOZMain formHOZMain;
  28. public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
  29. //模板路径
  30. private string readConfigPath;
  31. public string ReadConfigPath { get => readConfigPath; set => readConfigPath = value; }
  32. //模板文件默认路径
  33. private string m_TemplateFilePath;
  34. #endregion
  35. #region 构造方法
  36. public UControl_Init(FormHOZMain formHOZ)
  37. {
  38. InitializeComponent();
  39. FormHOZMainObject = formHOZ;
  40. }
  41. #endregion
  42. private void UControl_Init_Load(object sender, EventArgs e)
  43. {
  44. }
  45. #region 关闭窗体
  46. private void btnClose_Click(object sender, EventArgs e)
  47. {
  48. Form fParent = this.ParentForm;
  49. fParent.Close();
  50. }
  51. #endregion
  52. #region 加载切孔文件,生成切孔列表
  53. private void pbCutHoleFile_Click(object sender, EventArgs e)
  54. {
  55. if (FormHOZMainObject.m_MeasureFile == null)
  56. {
  57. MessageBox.Show("请新建一个测量文件");
  58. }
  59. else
  60. {
  61. if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
  62. {
  63. MessageBox.Show("导入切孔失败");
  64. }
  65. else
  66. {
  67. List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
  68. //文件路径
  69. string CutHoleFilePath = FormHOZMainObject.m_MeasureFile.CutHoleFilePath;
  70. FormHOZMainObject.CreateCutHoleList(ListCutHole);
  71. //显示导入的切孔数量
  72. lblCutHoleCount.Text = string.Format("成功导入{0}个切孔", ListCutHole.Count);
  73. tbCutHoleFilePath.Text = CutHoleFilePath;
  74. //保存测量文件
  75. if (FormHOZMainObject.IsSave)
  76. {
  77. FormHOZMainObject.m_MeasureFile.Save();
  78. }
  79. }
  80. }
  81. }
  82. #endregion
  83. #region 根据一个切孔文件,自动计算其他切孔信息
  84. /// <summary>
  85. /// 根据一个切孔,自动计算其他切孔信息
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. private void pbCutHoleAuto_Click(object sender, EventArgs e)
  90. {
  91. }
  92. #endregion
  93. #region 加载PT模板文件
  94. private void pbTemplateFile_Click(object sender, EventArgs e)
  95. {
  96. string FilePathName;
  97. string fileNameWithoutExtension;
  98. //新建一个文件对话框
  99. OpenFileDialog pOpenFileDialog = new OpenFileDialog();
  100. //设置对话框标题
  101. pOpenFileDialog.Title = "选择模板文件";
  102. //设置打开文件类型
  103. pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
  104. ////监测文件是否存在
  105. //pOpenFileDialog.CheckFileExists = true;
  106. //文件打开后执行以下程序
  107. if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
  108. {
  109. FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
  110. fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
  111. this.txtWPTF.Text = FilePathName;
  112. }
  113. }
  114. #endregion
  115. #region 加载FIB模板文件
  116. private void pbFIBTemplateFile_Click(object sender, EventArgs e)
  117. {
  118. string FilePathName;
  119. string fileNameWithoutExtension;
  120. //新建一个文件对话框
  121. OpenFileDialog pOpenFileDialog = new OpenFileDialog();
  122. //设置对话框标题
  123. pOpenFileDialog.Title = "选择模板文件";
  124. //设置打开文件类型
  125. pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
  126. ////监测文件是否存在
  127. //pOpenFileDialog.CheckFileExists = true;
  128. //文件打开后执行以下程序
  129. if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
  130. {
  131. FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName); //绝对路径
  132. fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
  133. this.txtWFIBF.Text = FilePathName;
  134. }
  135. }
  136. #endregion
  137. #region 创建与读取样品参数、配置文件
  138. private void btnCreateConfig_Click(object sender, EventArgs e)
  139. {
  140. SaveTemplateFile();
  141. }
  142. /// <summary>
  143. /// 获取测量参数,初始化窗体中的控件信息
  144. /// </summary>
  145. /// <returns></returns>
  146. public MeasureParam GetMeasureParamInfo()
  147. {
  148. MeasureParam cfm = new MeasureParam();
  149. cfm.Is_Photograph = chkWIsP.Checked;
  150. cfm.PT = chkWPT.Checked;
  151. //自动对焦模式
  152. //cfm.FocusMode = chkManul.Checked;
  153. cfm.PTTemp = txtWPTF.Text;
  154. cfm.FIBTemp = txtWFIBF.Text;
  155. cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
  156. cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
  157. cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
  158. cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
  159. cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
  160. if (cbbWXZ.SelectedIndex == 0)
  161. {
  162. cfm.Correction_Angle = 36;
  163. }
  164. else
  165. {
  166. cfm.Correction_Angle = 54;
  167. }
  168. cfm.SampleName = cbbWYP.Text;
  169. cfm.Firm = cbbWCS.Text;
  170. return cfm;
  171. }
  172. public void SaveTemplateFile()
  173. {
  174. MeasureParam cfm = new MeasureParam();
  175. cfm.Is_Photograph = chkWIsP.Checked;
  176. cfm.PT = chkWPT.Checked;
  177. //自动对焦模式
  178. //cfm.FocusMode = chkManul.Checked;
  179. cfm.PTTemp = txtWPTF.Text;
  180. cfm.FIBTemp = txtWFIBF.Text;
  181. cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
  182. cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
  183. cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
  184. cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
  185. cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
  186. if (cbbWXZ.SelectedIndex == 0)
  187. {
  188. cfm.Correction_Angle = 36;
  189. }
  190. else
  191. {
  192. cfm.Correction_Angle = 54;
  193. }
  194. cfm.SampleName = cbbWYP.Text;
  195. cfm.Firm = cbbWCS.Text;
  196. ConfigFile cf = new ConfigFile(cfm);
  197. if (!m_TemplateFilePath.Equals(""))
  198. {
  199. if (!Directory.Exists(m_TemplateFilePath))
  200. {
  201. //创建路径
  202. Directory.CreateDirectory(m_TemplateFilePath);
  203. }
  204. }
  205. SaveFileDialog saveFileDialog = new SaveFileDialog();
  206. //设置默认打开路径(绝对路径)
  207. saveFileDialog.InitialDirectory = m_TemplateFilePath;
  208. saveFileDialog.Filter = "样品参数文件|*.cfg";
  209. if (saveFileDialog.ShowDialog() == DialogResult.OK)
  210. {
  211. cf.Save(saveFileDialog.FileName);
  212. }
  213. else
  214. {
  215. return;
  216. }
  217. //编辑Config文件
  218. EditConfig();
  219. }
  220. /// <summary>
  221. /// 编辑confing 文件信息
  222. /// </summary>
  223. public bool EditConfig()
  224. {
  225. try
  226. {
  227. //设置数据源信息
  228. //样品类型
  229. List<String> _sT = sT.ToList();
  230. if (_sT.IndexOf(cbbWYP.Text) < 0)
  231. {
  232. _sT.Add(cbbWYP.Text);
  233. string wsT = string.Join(",", _sT.ToArray());
  234. config.AppSettings.Settings["Sample_Type"].Value = wsT;
  235. }
  236. //厂商
  237. List<String> _firms = firms.ToList();
  238. if (_firms.IndexOf(cbbWCS.Text) < 0)
  239. {
  240. _firms.Add(cbbWCS.Text);
  241. string wFirms = string.Join(",", _firms.ToArray());
  242. config.AppSettings.Settings["Firm"].Value = wFirms;
  243. }
  244. //拍照电压
  245. List<String> _WPZD = WPZD.ToList();
  246. if (_WPZD.IndexOf(cbbWPZD.Text) < 0)
  247. {
  248. _WPZD.Add(cbbWPZD.Text);
  249. string wWPZD = string.Join(",", _WPZD.ToArray());
  250. config.AppSettings.Settings["WPZD"].Value = wWPZD;
  251. }
  252. //拍照放大位数
  253. List<String> _WPZF = WPZF.ToList();
  254. if (_WPZF.IndexOf(cbbWPZF.Text) < 0)
  255. {
  256. _WPZF.Add(cbbWPZF.Text);
  257. string wWPZF = string.Join(",", _WPZF.ToArray());
  258. config.AppSettings.Settings["WPZF"].Value = wWPZF;
  259. }
  260. //定位切割电压
  261. List<String> _WQGD = WQGD.ToList();
  262. if (_WQGD.IndexOf(cbbWQGD.Text) < 0)
  263. {
  264. _WQGD.Add(cbbWQGD.Text);
  265. string wWQGD = string.Join(",", _WQGD.ToArray());
  266. config.AppSettings.Settings["WQGD"].Value = wWQGD;
  267. }
  268. //定位切割放大位数
  269. List<String> _WQGF = WQGF.ToList();
  270. if (_WQGF.IndexOf(cbbWQGF.Text) < 0)
  271. {
  272. _WQGF.Add(cbbWQGF.Text);
  273. string wWQGF = string.Join(",", _WQGF.ToArray());
  274. config.AppSettings.Settings["WQGF"].Value = wWQGF;
  275. }
  276. //拉直操作放大位数
  277. List<String> _WLZ = WLZ.ToList();
  278. if (_WLZ.IndexOf(cbbWLZ.Text) < 0)
  279. {
  280. _WLZ.Add(cbbWLZ.Text);
  281. string wWLZ = string.Join(",", _WLZ.ToArray());
  282. config.AppSettings.Settings["WLZ"].Value = wWLZ;
  283. }
  284. MeasureParam cfm = new MeasureParam();
  285. cfm.Is_Photograph = chkWIsP.Checked;
  286. cfm.FocusMode = Convert.ToInt32(config.AppSettings.Settings["Focus_Mode"].Value);
  287. cfm.PT = chkWPT.Checked;
  288. //自动对焦模式
  289. //cfm.FocusMode = chkManul.Checked;
  290. cfm.PTTemp = txtWPTF.Text;
  291. cfm.FIBTemp = txtWFIBF.Text;
  292. cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
  293. cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
  294. cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
  295. cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
  296. cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
  297. if (cbbWXZ.SelectedIndex == 0)
  298. {
  299. cfm.Correction_Angle = 36;
  300. }
  301. else
  302. {
  303. cfm.Correction_Angle = 54;
  304. }
  305. cfm.SampleName = cbbWYP.Text;
  306. cfm.Firm = cbbWCS.Text;
  307. //设置配置文件默认值
  308. config.AppSettings.Settings["Is_Photograph"].Value = cfm.Is_Photograph.ToString();
  309. config.AppSettings.Settings["PT_Depostion"].Value = cfm.PT.ToString();
  310. config.AppSettings.Settings["PT_ELYFile"].Value = cfm.PTTemp;
  311. config.AppSettings.Settings["FIB_ELYFile"].Value = cfm.FIBTemp;
  312. config.AppSettings.Settings["Stretch_Magnification"].Value = cfm.Stretch_Magnification.ToString();
  313. config.AppSettings.Settings["Location_Magnification"].Value = cfm.Location_Magnification.ToString();
  314. config.AppSettings.Settings["Location_Voltage"].Value = cfm.Location_Voltage.ToString();
  315. config.AppSettings.Settings["Photograph_Magnification"].Value = cfm.Photograph_Magnification.ToString();
  316. config.AppSettings.Settings["Photograph_Voltage"].Value = cfm.Photograph_Voltage.ToString();
  317. config.AppSettings.Settings["Correction_Angle"].Value = cfm.Correction_Angle.ToString();
  318. config.AppSettings.Settings["SampleName"].Value = cfm.SampleName;
  319. config.AppSettings.Settings["Firms"].Value = cfm.Firm;
  320. config.Save(ConfigurationSaveMode.Modified);
  321. ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
  322. return true;
  323. }
  324. catch (Exception ex)
  325. {
  326. LogManager.LogError(ex.Message);
  327. return false;
  328. }
  329. }
  330. /// <summary>
  331. /// 删除config文件节点中内容信息
  332. /// </summary>
  333. public bool DelConfigNodeContentInfo(string delControlName, string selName)
  334. {
  335. try
  336. {
  337. switch (delControlName)
  338. {
  339. case "WYP":
  340. //样品类型
  341. List<String> _sT = sT.ToList();
  342. _sT.Remove(selName);
  343. string wsT = string.Join(",", _sT.ToArray());
  344. config.AppSettings.Settings["Sample_Type"].Value = wsT;
  345. break;
  346. case "WCS":
  347. //厂商
  348. List<String> _firms = firms.ToList();
  349. _firms.Remove(selName);
  350. string wFirms = string.Join(",", _firms.ToArray());
  351. config.AppSettings.Settings["Firm"].Value = wFirms;
  352. break;
  353. case "WPZD":
  354. //拍照电压
  355. List<String> _WPZD = WPZD.ToList();
  356. _WPZD.Remove(selName);
  357. string wWPZD = string.Join(",", _WPZD.ToArray());
  358. config.AppSettings.Settings["WPZD"].Value = wWPZD;
  359. break;
  360. case "WPZF":
  361. //拍照放大位数
  362. List<String> _WPZF = WPZF.ToList();
  363. _WPZF.Remove(selName);
  364. string wWPZF = string.Join(",", _WPZF.ToArray());
  365. config.AppSettings.Settings["WPZF"].Value = wWPZF;
  366. break;
  367. case "WQGD"://定位切割电压
  368. List<String> _WQGD = WQGD.ToList();
  369. _WQGD.Remove(selName);
  370. string wWQGD = string.Join(",", _WQGD.ToArray());
  371. config.AppSettings.Settings["WQGD"].Value = wWQGD;
  372. break;
  373. case "WQGF": //定位切割放大位数
  374. List<String> _WQGF = WQGF.ToList();
  375. _WQGF.Remove(selName);
  376. string wWQGF = string.Join(",", _WQGF.ToArray());
  377. config.AppSettings.Settings["WQGF"].Value = wWQGF;
  378. break;
  379. case "WLZ":
  380. //拉直操作放大位数
  381. List<String> _WLZ = WLZ.ToList();
  382. _WLZ.Remove(selName);
  383. string wWLZ = string.Join(",", _WLZ.ToArray());
  384. config.AppSettings.Settings["WLZ"].Value = wWLZ;
  385. break;
  386. }
  387. config.Save(ConfigurationSaveMode.Modified);
  388. ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
  389. return true;
  390. }
  391. catch (Exception ex)
  392. {
  393. LogManager.LogError(ex.Message);
  394. return true;
  395. }
  396. }
  397. /// <summary>
  398. /// 绑定下拉菜单
  399. /// </summary>
  400. /// <param name="cb"></param>
  401. /// <param name="strGroup"></param>
  402. private void BindComboxData(ComboBox cb, string[] strGroup)
  403. {
  404. for (int i = 0; i < strGroup.Length; i++)
  405. {
  406. if (!strGroup[i].Equals(""))
  407. {
  408. cb.Items.Add(strGroup[i]);
  409. }
  410. }
  411. }
  412. /// <summary>
  413. /// 读取Config文件信息
  414. /// </summary>
  415. public void ReloadConfig()
  416. {
  417. cbbWYP.Items.Clear();
  418. cbbWCS.Items.Clear();
  419. cbbWPZD.Items.Clear();
  420. cbbWPZF.Items.Clear();
  421. cbbWQGD.Items.Clear();
  422. cbbWQGF.Items.Clear();
  423. cbbWLZ.Items.Clear();
  424. m_TemplateFilePath = config.AppSettings.Settings["TemplateFilePath"].Value.ToString();
  425. string sample_Type = config.AppSettings.Settings["Sample_Type"].Value.ToString();
  426. string firm = config.AppSettings.Settings["Firm"].Value.ToString();
  427. string WPZDTemp = config.AppSettings.Settings["WPZD"].Value.ToString();
  428. string WPZFTemp = config.AppSettings.Settings["WPZF"].Value.ToString();
  429. string WQGDTemp = config.AppSettings.Settings["WQGD"].Value.ToString();
  430. string WQGFTemp = config.AppSettings.Settings["WQGF"].Value.ToString();
  431. string WLZTemp = config.AppSettings.Settings["WLZ"].Value.ToString();
  432. //样品类型
  433. sT = sample_Type.Split(',');
  434. BindComboxData(cbbWYP, sT);
  435. //厂商
  436. firms = firm.Split(',');
  437. BindComboxData(cbbWCS, firms);
  438. //拍照电压
  439. WPZD = WPZDTemp.Split(',');
  440. BindComboxData(cbbWPZD, WPZD);
  441. //拍照放大位数
  442. WPZF = WPZFTemp.Split(',');
  443. BindComboxData(cbbWPZF, WPZF);
  444. //定位切割电压
  445. WQGD = WQGDTemp.Split(',');
  446. BindComboxData(cbbWQGD, WQGD);
  447. //定位切割放大位数
  448. WQGF = WQGFTemp.Split(',');
  449. BindComboxData(cbbWQGF, WQGF);
  450. //拉直操作放大位数
  451. WLZ = WLZTemp.Split(',');
  452. BindComboxData(cbbWLZ, WLZ);
  453. //设置配置文件默认值
  454. chkWIsP.Checked=Convert.ToBoolean(config.AppSettings.Settings["Is_Photograph"].Value);
  455. chkWPT.Checked = Convert.ToBoolean(config.AppSettings.Settings["PT_Depostion"].Value);
  456. //自动对焦模式
  457. //chkManul.Checked = Convert.ToBoolean(config.AppSettings.Settings["Focus_Mode"].Value);
  458. txtWPTF.Text = config.AppSettings.Settings["PT_ELYFile"].Value;
  459. txtWFIBF.Text = config.AppSettings.Settings["FIB_ELYFile"].Value;
  460. cbbWLZ.Text = config.AppSettings.Settings["Stretch_Magnification"].Value;
  461. cbbWQGF.Text = config.AppSettings.Settings["Location_Magnification"].Value;
  462. cbbWQGD.Text = config.AppSettings.Settings["Location_Voltage"].Value;
  463. cbbWPZF.Text = config.AppSettings.Settings["Photograph_Magnification"].Value;
  464. cbbWPZD.Text = config.AppSettings.Settings["Photograph_Voltage"].Value;
  465. string Correction_Angle = config.AppSettings.Settings["Correction_Angle"].Value;
  466. if (Correction_Angle == "36")
  467. {
  468. cbbWXZ.SelectedIndex = 0;
  469. }
  470. else
  471. {
  472. cbbWXZ.SelectedIndex = 1;
  473. }
  474. cbbWYP.Text = config.AppSettings.Settings["SampleName"].Value;
  475. cbbWCS.Text = config.AppSettings.Settings["Firms"].Value;
  476. }
  477. /// <summary>
  478. /// 根据所选路径,读取模板文件
  479. /// </summary>
  480. public void ReadConfigInfo()
  481. {
  482. if (!ReadConfigPath.Equals(""))
  483. {
  484. ReloadConfig();
  485. ConfigFile cfm = new ConfigFile(new MeasureParam());
  486. cfm.Read(ReadConfigPath);
  487. chkWIsP.Checked = cfm.m_Config.Is_Photograph;
  488. chkWPT.Checked = cfm.m_Config.PT;
  489. //自动对焦模式
  490. //cfm.FocusMode = chkManul.Checked;
  491. txtWPTF.Text = cfm.m_Config.PTTemp;
  492. txtWFIBF.Text = cfm.m_Config.FIBTemp;
  493. cbbWLZ.Text = cfm.m_Config.Stretch_Magnification.ToString();
  494. cbbWQGF.Text = cfm.m_Config.Location_Magnification.ToString();
  495. cbbWQGD.Text = cfm.m_Config.Location_Voltage.ToString();
  496. cbbWPZF.Text = cfm.m_Config.Photograph_Magnification.ToString();
  497. cbbWPZD.Text = cfm.m_Config.Photograph_Voltage.ToString();
  498. string Correction_Angle = cfm.m_Config.Correction_Angle.ToString();
  499. if (Correction_Angle == "36")
  500. {
  501. cbbWXZ.SelectedIndex = 0;
  502. }
  503. else
  504. {
  505. cbbWXZ.SelectedIndex = 1;
  506. }
  507. cbbWYP.Text = cfm.m_Config.SampleName;
  508. cbbWCS.Text = cfm.m_Config.Firm;
  509. }
  510. }
  511. /// <summary>
  512. /// 修改配置文件默认值
  513. /// </summary>
  514. /// <param name="sender"></param>
  515. /// <param name="e"></param>
  516. private void btnSaveDefalutPara_Click(object sender, EventArgs e)
  517. {
  518. if (EditConfig())
  519. {
  520. MessageBox.Show("保存成功!", "提示");
  521. }
  522. }
  523. #endregion
  524. #region 删除下拉菜单选择项
  525. private void DelComboBoxItem_Click(object sender, EventArgs e)
  526. {
  527. if (MessageBox.Show("是否删除所选项信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  528. {
  529. PictureBox pbDel = (PictureBox)sender;
  530. string ctrlName = pbDel.Name.Substring(5, pbDel.Name.Length - 5);
  531. if (DelComboBoxItem(ctrlName))
  532. {
  533. //重新加载
  534. ReloadConfig();
  535. }
  536. }
  537. }
  538. /// <summary>
  539. /// 删除下拉菜单选择项
  540. /// </summary>
  541. public bool DelComboBoxItem(string controlName)
  542. {
  543. string delName = controlName;
  544. foreach (Control item in this.Controls)
  545. {
  546. if (item is ComboBox)
  547. {
  548. if (item.Name.Contains(delName))
  549. {
  550. ComboBox cb = (ComboBox)item;
  551. return DelConfigNodeContentInfo(delName, cb.Text);
  552. }
  553. }
  554. }
  555. return false;
  556. }
  557. #endregion
  558. #region 根据是否仅拍照,进行逻辑判断
  559. private void chkWIsP_CheckedChanged(object sender, EventArgs e)
  560. {
  561. if (chkWIsP.Checked)
  562. {
  563. chkWPT.Checked = false;
  564. chkWPT.Visible = false;
  565. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.Photo;
  566. }
  567. else
  568. {
  569. chkWPT.Visible = true;
  570. if (!chkWPT.Checked)
  571. {
  572. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.FIB;
  573. }
  574. }
  575. CreateCutHoleList();
  576. }
  577. #endregion
  578. private void CreateCutHoleList()
  579. {
  580. List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
  581. FormHOZMainObject.CreateCutHoleList(ListCutHole);
  582. }
  583. private void chkWPT_CheckedChanged(object sender, EventArgs e)
  584. {
  585. if (chkWPT.Checked)
  586. {
  587. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.PT;
  588. }
  589. else
  590. {
  591. if (!chkWIsP.Checked)
  592. {
  593. FormHOZMainObject.m_MeasureType = (int)MeasureMsgManage.measureType.FIB;
  594. }
  595. }
  596. CreateCutHoleList();
  597. }
  598. #region 关闭按钮 鼠标操作事件
  599. private void pbClose_MouseEnter(object sender, EventArgs e)
  600. {
  601. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Red;
  602. }
  603. private void pbClose_MouseLeave(object sender, EventArgs e)
  604. {
  605. pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Gray;
  606. }
  607. #endregion
  608. }
  609. }