ListOfSimilarParticles.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  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.Particledata.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. OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = _particlesGridDevidePage.result.GetXAxisDirEnum();
  343. OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = _particlesGridDevidePage.result.GetYAxisDirEnum();
  344. particleM = particleM + "," + subt;
  345. Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapForBig(subt, xs, _particlesGridDevidePage.result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
  346. if (bmap != null)
  347. {
  348. string[] str = subt.Split(',');
  349. bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
  350. dgV_SimilarParticles.Rows[add_rowindex].Height = 150;
  351. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = bmap;
  352. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
  353. dgV_SimilarParticles.Rows[add_rowindex].DefaultCellStyle.ForeColor = Color.Chocolate;
  354. }
  355. else
  356. {
  357. dgV_SimilarParticles.Rows[add_rowindex].Height = 150;
  358. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
  359. }
  360. }
  361. }
  362. else
  363. {
  364. if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
  365. {
  366. string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
  367. FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), _particlesGridDevidePage.Particledata.ReadImageFile(imagePath));
  368. }
  369. 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"]) };
  370. Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapByParticle(FieldImage.Value, rectangle);
  371. 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() };
  372. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = bmap;
  373. dgV_SimilarParticles.Rows[add_rowindex].Height = bmap.Height + 20;
  374. }
  375. }
  376. if (enl.Current.Key == "DiameterRatio")
  377. {
  378. double d = Convert.ToDouble(particles.Rows[i]["DMAX"]) / Convert.ToDouble(particles.Rows[i]["DMIN"]);
  379. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  380. }
  381. if (en.Current.Key == "Element")
  382. {
  383. }
  384. if (enl.Current.Key == "ASPECT_ELONG")
  385. {
  386. double d = Convert.ToDouble(particles.Rows[i]["DELONG"]) / Convert.ToDouble(particles.Rows[i]["DMEAN"]);
  387. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  388. }
  389. if (particles.Columns.Contains(enl.Current.Key))
  390. {
  391. double num = 0;
  392. if (double.TryParse(particles.Rows[i][enl.Current.Key].ToString(), out num))
  393. {
  394. if (enl.Current.Key == "SimilarRatio")
  395. {
  396. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 5);
  397. }
  398. else
  399. {
  400. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 2);}
  401. }
  402. else if (enl.Current.Key == "Element")
  403. {
  404. List<string> elementtemp = new List<string>(ElementTypeSort);
  405. string[] strcbo = particles.Rows[i][enl.Current.Key].ToString().Split(';');
  406. for (int j = 0; j < strcbo.Length; j++)
  407. {
  408. if (ElementTypeSort.Count == 0)
  409. {
  410. break;
  411. }
  412. string[] str = strcbo[j].Split('-');
  413. if (ElementTypeSort.Contains(str[0]))
  414. { dgV_SimilarParticles.Rows[add_rowindex].Cells[str[0].ToString()].Value = Math.Round(double.Parse(str[1]), 2).ToString(); }
  415. elementtemp.Remove(str[0].ToString());
  416. }
  417. foreach (var ele in elementtemp)
  418. {
  419. dgV_SimilarParticles.Rows[add_rowindex].Cells[ele].Value = "0";
  420. }
  421. }
  422. else
  423. {
  424. double val = 0;
  425. if (double.TryParse(Convert.ToString(particles.Rows[i][enl.Current.Key]), out val))
  426. {
  427. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = val;
  428. }
  429. else
  430. {
  431. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = particles.Rows[i][enl.Current.Key];
  432. }
  433. }
  434. }
  435. if (enl.Current.Key == "TypeName")
  436. {
  437. if (particles.Rows[i]["TypeId"].ToString() == "9")
  438. {
  439. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = "Not Identified";
  440. }
  441. }
  442. if (enl.Current.Key == "Equivalent")
  443. {
  444. double dSize = Convert.ToDouble(particles.Rows[i]["Area"]);
  445. double Diameter = Math.Sqrt(dSize / Math.PI) * 2;
  446. dgV_SimilarParticles.Rows[add_rowindex].Cells[k].Value = Math.Round(Diameter, 2);
  447. }
  448. if (enl.Current.Key == "AbPosX")
  449. {
  450. 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"])));
  451. dgV_SimilarParticles.Rows[add_rowindex].Cells["AbPosX"].Value = point.X;
  452. dgV_SimilarParticles.Rows[add_rowindex].Cells["AbPosY"].Value = point.Y;
  453. }
  454. }
  455. }
  456. }
  457. DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
  458. checkBoxColumn.HeaderText = "选择";
  459. checkBoxColumn.Name = "IsSelected";
  460. checkBoxColumn.TrueValue = true;
  461. checkBoxColumn.FalseValue = false;
  462. checkBoxColumn.Width = 30;
  463. checkBoxColumn.ReadOnly = false;
  464. dgV_SimilarParticles.Columns.Insert(0, checkBoxColumn);
  465. if (_RenameInfo != null)
  466. {
  467. dgV_SimilarParticles.Rows[0].Cells[2].Value = _RenameInfo[1];
  468. }
  469. dgV_SimilarParticles.Visible = true;
  470. }
  471. private double GetCosValue(CPosXrayClr posXray, CPosXrayClr posXray1)
  472. {
  473. if (posXray == null) return 0;
  474. if (posXray1 == null) return 0;
  475. if (posXray.GetChannelsNum() != posXray1.GetChannelsNum())
  476. {
  477. return 0;
  478. }
  479. var pXrayData = posXray.GetXrayData();
  480. var pXrayData1 = posXray1.GetXrayData();
  481. // 公式: (x1y1+x2y2+x3y3+...x2000y2000) / (sqrt(x1^2 + x2^2 + ...x2000^2) * sqrt(y1^2 + y2^2 + ...y2000^2))
  482. double dotProduct = 0;
  483. double d1 = 0;
  484. double d2 = 0;
  485. for (int i = 0; i < posXray.GetChannelsNum(); i++)
  486. {
  487. double r1 = pXrayData[i];
  488. double r2 = pXrayData1[i];
  489. r1 *= r2;
  490. dotProduct = dotProduct + r1;
  491. }
  492. d1 = posXray.GetXrayDataVectorNorm();
  493. d2 = posXray1.GetXrayDataVectorNorm();
  494. return (0 == d1 || 0 == d2) ? 0 : dotProduct / (d1 * d2);
  495. }
  496. private void ListOfSimilarParticles_Load(object sender, EventArgs e)
  497. {
  498. btn_Search_Click(null, null);
  499. }
  500. private void btn_OK_Click(object sender, EventArgs e)
  501. {
  502. if (_RenameInfo == null)
  503. {
  504. string CategoryName = "";
  505. //循环选中颗粒
  506. DataGridViewRow dgvr = dgV_SimilarParticles.Rows[0];
  507. CategoryName = dgvr.Cells[2].Value.ToString();
  508. string TypeId = "";
  509. string TypeName = "";
  510. string TypeColor = "";
  511. string GroupName = "";
  512. string GroupID = "";
  513. string GroupColor = "";
  514. string[] resulta = _particlesGridDevidePage.result.GetSTDName().Split('.');
  515. DataTable data = ReadClassification(_particlesGridDevidePage.result.FilePath, resulta[0]);
  516. ModifyCategoryForm modifyCategoryForm = new ModifyCategoryForm(data, CategoryName);
  517. DialogResult result = modifyCategoryForm.ShowDialog();
  518. if (modifyCategoryForm.DoYouWantToModifyIt)
  519. {
  520. TypeId = modifyCategoryForm.OutTypeAndName[0];
  521. TypeName = modifyCategoryForm.OutTypeAndName[1];
  522. TypeColor = modifyCategoryForm.OutTypeAndName[2];
  523. GroupName = modifyCategoryForm.OutTypeAndName[3];
  524. GroupID = modifyCategoryForm.OutTypeAndName[4];
  525. GroupColor = modifyCategoryForm.OutTypeAndName[5];
  526. _RenameInfo = new List<string>();
  527. _RenameInfo.Add(TypeId);
  528. _RenameInfo.Add(TypeName);
  529. _RenameInfo.Add(TypeColor);
  530. _RenameInfo.Add(GroupName);
  531. _RenameInfo.Add(GroupID);
  532. _RenameInfo.Add(GroupColor);
  533. }
  534. else
  535. {
  536. return;
  537. }
  538. }
  539. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  540. foreach (DataGridViewRow row in dgV_SimilarParticles.Rows)
  541. {
  542. if (row.Cells["IsSelected"].Value != null && (bool)row.Cells["IsSelected"].Value)
  543. {
  544. row.Cells[1].Value = _RenameInfo[0];
  545. Bitmap ls_bp = (Bitmap)row.Cells[3].Value;
  546. List<string> list_str = (List<string>)ls_bp.Tag;
  547. int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  548. int i_ls_particleid = Convert.ToInt32(list_str[1]);
  549. List<int> ints = new List<int>();
  550. ints.Add(i_ls_fieldid);
  551. ints.Add(i_ls_particleid);
  552. var cmd = _particlesGridDevidePage.Particledata.GetUpdataAIncACmd(ints, _RenameInfo);
  553. cmdlist.Add(cmd);
  554. }
  555. }
  556. _particlesGridDevidePage.Particledata.ExecuteNonQueryBatch(cmdlist);
  557. this.DialogResult = DialogResult.OK;
  558. this.Close();
  559. }
  560. /// <summary>
  561. /// 读取标准库的ClassifySTD表
  562. /// </summary>
  563. /// <param name="a_address"></param>
  564. /// <returns></returns>
  565. private DataTable ReadClassification(string a_address, string STDName)
  566. {
  567. DataTable dt_STDGroups = new DataTable();
  568. DataTable dt_ClassifySTD = new DataTable();
  569. DataTable dt_IncAData = new DataTable();
  570. var systype = m_ReportApp.m_RptConfigFile.Systype;
  571. if (systype == OTS_SysType_ID.IncA)
  572. {
  573. dt_ClassifySTD.Columns.Add("STDId");
  574. dt_ClassifySTD.Columns.Add("StrName");
  575. dt_ClassifySTD.Columns.Add("Color");
  576. dt_ClassifySTD.Columns.Add("KeyElementList");
  577. dt_ClassifySTD.Columns.Add("SubElementList");
  578. dt_ClassifySTD.Columns.Add("UsingImgPropertyList");
  579. dt_ClassifySTD.Columns.Add("UsingOtherPropertyList");
  580. dt_ClassifySTD.Columns.Add("Expression");
  581. dt_ClassifySTD.Columns.Add("Hardness");
  582. dt_ClassifySTD.Columns.Add("Density");
  583. dt_ClassifySTD.Columns.Add("Electrical_conductivity");
  584. dt_ClassifySTD.Columns.Add("BSE");
  585. dt_ClassifySTD.Columns.Add("Formula");
  586. dt_ClassifySTD.Columns.Add("Element");
  587. dt_ClassifySTD.Columns.Add("IfElementAnalysis");
  588. dt_ClassifySTD.Columns.Add("ListNum");
  589. dt_ClassifySTD.Columns.Add("GroupId");
  590. dt_ClassifySTD.Columns.Add("GroupName");
  591. dt_ClassifySTD.Columns.Add("GroupColor");
  592. DataTable da = _particlesGridDevidePage.Particledata.GetParticleListForParticlSizeID("area", "");
  593. for (int i = 0; i < da.Rows.Count; i++)
  594. {
  595. if (Convert.ToInt64(da.Rows[i]["TypeId"]) > 9)
  596. {
  597. DataRow newRow = dt_ClassifySTD.NewRow();
  598. newRow["STDId"] = da.Rows[i]["TypeId"];
  599. newRow["StrName"] = da.Rows[i]["TypeName"];
  600. newRow["Color"] = da.Rows[i]["TypeColor"];
  601. newRow["GroupId"] = da.Rows[i]["GroupId"];
  602. newRow["GroupName"] = da.Rows[i]["GroupName"];
  603. newRow["GroupColor"] = da.Rows[i]["GroupColor"];
  604. dt_ClassifySTD.Rows.Add(newRow);
  605. }
  606. }
  607. }
  608. else
  609. {
  610. SqLiteHelper sh_STDGroups = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
  611. dt_STDGroups = sh_STDGroups.ExecuteQuery("select * from STDGroups");
  612. SqLiteHelper sh_ClassifySTD = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
  613. dt_ClassifySTD = sh_ClassifySTD.ExecuteQuery("select * from ClassifySTD");
  614. dt_ClassifySTD.Columns.Add("GroupName");
  615. dt_ClassifySTD.Columns.Add("GroupColor");
  616. for (int i = 0; i < dt_ClassifySTD.Rows.Count; i++)
  617. {
  618. for (int a = 0; a < dt_STDGroups.Rows.Count; a++)
  619. {
  620. if (dt_ClassifySTD.Rows[i]["GroupId"].ToString() == dt_STDGroups.Rows[a]["id"].ToString())
  621. {
  622. dt_ClassifySTD.Rows[i]["GroupName"] = dt_STDGroups.Rows[a]["name"].ToString();
  623. dt_ClassifySTD.Rows[i]["GroupColor"] = dt_STDGroups.Rows[a]["color"].ToString();
  624. continue;
  625. }
  626. }
  627. }
  628. SqLiteHelper sh_Inclusion = new SqLiteHelper("data source='" + a_address + "\\FIELD_FILES\\Inclusion.db" + "'");
  629. dt_IncAData = sh_Inclusion.ExecuteQuery("select * from IncAData");
  630. for (int i = 0; i < dt_IncAData.Rows.Count; i++)
  631. {
  632. if (Convert.ToInt64(dt_IncAData.Rows[i]["TypeId"]) > 50000)
  633. {
  634. DataRow newRow = dt_ClassifySTD.NewRow();
  635. newRow["STDId"] = dt_IncAData.Rows[i]["TypeId"];
  636. newRow["StrName"] = dt_IncAData.Rows[i]["TypeName"];
  637. newRow["Color"] = dt_IncAData.Rows[i]["TypeColor"];
  638. newRow["GroupId"] = dt_IncAData.Rows[i]["GroupId"];
  639. newRow["GroupName"] = dt_IncAData.Rows[i]["GroupName"];
  640. newRow["GroupColor"] = dt_IncAData.Rows[i]["GroupColor"];
  641. dt_ClassifySTD.Rows.Add(newRow);
  642. }
  643. }
  644. }
  645. return dt_ClassifySTD;
  646. }
  647. private void cBx_All_CheckedChanged(object sender, EventArgs e)
  648. {
  649. CheckBox selectAllCheckBox = (CheckBox)sender;
  650. foreach (DataGridViewRow row in dgV_SimilarParticles.Rows)
  651. {
  652. DataGridViewCheckBoxCell checkBox = row.Cells["IsSelected"] as DataGridViewCheckBoxCell;
  653. checkBox.Value = selectAllCheckBox.Checked;
  654. }
  655. dgV_SimilarParticles.Rows[0].Cells[0].Value = true;
  656. }
  657. DataTable ObtainSourceOfSimilarParticles(int _classifyid)
  658. {
  659. if (_classifyid == -1)
  660. {
  661. return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_InvalidParticle("");
  662. }
  663. else if (_classifyid == 9)
  664. {
  665. return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_NotIdentifyParticle("");
  666. }
  667. else if (_classifyid != 4)
  668. {
  669. return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_analyticalParticle("");
  670. }
  671. else if (_classifyid == 4)
  672. {
  673. return _particlesGridDevidePage.Particledata.GetInfoForPartucleDevidePage_LowCountsParticle("");
  674. }
  675. return null;
  676. }
  677. private void btn_Cannnel_Click(object sender, EventArgs e)
  678. {
  679. this.DialogResult = DialogResult.Cancel;
  680. this.Close();
  681. }
  682. private void dgV_SimilarParticles_MouseUp(object sender, MouseEventArgs e)
  683. {
  684. var SelectRows = dgV_SimilarParticles.SelectedRows;
  685. if (SelectRows.Count != 0)
  686. {
  687. if (SelectRows.Count == 1)
  688. {
  689. DataGridViewRow dgvr = SelectRows[0];
  690. Bitmap ls_bp = (Bitmap)dgvr.Cells[3].Value;
  691. List<string> list_str = (List<string>)ls_bp.Tag;
  692. uint[] Search_xray = new uint[2000];
  693. uint[] Analysis_xray = new uint[2000];
  694. int i_xray_id = 0;
  695. List<Element> list_celementchemistryclr = new List<Element>();
  696. _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);
  697. List<OTSIncAReportGraph.Controls.ShowElementInfo> list_showelementinfo = new List<OTSIncAReportGraph.Controls.ShowElementInfo>();
  698. for (int i = 0; i < list_celementchemistryclr.Count; i++)
  699. {
  700. OTSIncAReportGraph.Controls.ShowElementInfo ls_sei = new OTSIncAReportGraph.Controls.ShowElementInfo();
  701. ls_sei.ElementName = list_celementchemistryclr[i].Name;
  702. ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
  703. ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
  704. double de_sx2 = 0;
  705. if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
  706. {
  707. de_sx2 = 0;
  708. }
  709. else
  710. {
  711. de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
  712. }
  713. ls_sei.dLF = de_sx2;
  714. list_showelementinfo.Add(ls_sei);
  715. }
  716. list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
  717. string str_IncAName = "";
  718. str_IncAName = Convert.ToString(dgvr.Cells[2].Value);
  719. 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));
  720. if (particle == null)
  721. {
  722. return;
  723. }
  724. 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));
  725. control_XRayTable1.Visible = true;
  726. control_XRayTable1.SetXRayShowLineValue(null, Analysis_xray, list_showelementinfo);
  727. //颗粒国标信息
  728. control_XRayTable1.GBInfoStr = "";
  729. control_XRayTable1.MaterialName = str_IncAName;//杂夹物
  730. control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
  731. string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
  732. DataRow[] drs = particles.Select(str);
  733. if (drs.Length > 0)
  734. {
  735. Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particle.RectLeft), Y = Convert.ToInt32(particle.RectTop), Width = Convert.ToInt32(particle.RectWidth), Height = Convert.ToInt32(particle.RectHeight) };
  736. Bitmap dpImage = new Bitmap(_particlesGridDevidePage.result.GetImageWidth(), _particlesGridDevidePage.result.GetImageHeight());
  737. using (Graphics graphics = Graphics.FromImage(dpImage))
  738. {
  739. graphics.Clear(Color.White); // 清除位图背景为白色
  740. }
  741. string filePath = _particlesGridDevidePage.result.FilePath + "\\FIELD_FILES\\";
  742. string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
  743. Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
  744. foreach (Segment seg in particle.SegmentList)
  745. {
  746. int f_length = seg.Length;
  747. for (int m = 0; m < f_length; m++)
  748. {
  749. int lsjs_x = seg.Start + m;
  750. int lsjs_y = seg.Height;
  751. var pixelColor = m_originalImage.GetPixel(lsjs_x, lsjs_y);
  752. dpImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
  753. }
  754. }
  755. Bitmap bmap = _particlesGridDevidePage.Particledata.GetBitmapByParticle(dpImage, rectangle);
  756. Bitmap bmap1 = _particlesGridDevidePage.Particledata.GetBitmapByParticle(m_originalImage, rectangle);
  757. control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
  758. Invalidate();
  759. }
  760. else
  761. {
  762. control_XRayTable1.Visible = false;
  763. }
  764. }
  765. }
  766. }
  767. private void movetoparticleToolStripMenuItem_Click(object sender, EventArgs e)
  768. {
  769. //先获取鼠标所选择的行里的颗粒的FieldID和ParticleID
  770. string i_ls_fieldid = "";
  771. string i_ls_particleid = "";
  772. int cou = dgV_SimilarParticles.SelectedRows.Count;
  773. if (cou > 0)
  774. {
  775. DataGridViewRow dgvr = dgV_SimilarParticles.SelectedRows[cou - 1];
  776. Bitmap ls_bp = (Bitmap)dgvr.Cells[3].Value;
  777. List<string> list_str = (List<string>)ls_bp.Tag;
  778. if (list_str != null)
  779. {
  780. i_ls_fieldid = list_str[0];
  781. i_ls_particleid = list_str[1];
  782. }
  783. }
  784. DataOperation.DataAccess.ParticleData particleData = new DataOperation.DataAccess.ParticleData(_particlesGridDevidePage.result.FilePath);
  785. Particle particle = particleData.GetParticleByFidAndPid(i_ls_fieldid, i_ls_particleid);
  786. //取得Field的Position,然后执行线程移动SEM到当前Field的位置
  787. if (m_mythread == null)
  788. {
  789. return;
  790. }
  791. if (m_mythread.ThreadState == ThreadState.Running || m_mythread.ThreadState == ThreadState.WaitSleepJoin)
  792. {
  793. return;
  794. }
  795. if (m_mythread.ThreadState == ThreadState.Stopped)
  796. {
  797. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  798. }
  799. Point point = OTSIncAReportGrids.ParticlesGridDevidePage.CalculateParticleCenterPosition(_particlesGridDevidePage.result, new Point(particle.SEMPosX, particle.SEMPosY), new Point(particle.PosX, particle.PosY));
  800. //改为线程调用,先判断线程状态
  801. m_mythread.Start(point);
  802. }
  803. #region 连接电镜相关
  804. /// <summary>
  805. /// 移动SEM到指定位置线程函数
  806. /// </summary>
  807. private void Thread_GO(object in_obj)
  808. {
  809. if (m_mythread_state == false)
  810. {
  811. m_mythread_state = true;
  812. Point sem_point = (Point)in_obj;
  813. //第一步,连接电镜
  814. m_OTSIncAReportGridsFun.Connection_ForParticlesGrid();
  815. Thread.Sleep(500);
  816. //第二步,移动到指定位置,先读取再设置
  817. if (m_OTSIncAReportGridsFun.m_SEMConnectionState == true)
  818. {
  819. m_OTSIncAReportGridsFun.MoveSemToPointXY_ForParticlesGrid(sem_point.X, sem_point.Y);
  820. }
  821. Thread.Sleep(1500);
  822. m_mythread_state = false;
  823. }
  824. }
  825. #endregion
  826. private void dgV_SimilarParticles_KeyUp(object sender, KeyEventArgs e)
  827. {
  828. if (e.KeyData == Keys.Down)
  829. {
  830. dgV_SimilarParticles_MouseUp(null, null);
  831. }
  832. if (e.KeyData == Keys.Up)
  833. {
  834. dgV_SimilarParticles_MouseUp(null, null);
  835. }
  836. if (e.KeyData == Keys.Space)
  837. {
  838. dgV_SimilarParticles_CellMouseDoubleClick(null,null);
  839. }
  840. }
  841. private void tB_SimilarRatio_KeyUp(object sender, KeyEventArgs e)
  842. {
  843. if (e.KeyData == Keys.Enter)
  844. {
  845. btn_Search_Click(null, null);
  846. }
  847. }
  848. private void dgV_SimilarParticles_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  849. {
  850. var SelectRows = dgV_SimilarParticles.SelectedRows;
  851. if (SelectRows.Count != 0)
  852. {
  853. if (SelectRows.Count == 1)
  854. {
  855. DataGridViewRow dgvr = SelectRows[0];
  856. if ((bool)dgvr.Cells[0].EditedFormattedValue == true)
  857. {
  858. dgvr.Cells[0].Value = false;
  859. }
  860. else
  861. {
  862. dgvr.Cells[0].Value = true;
  863. }
  864. dgV_SimilarParticles.Rows[0].Cells[0].Value = true;
  865. }
  866. }
  867. }
  868. public ListOfSimilarParticles(OTSIncAReportGrids.ParticlesGridDevidePage particlesGridDevidePage, uint[] SelXray, int classifyid, frmReportApp ReportApp)
  869. {
  870. InitializeComponent();
  871. _particlesGridDevidePage = particlesGridDevidePage;
  872. SelXrayclr.SetXrayData(SelXray);
  873. table = particlesGridDevidePage.table;
  874. _classifyid = classifyid;
  875. m_ReportApp = ReportApp;
  876. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  877. //设置窗体的双缓冲,以保证大数据时拖动不卡
  878. this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
  879. this.UpdateStyles();
  880. //利用反射设置DataGridView的双缓冲
  881. Type dgvType = this.dgV_SimilarParticles.GetType();
  882. PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
  883. pi.SetValue(this.dgV_SimilarParticles, true, null);
  884. this.control_XRayTable1 = new OTSIncAReportGraph.Controls.Control_XRayTable(null);
  885. this.control_XRayTable1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  886. this.control_XRayTable1.Dock = System.Windows.Forms.DockStyle.Bottom;
  887. this.control_XRayTable1.GBInfoStr = "";
  888. this.control_XRayTable1.GoodChineseName = "";
  889. this.control_XRayTable1.MaterialName = "";
  890. this.control_XRayTable1.Location = new System.Drawing.Point(0, 400);
  891. this.control_XRayTable1.Name = "control_XRayTable1";
  892. this.control_XRayTable1.ShowAnalysisXray = true;
  893. this.control_XRayTable1.ShowSearchXray = false;
  894. this.control_XRayTable1.Size = new System.Drawing.Size(1004, 200);
  895. this.control_XRayTable1.STDName = "";
  896. this.control_XRayTable1.Visible = false;
  897. this.control_XRayTable1.label_close.Visible = true;
  898. panel1.Controls.Add(this.control_XRayTable1);
  899. }
  900. private void 从此颗粒之下取消选择ToolStripMenuItem_Click(object sender, EventArgs e)
  901. {
  902. var SelectRows = dgV_SimilarParticles.SelectedRows;
  903. if (SelectRows.Count != 0)
  904. {
  905. DataGridViewRow dgvr = SelectRows[0];
  906. for (int i = dgvr.Index + 1; i < dgV_SimilarParticles.Rows.Count; i++)
  907. {
  908. dgV_SimilarParticles.Rows[i].Cells[0].Value=false;
  909. }
  910. if(dgvr.Index + 1!= dgV_SimilarParticles.Rows.Count)
  911. {
  912. this.cBx_All.CheckedChanged -= new System.EventHandler(this.cBx_All_CheckedChanged);
  913. cBx_All.Checked=false;
  914. this.cBx_All.CheckedChanged += new System.EventHandler(this.cBx_All_CheckedChanged);
  915. }
  916. }
  917. }
  918. }
  919. }