ParticlesGridDevidePageShowConfig.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. using OTSIncAReportApp.OTSRstMgrFunction;
  2. using OTSIncAReportApp.SysMgrTools;
  3. using OTSPeriodicTable;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Windows.Forms;
  9. using static OTSDataType.otsdataconst;
  10. namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
  11. {
  12. public partial class ParticlesGridDevidePageShowConfig : Form
  13. {
  14. Hashtable languageTable;
  15. Language lan;
  16. OTS_SysType_ID systype = OTS_SysType_ID.IncA;
  17. string _elementstr = "";
  18. public ParticlesGridDevidePageShowConfig(OTS_SysType_ID a_systype,string elementstr)
  19. {
  20. InitializeComponent();
  21. systype = a_systype;
  22. _elementstr= elementstr;
  23. }
  24. private void ParticlesGridDevidePageShowConfig_Load(object sender, EventArgs e)
  25. {
  26. InitMyComponent();
  27. #region 国际化语言
  28. lan = new Language(this);
  29. languageTable = lan.GetNameTable(this.Name);
  30. #endregion
  31. }
  32. private void btn_xsys_Click(object sender, EventArgs e)
  33. {
  34. //打开编辑元素列表窗体
  35. OTSPeriodicTable.OTSPeriodicTableForm_Small opts = new OTSPeriodicTable.OTSPeriodicTableForm_Small();
  36. //获取需要显示的元素列表,并转换成元素周期表窗体可接受的格式,传入----------------------
  37. string str_xsys = tb_xsys.Text.Trim();
  38. List<string> list_str = new List<string>();
  39. string[] strs = str_xsys.Split(',');
  40. for (int i = 0; i < strs.Length; i++)
  41. {
  42. list_str.Add(strs[i]);
  43. }
  44. //清除元素周期表中所有的记录
  45. opts.m_List_Periodic.Clear();
  46. //将该分类下的元素添加到元素周期表窗体的List_periodic中
  47. for (int i = 0; i < strs.Length; i++)
  48. {
  49. string str_ysm = strs[i];
  50. Periodic ls_periodic = new Periodic();
  51. ls_periodic = CListPeriodic.GetPeriodicByEleName(str_ysm);
  52. opts.m_List_Periodic.Add(ls_periodic);
  53. }
  54. //----------------------------------------------------------------------------------------
  55. opts.StartPosition = FormStartPosition.CenterScreen;
  56. opts.ShowDialog();
  57. List<string> PeriodicFH = new List<string>();
  58. for (int j = 0; j < opts.m_List_Periodic.Count; j++)
  59. {
  60. PeriodicFH.Add(opts.m_List_Periodic[j].Symbol);
  61. }
  62. PeriodicFH.Sort(delegate (string a, string b) { return ReturnsAtomicNumberByElementName(a).CompareTo(ReturnsAtomicNumberByElementName(b)); });//排序 从小到大原子序数
  63. list_str = list_str.FindAll(delegate (string a) { return PeriodicFH.Contains(a); });
  64. PeriodicFH = PeriodicFH.FindAll(delegate (string a) { return !list_str.Contains(a); });
  65. //先清空元素
  66. str_xsys = "";
  67. //然后再将选择的元素,组合起来,返回显示到该窗体上
  68. for (int i = 0; i < list_str.Count; i++)
  69. {
  70. if (str_xsys == "")
  71. {
  72. str_xsys = list_str[i];
  73. }
  74. else
  75. {
  76. str_xsys = str_xsys + "," + list_str[i];
  77. }
  78. }
  79. for (int i = 0; i < PeriodicFH.Count; i++)
  80. {
  81. if (str_xsys == "")
  82. {
  83. str_xsys = PeriodicFH[i];
  84. }
  85. else
  86. {
  87. str_xsys = str_xsys + "," + PeriodicFH[i];
  88. }
  89. }
  90. //再对选择的元素进行显示
  91. tb_xsys.Text = str_xsys;
  92. }
  93. private void btn_ybcsbc_Click(object sender, EventArgs e)
  94. {
  95. //保存显示计算项
  96. string[] AttributeName_DefaultComputedColName = new string[] { "RegName", "strValue" };
  97. string[] Value_DefaultComputedColName = new string[] { "DefaultComputedColName", GetShowColumnsListStr() };
  98. bool ret = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.UpdateByAttribute(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, AttributeName_DefaultComputedColName, Value_DefaultComputedColName);
  99. //保存显示元素信息
  100. string[] AttributeName_ElementsColName = new string[] { "RegName", "strValue" };
  101. string[] Value_ElementsColName = new string[] { "ElementsColName", tb_xsys.Text.Trim() };
  102. ret = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.UpdateByAttribute(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, AttributeName_ElementsColName, Value_ElementsColName);
  103. this.DialogResult = DialogResult.OK;
  104. this.Close();
  105. }
  106. private void btn_ybcsqx_Click(object sender, EventArgs e)
  107. {
  108. this.DialogResult = DialogResult.Cancel;
  109. this.Close();
  110. }
  111. /// <summary>
  112. /// 获取从各checkbox中组合完成的字段
  113. /// </summary>
  114. private string GetShowColumnsListStr()
  115. {
  116. string str_ret = "";
  117. if (cB_particleImage.Checked == true)
  118. {
  119. str_ret = str_ret + "ParticleImage" + ",";
  120. }
  121. if (cB_fieldid.Checked == true)
  122. {
  123. str_ret = str_ret + "FieldId" + ",";
  124. }
  125. if (cB_particleid.Checked == true)
  126. {
  127. str_ret = str_ret + "ParticleId" + ",";
  128. }
  129. if (cB_fieldPos.Checked == true)
  130. {
  131. str_ret = str_ret + "FieldPos" + ",";
  132. }
  133. //帧图坐标
  134. if (cb_ParticleCoordinate.Checked == true)
  135. {
  136. str_ret = str_ret + "ParticleCoordinate" + ",";
  137. }
  138. //面积
  139. if (cb_Area.Checked == true)
  140. {
  141. str_ret = str_ret + "Area" + ",";
  142. }
  143. //等效圆直径
  144. if (cb_EquivalentCircleDiameter.Checked == true)
  145. {
  146. str_ret = str_ret + "EquivalentCircleDiameter" + ",";
  147. }
  148. //最长直径
  149. if (cb_MaxDiameter.Checked == true)
  150. {
  151. str_ret = str_ret + "MaxDiameter" + ",";
  152. }
  153. //最短直径
  154. if (cb_MinDiameter.Checked == true)
  155. {
  156. str_ret = str_ret + "MinDiameter" + ",";
  157. }
  158. //长短直径比
  159. if (cb_DiameterRatio.Checked == true)
  160. {
  161. str_ret = str_ret + "DiameterRatio" + ",";
  162. }
  163. //费雷特直径
  164. if (cb_FerretDiameter.Checked == true)
  165. {
  166. str_ret = str_ret + "FerretDiameter" + ",";
  167. }
  168. //正交直径
  169. if (cb_PERP.Checked == true)
  170. {
  171. str_ret = str_ret + "PERP" + ",";
  172. }
  173. //周长
  174. if (cb_PERI.Checked == true)
  175. {
  176. str_ret = str_ret + "PERI" + ",";
  177. }
  178. //内接圆直径
  179. if (cb_INSCR.Checked == true)
  180. {
  181. str_ret = str_ret + "INSCR" + ",";
  182. }
  183. //内接圆平均直径
  184. if (cb_MEAN.Checked == true)
  185. {
  186. str_ret = str_ret + "MEAN" + ",";
  187. }
  188. //展开长度
  189. if (cb_ELONG.Checked == true)
  190. {
  191. str_ret = str_ret + "ELONG" + ",";
  192. }
  193. //展开长度比
  194. if (cb_ASPECT_ELONG.Checked == true)
  195. {
  196. str_ret = str_ret + "ASPECT_ELONG" + ",";
  197. }
  198. //朝向角度
  199. if (cb_Orientation.Checked == true)
  200. {
  201. str_ret = str_ret + "Orientation" + ",";
  202. }
  203. //导电性
  204. if (cB_Electrical_conductivity.Checked == true)
  205. {
  206. str_ret = str_ret + "Electrical_conductivity" + ",";
  207. }
  208. //密度
  209. if (cB_Density.Checked == true)
  210. {
  211. str_ret = str_ret + "Density" + ",";
  212. }
  213. //硬度
  214. if (cB_Hardness.Checked == true)
  215. {
  216. str_ret = str_ret + "Hardness" + ",";
  217. }
  218. if (cB_XRayDataCount.Checked == true)
  219. {
  220. str_ret = str_ret + "XRayDataCount" + ",";
  221. }
  222. if (str_ret.Length > 0)
  223. {
  224. str_ret = str_ret.Substring(0, str_ret.Length - 1);
  225. }
  226. return str_ret;
  227. }
  228. int ReturnsAtomicNumberByElementName(string ElementName)
  229. {
  230. switch (ElementName)
  231. {
  232. case "H": return 1;
  233. case "He": return 2;
  234. case "Li": return 3;
  235. case "Be": return 4;
  236. case "B": return 5;
  237. case "C": return 6;
  238. case "N": return 7;
  239. case "O": return 8;
  240. case "F": return 9;
  241. case "Ne": return 10;
  242. case "Na": return 11;
  243. case "Mg": return 12;
  244. case "Al": return 13;
  245. case "Si": return 14;
  246. case "P": return 15;
  247. case "S": return 16;
  248. case "Cl": return 17;
  249. case "Ar": return 18;
  250. case "K": return 19;
  251. case "Ca": return 20;
  252. case "Sc": return 21;
  253. case "Ti": return 22;
  254. case "V": return 23;
  255. case "Cr": return 24;
  256. case "Mn": return 25;
  257. case "Fe": return 26;
  258. case "Co": return 27;
  259. case "Ni": return 28;
  260. case "Cu": return 29;
  261. case "Zn": return 30;
  262. case "Ga": return 31;
  263. case "Ge": return 32;
  264. case "As": return 33;
  265. case "Se": return 34;
  266. case "Br": return 35;
  267. case "Kr": return 36;
  268. case "Rb": return 37;
  269. case "Sr": return 38;
  270. case "Y": return 39;
  271. case "Zr": return 40;
  272. case "Nb": return 41;
  273. case "Mo": return 42;
  274. case "Tc": return 43;
  275. case "Ru": return 44;
  276. case "Rh": return 45;
  277. case "Pd": return 46;
  278. case "Ag": return 47;
  279. case "Cd": return 48;
  280. case "In": return 49;
  281. case "Sn": return 50;
  282. case "Sb": return 51;
  283. case "Te": return 52;
  284. case "I": return 53;
  285. case "Xe": return 54;
  286. case "Cs": return 55;
  287. case "Ba": return 56;
  288. case "La": return 57;
  289. case "Ce": return 58;
  290. case "Pr": return 59;
  291. case "Nd": return 60;
  292. case "Pm": return 61;
  293. case "Sm": return 62;
  294. case "Eu": return 63;
  295. case "Gd": return 64;
  296. case "Tb": return 65;
  297. case "Dy": return 66;
  298. case "Ho": return 67;
  299. case "Er": return 68;
  300. case "Tm": return 69;
  301. case "Yb": return 70;
  302. case "Lu": return 71;
  303. case "Hf": return 72;
  304. case "Ta": return 73;
  305. case "W": return 74;
  306. case "Re": return 75;
  307. case "Os": return 76;
  308. case "Ir": return 77;
  309. case "Pt": return 78;
  310. case "Au": return 79;
  311. case "Hq": return 80;
  312. case "TI": return 81;
  313. case "Pb": return 82;
  314. case "Bi": return 83;
  315. case "Po": return 84;
  316. case "At": return 85;
  317. case "Rn": return 86;
  318. case "Fr": return 87;
  319. case "Ra": return 88;
  320. case "Ac": return 89;
  321. case "Th": return 90;
  322. case "Pa": return 91;
  323. case "U": return 92;
  324. case "Np": return 93;
  325. case "Pu": return 94;
  326. case "Am": return 95;
  327. case "Cm": return 96;
  328. case "Bk": return 97;
  329. case "Cf": return 98;
  330. case "Es": return 99;
  331. case "Fm": return 100;
  332. case "Mc": return 101;
  333. case "No": return 102;
  334. case "Lr": return 103;
  335. case "Rf": return 104;
  336. case "Db": return 105;
  337. case "Sg": return 106;
  338. case "Bh": return 107;
  339. case "Hs": return 108;
  340. case "Mt": return 109;
  341. case "Ds": return 110;
  342. case "Rg": return 111;
  343. case "Unb": return 112;
  344. default: return 1000;
  345. }
  346. }
  347. public void InitMyComponent()
  348. {
  349. string str_DefaultComputedColName = "", str_ElementsColName = "";
  350. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
  351. DataTable dt = ds.Tables["Member"];
  352. string str_scale = "";
  353. foreach (DataRow element in dt.Rows)
  354. {
  355. string RegName = element["RegName"].ToString();
  356. if (RegName == "DefaultComputedColName")
  357. {
  358. str_DefaultComputedColName = element["strValue"].ToString();
  359. }
  360. if (RegName == "ElementsColName")
  361. {
  362. str_ElementsColName = element["strValue"].ToString();
  363. }
  364. if (RegName == "Scale")
  365. {
  366. str_scale = element["strValue"].ToString();
  367. }
  368. }
  369. //显示元素
  370. tb_xsys.Text = str_ElementsColName;
  371. //设置计算显示列
  372. SetShowColumnsListStr(str_DefaultComputedColName);
  373. }
  374. private void SetShowColumnsListStr(string in_str)
  375. {
  376. foreach(Control control in groupBox2.Controls)
  377. {
  378. if (control is CheckBox)
  379. {
  380. (control as CheckBox).Checked = false;
  381. }
  382. }
  383. //面积
  384. if (in_str.IndexOf("Area") > -1)
  385. {
  386. cb_Area.Checked = true;
  387. }
  388. //等效圆直径
  389. if (in_str.IndexOf("EquivalentCircleDiameter") > -1)
  390. {
  391. cb_EquivalentCircleDiameter.Checked = true;
  392. }
  393. //最长直径
  394. if (in_str.IndexOf("MaxDiameter") > -1)
  395. {
  396. cb_MaxDiameter.Checked = true;
  397. }
  398. //最短直径
  399. if (in_str.IndexOf("MinDiameter") > -1)
  400. {
  401. cb_MinDiameter.Checked = true;
  402. }
  403. //长短直径比
  404. if (in_str.IndexOf("DiameterRatio") > -1)
  405. {
  406. cb_DiameterRatio.Checked = true;
  407. }
  408. //费雷特直径
  409. if (in_str.IndexOf("FerretDiameter") > -1)
  410. {
  411. cb_FerretDiameter.Checked = true;
  412. }
  413. //正交直径
  414. if (in_str.IndexOf("PERP") > -1)
  415. {
  416. cb_PERP.Checked = true;
  417. }
  418. //周长
  419. if (in_str.IndexOf("PERI") > -1)
  420. {
  421. cb_PERI.Checked = true;
  422. }
  423. //内接圆直径
  424. if (in_str.IndexOf("INSCR") > -1)
  425. {
  426. cb_INSCR.Checked = true;
  427. }
  428. //内接圆平均直径
  429. if (in_str.IndexOf("MEAN") > -1)
  430. {
  431. cb_MEAN.Checked = true;
  432. }
  433. //展开长度
  434. if (in_str.IndexOf("ELONG") > -1)
  435. {
  436. cb_ELONG.Checked = true;
  437. }
  438. //展开长度比
  439. if (in_str.IndexOf("ASPECT_ELONG") > -1)
  440. {
  441. cb_ASPECT_ELONG.Checked = true;
  442. }
  443. //朝向角度
  444. if (in_str.IndexOf("Orientation") > -1)
  445. {
  446. cb_Orientation.Checked = true;
  447. }
  448. //帧图坐标
  449. if (in_str.IndexOf("ParticleCoordinate") > -1)
  450. {
  451. cb_ParticleCoordinate.Checked = true;
  452. }
  453. if (in_str.IndexOf("XRayDataCount") > -1)
  454. {
  455. cB_XRayDataCount.Checked = true;
  456. }
  457. if (in_str.IndexOf("ParticleImage") > -1)
  458. {
  459. cB_particleImage.Checked = true;
  460. }
  461. if (in_str.IndexOf("FieldId") > -1)
  462. {
  463. cB_fieldid.Checked = true;
  464. }
  465. if (in_str.IndexOf("ParticleId") > -1)
  466. {
  467. cB_particleid.Checked = true;
  468. }
  469. if (in_str.IndexOf("FieldPos") > -1)
  470. {
  471. cB_fieldPos.Checked = true;
  472. }
  473. if (systype == OTS_SysType_ID.TCCleannessA|| systype == OTS_SysType_ID.BatteryCleannessA)
  474. {
  475. cB_Hardness.Enabled = true;
  476. cB_Density.Enabled = true;
  477. cB_Electrical_conductivity.Enabled = true;
  478. //硬度
  479. if (in_str.IndexOf("Hardness") > -1)
  480. {
  481. cB_Hardness.Checked = true;
  482. }
  483. //密度
  484. if (in_str.IndexOf("Density") > -1)
  485. {
  486. cB_Density.Checked = true;
  487. }
  488. //导电性
  489. if (in_str.IndexOf("Electrical_conductivity") > -1)
  490. {
  491. cB_Electrical_conductivity.Checked = true;
  492. }
  493. }
  494. else
  495. {
  496. cB_Hardness.Enabled = false;
  497. cB_Density.Enabled = false;
  498. cB_Electrical_conductivity.Enabled = false;
  499. }
  500. }
  501. private void label_help_MouseHover(object sender, EventArgs e)
  502. {
  503. // 创建the ToolTip
  504. ToolTip toolTip1 = new ToolTip();
  505. // 设置显示样式
  506. toolTip1.AutoPopDelay = 7000;//提示信息的可见时间
  507. toolTip1.InitialDelay = 500;//事件触发多久后出现提示
  508. toolTip1.ReshowDelay = 500;//指针从一个控件移向另一个控件时,经过多久才会显示下一个提示框
  509. toolTip1.ShowAlways = true;//是否显示提示框
  510. string str = "";
  511. if (Language.ReadDefaultLanguage().ToString() == "ZH")
  512. {
  513. str = " 最长直径:颗粒最大卡规直径\n" +
  514. "最短直径: 颗粒最小卡规直径\n" +
  515. "长短直径比:颗粒长宽比\n" +
  516. "正交直径:与Dmax垂直的对应直径\n" +
  517. "内接圆平均直径:平均内接圆直径\n" +
  518. "内接圆直径:最大内接圆直径";
  519. }
  520. else
  521. {
  522. str = "Dmax:Maximum caliper diameter of particle\n" +
  523. "Dmin: Minimum caliper diameter of particle\n" +
  524. "Aspect:The aspect ratio of the particle\n" +
  525. "Dperp:Corresponding diameter perpendicular to Dmax\n" +
  526. "Dmean:Average diameter of the internal circle\n" +
  527. "Dinscr:Maximum diameter of the inner circle\n" +
  528. "Dequalcircle:Equivalent circular diameter";
  529. }
  530. // 设置伴随的对象.
  531. toolTip1.SetToolTip(this.label_help, str);
  532. }
  533. private void btn_auto_Click(object sender, EventArgs e)
  534. {
  535. tb_xsys.Text = _elementstr;
  536. }
  537. }
  538. }