ParticlesGridDevidePageShowConfig.cs 19 KB

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