ListOfSimilarParticles.cs 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. using OTSCLRINTERFACE;
  2. using OTSCommon;
  3. using OTSCommon.DBOperate;
  4. using OTSCommon.DBOperate.Model;
  5. using OTSIncAReportApp._2_CommonFunction.CommonClass;
  6. using OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess;
  7. using OTSIncAReportApp.DataOperation.DataAccess;
  8. using OTSIncAReportApp.OTSRstMgrFunction;
  9. using OTSIncAReportGraph.Class;
  10. using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
  11. using OTSPeriodicTable;
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using System.Data;
  16. using System.Data.SQLite;
  17. using System.Drawing;
  18. using System.Linq;
  19. using System.Reflection;
  20. using System.Threading;
  21. using System.Windows.Forms;
  22. using static OTSDataType.otsdataconst;
  23. using Color = System.Drawing.Color;
  24. namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
  25. {
  26. public partial class ListOfSimilarParticles : Form
  27. {
  28. OTSIncAReportGrids.ParticlesGridDevidePage _particlesGridDevidePage;
  29. CPosXrayClr SelXrayclr = new CPosXrayClr();
  30. DataTable particlesAll;
  31. DataTable particlesFilter;
  32. Hashtable table;
  33. List<string> _RenameInfo;
  34. private Thread m_mythread;
  35. //记录线程是否已经运行完成的状态
  36. private bool m_mythread_state = false;
  37. //底层操作类
  38. SEMAndEDSOperate m_OTSIncAReportGridsFun = null;
  39. frmReportApp m_ReportApp;
  40. public ParticleData Particledata;
  41. public UserSTDDbAccess userSTDDb;
  42. public FieldImage fldImgAccess;
  43. public ResultFile _result = null;
  44. public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, List<string> RenameInfo,frmReportApp ReportApp)
  45. {
  46. InitializeComponent();
  47. _particlesGridDevidePage = particlesGridDevidePage;
  48. SelXrayclr.SetXrayData(SelXray);
  49. table = particlesGridDevidePage.table;
  50. _RenameInfo = RenameInfo;
  51. m_ReportApp = ReportApp;
  52. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  53. _result= particlesGridDevidePage.result;
  54. fldImgAccess = new FieldImage(_result.FilePath);
  55. Particledata = new ParticleData(_result.FilePath);
  56. //设置窗体的双缓冲,以保证大数据时拖动不卡
  57. this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
  58. this.UpdateStyles();
  59. //利用反射设置DataGridView的双缓冲
  60. Type dgvType = this.dgV_SimilarParticles.GetType();
  61. PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
  62. pi.SetValue(this.dgV_SimilarParticles, true, null);
  63. this.control_XRayTable1 = new OTSIncAReportGraph.Controls.Control_XRayTable(null);
  64. this.control_XRayTable1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  65. this.control_XRayTable1.Dock = System.Windows.Forms.DockStyle.Bottom;
  66. this.control_XRayTable1.GBInfoStr = "";
  67. this.control_XRayTable1.GoodChineseName = "";
  68. this.control_XRayTable1.MaterialName = "";
  69. this.control_XRayTable1.Location = new System.Drawing.Point(0, 400);
  70. this.control_XRayTable1.Name = "control_XRayTable1";
  71. this.control_XRayTable1.ShowAnalysisXray = true;
  72. this.control_XRayTable1.ShowSearchXray = false;
  73. this.control_XRayTable1.Size = new System.Drawing.Size(1004, 200);
  74. this.control_XRayTable1.STDName = "";
  75. this.control_XRayTable1.Visible = false;
  76. this.control_XRayTable1.label_close.Visible = true;
  77. panel1.Controls.Add(this.control_XRayTable1);
  78. }
  79. private void btn_Search_Click(object sender, EventArgs e)
  80. {
  81. double val;
  82. if (!double.TryParse(tB_SimilarRatio.Text, out val))
  83. {
  84. MessageBox.Show("The value must range from 0 to 100!");
  85. return;
  86. }
  87. else
  88. {
  89. this.Cursor = Cursors.WaitCursor;
  90. particlesAll = ObtainSourceOfSimilarParticles();
  91. DataTable elementchemistry = Particledata.GetElementChemistry();
  92. for (int i = 0; i < particlesAll.Rows.Count; i++)
  93. {
  94. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  95. DataRow[] drs = elementchemistry.Select(str);
  96. string ConcatenatedString = "";
  97. for (int j = 0; j < drs.Length; j++)
  98. {
  99. ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
  100. }
  101. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  102. }
  103. particlesAll.Columns.Add("SimilarRatio", typeof(double));
  104. DataTable XRayData = Particledata.GetXRayData();
  105. particlesAll.Columns.Add("XRayDataCount");
  106. particlesFilter = particlesAll.Clone();
  107. for (int i = 0; i < particlesAll.Rows.Count; i++)
  108. {
  109. if (int.Parse(particlesAll.Rows[i]["particleId"].ToString()) > -1)
  110. {
  111. string subParticleString = particlesAll.Rows[i]["SubParticles"].ToString();
  112. uint[] Analysis_xray = new uint[2000];
  113. particlesAll.Rows[i]["XRayDataCount"] = 0;
  114. if (subParticleString == "")
  115. {
  116. string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  117. DataRow[] drs = XRayData.Select(str);
  118. uint xraycount = 0;
  119. if (drs != null)
  120. {
  121. if (drs.Length > 0)
  122. {
  123. for (int j = 0; j < 2000; j++)
  124. {
  125. Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
  126. }
  127. for (int j = 0; j < 2000; j++)
  128. {
  129. xraycount += Analysis_xray[j];
  130. }
  131. particlesAll.Rows[i]["XRayDataCount"] = xraycount;
  132. }
  133. }
  134. }
  135. else
  136. {
  137. DataRow dgvr = particlesAll.Rows[i];
  138. Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Analysis_xray);
  139. uint xraycount = 0;
  140. for (int j = 0; j < 2000; j++)
  141. {
  142. xraycount += Analysis_xray[j];
  143. }
  144. particlesAll.Rows[i]["XRayDataCount"] = xraycount;
  145. }
  146. CPosXrayClr Xrayclr = new CPosXrayClr();
  147. Xrayclr.SetXrayData(Analysis_xray);
  148. particlesAll.Rows[i]["SimilarRatio"] = GetCosValue(SelXrayclr, Xrayclr);
  149. if ((double)particlesAll.Rows[i]["SimilarRatio"] >= val / 100)
  150. {
  151. particlesFilter.ImportRow(particlesAll.Rows[i]);
  152. }
  153. }
  154. }
  155. particlesFilter.DefaultView.Sort = "SimilarRatio DESC";
  156. particlesFilter = particlesFilter.DefaultView.ToTable();
  157. BindDataGridView();
  158. SetDataGridViewStyle();
  159. cBx_All.Checked = false;
  160. cBx_All.Checked = true;
  161. label3.Text = "共搜索到" + (dgV_SimilarParticles.Rows.Count-1).ToString() + "个相似颗粒";
  162. this.Cursor = Cursors.Default;
  163. }
  164. }
  165. private void SetDataGridViewStyle()
  166. {
  167. //用户不能调整标题的高度
  168. dgV_SimilarParticles.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  169. //用户不能调整 行高
  170. dgV_SimilarParticles.AllowUserToResizeRows = false;
  171. //点击选择整行
  172. dgV_SimilarParticles.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  173. //居中显示
  174. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  175. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  176. dgV_SimilarParticles.DefaultCellStyle = dataGridViewCellStyle1;
  177. dgV_SimilarParticles.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  178. //再次重覆禁用拖动表头高度,居然有效果了
  179. dgV_SimilarParticles.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  180. //设置grid可以复制
  181. dgV_SimilarParticles.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  182. //设置每列的宽度
  183. dgV_SimilarParticles.Columns[0].Width = 30;//第一列序号的宽度设置一下吧,要不太丑
  184. dgV_SimilarParticles.Columns[1].Width = 100;
  185. for (int i = 4; i < dgV_SimilarParticles.Columns.Count; i++)
  186. {
  187. dgV_SimilarParticles.Columns[i].Width = 65;
  188. }
  189. //设置序号列不排序
  190. dgV_SimilarParticles.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  191. dgV_SimilarParticles.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  192. //设置序号列不可以设置宽度
  193. dgV_SimilarParticles.Columns[0].Resizable = DataGridViewTriState.False;
  194. dgV_SimilarParticles.RowsDefaultCellStyle.BackColor = Color.Azure;
  195. if (dgV_SimilarParticles.Rows.Count > 0)
  196. {
  197. dgV_SimilarParticles.Rows[0].Frozen = true;
  198. }
  199. }
  200. private void BindDataGridView()
  201. {
  202. dgV_SimilarParticles.Visible = false;
  203. dgV_SimilarParticles.Rows.Clear();
  204. dgV_SimilarParticles.Columns.Clear();
  205. string str_DefaultComputedColName = "", str_ElementsColName = "";
  206. DataSet ds = OTSCommon.XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
  207. DataTable dt = ds.Tables["Member"];
  208. foreach (DataRow element in dt.Rows)
  209. {
  210. string RegName = element["RegName"].ToString();
  211. if (RegName == "DefaultComputedColName")
  212. {
  213. str_DefaultComputedColName = element["strValue"].ToString();
  214. }
  215. if (RegName == "ElementsColName")
  216. {
  217. str_ElementsColName = element["strValue"].ToString();
  218. }
  219. }
  220. string[] strs = str_DefaultComputedColName.Split(',');
  221. Dictionary<string, string> keyValues = new Dictionary<string, string>() { };
  222. keyValues.Add("SimilarRatio", "相似度");
  223. keyValues.Add("TypeName", table["str6"].ToString());
  224. keyValues.Add("ParticleImage", table["str5"].ToString());
  225. keyValues.Add("FieldId", "FieldId");
  226. keyValues.Add("ParticleId", "ParticleId");
  227. keyValues.Add("SEMPosX", "SEMPosX");
  228. keyValues.Add("SEMPosY", "SEMPosY");
  229. for (int i = 0; i < strs.Count(); i++)
  230. {
  231. if (strs[i] == "ParticleCoordinate")
  232. {
  233. keyValues.Add("AbPosX", "PosX");
  234. keyValues.Add("AbPosY", "PosY");
  235. }
  236. if (strs[i] == "Area")
  237. {
  238. keyValues.Add("Area", table["str21"].ToString());
  239. }
  240. if (strs[i] == "EquivalentCircleDiameter")
  241. {
  242. keyValues.Add("Equivalent", table["str22"].ToString());
  243. }
  244. if (strs[i] == "MaxDiameter")
  245. {
  246. keyValues.Add("DMAX", table["str23"].ToString());
  247. }
  248. if (strs[i] == "MinDiameter")
  249. {
  250. keyValues.Add("DMIN", table["str24"].ToString());
  251. }
  252. if (strs[i] == "DiameterRatio")
  253. {
  254. keyValues.Add("DiameterRatio", table["str25"].ToString());
  255. }
  256. if (strs[i] == "FerretDiameter")
  257. {
  258. keyValues.Add("DFERET", table["str26"].ToString());
  259. }
  260. if (strs[i] == "PERP")
  261. {
  262. keyValues.Add("DPERP", table["str27"].ToString());
  263. }
  264. if (strs[i] == "PERI")
  265. {
  266. keyValues.Add("PERIMETER", table["str28"].ToString());
  267. }
  268. if (strs[i] == "INSCR")
  269. {
  270. keyValues.Add("DINSCR", table["str29"].ToString());
  271. }
  272. if (strs[i] == "MEAN")
  273. {
  274. keyValues.Add("DMEAN", table["str30"].ToString());
  275. }
  276. if (strs[i] == "ELONG")
  277. {
  278. keyValues.Add("DELONG", table["str31"].ToString());
  279. }
  280. if (strs[i] == "ASPECT_ELONG")
  281. {
  282. keyValues.Add("ASPECT_ELONG", table["str32"].ToString());
  283. }
  284. if (strs[i] == "Orientation")
  285. {
  286. keyValues.Add("ORIENTATION", table["str33"].ToString());
  287. }
  288. if (strs[i] == "XRayDataCount")
  289. {
  290. keyValues.Add("XRayDataCount", "XRay计数");
  291. }
  292. }
  293. keyValues.Add("Element", "Element");
  294. Dictionary<string, string>.Enumerator en = keyValues.GetEnumerator();
  295. for (int irow = 0; irow < keyValues.Count; irow++)
  296. {
  297. if (en.MoveNext())
  298. {
  299. if (en.Current.Key == "ParticleImage")
  300. {
  301. DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
  302. iconColumn.Name = en.Current.Key;
  303. iconColumn.HeaderText = en.Current.Value;
  304. dgV_SimilarParticles.Columns.Add(iconColumn);
  305. }
  306. else if (en.Current.Key == "Element")
  307. {
  308. }
  309. else
  310. {
  311. dgV_SimilarParticles.Columns.Add(en.Current.Key, en.Current.Value);
  312. if (en.Current.Key == "Area" || en.Current.Key == "EquivalentCircleDiameter" || en.Current.Key == "MaxDiameter" || en.Current.Key == "MinDiameter" || en.Current.Key == "DiameterRatio" || en.Current.Key == "FerretDiameter" || en.Current.Key == "PERP" || en.Current.Key == "PERI" || en.Current.Key == "INSCR" || en.Current.Key == "MEAN" || en.Current.Key == "ELONG" || en.Current.Key == "ASPECT_ELONG" || en.Current.Key == "Orientation")
  313. {
  314. int id = dgV_SimilarParticles.Columns.Count;
  315. dgV_SimilarParticles.Columns[id - 1].Tag = "NumericType";
  316. }
  317. }
  318. }
  319. }
  320. if (particlesAll == null)
  321. {
  322. return;
  323. }
  324. string particleM = "";
  325. List<string> ElementTypeSort = new List<string>(str_ElementsColName.Split(',').ToList());//去重
  326. for (int i = 0; i < ElementTypeSort.Count; i++)
  327. {
  328. if (ElementTypeSort[0] == "")
  329. {
  330. ElementTypeSort.RemoveAt(0);
  331. break;
  332. }
  333. dgV_SimilarParticles.Columns.Add(ElementTypeSort[i], ElementTypeSort[i]);
  334. int id = dgV_SimilarParticles.Columns.Count;
  335. dgV_SimilarParticles.Columns[id - 1].Tag = "NumericType";
  336. }
  337. string filePath = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
  338. KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
  339. for (int i = 0; i < particlesFilter.Rows.Count; i++)
  340. {
  341. Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
  342. Dictionary<string, Bitmap> fieldpics = new Dictionary<string, Bitmap>();
  343. int add_rowindex = dgV_SimilarParticles.Rows.Add();
  344. for (int k = 0; k < keyValues.Count; k++)
  345. {
  346. if (enl.MoveNext())
  347. {
  348. if (enl.Current.Key == "ParticleImage")
  349. {
  350. string subParticleString = particlesFilter.Rows[i]["SubParticles"].ToString();
  351. dgV_SimilarParticles.Rows[add_rowindex].Height = 150;
  352. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
  353. Bitmap bmap = null;
  354. if (subParticleString != null && subParticleString != "" && subParticleString != "IsSubParticle")
  355. {
  356. double pix = _result.GetPixelSize();
  357. int width = _result.GetImageWidth();
  358. int height = _result.GetImageHeight();
  359. string substring = "," + subParticleString.Replace(':', '-') + ",";
  360. DataTable dataTable = Particledata.GetParticleAllForBig(substring);//组成拼接颗粒的子颗粒
  361. bmap = fldImgAccess.GetBitmapForMergedParticle(subParticleString, pix, height, width, dataTable);
  362. if (bmap != null)
  363. {
  364. string[] str = subParticleString.Split(',');
  365. bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1] };
  366. }
  367. }
  368. else if (subParticleString != "IsSubParticle")
  369. {
  370. if (!fieldpics.Keys.Contains(particlesFilter.Rows[i]["fieldid"].ToString()))
  371. {
  372. string imagePath = "Field" + particlesFilter.Rows[i]["fieldid"].ToString() + ".bmp";
  373. fieldpics.Add(particlesFilter.Rows[i]["fieldid"].ToString(), fldImgAccess.ReadImageFile(imagePath));
  374. }
  375. Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particlesFilter.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particlesFilter.Rows[i]["RectTop"]), Width = Convert.ToInt32(particlesFilter.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particlesFilter.Rows[i]["RectHeight"]) };
  376. bmap = fldImgAccess.CapturePic(fieldpics[particlesFilter.Rows[i]["fieldid"].ToString()], rectangle);
  377. bmap.Tag = new List<string>() { particlesFilter.Rows[i]["FieldId"].ToString(), particlesFilter.Rows[i]["ParticleId"].ToString() };
  378. dgV_SimilarParticles.Rows[add_rowindex].Height = bmap.Height + 20;
  379. }
  380. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = bmap;
  381. }
  382. if (enl.Current.Key == "DiameterRatio")
  383. {
  384. double d = Convert.ToDouble(particlesFilter.Rows[i]["DMAX"]) / Convert.ToDouble(particlesFilter.Rows[i]["DMIN"]);
  385. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  386. }
  387. if (en.Current.Key == "Element")
  388. {
  389. }
  390. if (enl.Current.Key == "ASPECT_ELONG")
  391. {
  392. double d = Convert.ToDouble(particlesFilter.Rows[i]["DELONG"]) / Convert.ToDouble(particlesFilter.Rows[i]["DMEAN"]);
  393. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  394. }
  395. if (particlesFilter.Columns.Contains(enl.Current.Key))
  396. {
  397. double num = 0;
  398. if (double.TryParse(particlesFilter.Rows[i][enl.Current.Key].ToString(), out num))
  399. {
  400. if (enl.Current.Key == "SimilarRatio")
  401. {
  402. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 5);
  403. }
  404. else
  405. {
  406. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 2);
  407. }
  408. }
  409. else if (enl.Current.Key == "Element")
  410. {
  411. List<string> elementtemp = new List<string>(ElementTypeSort);
  412. string[] strcbo = particlesFilter.Rows[i][enl.Current.Key].ToString().Split(';');
  413. for (int j = 0; j < strcbo.Length; j++)
  414. {
  415. if (ElementTypeSort.Count == 0)
  416. {
  417. break;
  418. }
  419. string[] str = strcbo[j].Split('-');
  420. if (ElementTypeSort.Contains(str[0]))
  421. { dgV_SimilarParticles.Rows[add_rowindex].Cells[str[0].ToString()].Value = Math.Round(double.Parse(str[1]), 2).ToString(); }
  422. elementtemp.Remove(str[0].ToString());
  423. }
  424. foreach (var ele in elementtemp)
  425. {
  426. dgV_SimilarParticles.Rows[add_rowindex].Cells[ele].Value = "0";
  427. }
  428. }
  429. else
  430. {
  431. double val = 0;
  432. if (double.TryParse(Convert.ToString(particlesFilter.Rows[i][enl.Current.Key]), out val))
  433. {
  434. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = val;
  435. }
  436. else
  437. {
  438. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = particlesFilter.Rows[i][enl.Current.Key];
  439. }
  440. }
  441. }
  442. if (enl.Current.Key == "TypeName")
  443. {
  444. if (particlesFilter.Rows[i]["TypeId"].ToString() == "9")
  445. {
  446. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = "Not Identified";
  447. }
  448. }
  449. if (enl.Current.Key == "Equivalent")
  450. {
  451. double dSize = Convert.ToDouble(particlesFilter.Rows[i]["Area"]);
  452. double Diameter = Math.Sqrt(dSize / Math.PI) * 2;
  453. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(Diameter, 2);
  454. }
  455. if (enl.Current.Key == "AbPosX")
  456. {
  457. Point point = OTSIncAReportGrids.ParticlesGridDevidePage.CalculateParticleCenterPosition(_particlesGridDevidePage.result, new Point(Convert.ToInt32(particlesFilter.Rows[i]["SEMPosX"]), Convert.ToInt32(particlesFilter.Rows[i]["SEMPosY"])), new Point(Convert.ToInt32(particlesFilter.Rows[i]["PosX"]), Convert.ToInt32(particlesFilter.Rows[i]["PosY"])));
  458. dgV_SimilarParticles.Rows[add_rowindex].Cells["AbPosX"].Value = point.X;
  459. dgV_SimilarParticles.Rows[add_rowindex].Cells["AbPosY"].Value = point.Y;
  460. }
  461. }
  462. }
  463. }
  464. DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
  465. checkBoxColumn.HeaderText = "选择";
  466. checkBoxColumn.Name = "IsSelected";
  467. checkBoxColumn.TrueValue = true;
  468. checkBoxColumn.FalseValue = false;
  469. checkBoxColumn.Width = 30;
  470. checkBoxColumn.ReadOnly = false;
  471. dgV_SimilarParticles.Columns.Insert(0, checkBoxColumn);
  472. if (_RenameInfo != null)
  473. {
  474. dgV_SimilarParticles.Rows[0].Cells[2].Value = _RenameInfo[1];
  475. }
  476. dgV_SimilarParticles.Visible = true;
  477. }
  478. private double GetCosValue(CPosXrayClr posXray, CPosXrayClr posXray1)
  479. {
  480. if (posXray == null) return 0;
  481. if (posXray1 == null) return 0;
  482. if (posXray.GetChannelsNum() != posXray1.GetChannelsNum())
  483. {
  484. return 0;
  485. }
  486. var pXrayData = posXray.GetXrayData();
  487. var pXrayData1 = posXray1.GetXrayData();
  488. // 公式: (x1y1+x2y2+x3y3+...x2000y2000) / (sqrt(x1^2 + x2^2 + ...x2000^2) * sqrt(y1^2 + y2^2 + ...y2000^2))
  489. double dotProduct = 0;
  490. double d1 = 0;
  491. double d2 = 0;
  492. for (int i = 0; i < posXray.GetChannelsNum(); i++)
  493. {
  494. double r1 = pXrayData[i];
  495. double r2 = pXrayData1[i];
  496. r1 *= r2;
  497. dotProduct = dotProduct + r1;
  498. }
  499. d1 = posXray.GetXrayDataVectorNorm();
  500. d2 = posXray1.GetXrayDataVectorNorm();
  501. return (0 == d1 || 0 == d2) ? 0 : dotProduct / (d1 * d2);
  502. }
  503. private void ListOfSimilarParticles_Load(object sender, EventArgs e)
  504. {
  505. btn_Search_Click(null, null);
  506. }
  507. private void btn_OK_Click(object sender, EventArgs e)
  508. {
  509. if (_RenameInfo == null)
  510. {
  511. string CategoryName = "";
  512. //循环选中颗粒
  513. DataGridViewRow dgvr = dgV_SimilarParticles.Rows[0];
  514. CategoryName = dgvr.Cells[2].Value.ToString();
  515. string TypeId = "";
  516. string TypeName = "";
  517. string TypeColor = "";
  518. string GroupName = "";
  519. string GroupID = "";
  520. string GroupColor = "";
  521. string[] resulta = _particlesGridDevidePage.result.GetSTDName().Split('.');
  522. DataTable data = ReadClassification(_particlesGridDevidePage.result.FilePath, resulta[0]);
  523. ModifyCategoryForm modifyCategoryForm = new ModifyCategoryForm(data, CategoryName);
  524. DialogResult result = modifyCategoryForm.ShowDialog();
  525. if (modifyCategoryForm.DoYouWantToModifyIt)
  526. {
  527. TypeId = modifyCategoryForm.OutTypeAndName[0];
  528. TypeName = modifyCategoryForm.OutTypeAndName[1];
  529. TypeColor = modifyCategoryForm.OutTypeAndName[2];
  530. GroupName = modifyCategoryForm.OutTypeAndName[3];
  531. GroupID = modifyCategoryForm.OutTypeAndName[4];
  532. GroupColor = modifyCategoryForm.OutTypeAndName[5];
  533. _RenameInfo = new List<string>();
  534. _RenameInfo.Add(TypeId);
  535. _RenameInfo.Add(TypeName);
  536. _RenameInfo.Add(TypeColor);
  537. _RenameInfo.Add(GroupName);
  538. _RenameInfo.Add(GroupID);
  539. _RenameInfo.Add(GroupColor);
  540. }
  541. else
  542. {
  543. return;
  544. }
  545. }
  546. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  547. foreach (DataGridViewRow row in dgV_SimilarParticles.Rows)
  548. {
  549. if (row.Cells["IsSelected"].Value != null && (bool)row.Cells["IsSelected"].Value)
  550. {
  551. row.Cells[1].Value = _RenameInfo[0];
  552. Bitmap ls_bp = (Bitmap)row.Cells[3].Value;
  553. List<string> list_str = (List<string>)ls_bp.Tag;
  554. int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  555. int i_ls_particleid = Convert.ToInt32(list_str[1]);
  556. List<int> ints = new List<int>();
  557. ints.Add(i_ls_fieldid);
  558. ints.Add(i_ls_particleid);
  559. var cmd = Particledata.GetUpdataAIncACmd(ints, _RenameInfo);
  560. cmdlist.Add(cmd);
  561. }
  562. }
  563. Particledata.ExecuteNonQueryBatch(cmdlist);
  564. this.DialogResult = DialogResult.OK;
  565. this.Close();
  566. }
  567. /// <summary>
  568. /// 读取标准库的ClassifySTD表
  569. /// </summary>
  570. /// <param name="a_address"></param>
  571. /// <returns></returns>
  572. private DataTable ReadClassification(string a_address, string STDName)
  573. {
  574. DataTable dt_STDGroups = new DataTable();
  575. DataTable dt_ClassifySTD = new DataTable();
  576. DataTable dt_IncAData = new DataTable();
  577. var systype = m_ReportApp.m_RptConfigFile.Systype;
  578. if (systype == OTS_SysType_ID.IncA)
  579. {
  580. dt_ClassifySTD.Columns.Add("STDId");
  581. dt_ClassifySTD.Columns.Add("StrName");
  582. dt_ClassifySTD.Columns.Add("Color");
  583. dt_ClassifySTD.Columns.Add("KeyElementList");
  584. dt_ClassifySTD.Columns.Add("SubElementList");
  585. dt_ClassifySTD.Columns.Add("UsingImgPropertyList");
  586. dt_ClassifySTD.Columns.Add("UsingOtherPropertyList");
  587. dt_ClassifySTD.Columns.Add("Expression");
  588. dt_ClassifySTD.Columns.Add("Hardness");
  589. dt_ClassifySTD.Columns.Add("Density");
  590. dt_ClassifySTD.Columns.Add("Electrical_conductivity");
  591. dt_ClassifySTD.Columns.Add("BSE");
  592. dt_ClassifySTD.Columns.Add("Formula");
  593. dt_ClassifySTD.Columns.Add("Element");
  594. dt_ClassifySTD.Columns.Add("IfElementAnalysis");
  595. dt_ClassifySTD.Columns.Add("ListNum");
  596. dt_ClassifySTD.Columns.Add("GroupId");
  597. dt_ClassifySTD.Columns.Add("GroupName");
  598. dt_ClassifySTD.Columns.Add("GroupColor");
  599. DataTable da = Particledata.GetParticleListForParticlSizeID("area", "");
  600. for (int i = 0; i < da.Rows.Count; i++)
  601. {
  602. if (Convert.ToInt64(da.Rows[i]["TypeId"]) > 9)
  603. {
  604. DataRow newRow = dt_ClassifySTD.NewRow();
  605. newRow["STDId"] = da.Rows[i]["TypeId"];
  606. newRow["StrName"] = da.Rows[i]["TypeName"];
  607. newRow["Color"] = da.Rows[i]["TypeColor"];
  608. newRow["GroupId"] = da.Rows[i]["GroupId"];
  609. newRow["GroupName"] = da.Rows[i]["GroupName"];
  610. newRow["GroupColor"] = da.Rows[i]["GroupColor"];
  611. dt_ClassifySTD.Rows.Add(newRow);
  612. }
  613. }
  614. }
  615. else
  616. {
  617. SqLiteHelper sh_STDGroups = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
  618. dt_STDGroups = sh_STDGroups.ExecuteQuery("select * from STDGroups");
  619. SqLiteHelper sh_ClassifySTD = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
  620. dt_ClassifySTD = sh_ClassifySTD.ExecuteQuery("select * from ClassifySTD");
  621. dt_ClassifySTD.Columns.Add("GroupName");
  622. dt_ClassifySTD.Columns.Add("GroupColor");
  623. for (int i = 0; i < dt_ClassifySTD.Rows.Count; i++)
  624. {
  625. for (int a = 0; a < dt_STDGroups.Rows.Count; a++)
  626. {
  627. if (dt_ClassifySTD.Rows[i]["GroupId"].ToString() == dt_STDGroups.Rows[a]["id"].ToString())
  628. {
  629. dt_ClassifySTD.Rows[i]["GroupName"] = dt_STDGroups.Rows[a]["name"].ToString();
  630. dt_ClassifySTD.Rows[i]["GroupColor"] = dt_STDGroups.Rows[a]["color"].ToString();
  631. continue;
  632. }
  633. }
  634. }
  635. SqLiteHelper sh_Inclusion = new SqLiteHelper("data source='" + a_address + "\\FIELD_FILES\\Inclusion.db" + "'");
  636. dt_IncAData = sh_Inclusion.ExecuteQuery("select * from IncAData");
  637. for (int i = 0; i < dt_IncAData.Rows.Count; i++)
  638. {
  639. if (Convert.ToInt64(dt_IncAData.Rows[i]["TypeId"]) > 50000)
  640. {
  641. DataRow newRow = dt_ClassifySTD.NewRow();
  642. newRow["STDId"] = dt_IncAData.Rows[i]["TypeId"];
  643. newRow["StrName"] = dt_IncAData.Rows[i]["TypeName"];
  644. newRow["Color"] = dt_IncAData.Rows[i]["TypeColor"];
  645. newRow["GroupId"] = dt_IncAData.Rows[i]["GroupId"];
  646. newRow["GroupName"] = dt_IncAData.Rows[i]["GroupName"];
  647. newRow["GroupColor"] = dt_IncAData.Rows[i]["GroupColor"];
  648. dt_ClassifySTD.Rows.Add(newRow);
  649. }
  650. }
  651. }
  652. return dt_ClassifySTD;
  653. }
  654. private void cBx_All_CheckedChanged(object sender, EventArgs e)
  655. {
  656. CheckBox selectAllCheckBox = (CheckBox)sender;
  657. foreach (DataGridViewRow row in dgV_SimilarParticles.Rows)
  658. {
  659. DataGridViewCheckBoxCell checkBox = row.Cells["IsSelected"] as DataGridViewCheckBoxCell;
  660. checkBox.Value = selectAllCheckBox.Checked;
  661. }
  662. dgV_SimilarParticles.Rows[0].Cells[0].Value = true;
  663. }
  664. DataTable ObtainSourceOfSimilarParticles()
  665. {
  666. return Particledata.GetInfoForPartucleDevidePage_allParticles("");
  667. }
  668. private void btn_Cannnel_Click(object sender, EventArgs e)
  669. {
  670. this.DialogResult = DialogResult.Cancel;
  671. this.Close();
  672. }
  673. private void dgV_SimilarParticles_MouseUp(object sender, MouseEventArgs e)
  674. {
  675. var SelectRows = dgV_SimilarParticles.SelectedRows;
  676. if (SelectRows.Count != 0)
  677. {
  678. if (SelectRows.Count == 1)
  679. {
  680. DataGridViewRow dgvr = SelectRows[0];
  681. Bitmap ls_bp = (Bitmap)dgvr.Cells[3].Value;
  682. uint[] Analysis_xray = new uint[2000];
  683. int i_xray_id = 0;
  684. List<Element> list_celementchemistryclr = new List<Element>();
  685. Particle particle = new Particle();
  686. string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
  687. DataRow[] drs = particlesFilter.Select(str);
  688. DataRow row = drs[0];
  689. string subParticleString = row["SubParticles"].ToString();
  690. if (subParticleString != "" && subParticleString != null)
  691. {
  692. particle = Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Analysis_xray);
  693. list_celementchemistryclr = particle.ElementList;
  694. }
  695. else
  696. {
  697. particle = _particlesGridDevidePage.ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
  698. }
  699. List<OTSIncAReportGraph.Controls.ShowElementInfo> list_showelementinfo = Particledata.GetShowElementInfos(list_celementchemistryclr);
  700. string str_IncAName = "";
  701. str_IncAName = Convert.ToString(dgvr.Cells[2].Value);
  702. if (particle == null)
  703. {
  704. return;
  705. }
  706. control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + " " + "DMAX:" + Math.Round(particle.DMAX, 2) + " " + "DELONG:" + Math.Round(particle.DELONG, 2) + " " + "DFERET:" + Math.Round(particle.DFERET, 2) + " " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + " " + "DMIN:" + Math.Round(particle.DMIN, 2) + " " + "DPERP:" + Math.Round(particle.DPERP, 2) + " " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + " " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
  707. control_XRayTable1.Visible = true;
  708. control_XRayTable1.SetXRayShowLineValue(Analysis_xray, list_showelementinfo);
  709. control_XRayTable1.GBInfoStr = "";
  710. control_XRayTable1.MaterialName = str_IncAName;
  711. control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
  712. DataTable dataTable = new DataTable();
  713. double pix = _result.GetPixelSize();
  714. int width = _result.GetImageWidth();
  715. int height = _result.GetImageHeight();
  716. Dictionary<string, List<Segment>> segsData = new Dictionary<string, List<Segment>>();
  717. if (subParticleString == "" || subParticleString == null)
  718. {
  719. int fldid = Convert.ToInt32(dgvr.Cells["fieldid"].Value);
  720. int partid = Convert.ToInt32(dgvr.Cells["particleId"].Value);
  721. var listseg = Particledata.GetSegmentData(fldid, partid);
  722. string key = fldid.ToString() + "_" + partid.ToString();
  723. segsData.Add(key, listseg);
  724. dataTable = particlesFilter.Clone();
  725. dataTable.ImportRow(row);
  726. }
  727. else
  728. {
  729. string vs = "," + subParticleString.Replace(':', '-') + ",";
  730. dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
  731. foreach (DataRow dow in dataTable.Rows)
  732. {
  733. int fldid = Convert.ToInt32(dow["fieldid"]);
  734. int partid = Convert.ToInt32(dow["particleId"]);
  735. var listseg = Particledata.GetSegmentData(fldid, partid);
  736. string key = dow["fieldid"].ToString() + "_" + dow["particleid"].ToString();
  737. segsData.Add(key, listseg);
  738. }
  739. }
  740. Bitmap bmap = fldImgAccess.GetBitmapForParticleAll(subParticleString, dataTable, pix, height, width);
  741. Bitmap bmap1 = fldImgAccess.GetBitmapForParticleAllWithBlackAndWhite(subParticleString, dataTable, segsData, pix, height, width);
  742. control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
  743. Invalidate();
  744. }
  745. }
  746. }
  747. private void movetoparticleToolStripMenuItem_Click(object sender, EventArgs e)
  748. {
  749. //先获取鼠标所选择的行里的颗粒的FieldID和ParticleID
  750. string i_ls_fieldid = "";
  751. string i_ls_particleid = "";
  752. int cou = dgV_SimilarParticles.SelectedRows.Count;
  753. if (cou > 0)
  754. {
  755. DataGridViewRow dgvr = dgV_SimilarParticles.SelectedRows[cou - 1];
  756. Bitmap ls_bp = (Bitmap)dgvr.Cells[3].Value;
  757. List<string> list_str = (List<string>)ls_bp.Tag;
  758. if (list_str != null)
  759. {
  760. i_ls_fieldid = list_str[0];
  761. i_ls_particleid = list_str[1];
  762. }
  763. }
  764. DataOperation.DataAccess.ParticleData particleData = new DataOperation.DataAccess.ParticleData(_particlesGridDevidePage.result.FilePath);
  765. Particle particle = particleData.GetParticleByFidAndPid(i_ls_fieldid, i_ls_particleid);
  766. //取得Field的Position,然后执行线程移动SEM到当前Field的位置
  767. if (m_mythread == null)
  768. {
  769. return;
  770. }
  771. if (m_mythread.ThreadState == ThreadState.Running || m_mythread.ThreadState == ThreadState.WaitSleepJoin)
  772. {
  773. return;
  774. }
  775. if (m_mythread.ThreadState == ThreadState.Stopped)
  776. {
  777. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  778. }
  779. Point point = OTSIncAReportGrids.ParticlesGridDevidePage.CalculateParticleCenterPosition(_particlesGridDevidePage.result, new Point(particle.SEMPosX, particle.SEMPosY), new Point(particle.PosX, particle.PosY));
  780. //改为线程调用,先判断线程状态
  781. m_mythread.Start(point);
  782. }
  783. #region 连接电镜相关
  784. /// <summary>
  785. /// 移动SEM到指定位置线程函数
  786. /// </summary>
  787. private void Thread_GO(object in_obj)
  788. {
  789. if (m_mythread_state == false)
  790. {
  791. m_mythread_state = true;
  792. Point sem_point = (Point)in_obj;
  793. //第一步,连接电镜
  794. m_OTSIncAReportGridsFun.Connection_ForParticlesGrid();
  795. Thread.Sleep(500);
  796. //第二步,移动到指定位置,先读取再设置
  797. if (m_OTSIncAReportGridsFun.m_SEMConnectionState == true)
  798. {
  799. m_OTSIncAReportGridsFun.MoveSemToPointXY_ForParticlesGrid(sem_point.X, sem_point.Y);
  800. }
  801. Thread.Sleep(1500);
  802. m_mythread_state = false;
  803. }
  804. }
  805. #endregion
  806. private void dgV_SimilarParticles_KeyUp(object sender, KeyEventArgs e)
  807. {
  808. if (e.KeyData == Keys.Down)
  809. {
  810. dgV_SimilarParticles_MouseUp(null, null);
  811. }
  812. if (e.KeyData == Keys.Up)
  813. {
  814. dgV_SimilarParticles_MouseUp(null, null);
  815. }
  816. if (e.KeyData == Keys.Space)
  817. {
  818. dgV_SimilarParticles_CellMouseDoubleClick(null,null);
  819. }
  820. }
  821. private void tB_SimilarRatio_KeyUp(object sender, KeyEventArgs e)
  822. {
  823. if (e.KeyData == Keys.Enter)
  824. {
  825. btn_Search_Click(null, null);
  826. }
  827. }
  828. private void dgV_SimilarParticles_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  829. {
  830. var SelectRows = dgV_SimilarParticles.SelectedRows;
  831. if (SelectRows.Count != 0)
  832. {
  833. if (SelectRows.Count == 1)
  834. {
  835. DataGridViewRow dgvr = SelectRows[0];
  836. if ((bool)dgvr.Cells[0].EditedFormattedValue == true)
  837. {
  838. dgvr.Cells[0].Value = false;
  839. }
  840. else
  841. {
  842. dgvr.Cells[0].Value = true;
  843. }
  844. dgV_SimilarParticles.Rows[0].Cells[0].Value = true;
  845. }
  846. }
  847. }
  848. public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, frmReportApp ReportApp)
  849. {
  850. InitializeComponent();
  851. _particlesGridDevidePage = particlesGridDevidePage;
  852. SelXrayclr.SetXrayData(SelXray);
  853. table = particlesGridDevidePage.table;
  854. m_ReportApp = ReportApp;
  855. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  856. _result = particlesGridDevidePage.result;
  857. fldImgAccess = new FieldImage(_result.FilePath);
  858. Particledata = new ParticleData(_result.FilePath);
  859. //设置窗体的双缓冲,以保证大数据时拖动不卡
  860. this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
  861. this.UpdateStyles();
  862. //利用反射设置DataGridView的双缓冲
  863. Type dgvType = this.dgV_SimilarParticles.GetType();
  864. PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
  865. pi.SetValue(this.dgV_SimilarParticles, true, null);
  866. this.control_XRayTable1 = new OTSIncAReportGraph.Controls.Control_XRayTable(null);
  867. this.control_XRayTable1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  868. this.control_XRayTable1.Dock = System.Windows.Forms.DockStyle.Bottom;
  869. this.control_XRayTable1.GBInfoStr = "";
  870. this.control_XRayTable1.GoodChineseName = "";
  871. this.control_XRayTable1.MaterialName = "";
  872. this.control_XRayTable1.Location = new System.Drawing.Point(0, 400);
  873. this.control_XRayTable1.Name = "control_XRayTable1";
  874. this.control_XRayTable1.ShowAnalysisXray = true;
  875. this.control_XRayTable1.ShowSearchXray = false;
  876. this.control_XRayTable1.Size = new System.Drawing.Size(1004, 200);
  877. this.control_XRayTable1.STDName = "";
  878. this.control_XRayTable1.Visible = false;
  879. this.control_XRayTable1.label_close.Visible = true;
  880. panel1.Controls.Add(this.control_XRayTable1);
  881. }
  882. private void 从此颗粒之下取消选择ToolStripMenuItem_Click(object sender, EventArgs e)
  883. {
  884. var SelectRows = dgV_SimilarParticles.SelectedRows;
  885. if (SelectRows.Count != 0)
  886. {
  887. DataGridViewRow dgvr = SelectRows[0];
  888. for (int i = dgvr.Index + 1; i < dgV_SimilarParticles.Rows.Count; i++)
  889. {
  890. dgV_SimilarParticles.Rows[i].Cells[0].Value=false;
  891. }
  892. if(dgvr.Index + 1!= dgV_SimilarParticles.Rows.Count)
  893. {
  894. this.cBx_All.CheckedChanged -= new System.EventHandler(this.cBx_All_CheckedChanged);
  895. cBx_All.Checked=false;
  896. this.cBx_All.CheckedChanged += new System.EventHandler(this.cBx_All_CheckedChanged);
  897. }
  898. }
  899. }
  900. }
  901. }