ParticlesGridDevidePageShowConfig.cs 19 KB

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