ParticlesGridDevidePage.cs 93 KB

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