UControl_Init.cs 24 KB

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