ListOfSimilarParticles.cs 46 KB

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