ListOfSimilarParticles.cs 46 KB

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