ParticlesGridDevidePageShowConfig.cs 19 KB

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