ParticlesGridDevidePage.cs 69 KB

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