UControl_Init.cs 24 KB

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