ParticlesGridDevidePage.cs 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793
  1. using NPOI.HSSF.UserModel;
  2. using NPOI.SS.UserModel;
  3. using OTSIncAReportApp;
  4. using OTSIncAReportApp.DataOperation.DataAccess;
  5. using OTSIncAReportApp.DataOperation.Model;
  6. using OTSIncAReportApp.SysMgrTools;
  7. using OTSIncAReportGraph.Class;
  8. using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
  9. using OTSIncAReportMailInterface;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Drawing.Imaging;
  16. using System.IO;
  17. using System.Linq;
  18. using System.Threading;
  19. using System.Windows.Forms;
  20. namespace OTSIncAReportGrids
  21. {
  22. public partial class ParticlesGridDevidePage : UserControl
  23. {
  24. #region 枚举定义
  25. /// <summary>
  26. /// 样品台X轴方向
  27. /// </summary>
  28. enum OTS_X_AXIS_DIRECTION
  29. {
  30. LEFT_TOWARD = 0,
  31. RIGHT_TOWARD = 1
  32. }
  33. /// <summary>
  34. /// 样品台Y轴方向
  35. /// </summary>
  36. enum OTS_Y_AXIS_DIRECTION
  37. {
  38. UP_TOWARD = 0,
  39. DOWN_TOWARD = 1
  40. }
  41. #endregion
  42. //设置模拟数据表
  43. public DataTable m_dt = new DataTable();
  44. //底层操作类
  45. OTSIncAReportGridsFun m_OTSIncAReportGridsFun = null;
  46. //进度条窗体
  47. public Frm_UserProgress m_frm_userprogress;
  48. //移动SEM到指定位置发生线程
  49. private Thread m_mythread;
  50. //记录线程是否已经运行完成的状态
  51. private bool m_mythread_state = false;
  52. //导出图像文件的路径
  53. private string m_imagefilepath = "";
  54. //显示元素列表
  55. public List<string> m_list_elementscolname = null;
  56. //单个数据源所拥有的列数,这里保存下来,供导出模块使用
  57. public int m_oneresult_columncount = 0;
  58. //多个数据源,每个数据源拥有的列数,这里保存下来,供分组使用
  59. public List<int> m_list_oneresult_columncount;
  60. //国际化
  61. Language lan;
  62. Hashtable table;
  63. //测量结果
  64. ResultFile result = null;
  65. FieldData fieldData;
  66. private string m_filename = "";
  67. #region 分页器相关
  68. #region 分页字段和属性
  69. string condition = "";
  70. public string FileName = null;
  71. private int pageIndex = 1;
  72. /// <summary>
  73. /// 当前页面
  74. /// </summary>
  75. public virtual int PageIndex
  76. {
  77. get { return pageIndex; }
  78. set { pageIndex = value; }
  79. }
  80. private int pageSize = 20;
  81. /// <summary>
  82. /// 每页记录数
  83. /// </summary>
  84. public virtual int PageSize
  85. {
  86. get { return pageSize; }
  87. set { pageSize = value; }
  88. }
  89. string OrderFunction = "fieldid,particleid";
  90. private int recordCount = 0;
  91. /// <summary>
  92. /// 总记录数
  93. /// </summary>
  94. public virtual int RecordCount
  95. {
  96. get { return recordCount; }
  97. set { recordCount = value; }
  98. }
  99. private int pageCount = 0;
  100. /// <summary>
  101. /// 总页数
  102. /// </summary>
  103. public int PageCount
  104. {
  105. get
  106. {
  107. pageCount = GetPageCount();
  108. return pageCount;
  109. }
  110. }
  111. /// <summary>
  112. /// 计算总页数
  113. /// </summary>
  114. /// <returns></returns>
  115. private int GetPageCount()
  116. {
  117. if (PageSize == 0)
  118. {
  119. return 0;
  120. }
  121. int pageCount = RecordCount / PageSize;
  122. if (RecordCount % PageSize == 0)
  123. {
  124. pageCount = RecordCount / PageSize;
  125. }
  126. else
  127. {
  128. pageCount = RecordCount / PageSize + 1;
  129. }
  130. return pageCount;
  131. }
  132. #endregion
  133. frmReportApp m_ReportApp;
  134. #endregion
  135. public ParticlesGridDevidePage(frmReportApp ReportApp)
  136. {
  137. m_ReportApp = ReportApp;
  138. result = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult];
  139. InitializeComponent();
  140. m_frm_userprogress = new Frm_UserProgress();
  141. m_mythread_state = false;
  142. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  143. lan = new Language(this);
  144. table = lan.GetNameTable(this.Name);
  145. fieldData = new FieldData(result.FilePath);
  146. }
  147. private void ParticlesGridDevidePage_Load(object sender, EventArgs e)
  148. {
  149. //初始化底层操作类
  150. m_OTSIncAReportGridsFun = new OTSIncAReportGridsFun(m_ReportApp, this);
  151. if (Language.ReadDefaultLanguage() == "EN")
  152. {
  153. cbB_order.Items.Add("Default");
  154. cbB_order.Items.Add("ParticlesName");
  155. cbB_order.Items.Add("Dmax Ascend");
  156. cbB_order.Items.Add("Dmax Descend");
  157. cbB_order.Items.Add("Area Ascend");
  158. cbB_order.Items.Add("Area Descend");
  159. }
  160. else
  161. {
  162. cbB_order.Items.Add("默认");
  163. cbB_order.Items.Add("颗粒名称");
  164. cbB_order.Items.Add("最大直径 升序");
  165. cbB_order.Items.Add("最大直径 降序");
  166. cbB_order.Items.Add("面积 升序");
  167. cbB_order.Items.Add("面积 降序");
  168. }
  169. cbB_order.SelectedIndex = 0;
  170. cbB_PageSize.Items.Add("20");
  171. cbB_PageSize.Items.Add("100");
  172. cbB_PageSize.Items.Add("500");
  173. cbB_PageSize.Items.Add("1000");
  174. cbB_PageSize.Items.Add("5000");
  175. cbB_PageSize.Items.Add("All");
  176. cbB_PageSize.SelectedIndexChanged -= new System.EventHandler(this.cbB_PageSize_SelectedIndexChanged);
  177. cbB_PageSize.SelectedIndex = 0;
  178. cbB_PageSize.SelectedIndexChanged += new System.EventHandler(this.cbB_PageSize_SelectedIndexChanged);
  179. }
  180. #region 自定义方法
  181. /// <summary>
  182. /// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
  183. /// </summary>
  184. /// <param name="in_cotsparticleclr"></param>
  185. /// <returns></returns>
  186. public Bitmap GetBitmapByParticle(string fieldImage, Rectangle offset_rect)
  187. {
  188. //然后将取出的数据,转换成Bitmap对象
  189. Bitmap ls_bt = DrawFuncation.ReadImageFile(fieldImage);
  190. //为了能把整个颗粒显示完整
  191. offset_rect.X = offset_rect.X - 5;
  192. offset_rect.Y = offset_rect.Y - 5;
  193. offset_rect.Width = offset_rect.Width + 10;
  194. offset_rect.Height = offset_rect.Height + 10;
  195. //防止计算偏差后,有坐标溢出现象
  196. if (offset_rect.X < 0)
  197. offset_rect.X = 0;
  198. if (offset_rect.Y < 0)
  199. offset_rect.Y = 0;
  200. if (offset_rect.X + offset_rect.Width > ls_bt.Width)
  201. {
  202. offset_rect.Width = ls_bt.Width - offset_rect.X;
  203. }
  204. if (offset_rect.Y + offset_rect.Height > ls_bt.Height)
  205. {
  206. offset_rect.Height = ls_bt.Height - offset_rect.Y;
  207. }
  208. //
  209. Bitmap new_ret_bp;
  210. //防止为0后面计算出错
  211. if (offset_rect.Width > 0 && offset_rect.Height > 0)
  212. {
  213. //最后通过list_showsegment组建成新的图片,进行返回
  214. new_ret_bp = ls_bt.Clone(offset_rect, PixelFormat.Format8bppIndexed);
  215. }
  216. else
  217. {
  218. new_ret_bp = new Bitmap(offset_rect.Width, offset_rect.Height);
  219. }
  220. return new_ret_bp;
  221. }
  222. public Bitmap GetBitmapForBig(string sub, ParticleData fielddata, double xs)
  223. {
  224. string vs = "," + sub.Replace(':', '-') + ",";
  225. DataTable dataTable = fielddata.GetParticleAll(vs);
  226. if (dataTable.Rows.Count == 0)
  227. {
  228. return null;
  229. }
  230. string path = result.FilePath;
  231. //内接矩形
  232. double max_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs - Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
  233. double max_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs + Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
  234. double min_Y = max_Y;
  235. double min_X = max_X;
  236. //拼接field矩形
  237. double MAX_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
  238. double MAX_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
  239. double MIN_Y = MAX_Y;
  240. double MIN_X = MAX_X;
  241. foreach (DataRow item in dataTable.Rows)
  242. {
  243. //颗粒外接矩形
  244. double lefttopX = Convert.ToInt64(item["FieldPosX"]) * xs + Convert.ToInt64(item["RectLeft"]);
  245. if (lefttopX < min_X)
  246. {
  247. min_X = lefttopX;
  248. }
  249. if (lefttopX + Convert.ToInt64(item["RectWidth"]) > max_X)
  250. {
  251. max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
  252. }
  253. double lrfttopY = Convert.ToInt64(item["FieldPosY"]) * xs - Convert.ToInt64(item["RectTop"]);
  254. if (max_Y < lrfttopY)
  255. {
  256. max_Y = lrfttopY;
  257. }
  258. if (min_Y > lrfttopY - Convert.ToInt64(item["RectHeight"]))
  259. {
  260. min_Y = lrfttopY - Convert.ToInt64(item["RectHeight"]);
  261. }
  262. //画布
  263. double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
  264. if (lefttopXH > MAX_X)
  265. {
  266. MAX_X = lefttopXH;
  267. }
  268. if (lefttopXH < MIN_X)
  269. {
  270. MIN_X = lefttopXH;
  271. }
  272. double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
  273. if (MAX_Y < lrfttopYH)
  274. {
  275. MAX_Y = lrfttopYH;
  276. }
  277. if (MIN_Y > lrfttopYH)
  278. {
  279. MIN_Y = lrfttopYH;
  280. }
  281. }
  282. int WIDTH = Convert.ToInt32(MAX_X - MIN_X) + 1024;
  283. int HEIGHT = Convert.ToInt32(MAX_Y - MIN_Y) + 768;
  284. //构造最终的图片白板
  285. Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
  286. Graphics graph = Graphics.FromImage(tableChartImage);
  287. //初始化这个大图
  288. graph.DrawImage(tableChartImage, 0, 0);
  289. int width = Convert.ToInt32(max_X - min_X);
  290. int height = Convert.ToInt32(max_Y - min_Y);
  291. int X = Convert.ToInt32(min_X - MIN_X);
  292. int Y = Convert.ToInt32(MAX_Y - max_Y);
  293. Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
  294. foreach (DataRow item in dataTable.Rows)
  295. {
  296. string filePath = path + "\\FIELD_FILES\\";
  297. string imagePath = filePath + "Field" + item["fieldid"].ToString() + ".bmp";
  298. //然后将取出的数据,转换成Bitmap对象
  299. Bitmap ls_bt = DrawFuncation.ReadImageFile(imagePath);
  300. int x = Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - MIN_X);
  301. int y = System.Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - MAX_Y));
  302. try
  303. {
  304. graph.DrawImage(ls_bt, x, y);
  305. }
  306. catch (Exception e)
  307. {
  308. throw;
  309. }
  310. }
  311. Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
  312. return bmap;
  313. }
  314. private void BindDataGridView()
  315. {
  316. #region 加载显示进度条部份
  317. this.Cursor = Cursors.WaitCursor;
  318. m_frm_userprogress = new Frm_UserProgress();
  319. //显示进度条,计算进度条应该显示的位置和宽度
  320. Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
  321. if (ls_main_form == null)
  322. {
  323. m_frm_userprogress.Visible = false;
  324. }
  325. else
  326. {
  327. string str7 = table["str7"].ToString();
  328. m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
  329. m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 80, ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
  330. m_frm_userprogress.Show();
  331. m_frm_userprogress.SetProgressValueAndText(0, str7);
  332. }
  333. #endregion
  334. dgV_ParticlesDevidePage.Rows.Clear();
  335. dgV_ParticlesDevidePage.Columns.Clear();
  336. //从报告xml文件中加载,显示计算列,显示元素信息
  337. string str_DefaultComputedColName = "", str_ElementsColName = "";
  338. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXmlData(Application.StartupPath + m_ReportApp.m_OTSReportMgrParamFile, "XMLData");
  339. DataTable dt = ds.Tables["Member"];
  340. foreach (DataRow element in dt.Rows)
  341. {
  342. string RegName = element["RegName"].ToString();
  343. if (RegName == "DefaultComputedColName")
  344. {
  345. str_DefaultComputedColName = element["strValue"].ToString();
  346. }
  347. if (RegName == "ElementsColName")
  348. {
  349. str_ElementsColName = element["strValue"].ToString();
  350. }
  351. }
  352. //获取需要显示的计算列
  353. string[] strs = str_DefaultComputedColName.Split(',');
  354. //列名
  355. Dictionary<string, string> keyValues = new Dictionary<string, string>() { };
  356. keyValues.Add("rowid", table["str4"].ToString());
  357. keyValues.Add("TypeName", table["str6"].ToString());
  358. keyValues.Add("ParticleImage", table["str5"].ToString());
  359. keyValues.Add("SEMPosX", "SEMPosX");
  360. keyValues.Add("SEMPosY", "SEMPosY");
  361. for (int i = 0; i < strs.Count(); i++)
  362. {
  363. if (strs[i] == "Area")
  364. {
  365. keyValues.Add("Area", table["str21"].ToString());
  366. }
  367. if (strs[i] == "EquivalentCircleDiameter")
  368. {
  369. keyValues.Add("Equivalent", table["str22"].ToString());
  370. }
  371. if (strs[i] == "MaxDiameter")
  372. {
  373. keyValues.Add("DMAX", table["str23"].ToString());
  374. }
  375. if (strs[i] == "MinDiameter")
  376. {
  377. keyValues.Add("DMIN", table["str24"].ToString());
  378. }
  379. if (strs[i] == "DiameterRatio")
  380. {
  381. keyValues.Add("DiameterRatio", table["str25"].ToString());
  382. }
  383. if (strs[i] == "FerretDiameter")
  384. {
  385. keyValues.Add("DFERET", table["str26"].ToString());
  386. }
  387. if (strs[i] == "PERP")
  388. {
  389. keyValues.Add("DPERP", table["str27"].ToString());
  390. }
  391. if (strs[i] == "PERI")
  392. {
  393. keyValues.Add("PERIMETER", table["str28"].ToString());
  394. }
  395. if (strs[i] == "INSCR")
  396. {
  397. keyValues.Add("DINSCR", table["str29"].ToString());
  398. }
  399. if (strs[i] == "MEAN")
  400. {
  401. keyValues.Add("DMEAN", table["str30"].ToString());
  402. }
  403. if (strs[i] == "ELONG")
  404. {
  405. keyValues.Add("DELONG", table["str31"].ToString());
  406. }
  407. if (strs[i] == "ASPECT_ELONG")
  408. {
  409. keyValues.Add("ASPECT_ELONG", table["str32"].ToString());
  410. }
  411. if (strs[i] == "Orientation")
  412. {
  413. keyValues.Add("ORIENTATION", table["str33"].ToString());
  414. }
  415. }
  416. keyValues.Add("Element", "Element");
  417. Dictionary<string, string>.Enumerator en = keyValues.GetEnumerator();
  418. for (int irow = 0; irow < keyValues.Count; irow++)
  419. {
  420. if (en.MoveNext())
  421. {
  422. if (en.Current.Key == "ParticleImage")
  423. {
  424. DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
  425. iconColumn.Name = en.Current.Key;
  426. iconColumn.HeaderText = en.Current.Value;
  427. dgV_ParticlesDevidePage.Columns.Add(iconColumn);
  428. }
  429. else if (en.Current.Key == "Element")
  430. {
  431. }
  432. else
  433. {
  434. int columndid = dgV_ParticlesDevidePage.Columns.Add(en.Current.Key, en.Current.Value);
  435. }
  436. }
  437. }
  438. ParticleData fielddata = new ParticleData(result.FilePath);
  439. DataTable particles = fielddata.GetInfoForPartucleDevidePage(PageIndex, pageSize, OrderFunction, condition);
  440. if(PageSize==-1)
  441. {
  442. PageSize = particles.Rows.Count;
  443. }
  444. if (particles == null)
  445. {
  446. return;
  447. }
  448. //获取需要显示的元素名
  449. List<string> ElementTypeSort = new List<string>(str_ElementsColName.Split(',').ToList());//去重
  450. for (int i = 0; i < ElementTypeSort.Count; i++)
  451. {
  452. dgV_ParticlesDevidePage.Columns.Add(ElementTypeSort[i], ElementTypeSort[i]);
  453. }
  454. RecordCount = fielddata.GetAllInfo(condition).Rows.Count;
  455. double jd = 95f / (double)particles.Rows.Count;//计算进度刻度
  456. string filePath = result.FilePath + "\\FIELD_FILES\\";
  457. KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
  458. for (int i = 0; i < particles.Rows.Count; i++)
  459. {
  460. //更新进度,每100条记录加载完,更新一次进度
  461. if (i % 2 == 0)
  462. m_frm_userprogress.SetProgressValueAndText((int)(jd * i), "loading..");
  463. Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
  464. int add_rowindex = dgV_ParticlesDevidePage.Rows.Add();
  465. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[0].Value = (pageSize * (PageIndex - 1) + add_rowindex + 1).ToString();
  466. for (int k = 0; k < keyValues.Count; k++)
  467. {
  468. if (enl.MoveNext())
  469. {
  470. if (enl.Current.Key == "rowid")
  471. {
  472. //dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = i + 1;
  473. }
  474. if (enl.Current.Key == "ParticleImage")
  475. {
  476. //string subt = particles.Rows[i]["SubParticles"].ToString();
  477. //if (subt != null && subt != "")
  478. //{
  479. // double ScanFieldSize = Convert.ToDouble(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["Sample"])["Members"])["SEMDataMsr"])["ScanFieldSize"]);
  480. // string filePatht = result.FilePath + "\\FIELD_FILES\\";
  481. // string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
  482. // //然后将取出的数据,转换成Bitmap对象
  483. // Bitmap tempbit = fielddata.ReadImageFile(imagePatht);
  484. // int pixw = tempbit.Width;
  485. // double xs = pixw / ScanFieldSize;
  486. // particleM = particleM + "," + subt;
  487. // Bitmap bmap = fielddata.GetBitmapForBig(subt, xs, result.FilePath);
  488. // if (bmap != null)
  489. // {
  490. // bmap.Tag = new List<string>() { subt.Split(',')[0].Split(':')[0], subt.Split(',')[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
  491. // dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
  492. // dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
  493. // dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
  494. // }
  495. // else
  496. // {
  497. // dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
  498. // dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
  499. // }
  500. //}
  501. //else
  502. //{
  503. if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
  504. {
  505. string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
  506. FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), fielddata.ReadImageFile(imagePath));
  507. }
  508. 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"]) };
  509. Bitmap bmap = fielddata.GetBitmapByParticle(FieldImage.Value, rectangle);
  510. bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString() };
  511. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
  512. dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height+20;
  513. //}
  514. }
  515. if (enl.Current.Key == "DiameterRatio")
  516. {
  517. double d = Convert.ToDouble(particles.Rows[i]["DMAX"]) / Convert.ToDouble(particles.Rows[i]["DMIN"]);
  518. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  519. }
  520. if (enl.Current.Key == "ASPECT_ELONG")
  521. {
  522. double d = Convert.ToDouble(particles.Rows[i]["DELONG"]) / Convert.ToDouble(particles.Rows[i]["DMEAN"]);
  523. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  524. }
  525. if (particles.Columns.Contains(enl.Current.Key))
  526. {
  527. double num = 0;
  528. if (double.TryParse(particles.Rows[i][enl.Current.Key].ToString(), out num))
  529. {
  530. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 2);
  531. }
  532. else if (enl.Current.Key == "Element")
  533. {
  534. List<string> elementtemp = new List<string>(ElementTypeSort);
  535. string[] strcbo = particles.Rows[i][enl.Current.Key].ToString().Split(';');
  536. for (int j = 0; j < strcbo.Length; j++)
  537. {
  538. string[] str = strcbo[j].Split('-');
  539. if (ElementTypeSort.Contains(str[0]))
  540. { dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[str[0].ToString()].Value = Math.Round(double.Parse(str[1]), 2).ToString(); }
  541. elementtemp.Remove(str[0].ToString());
  542. }
  543. foreach (var ele in elementtemp)
  544. {
  545. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[ele].Value = "0";
  546. }
  547. }
  548. else
  549. {
  550. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = particles.Rows[i][enl.Current.Key];
  551. }
  552. }
  553. if (enl.Current.Key == "TypeName")
  554. {
  555. if (particles.Rows[i]["TypeId"].ToString() == "9")
  556. {
  557. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = "Not Identified";
  558. }
  559. }
  560. if (enl.Current.Key == "Equivalent")
  561. {
  562. double dSize = Convert.ToDouble(particles.Rows[i]["Area"]);
  563. double Diameter = Math.Sqrt(dSize / Math.PI) * 2;
  564. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(Diameter, 2);
  565. }
  566. }
  567. }
  568. }
  569. #region 加载进度条进度部份结束
  570. //加载完成设置鼠标为默认
  571. this.Cursor = Cursors.Default;
  572. string str8 = table["str8"].ToString();
  573. m_frm_userprogress.SetProgressValueAndText(100, str8);
  574. //加载完成,关闭进度条
  575. m_frm_userprogress.Close();
  576. #endregion
  577. }
  578. /// <summary>
  579. /// 设置DataGridView样式
  580. /// </summary>
  581. private void SetDataGridViewStyle()
  582. {
  583. //用户不能调整标题的高度
  584. dgV_ParticlesDevidePage.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  585. //用户不能调整 行高
  586. dgV_ParticlesDevidePage.AllowUserToResizeRows = false;
  587. //改变行的高度;
  588. //Gview_gz.RowTemplate.Height = 20;
  589. //点击选择整行
  590. dgV_ParticlesDevidePage.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  591. //居中显示
  592. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  593. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  594. dgV_ParticlesDevidePage.DefaultCellStyle = dataGridViewCellStyle1;
  595. dgV_ParticlesDevidePage.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  596. //再次重覆禁用拖动表头高度,居然有效果了
  597. dgV_ParticlesDevidePage.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  598. //设置grid可以复制
  599. dgV_ParticlesDevidePage.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  600. //设置每列的宽度
  601. dgV_ParticlesDevidePage.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  602. dgV_ParticlesDevidePage.Columns[1].Width = 150;
  603. //dgV_ParticlesDevidePage.Columns[dgV_ParticlesDevidePage.Columns.Count - 1].Width = 450;
  604. //dgV_ParticlesDevidePage.Columns[dgV_ParticlesDevidePage.Columns.Count - 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
  605. //设置序号列不排序
  606. dgV_ParticlesDevidePage.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  607. //设置序号列不可以设置宽度
  608. dgV_ParticlesDevidePage.Columns[0].Resizable = DataGridViewTriState.False;
  609. dgV_ParticlesDevidePage.RowsDefaultCellStyle.BackColor = Color.Azure;
  610. }
  611. #endregion
  612. #region 相关事件
  613. private void ToolStripMenuItem1_Click(object sender, EventArgs e)
  614. {
  615. //复制整个表
  616. CopyAll();
  617. }
  618. private void ToolStripMenuItem2_Click(object sender, EventArgs e)
  619. {
  620. //复制选择区域
  621. CopySelected();
  622. }
  623. /// <summary>
  624. /// 复制选择区域
  625. /// </summary>
  626. public void CopySelected()
  627. {
  628. //复制选择区域
  629. object oo = dgV_ParticlesDevidePage.GetClipboardContent();
  630. if (oo != null)
  631. Clipboard.SetDataObject(dgV_ParticlesDevidePage.GetClipboardContent());
  632. }
  633. /// <summary>
  634. /// 复制所有
  635. /// </summary>
  636. public void CopyAll()
  637. {
  638. dgV_ParticlesDevidePage.SelectAll();
  639. Clipboard.SetDataObject(dgV_ParticlesDevidePage.GetClipboardContent());
  640. }
  641. /// <summary>
  642. /// 以图像的方式将GridView进行截图
  643. /// </summary>
  644. public void CopyImage()
  645. {
  646. int height, width;
  647. width = dgV_ParticlesDevidePage.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) + 2;
  648. height = this.Height;
  649. Bitmap image = new Bitmap(width, height);
  650. dgV_ParticlesDevidePage.DrawToBitmap(image, new Rectangle(0, 0, width, height));
  651. Clipboard.SetImage(image);
  652. }
  653. private void toolStripMenuItem4_Click(object sender, EventArgs e)
  654. {
  655. //对gridview进行截图
  656. CopyImage();
  657. }
  658. private void dgV_ParticlesDevidePage_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  659. {
  660. //排序中
  661. if (this.dgV_ParticlesDevidePage.Rows[e.RowIndex1].Tag != null && this.dgV_ParticlesDevidePage.Rows[e.RowIndex1].Tag.ToString() == "统计行")
  662. {
  663. //ROW1>ROW2
  664. e.SortResult = 1;
  665. if (this.dgV_ParticlesDevidePage.SortOrder == SortOrder.Descending)
  666. e.SortResult = -1;
  667. e.Handled = true;
  668. return;
  669. }
  670. if (this.dgV_ParticlesDevidePage.Rows[e.RowIndex2].Tag != null && this.dgV_ParticlesDevidePage.Rows[e.RowIndex2].Tag.ToString() == "统计行")
  671. {
  672. //ROW1<ROW2
  673. e.SortResult = -1;
  674. if (this.dgV_ParticlesDevidePage.SortOrder == SortOrder.Descending)
  675. e.SortResult = 1;
  676. e.Handled = true;
  677. return;
  678. }
  679. }
  680. /// <summary>
  681. /// 将OTS坐标转换为Sem 坐标
  682. /// </summary>
  683. /// <param name="POTSCoord"></param>
  684. /// <returns></returns>
  685. public Point ChangeOTSToSemCoord(Point POTSCoord)
  686. {
  687. //first if m_semstagedata is null to get stage inforation
  688. Convert.ToDouble(((Dictionary<string, object>)result.ResultInfo["SEMStageData"])["scanFieldSize"]);
  689. //after obtaining stage info,calc stage point data
  690. Point ret_SEM_point = new Point();
  691. // get center point, um
  692. long xStart = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["SEMStageData"])["Members"])["XAxis"])["start"]);
  693. long xEnd = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["SEMStageData"])["Members"])["XAxis"])["end"]);
  694. long xCenter = (xStart + xEnd) / 2;
  695. long yStart = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["SEMStageData"])["Members"])["YAxis"])["start"]);
  696. long yEnd = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["SEMStageData"])["Members"])["YAxis"])["end"]);
  697. long yCenter = (yStart + yEnd) / 2;
  698. // delte = SEM - OTSa
  699. long deltex = xCenter - 0;
  700. long deltey = yCenter - 0;
  701. int xdir = Convert.ToInt32(((Dictionary<string, object>)result.ResultInfo["SEMStageData"])["xAxisDir"]);
  702. int ydir = Convert.ToInt32(((Dictionary<string, object>)result.ResultInfo["SEMStageData"])["yAxisDir"]);
  703. if (xdir == (int)OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
  704. {
  705. ret_SEM_point.X = -1 * (POTSCoord.X - Convert.ToInt32(deltex));
  706. }
  707. else if (xdir == (int)OTS_X_AXIS_DIRECTION.RIGHT_TOWARD)
  708. {
  709. ret_SEM_point.X = POTSCoord.X + Convert.ToInt32(deltex);
  710. }
  711. if (ydir == (int)OTS_Y_AXIS_DIRECTION.UP_TOWARD)
  712. {
  713. ret_SEM_point.Y = POTSCoord.Y + Convert.ToInt32(deltey);
  714. }
  715. else if (ydir == (int)OTS_Y_AXIS_DIRECTION.DOWN_TOWARD)
  716. {
  717. ret_SEM_point.Y = -1 * (POTSCoord.Y - Convert.ToInt32(deltey));
  718. }
  719. return ret_SEM_point;
  720. }
  721. #endregion
  722. #region 获取向导出模块提供的DataTable和GridView对象
  723. /// <summary>
  724. /// 获取到该模块输出后形成的DataTable,和GridView
  725. /// </summary>
  726. /// <param name="out_dt"></param>
  727. /// <param name="out_dg"></param>
  728. public void GetDataTableAndGridView(out DataTable out_dt, out DataGridView out_dg)
  729. {
  730. out_dt = m_dt;
  731. out_dg = this.dgV_ParticlesDevidePage;//同样通过 dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[2].Value 来获取bitmap对象
  732. }
  733. #endregion
  734. #region 连接电镜相关
  735. /// <summary>
  736. /// 移动SEM到指定位置线程函数
  737. /// </summary>
  738. private void Thread_GO(object in_obj)
  739. {
  740. if (m_mythread_state == false)
  741. {
  742. m_mythread_state = true;
  743. Point sem_point = (Point)in_obj;
  744. //第一步,连接电镜
  745. m_OTSIncAReportGridsFun.Connection_ForParticlesGrid();
  746. Thread.Sleep(500);
  747. //第二步,移动到指定位置,先读取再设置
  748. if (m_OTSIncAReportGridsFun.m_SEMConnectionState == true)
  749. {
  750. m_OTSIncAReportGridsFun.MoveSemToPointXY_ForParticlesGrid(sem_point.X, sem_point.Y);
  751. }
  752. Thread.Sleep(1500);
  753. //第三步,断开电镜连接
  754. m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
  755. //Thread.Sleep(500);
  756. m_mythread_state = false;
  757. }
  758. }
  759. #endregion
  760. private void ToolStripMenuItem_exportzoomimagefile_Click(object sender, EventArgs e)
  761. {
  762. //导出放大图像
  763. FolderBrowserDialog fbd = new FolderBrowserDialog();
  764. if (fbd.ShowDialog() == DialogResult.OK)
  765. {
  766. m_imagefilepath = fbd.SelectedPath;
  767. for (int i = 0; i < m_dt.Rows.Count; i++)
  768. {
  769. Bitmap ls_bp = new Bitmap(1, 1);
  770. ls_bp = (Bitmap)m_dt.Rows[i][1];
  771. string strPath = m_imagefilepath + "\\" + (i + 1).ToString() + ".jpg";
  772. string strPath2 = m_imagefilepath + "\\" + (i + 1).ToString() + "s.jpg";
  773. ls_bp.Save(strPath);
  774. //m_COTSReportProjFileMgrClr.ReZoom(strPath, strPath2);
  775. System.IO.File.Delete(strPath);//再将文件删除
  776. }
  777. string str1 = table["str9"].ToString();
  778. MessageBox.Show(str1 + m_dt.Rows.Count.ToString());
  779. }
  780. }
  781. /// <summary>
  782. /// 导出二次放大图像
  783. /// </summary>
  784. /// <param name="str_srcPathName"></param>
  785. /// <param name="str_outPathName"></param>
  786. public void ParticleReZoom(string str_srcPathName, string str_outPathName)
  787. {
  788. //m_COTSReportProjFileMgrClr.ReZoom(str_srcPathName, str_outPathName);
  789. }
  790. private void ToolStripMenuItem3_Click(object sender, EventArgs e)
  791. {
  792. //恢复至初始状态
  793. dgV_ParticlesDevidePage.Rows.Clear();
  794. dgV_ParticlesDevidePage.Columns.Clear();
  795. BindDataGridView();
  796. SetDataGridViewStyle();
  797. }
  798. private void ToolStripMenuItem5_Click(object sender, EventArgs e)
  799. {
  800. /*注意:多数据源情况下,只获取第一个数据源的选择了多行的情况下,只获取最后一个选择行的,没有办法,这是为了符合李阳博士提出的要求*/
  801. //先获取鼠标所选择的行里的颗粒的FieldID和ParticleID
  802. string i_ls_fieldid = "";
  803. string i_ls_particleid = "";
  804. int cou = dgV_ParticlesDevidePage.SelectedRows.Count;
  805. if (cou > 0)
  806. {
  807. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[cou - 1];
  808. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  809. List<string> list_str = (List<string>)ls_bp.Tag;
  810. if (list_str != null)
  811. {
  812. i_ls_fieldid = list_str[0];
  813. i_ls_particleid = list_str[1];
  814. }
  815. }
  816. ParticleData particleData = new ParticleData(result.FilePath);
  817. Particle particle = particleData.GetParticleByFidAndPid(i_ls_fieldid, i_ls_particleid);
  818. ////然后遍历所有的Field
  819. //Point ls_ots_point = new Point() { X = particle.PosX, Y = particle.PosY };
  820. ////将该坐标转成SEM坐标
  821. //Point ls_sem_point = ChangeOTSToSemCoord(ls_ots_point);
  822. //取得Field的Position,然后执行线程移动SEM到当前Field的位置
  823. if (m_mythread == null)
  824. {
  825. return;
  826. }
  827. if (m_mythread.ThreadState == ThreadState.Running || m_mythread.ThreadState == ThreadState.WaitSleepJoin)
  828. {
  829. return;
  830. }
  831. if (m_mythread.ThreadState == ThreadState.Stopped)
  832. {
  833. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  834. }
  835. //改为线程调用,先判断线程状态
  836. m_mythread.Start(new Point(particle.SEMPosX, particle.SEMPosY));
  837. }
  838. private void ToolStripMenuItem_selectparticle_Click(object sender, EventArgs e)
  839. {
  840. string path = result.FilePath;
  841. ParticleData fielddata = new ParticleData(result.FilePath);
  842. List<Particle> particles = fielddata.GetParticleAllList();
  843. List<Particle> ls_list_cotsparticleclr = new List<Particle>();
  844. for (int l = 0; l < dgV_ParticlesDevidePage.SelectedRows.Count; l++)
  845. {
  846. //从事先加载的Bitmap对象的Tag中取出List<string>
  847. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[l];
  848. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  849. List<string> list_str = (List<string>)ls_bp.Tag;
  850. if (list_str != null)
  851. {
  852. int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  853. int i_ls_particleid = Convert.ToInt32(list_str[1]);
  854. foreach (Particle item in particles)
  855. {
  856. if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
  857. {
  858. ls_list_cotsparticleclr.Add(item);
  859. break;
  860. }
  861. }
  862. }
  863. }
  864. m_ReportApp.SelectedParticles = ls_list_cotsparticleclr;
  865. string str1 = table["str1"].ToString();
  866. //然后循环得出,list cotsparticleclr列表,返回给框架
  867. //m_sec.SendCall(str1, "", "", ls_list_cotsparticleclr);
  868. string str2 = table["str2"].ToString();
  869. string str3 = table["str3"].ToString();
  870. MessageBox.Show(str2 + ls_list_cotsparticleclr.Count.ToString() + str3);
  871. }
  872. private void ToolStripMenuItem_exportimagefile_Click(object sender, EventArgs e)
  873. {
  874. FolderBrowserDialog fbd = new FolderBrowserDialog();
  875. if (fbd.ShowDialog() == DialogResult.OK)
  876. {
  877. m_imagefilepath = fbd.SelectedPath;
  878. for (int i = 0; i < dgV_ParticlesDevidePage.Rows.Count; i++)
  879. {
  880. Bitmap ls_bp = new Bitmap(1, 1);
  881. ls_bp = (Bitmap)dgV_ParticlesDevidePage.Rows[i].Cells[2].Value;
  882. ls_bp.Save(m_imagefilepath + "\\" + (i + 1).ToString() + ".jpg");
  883. }
  884. string str9 = table["str9"].ToString();
  885. MessageBox.Show(str9 + dgV_ParticlesDevidePage.Rows.Count.ToString());
  886. }
  887. }
  888. private void testToolStripMenuItem_Click(object sender, EventArgs e)
  889. {
  890. ////测试导出指定颗粒的能谱图,测试相关代码
  891. //OTSIncAReportGraph.DParticle ls_dparticle = new OTSIncAReportGraph.DParticle();
  892. //for (int i = 0; i < dgV_ParticlesDevidePage.SelectedRows.Count; i++)
  893. //{
  894. // //获取选择行颗粒的fieldid,和particleid
  895. // string str_fieldid = "";
  896. // string str_particleid = "";
  897. // string str_stdtypeid = "";
  898. // DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[i];
  899. // Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  900. // List<string> list_str = (List<string>)ls_bp.Tag;
  901. // if (list_str != null)
  902. // {
  903. // str_fieldid = list_str[0];
  904. // str_particleid = list_str[1];
  905. // str_stdtypeid = list_str[2];
  906. // }
  907. // ls_dparticle.CLRFieldID = Convert.ToInt32(str_fieldid);
  908. // ls_dparticle.CLRTagID = Convert.ToInt32(str_particleid);
  909. // ls_dparticle.STDTypeID = Convert.ToInt32(str_stdtypeid);
  910. //}
  911. ////显示xray能谱
  912. //ShowXRay(ls_dparticle);
  913. //Bitmap ls_bpex = new Bitmap(control_XRayTable1.Width, control_XRayTable1.Height);
  914. //control_XRayTable1.DrawToBitmap(ls_bpex, new Rectangle(0, 0, control_XRayTable1.Width, control_XRayTable1.Height));
  915. ////Bitmap ls_bpex = control_XRayTable1.ExportXRayImage();
  916. //ls_bpex.Save("e:\\test222.jpg");
  917. }
  918. /// <summary>
  919. /// 判断条件输入 前<后
  920. /// </summary>
  921. /// <param name="min"></param>
  922. /// <param name="max"></param>
  923. /// <returns></returns>
  924. bool CompareInput(string min,string max)
  925. {
  926. int imax = 0;
  927. int imin = 0;
  928. double dmax = 0;
  929. double dmin = 0;
  930. if (int.TryParse(max, out imax))
  931. {
  932. dmax = (double)imax;
  933. }
  934. else
  935. {
  936. dmax = Convert.ToDouble(max);
  937. }
  938. if (int.TryParse(min, out imin))
  939. {
  940. dmin = (double)imin;
  941. }
  942. else
  943. {
  944. dmin = Convert.ToDouble(min);
  945. }
  946. if(dmin<=dmax)
  947. {
  948. return true;
  949. }
  950. else
  951. {
  952. return false;
  953. }
  954. }
  955. private void btn_Sel_Click(object sender, EventArgs e)
  956. {
  957. condition = "";
  958. if (!string.IsNullOrWhiteSpace(tBx_AreaMin.Text))
  959. {
  960. double dnum = 0;
  961. int inum = 0;
  962. if (double.TryParse(tBx_AreaMin.Text, out dnum) && dnum >= 0)
  963. {
  964. condition += " and Area" + " > " + tBx_AreaMin.Text;
  965. }
  966. else if(int.TryParse(tBx_AreaMin.Text, out inum) && inum >= 0)
  967. {
  968. condition += " and Area" + " > " + tBx_AreaMin.Text;
  969. }
  970. else
  971. {
  972. MessageBox.Show(table["str10"].ToString());
  973. return;
  974. }
  975. }
  976. if (!string.IsNullOrWhiteSpace(Tbx_AreaMax.Text))
  977. {
  978. double dnum = 0;
  979. int inum = 0;
  980. if (double.TryParse(Tbx_AreaMax.Text, out dnum) && dnum >= 0)
  981. {
  982. condition += " and Area" + "<" + Tbx_AreaMax.Text;
  983. }
  984. else if (int.TryParse(Tbx_AreaMax.Text, out inum) && inum >= 0)
  985. {
  986. condition += " and Area" + "<" + Tbx_AreaMax.Text;
  987. }
  988. else
  989. {
  990. MessageBox.Show(table["str10"].ToString());
  991. return;
  992. }
  993. }
  994. if (!string.IsNullOrWhiteSpace(tBx_AreaMin.Text) && !string.IsNullOrWhiteSpace(Tbx_AreaMax.Text))
  995. {
  996. if (!CompareInput(tBx_AreaMin.Text, Tbx_AreaMax.Text))
  997. {
  998. MessageBox.Show(table["str11"].ToString());
  999. return;
  1000. }
  1001. }
  1002. if (!string.IsNullOrWhiteSpace(tbx_DmaxMin.Text))
  1003. {
  1004. double dnum = 0;
  1005. int inum = 0;
  1006. if (double.TryParse(tbx_DmaxMin.Text, out dnum) && dnum >= 0)
  1007. {
  1008. condition += " and DMAX" + " > " + tbx_DmaxMin.Text;
  1009. }
  1010. else if(int.TryParse(tbx_DmaxMin.Text, out inum)&& inum >= 0)
  1011. {
  1012. condition += " and DMAX" + " > " + tbx_DmaxMin.Text;
  1013. }
  1014. else
  1015. {
  1016. MessageBox.Show(table["str10"].ToString());
  1017. return;
  1018. }
  1019. }
  1020. if (!string.IsNullOrWhiteSpace(tbx_DmaxMax.Text))
  1021. {
  1022. double dnum = 0;
  1023. int inum = 0;
  1024. if (double.TryParse(tbx_DmaxMax.Text, out dnum) && dnum > 0)
  1025. {
  1026. condition += " and DMAX" + "<" + tbx_DmaxMax.Text;
  1027. }
  1028. else if(int.TryParse(tbx_DmaxMax.Text, out inum)&& inum >= 0)
  1029. {
  1030. condition += " and DMAX" + "<" + tbx_DmaxMax.Text;
  1031. }
  1032. else
  1033. {
  1034. MessageBox.Show(table["str10"].ToString());
  1035. return;
  1036. }
  1037. }
  1038. if (!string.IsNullOrWhiteSpace(tbx_DmaxMin.Text) && !string.IsNullOrWhiteSpace(tbx_DmaxMax.Text))
  1039. {
  1040. if (!CompareInput(tbx_DmaxMin.Text, tbx_DmaxMax.Text))
  1041. {
  1042. MessageBox.Show(table["str11"].ToString());
  1043. return;
  1044. }
  1045. }
  1046. if (!string.IsNullOrWhiteSpace(tbx_Type.Text))
  1047. {
  1048. condition += " and TypeName Like \"%" + tbx_Type.Text + "%\" ";
  1049. }
  1050. lnkFirst_Click(null, null);
  1051. SetDataGridViewStyle();
  1052. }
  1053. private void cbB_order_SelectedIndexChanged(object sender, EventArgs e)
  1054. {
  1055. int ordernum = cbB_order.SelectedIndex;
  1056. if (ordernum == 0)
  1057. {
  1058. OrderFunction = "fieldid,particleid";
  1059. }
  1060. else if (ordernum == 1)
  1061. {
  1062. OrderFunction = "TypeName";
  1063. }
  1064. else if (ordernum == 2)
  1065. {
  1066. OrderFunction = "DMAX";
  1067. }
  1068. else if (ordernum == 3)
  1069. {
  1070. OrderFunction = "DMAX desc";
  1071. }
  1072. else if (ordernum == 4)
  1073. {
  1074. OrderFunction = "Area";
  1075. }
  1076. else if (ordernum == 5)
  1077. {
  1078. OrderFunction = "Area desc";
  1079. }
  1080. lnkFirst_Click(null, null);
  1081. SetDataGridViewStyle();
  1082. }
  1083. /// <summary>
  1084. /// 页面控件呈现
  1085. /// </summary>
  1086. private void DrawControl(bool callEvent)
  1087. {
  1088. BindDataGridView();
  1089. lblTotalCount.Text = RecordCount.ToString();
  1090. lblPageCount.Text = PageCount.ToString();
  1091. txtPageNum.Text = PageIndex.ToString();
  1092. SetFormCtrEnabled();
  1093. if (PageCount == 0 || PageCount == 1)//有且仅有一页
  1094. {
  1095. lnkFirst.Enabled = false;
  1096. lnkPrev.Enabled = false;
  1097. lnkNext.Enabled = false;
  1098. lnkLast.Enabled = false;
  1099. btnGo.Enabled = false;
  1100. }
  1101. else if (PageIndex == 1)//第一页
  1102. {
  1103. lnkFirst.Enabled = false;
  1104. lnkPrev.Enabled = false;
  1105. }
  1106. else if (PageIndex == PageCount)//最后一页
  1107. {
  1108. lnkNext.Enabled = false;
  1109. lnkLast.Enabled = false;
  1110. }
  1111. }
  1112. private void SetFormCtrEnabled()
  1113. {
  1114. lnkFirst.Enabled = true;
  1115. lnkPrev.Enabled = true;
  1116. lnkNext.Enabled = true;
  1117. lnkLast.Enabled = true;
  1118. btnGo.Enabled = true;
  1119. }
  1120. bool isTextChanged = false;
  1121. /// <summary>
  1122. /// 分页属性改变了。
  1123. /// </summary>
  1124. private void txtPageSize_TextChanged(object sender, EventArgs e)
  1125. {
  1126. int num = 0;
  1127. if (int.TryParse(txtPageNum.Text.Trim(), out num) && num > 0)
  1128. {
  1129. }
  1130. else { txtPageNum.Text = "1"; }
  1131. }
  1132. /// <summary>
  1133. /// 光标离开分页属性
  1134. private void txtPageSize_Leave(object sender, EventArgs e)
  1135. {
  1136. if (isTextChanged)
  1137. {
  1138. isTextChanged = false;
  1139. lnkFirst_Click(null, null);
  1140. }
  1141. }
  1142. private void txtPageSize_KeyPress(object sender, KeyPressEventArgs e)
  1143. {
  1144. if (isTextChanged)
  1145. {
  1146. isTextChanged = false;
  1147. lnkFirst_Click(null, null);
  1148. }
  1149. }
  1150. private void lnkFirst_Click(object sender, EventArgs e)
  1151. {
  1152. PageIndex = 1;
  1153. DrawControl(true);
  1154. }
  1155. private void lnkPrev_Click(object sender, EventArgs e)
  1156. {
  1157. PageIndex = Math.Max(1, PageIndex - 1);
  1158. DrawControl(true);
  1159. }
  1160. private void lnkNext_Click(object sender, EventArgs e)
  1161. {
  1162. PageIndex = Math.Min(PageCount, PageIndex + 1);
  1163. DrawControl(true);
  1164. }
  1165. private void lnkLast_Click(object sender, EventArgs e)
  1166. {
  1167. PageIndex = PageCount;
  1168. DrawControl(true);
  1169. }
  1170. /// <summary>
  1171. /// 跳转
  1172. /// </summary>
  1173. /// <param name="sender"></param>
  1174. /// <param name="e"></param>
  1175. private void btnGo_Click(object sender, EventArgs e)
  1176. {
  1177. int num = 0;
  1178. if (int.TryParse(txtPageNum.Text.Trim(), out num) && num > 0)
  1179. {
  1180. if (num > PageCount)
  1181. {
  1182. num = PageCount;
  1183. txtPageNum.Text = PageCount.ToString();
  1184. }
  1185. PageIndex = num;
  1186. DrawControl(true);
  1187. }
  1188. }
  1189. /// <summary>
  1190. /// 跳转页数限制
  1191. /// </summary>
  1192. private void txtPageNum_TextChanged(object sender, EventArgs e)
  1193. {
  1194. int num = 0;
  1195. if (int.TryParse(txtPageNum.Text.Trim(), out num) && num > 0)
  1196. {
  1197. }
  1198. else { txtPageNum.Text = "1"; }
  1199. }
  1200. /// <summary>
  1201. /// enter键功能
  1202. /// </summary>
  1203. private void txtPageNum_KeyPress(object sender, KeyPressEventArgs e)
  1204. {
  1205. btnGo_Click(null, null);
  1206. }
  1207. private void cbB_PageSize_SelectedIndexChanged(object sender, EventArgs e)
  1208. {
  1209. if (cbB_PageSize.SelectedItem.ToString() == "All")
  1210. {
  1211. pageSize = -1;
  1212. }
  1213. else
  1214. {
  1215. pageSize = int.Parse(cbB_PageSize.SelectedItem.ToString());
  1216. }
  1217. lnkFirst_Click(null, null);
  1218. }
  1219. /// <summary>
  1220. /// 在帧图上标记颗粒的位置矩形,并保存到FIELD_FILES_MARK文件夹中
  1221. /// </summary>
  1222. public void SaveMarkParticleRectangleOnFieldFile(DataTable dataTable)
  1223. {
  1224. string str_path_FIELD_FILES = result.FilePath + "\\FIELD_FILES\\";
  1225. string str_path_FIELD_FILES_MARK = result.FilePath + "\\FIELD_FILES_MARK\\";
  1226. ////判断是否已经有导出过的标记帧图文件夹,如果已经存在,则直接返回不输出,先不加
  1227. DirectoryInfo theFolder_FieldMark = new DirectoryInfo(str_path_FIELD_FILES_MARK);
  1228. if (!theFolder_FieldMark.Exists)
  1229. {
  1230. //创建
  1231. theFolder_FieldMark.Create();
  1232. }
  1233. else
  1234. {
  1235. //已经存在的话,直接返回
  1236. //return;
  1237. }
  1238. //查找该field下对应所有的颗粒
  1239. DataTable dt_AllParticle = fieldData.GetAllParticle_DataTable();
  1240. DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES);
  1241. if (theFolder.Exists)
  1242. {
  1243. //循环帧图,再循环各帧图中的颗粒,进行标记,保存
  1244. foreach (FileInfo nextifile in theFolder.GetFiles())
  1245. {
  1246. //找出所有的用户库文件,在这个目录中
  1247. if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
  1248. {
  1249. //确认对应的帧图名
  1250. string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
  1251. str_fieldid = str_fieldid.Substring(5, str_fieldid.Length - 5);//减去field字符长度
  1252. if (dataTable.Select(" fieldid = " + str_fieldid).Count() > 0)
  1253. {
  1254. Image img = Image.FromFile(nextifile.FullName);
  1255. Bitmap ls_fieldbp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  1256. using (Graphics g = Graphics.FromImage(ls_fieldbp))
  1257. {
  1258. g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  1259. g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
  1260. g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
  1261. g.DrawImage(img, 0, 0);
  1262. }
  1263. img.Dispose();
  1264. img = null;
  1265. //循环将颗粒,进行标记到bitmap图上
  1266. DataRow[] drlist = dt_AllParticle.Select(" fieldid = " + str_fieldid);
  1267. for (int i_row = 0; i_row < drlist.Count(); i_row++)
  1268. {
  1269. //string str_fieldid = drlist[i_row]["fieldid"].ToString();
  1270. string str_particleid = drlist[i_row]["particleid"].ToString();
  1271. string str_stdtypeid = drlist[i_row]["typeid"].ToString();
  1272. string str_offset_rect_X = drlist[i_row]["RectLeft"].ToString();
  1273. string str_offset_rect_Y = drlist[i_row]["RectTop"].ToString();
  1274. string str_offset_rect_Width = drlist[i_row]["RectWidth"].ToString();
  1275. string str_offset_rect_Height = drlist[i_row]["RectHeight"].ToString();
  1276. //确定需要标记颗粒的定位
  1277. Rectangle offset_rect = new Rectangle(Convert.ToInt32(str_offset_rect_X), Convert.ToInt32(str_offset_rect_Y),
  1278. Convert.ToInt32(str_offset_rect_Width), Convert.ToInt32(str_offset_rect_Height));
  1279. //向帧图进行标记颗粒位置
  1280. Graphics g = Graphics.FromImage(ls_fieldbp);
  1281. g.DrawRectangle(new Pen(Color.Aquamarine), offset_rect);
  1282. //判断是否超出了图像外面,是的话,让文字在左侧显示,默认在右侧显示
  1283. int ls_offsetx = offset_rect.X + offset_rect.Width;
  1284. if (ls_offsetx > ls_fieldbp.Width - 10)
  1285. {
  1286. ls_offsetx = offset_rect.X - 10;
  1287. }
  1288. g.DrawString(str_fieldid + "" + str_particleid.ToString(),
  1289. new Font("黑体", 8), new SolidBrush(Color.Aqua), new PointF(ls_offsetx, offset_rect.Y));
  1290. //保存带有标记的帧图
  1291. ls_fieldbp.Save(str_path_FIELD_FILES_MARK + str_fieldid.ToString() + ".bmp");
  1292. //ls_fieldbp.Dispose();
  1293. }
  1294. }
  1295. }
  1296. }
  1297. }
  1298. //
  1299. GC.Collect();
  1300. GC.WaitForPendingFinalizers();
  1301. }
  1302. private void testToolStripMenuItem1_Click(object sender, EventArgs e)
  1303. {
  1304. //SaveMarkParticleRectangleOnFieldFile();
  1305. MessageBox.Show("导出完成!");
  1306. }
  1307. private void EXCELToolStripMenuItem_Click(object sender, EventArgs e)
  1308. {
  1309. //将所有的数据导出到EXCEL中
  1310. SaveFileDialog sfd = new SaveFileDialog();
  1311. sfd.Filter = "Excel文件(*.xls)|*.xls";
  1312. //设置默认文件类型显示顺序
  1313. sfd.FilterIndex = 1;
  1314. //保存对话框是否记忆上次打开的目录
  1315. sfd.RestoreDirectory = true;
  1316. if (sfd.ShowDialog() == DialogResult.OK)
  1317. {
  1318. IWorkbook workbook = new HSSFWorkbook(); //用于创建.xls office2003开始以前的
  1319. //IWorkbook workbook = new XSSFWorkbook(); //用于创建.xlsx office2007开始以后的
  1320. ISheet sheet;
  1321. //创建Excel文件
  1322. FileStream fs = File.Create(sfd.FileName);
  1323. fs.Close();
  1324. sheet = workbook.CreateSheet("Particles");//创建工作表
  1325. //创建表格边框样式风格
  1326. ICellStyle cellStyle = workbook.CreateCellStyle();
  1327. cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
  1328. cellStyle.VerticalAlignment = VerticalAlignment.Center;
  1329. //设置上4边
  1330. cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
  1331. cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
  1332. cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
  1333. cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
  1334. //设置字符大小和颜色
  1335. IFont font = workbook.CreateFont();
  1336. font.FontName = "黑体";
  1337. font.FontHeightInPoints = 10;
  1338. cellStyle.SetFont(font);
  1339. //设置颗粒名列宽
  1340. sheet.SetColumnWidth(1, 30 * 256);//夹杂物名列宽
  1341. sheet.SetColumnWidth(2, 3 * 256);//图像列宽
  1342. IRow row;
  1343. ICell cell;
  1344. //插入表头
  1345. row = sheet.CreateRow(1);//从第15行添加一行
  1346. for (int i_cell = 0; i_cell < dgV_ParticlesDevidePage.Columns.Count; i_cell++)
  1347. {
  1348. cell = row.CreateCell(i_cell);
  1349. cell.CellStyle = cellStyle;
  1350. cell.SetCellValue(dgV_ParticlesDevidePage.Columns[i_cell].Name);
  1351. }
  1352. //插入表内容
  1353. for (int i_row = 0; i_row < dgV_ParticlesDevidePage.Rows.Count; i_row++)
  1354. {
  1355. row = sheet.CreateRow(2 + i_row);
  1356. for (int i_cell = 0; i_cell < dgV_ParticlesDevidePage.Columns.Count; i_cell++)
  1357. {
  1358. cell = row.CreateCell(i_cell);
  1359. cell.CellStyle = cellStyle;
  1360. if (dgV_ParticlesDevidePage[i_cell, i_row].Value == null)
  1361. continue;
  1362. if (i_cell == 2)
  1363. {
  1364. //颗粒图像列
  1365. Bitmap bp = (Bitmap)dgV_ParticlesDevidePage.Rows[i_row].Cells[2].Value;
  1366. byte[] bytes = ImageConvertToBytes(bp);
  1367. //第二步,将图片添加到workbook中,指定图片的格式,返回图片所在workbook->paicture数组中的索引的地址,从1开始
  1368. int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
  1369. //第三步,在sheet中创建画布
  1370. IDrawing patriarch = sheet.CreateDrawingPatriarch();
  1371. //第四步,设置锚点,(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格行数,列数,终止单元格行数,列数)
  1372. IClientAnchor anchor = patriarch.CreateAnchor(1, 1, 2, 2, i_cell, i_row + 2, i_cell + 1, i_row + 3);//终止比开始位置大1,会自动缩放到一个单元格内的
  1373. //第五步,创建图片
  1374. IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
  1375. //图像效果不好,自己另外导出吧,这里对该列宽进行了设置0
  1376. }
  1377. else
  1378. {
  1379. //非图像列
  1380. cell.SetCellValue(dgV_ParticlesDevidePage[i_cell, i_row].Value.ToString());
  1381. }
  1382. }
  1383. }
  1384. //完成后,对Excel进行保存
  1385. FileStream file = new FileStream(sfd.FileName, FileMode.Create);
  1386. workbook.Write(file);
  1387. file.Close();
  1388. MessageBox.Show("导出完成!");
  1389. //导出完成后,打开Excel文件
  1390. if (File.Exists(sfd.FileName))
  1391. {
  1392. //打开刚才导出的文件
  1393. System.Diagnostics.Process.Start(sfd.FileName);
  1394. }
  1395. }
  1396. }
  1397. /// <summary>
  1398. /// 将image转成bytes
  1399. /// </summary>
  1400. /// <param name="in_img"></param>
  1401. /// <returns></returns>
  1402. public byte[] ImageConvertToBytes(System.Drawing.Image in_img)
  1403. {
  1404. MemoryStream ms = new MemoryStream();
  1405. in_img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  1406. return ms.ToArray();
  1407. }
  1408. /// <summary>
  1409. /// 返回原子序数
  1410. /// </summary>
  1411. /// <param name="ElementName"></param>
  1412. /// <returns></returns>
  1413. int ReturnsAtomicNumberByElementName(string ElementName)
  1414. {
  1415. switch (ElementName)
  1416. {
  1417. case "H": return 1;
  1418. case "He": return 2;
  1419. case "Li": return 3;
  1420. case "Be": return 4;
  1421. case "B": return 5;
  1422. case "C": return 6;
  1423. case "N": return 7;
  1424. case "O": return 8;
  1425. case "F": return 9;
  1426. case "Ne": return 10;
  1427. case "Na": return 11;
  1428. case "Mg": return 12;
  1429. case "Al": return 13;
  1430. case "Si": return 14;
  1431. case "P": return 15;
  1432. case "S": return 16;
  1433. case "Cl": return 17;
  1434. case "Ar": return 18;
  1435. case "K": return 19;
  1436. case "Ca": return 20;
  1437. case "Sc": return 21;
  1438. case "Ti": return 22;
  1439. case "V": return 23;
  1440. case "Cr": return 24;
  1441. case "Mn": return 25;
  1442. case "Fe": return 26;
  1443. case "Co": return 27;
  1444. case "Ni": return 28;
  1445. case "Cu": return 29;
  1446. case "Zn": return 30;
  1447. case "Ga": return 31;
  1448. case "Ge": return 32;
  1449. case "As": return 33;
  1450. case "Se": return 34;
  1451. case "Br": return 35;
  1452. case "Kr": return 36;
  1453. case "Rb": return 37;
  1454. case "Sr": return 38;
  1455. case "Y": return 39;
  1456. case "Zr": return 40;
  1457. case "Nb": return 41;
  1458. case "Mo": return 42;
  1459. case "Tc": return 43;
  1460. case "Ru": return 44;
  1461. case "Rh": return 45;
  1462. case "Pd": return 46;
  1463. case "Ag": return 47;
  1464. case "Cd": return 48;
  1465. case "In": return 49;
  1466. case "Sn": return 50;
  1467. case "Sb": return 51;
  1468. case "Te": return 52;
  1469. case "I": return 53;
  1470. case "Xe": return 54;
  1471. case "Cs": return 55;
  1472. case "Ba": return 56;
  1473. case "La": return 57;
  1474. case "Ce": return 58;
  1475. case "Pr": return 59;
  1476. case "Nd": return 60;
  1477. case "Pm": return 61;
  1478. case "Sm": return 62;
  1479. case "Eu": return 63;
  1480. case "Gd": return 64;
  1481. case "Tb": return 65;
  1482. case "Dy": return 66;
  1483. case "Ho": return 67;
  1484. case "Er": return 68;
  1485. case "Tm": return 69;
  1486. case "Yb": return 70;
  1487. case "Lu": return 71;
  1488. case "Hf": return 72;
  1489. case "Ta": return 73;
  1490. case "W": return 74;
  1491. case "Re": return 75;
  1492. case "Os": return 76;
  1493. case "Ir": return 77;
  1494. case "Pt": return 78;
  1495. case "Au": return 79;
  1496. case "Hq": return 80;
  1497. case "TI": return 81;
  1498. case "Pb": return 82;
  1499. case "Bi": return 83;
  1500. case "Po": return 84;
  1501. case "At": return 85;
  1502. case "Rn": return 86;
  1503. case "Fr": return 87;
  1504. case "Ra": return 88;
  1505. case "Ac": return 89;
  1506. case "Th": return 90;
  1507. case "Pa": return 91;
  1508. case "U": return 92;
  1509. case "Np": return 93;
  1510. case "Pu": return 94;
  1511. case "Am": return 95;
  1512. case "Cm": return 96;
  1513. case "Bk": return 97;
  1514. case "Cf": return 98;
  1515. case "Es": return 99;
  1516. case "Fm": return 100;
  1517. case "Mc": return 101;
  1518. case "No": return 102;
  1519. case "Lr": return 103;
  1520. case "Rf": return 104;
  1521. case "Db": return 105;
  1522. case "Sg": return 106;
  1523. case "Bh": return 107;
  1524. case "Hs": return 108;
  1525. case "Mt": return 109;
  1526. case "Ds": return 110;
  1527. case "Rg": return 111;
  1528. case "Unb": return 112;
  1529. default: return 1000;
  1530. }
  1531. }
  1532. public List<string> GetElementsColName()
  1533. {
  1534. List<string> list_str = new List<string>();
  1535. string ls_str = "Ar,Al,Si,B,P,C,S,N,Cl,O,F,Ne,He,Lr,Lu,Rn,Xe,Kr,Md,Tm,Po,Te,Se,Es,Ho,Pb,Sn,Ge,Np,Pm,Os,Ru,Fe,Bk,Tb,Hg,Cd,Zn,Pa,Pr,W,Mo,Cr,No,Yb,At,I,Br,Fm,Er,Bi,Sb,As,Hf,Zr,Ti,Am,Eu,Pt,Pd,Ni,U,Nd,Re,Tc,Mn,Cf,Dy,Tl,In,Ga,Ra,Ba,Sr,Ca,Cm,Gd,Au,Ag,Cu,Th,Ce,Ta,Pu,Nb,Sm,V,Ir,Rh,Co,Ac,La,Y,Sc,Fr,Cs,Rb,K,Na,Mg,Be,Li,H";
  1536. string[] strs = ls_str.Split(',');
  1537. for (int i = 0; i < strs.Count(); i++)
  1538. {
  1539. list_str.Add(strs[i]);
  1540. }
  1541. return list_str;
  1542. }
  1543. private void panel2_Paint(object sender, PaintEventArgs e)
  1544. {
  1545. }
  1546. }
  1547. }