ParticlesGridDevidePageShowConfig.cs 19 KB

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