ListOfSimilarParticles.cs 48 KB

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