ParticlesGridDevidePage.cs 112 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688
  1. using NPOI.SS.Formula.Functions;
  2. using NPOI.SS.UserModel;
  3. using NPOI.SS.UserModel.Charts;
  4. using NPOI.SS.Util;
  5. using NPOI.XSSF.UserModel;
  6. using OTSCommon.DBOperate;
  7. using OTSCommon.DBOperate.Model;
  8. using OTSIncAReportApp;
  9. using OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage;
  10. using OTSIncAReportApp._2_CommonFunction.CommonClass;
  11. using OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess;
  12. using OTSIncAReportApp.DataOperation.DataAccess;
  13. using OTSIncAReportApp.OTSRstMgrFunction;
  14. using OTSIncAReportApp.SysMgrTools;
  15. using OTSIncAReportGraph.Class;
  16. using OTSIncAReportGraph.Controls;
  17. using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
  18. using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
  19. using OTSIncAReportMailInterface;
  20. using System;
  21. using System.Collections;
  22. using System.Collections.Generic;
  23. using System.Data;
  24. using System.Data.SQLite;
  25. using System.Drawing;
  26. using System.IO;
  27. using System.Linq;
  28. using System.Reflection;
  29. using System.Threading;
  30. using System.Windows.Forms;
  31. using static OTSDataType.otsdataconst;
  32. namespace OTSIncAReportGrids
  33. {
  34. public partial class ParticlesGridDevidePage : UserControl
  35. {
  36. ParticlesGridDevidePageShowConfig m_particlesGridDevidePageShowConfig = null;
  37. //设置模拟数据表
  38. public DataTable m_dt = new DataTable();
  39. //底层操作类
  40. SEMAndEDSOperate m_OTSIncAReportGridsFun = null;
  41. //进度条窗体
  42. public Frm_UserProgress m_frm_userprogress;
  43. //移动SEM到指定位置发生线程
  44. private Thread m_mythread;
  45. //记录线程是否已经运行完成的状态
  46. private bool m_mythread_state = false;
  47. //导出图像文件的路径
  48. private string m_imagefilepath = "";
  49. //显示元素列表
  50. public List<string> m_list_elementscolname = null;
  51. //单个数据源所拥有的列数,这里保存下来,供导出模块使用
  52. public int m_oneresult_columncount = 0;
  53. OTSImageDisHelp m_ReportFun = null;
  54. public OTSImageDisHelp ReportFun { get => m_ReportFun; set => m_ReportFun = value; }
  55. /// <summary>
  56. /// 选择颗粒缓存表
  57. /// </summary>
  58. List<Particle> Particleslist_selecttodisplay = new List<Particle>();
  59. //多个数据源,每个数据源拥有的列数,这里保存下来,供分组使用
  60. public List<int> m_list_oneresult_columncount;
  61. //国际化
  62. Language lan;
  63. public Hashtable table;
  64. //测量结果
  65. public ResultFile result = null;
  66. frmReportConditionChoose m_condition;
  67. FieldData fieldData;
  68. DataTable particlesAll;
  69. DataTable particles;
  70. public ParticleData Particledata;
  71. public UserSTDDbAccess userSTDDb;
  72. public FieldImage fldImgAccess;
  73. DataTable userSTDDbData;
  74. NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  75. enum SelItem
  76. {
  77. analyticalParticle = 0,
  78. otherParticles = 1,
  79. MergeParticles = 2,
  80. allParticles = 3
  81. }
  82. #region 分页器相关
  83. #region 分页字段和属性
  84. string condition = "";
  85. public string FileName = null;
  86. private int pageIndex = 1;
  87. /// <summary>
  88. /// 当前页面
  89. /// </summary>
  90. public virtual int PageIndex
  91. {
  92. get { return pageIndex; }
  93. set { pageIndex = value; }
  94. }
  95. private int pageSize = 20;
  96. /// <summary>
  97. /// 每页记录数
  98. /// </summary>
  99. public virtual int PageSize
  100. {
  101. get { return pageSize; }
  102. set { pageSize = value; }
  103. }
  104. private int recordCount = 0;
  105. /// <summary>
  106. /// 总记录数
  107. /// </summary>
  108. public virtual int RecordCount
  109. {
  110. get { return recordCount; }
  111. set { recordCount = value; }
  112. }
  113. private int pageCount = 0;
  114. /// <summary>
  115. /// 总页数
  116. /// </summary>
  117. public int PageCount
  118. {
  119. get
  120. {
  121. pageCount = GetPageCount();
  122. return pageCount;
  123. }
  124. }
  125. /// <summary>
  126. /// 计算总页数
  127. /// </summary>
  128. /// <returns></returns>
  129. private int GetPageCount()
  130. {
  131. if (PageSize == 0)
  132. {
  133. return 0;
  134. }
  135. int pageCount = RecordCount / PageSize;
  136. if (RecordCount % PageSize == 0)
  137. {
  138. pageCount = RecordCount / PageSize;
  139. }
  140. else
  141. {
  142. pageCount = RecordCount / PageSize + 1;
  143. }
  144. return pageCount;
  145. }
  146. #endregion
  147. frmReportApp m_ReportApp;
  148. #endregion
  149. public ParticlesGridDevidePage(frmReportApp ReportApp)
  150. {
  151. m_ReportApp = ReportApp;
  152. m_condition = ReportApp.m_conditionChoose;
  153. string sou = m_condition.m_CurrentConditions[OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE].itemDisplayVal.ToString();
  154. if (sou.Contains("+"))
  155. {
  156. MessageBox.Show("This function does not support multiple samples!");
  157. result = m_ReportApp.m_rstDataMgr.ResultFilesList[0];
  158. }
  159. else
  160. {
  161. result = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE)];
  162. }
  163. ReportFun = new OTSImageDisHelp(result);
  164. //设置窗体的双缓冲,以保证大数据时拖动不卡
  165. this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
  166. this.UpdateStyles();
  167. InitializeComponent();
  168. //利用反射设置DataGridView的双缓冲
  169. Type dgvType = this.dgV_ParticlesDevidePage.GetType();
  170. PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
  171. pi.SetValue(this.dgV_ParticlesDevidePage, true, null);
  172. this.control_XRayTable1 = new Control_XRayTable(null);
  173. this.control_XRayTable1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  174. this.control_XRayTable1.Dock = System.Windows.Forms.DockStyle.Bottom;
  175. this.control_XRayTable1.GBInfoStr = "";
  176. this.control_XRayTable1.GoodChineseName = "";
  177. this.control_XRayTable1.MaterialName = "";
  178. this.control_XRayTable1.Location = new System.Drawing.Point(0, 400);
  179. this.control_XRayTable1.Name = "control_XRayTable1";
  180. this.control_XRayTable1.ShowAnalysisXray = true;
  181. this.control_XRayTable1.ShowSearchXray = false;
  182. this.control_XRayTable1.Size = new System.Drawing.Size(1004, 200);
  183. this.control_XRayTable1.STDName = "";
  184. this.control_XRayTable1.Visible = false;
  185. this.control_XRayTable1.label_close.Visible = true;
  186. this.Controls.Add(this.control_XRayTable1);
  187. }
  188. bool Init()
  189. {
  190. if (result == null)
  191. {
  192. return false;
  193. }
  194. try
  195. {
  196. lan = new Language(this);
  197. table = lan.GetNameTable(this.Name);
  198. m_mythread_state = false;
  199. m_mythread = new Thread(new ParameterizedThreadStart(ControlThread_GO));
  200. fieldData = new FieldData(result.FilePath);
  201. Particledata = new ParticleData(result.FilePath);
  202. fldImgAccess = new FieldImage(result.FilePath);
  203. var systype = m_ReportApp.m_RptConfigFile.Systype;
  204. if (systype == OTS_SysType_ID.TCCleannessA || systype == OTS_SysType_ID.BatteryCleannessA)
  205. {
  206. string str_STDDbName = result.GetSTDName();
  207. userSTDDb = new UserSTDDbAccess(str_STDDbName, result.FilePath + "\\");
  208. if (userSTDDb.GetSqlHelper() != null)
  209. {
  210. userSTDDbData = userSTDDb.GetSubAttributeFromDatabase();
  211. }
  212. else
  213. {
  214. userSTDDbData = null;
  215. }
  216. }
  217. //初始化底层操作类
  218. m_OTSIncAReportGridsFun = new SEMAndEDSOperate();
  219. return true;
  220. }
  221. catch (Exception ex)
  222. {
  223. log.Error(ex.ToString());
  224. return false;
  225. }
  226. }
  227. private void ParticlesGridDevidePage_Load(object sender, EventArgs e)
  228. {
  229. if (!Init())
  230. {
  231. return;
  232. }
  233. ProgressStart();//进度条关闭通过cbB_PageSize.SelectedIndex事件
  234. if (!UpdateDataGrid())
  235. {
  236. return;
  237. }
  238. cbB_PageSize.Items.Add("20");
  239. cbB_PageSize.Items.Add("100");
  240. cbB_PageSize.Items.Add("500");
  241. cbB_PageSize.Items.Add("1000");
  242. cbB_PageSize.Items.Add("5000");
  243. cbB_PageSize.Items.Add("All");
  244. cbB_PageSize.SelectedIndex = 0;
  245. DataTable table = GetClassificationOfAllParticles();
  246. if (table != null)
  247. {
  248. if (table.Rows.Count > 0)
  249. {
  250. foreach (DataRow row in table.Rows)
  251. {
  252. tbx_Type.Text += row["TypeName"].ToString() + '$';
  253. }
  254. }
  255. if (tbx_Type.Text != "")
  256. {
  257. tbx_Type.Text = tbx_Type.Text.Remove(tbx_Type.Text.Length - 1);
  258. }
  259. }
  260. dgV_ParticlesDevidePage.Focus();
  261. }
  262. #region 自定义方法
  263. bool UpdateDataGrid()
  264. {
  265. int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
  266. particlesAll = new DataTable();
  267. if (sel == (int)SelItem.analyticalParticle)
  268. {
  269. particlesAll = Particledata.GetInfoForPartucleDevidePage_analyticalParticle(condition);
  270. }
  271. if (sel == (int)SelItem.otherParticles)
  272. {
  273. particlesAll = Particledata.GetInfoForPartucleDevidePage_otherParticle(condition);
  274. }
  275. if (sel == (int)SelItem.MergeParticles)
  276. {
  277. particlesAll = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
  278. }
  279. if (sel == (int)SelItem.allParticles)
  280. {
  281. particlesAll = Particledata.GetInfoForPartucleDevidePage_allParticles(condition);
  282. }
  283. particlesAll.Columns.Add("Hardness");
  284. particlesAll.Columns.Add("Density");
  285. particlesAll.Columns.Add("Electrical_conductivity");
  286. if (userSTDDbData != null)
  287. {
  288. for (int i = 0; i < particlesAll.Rows.Count; i++)
  289. {
  290. DataRow[] dr = userSTDDbData.Select("STDId=" + particlesAll.Rows[i]["TypeId"].ToString());
  291. if (dr.Length > 0)
  292. {
  293. particlesAll.Rows[i]["Hardness"] = dr[0]["Hardness"].ToString();
  294. particlesAll.Rows[i]["Density"] = dr[0]["Density"].ToString();
  295. particlesAll.Rows[i]["Electrical_conductivity"] = dr[0]["Electrical_conductivity"].ToString();
  296. }
  297. else
  298. {
  299. particlesAll.Rows[i]["Hardness"] = "";
  300. particlesAll.Rows[i]["Density"] = "";
  301. particlesAll.Rows[i]["Electrical_conductivity"] = "";
  302. }
  303. }
  304. }
  305. else
  306. {
  307. for (int i = 0; i < particlesAll.Rows.Count; i++)
  308. {
  309. particlesAll.Rows[i]["Hardness"] = "";
  310. particlesAll.Rows[i]["Density"] = "";
  311. particlesAll.Rows[i]["Electrical_conductivity"] = "";
  312. }
  313. }
  314. btn_Sel.Enabled = true;
  315. if (particlesAll == null)
  316. {
  317. log.Error("There is an exception in the data of the database!");
  318. #region 加载进度条进度部份结束
  319. this.Cursor = Cursors.Default;
  320. m_frm_userprogress.Close();
  321. #endregion
  322. return false;
  323. }
  324. DataTable elementchemistry = Particledata.GetElementChemistry();
  325. for (int i = 0; i < particlesAll.Rows.Count; i++)
  326. {
  327. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  328. DataRow[] drs = elementchemistry.Select(str);
  329. string ConcatenatedString = "";
  330. for (int j = 0; j < drs.Length; j++)
  331. {
  332. ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
  333. }
  334. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  335. }
  336. particlesAll.Columns.Add("XRayDataCount");
  337. DataTable XRayData = Particledata.GetXRayData();
  338. for (int i = 0; i < particlesAll.Rows.Count; i++)
  339. {
  340. string subt = particlesAll.Rows[i]["SubParticles"].ToString();
  341. if (subt =="")
  342. {
  343. particlesAll.Rows[i]["XRayDataCount"] = 0;
  344. string str = " XrayIndex= " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  345. DataRow[] drs = XRayData.Select(str);
  346. uint xraycount = 0;
  347. if (drs != null)
  348. {
  349. if (drs.Length > 0)
  350. {
  351. uint[] Analysis_xray = new uint[2000];
  352. for (int j = 0; j < 2000; j++)
  353. {
  354. Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
  355. }
  356. for (int j = 0; j < 2000; j++)
  357. {
  358. xraycount += Analysis_xray[j];
  359. }
  360. particlesAll.Rows[i]["XRayDataCount"] = xraycount;
  361. }
  362. }
  363. }
  364. else
  365. {
  366. particlesAll.Rows[i]["XRayDataCount"] = 0;
  367. DataRow dgvr = particlesAll.Rows[i];
  368. uint[] Search_xray = new uint[2000];
  369. uint[] Analysis_xray = new uint[2000];
  370. Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Search_xray, out Analysis_xray);
  371. uint xraycount = 0;
  372. for (int j = 0; j < 2000; j++)
  373. {
  374. xraycount += Analysis_xray[j];
  375. }
  376. particlesAll.Rows[i]["XRayDataCount"] = xraycount;
  377. }
  378. }
  379. return true;
  380. }
  381. private void RefreshGridView()
  382. {
  383. dgV_ParticlesDevidePage.Visible = false;
  384. if (m_frm_userprogress.IsDisposed)
  385. {
  386. ProgressStart();
  387. }
  388. string str_ElementsColName = null;
  389. Dictionary<string, string> keyValues = InitializeTable(ref str_ElementsColName);
  390. Dictionary<string, string>.Enumerator en = keyValues.GetEnumerator();
  391. for (int irow = 0; irow < keyValues.Count; irow++)
  392. {
  393. if (en.MoveNext())
  394. {
  395. if (en.Current.Key == "ParticleImage")
  396. {
  397. DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
  398. iconColumn.Name = en.Current.Key;
  399. iconColumn.HeaderText = en.Current.Value;
  400. iconColumn.ImageLayout = DataGridViewImageCellLayout.Zoom;
  401. dgV_ParticlesDevidePage.Columns.Add(iconColumn);
  402. }
  403. else if (en.Current.Key == "Element")
  404. {
  405. }
  406. else
  407. {
  408. dgV_ParticlesDevidePage.Columns.Add(en.Current.Key, en.Current.Value);
  409. if (en.Current.Key == "Area" || en.Current.Key == "EquivalentCircleDiameter" || en.Current.Key == "MaxDiameter" || en.Current.Key == "MinDiameter" || en.Current.Key == "DiameterRatio" || en.Current.Key == "FerretDiameter" || en.Current.Key == "PERP" || en.Current.Key == "PERI" || en.Current.Key == "INSCR" || en.Current.Key == "MEAN" || en.Current.Key == "ELONG" || en.Current.Key == "ASPECT_ELONG" || en.Current.Key == "Orientation")
  410. {
  411. int id = dgV_ParticlesDevidePage.Columns.Count;
  412. dgV_ParticlesDevidePage.Columns[id - 1].Tag = "NumericType";
  413. }
  414. }
  415. }
  416. }
  417. if (PageSize == -1|| PageSize == 0)
  418. {
  419. PageSize = particlesAll.Rows.Count;
  420. }
  421. if (particlesAll == null)
  422. {
  423. return;
  424. }
  425. RecordCount = particlesAll.Rows.Count;
  426. particles = particlesAll.Clone();
  427. for (int fi = (PageIndex - 1) * pageSize; fi < PageIndex * pageSize; fi++)
  428. {
  429. if (fi > RecordCount - 1)
  430. {
  431. break;
  432. }
  433. particles.ImportRow(particlesAll.Rows[fi]);
  434. }
  435. List<string> ElementTypeSort = new List<string>(str_ElementsColName.Split(',').ToList());//去重
  436. for (int i = 0; i < ElementTypeSort.Count; i++)
  437. {
  438. if (ElementTypeSort[0] == "")
  439. {
  440. ElementTypeSort.RemoveAt(0);
  441. break;
  442. }
  443. dgV_ParticlesDevidePage.Columns.Add(ElementTypeSort[i], ElementTypeSort[i]);
  444. int id = dgV_ParticlesDevidePage.Columns.Count;
  445. dgV_ParticlesDevidePage.Columns[id - 1].Tag = "NumericType";
  446. }
  447. double jd = 95f / (double)particles.Rows.Count;
  448. string filePath = result.FilePath + "\\FIELD_FILES\\";
  449. for (int i = 0; i < particles.Rows.Count; i++)
  450. {
  451. if (i % 10 == 0)
  452. m_frm_userprogress.SetProgressValueAndText((int)(jd * i), "loading..");
  453. Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
  454. int add_rowindex = dgV_ParticlesDevidePage.Rows.Add();
  455. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[0].Value = (pageSize * (PageIndex - 1) + add_rowindex + 1).ToString();
  456. Dictionary<string, Bitmap> fieldpics=new Dictionary<string, Bitmap>();
  457. for (int k = 0; k < keyValues.Count; k++)
  458. {
  459. if (enl.MoveNext())
  460. {
  461. if (enl.Current.Key == "ParticleImage")
  462. {
  463. string subt = particles.Rows[i]["SubParticles"].ToString();
  464. dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
  465. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
  466. Bitmap bmap = null;
  467. if (subt != null && subt != "" && subt != "IsSubParticle")
  468. {
  469. //double ScanFieldSize = result.GetScanFieldSizeX();
  470. //string filePatht = result.FilePath + "\\FIELD_FILES\\";
  471. //string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
  472. //Bitmap tempbit = Particledata.ReadImageFile(imagePatht);
  473. //int pixw = tempbit.Width;
  474. double xs = result.GetPixelSize();
  475. int width = result.GetImageWidth();
  476. int height = result.GetImageHeight();
  477. string vs = "," + subt.Replace(':', '-') + ",";
  478. DataTable dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
  479. bmap = fldImgAccess.GetBitmapForMergedParticle(subt, xs, result.FilePath, height, width);
  480. if (bmap != null)
  481. {
  482. string[] str = subt.Split(',');
  483. bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1] };
  484. }
  485. }
  486. else if (subt != "IsSubParticle")
  487. {
  488. if (!fieldpics.Keys.Contains(particles.Rows[i]["fieldid"].ToString()))
  489. {
  490. string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
  491. fieldpics.Add(particles.Rows[i]["fieldid"].ToString(), fldImgAccess.ReadImageFile(imagePath));
  492. }
  493. 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"]) };
  494. bmap = fldImgAccess.GetBitmapByParticle(fieldpics[particles.Rows[i]["fieldid"].ToString()], rectangle);
  495. bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString()};
  496. dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
  497. }
  498. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
  499. }
  500. if (enl.Current.Key == "DiameterRatio")
  501. {
  502. double d = Convert.ToDouble(particles.Rows[i]["DMAX"]) / Convert.ToDouble(particles.Rows[i]["DMIN"]);
  503. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  504. }
  505. if (enl.Current.Key == "ASPECT_ELONG")
  506. {
  507. double d = Convert.ToDouble(particles.Rows[i]["DELONG"]) / Convert.ToDouble(particles.Rows[i]["DMEAN"]);
  508. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(d, 2);
  509. }
  510. if (particles.Columns.Contains(enl.Current.Key))
  511. {
  512. double num = 0;
  513. if (double.TryParse(particles.Rows[i][enl.Current.Key].ToString(), out num))
  514. {
  515. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(num, 2);
  516. }
  517. else if (enl.Current.Key == "Element")
  518. {
  519. List<string> elementtemp = new List<string>(ElementTypeSort);
  520. string[] strcbo = particles.Rows[i][enl.Current.Key].ToString().Split(';');
  521. for (int j = 0; j < strcbo.Length; j++)
  522. {
  523. if (ElementTypeSort.Count == 0)
  524. {
  525. break;
  526. }
  527. string[] str = strcbo[j].Split('-');
  528. if (ElementTypeSort.Contains(str[0]))
  529. { dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[str[0].ToString()].Value = Math.Round(double.Parse(str[1]), 2).ToString(); }
  530. elementtemp.Remove(str[0].ToString());
  531. }
  532. foreach (var ele in elementtemp)
  533. {
  534. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[ele].Value = "0";
  535. }
  536. }
  537. else
  538. {
  539. double val = 0;
  540. if (double.TryParse(Convert.ToString(particles.Rows[i][enl.Current.Key]), out val))
  541. {
  542. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = val;
  543. }
  544. else
  545. {
  546. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = particles.Rows[i][enl.Current.Key];
  547. }
  548. }
  549. }
  550. if (enl.Current.Key == "TypeName")
  551. {
  552. if (particles.Rows[i]["TypeId"].ToString() == "9")
  553. {
  554. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = "Not Identified";
  555. }
  556. }
  557. if (enl.Current.Key == "Equivalent")
  558. {
  559. double dSize = Convert.ToDouble(particles.Rows[i]["Area"]);
  560. double Diameter = Math.Sqrt(dSize / Math.PI) * 2;
  561. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Math.Round(Diameter, 2);
  562. }
  563. if (enl.Current.Key == "Hardness")
  564. {
  565. string str = ChangeHardnessColor(particles.Rows[i]["Hardness"].ToString());
  566. {
  567. if (str == "#FF0000")
  568. {
  569. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.ForeColor = Color.Red;
  570. }
  571. }
  572. }
  573. if (enl.Current.Key == "AbPosX")
  574. {
  575. Point point = CalculateParticleCenterPosition(result, new Point(Convert.ToInt32(particles.Rows[i]["SEMPosX"]), Convert.ToInt32(particles.Rows[i]["SEMPosY"])), new Point(Convert.ToInt32(particles.Rows[i]["PosX"]), Convert.ToInt32(particles.Rows[i]["PosY"])));
  576. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells["AbPosX"].Value = point.X;
  577. dgV_ParticlesDevidePage.Rows[add_rowindex].Cells["AbPosY"].Value = point.Y;
  578. }
  579. }
  580. }
  581. }
  582. #region 加载进度条进度部份结束
  583. //加载完成设置鼠标为默认
  584. this.Cursor = Cursors.Default;
  585. string str8 = table["str8"].ToString();
  586. m_frm_userprogress.SetProgressValueAndText(100, str8);
  587. //加载完成,关闭进度条
  588. m_frm_userprogress.Close();
  589. #endregion
  590. dgV_ParticlesDevidePage.Visible = true;
  591. }
  592. Dictionary<string, string> InitializeTable(ref string str_ElementsColName)
  593. {
  594. dgV_ParticlesDevidePage.Rows.Clear();
  595. dgV_ParticlesDevidePage.Columns.Clear();
  596. var startFun = m_ReportApp.m_RptConfigFile.Systype;
  597. string str_DefaultComputedColName = "";str_ElementsColName = "";
  598. DataSet ds = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
  599. DataTable dt = ds.Tables["Member"];
  600. foreach (DataRow element in dt.Rows)
  601. {
  602. string RegName = element["RegName"].ToString();
  603. if (RegName == "DefaultComputedColName")
  604. {
  605. str_DefaultComputedColName = element["strValue"].ToString();
  606. }
  607. if (RegName == "ElementsColName")
  608. {
  609. str_ElementsColName = element["strValue"].ToString();
  610. }
  611. }
  612. string[] strs = str_DefaultComputedColName.Split(',');
  613. Dictionary<string, string> keyValues = new Dictionary<string, string>() { };
  614. keyValues.Add("rowid", table["str4"].ToString());
  615. keyValues.Add("TypeName", table["str6"].ToString());
  616. keyValues.Add("ParticleImage", table["str5"].ToString());
  617. keyValues.Add("FieldId", "FieldId");
  618. keyValues.Add("ParticleId", "ParticleId");
  619. keyValues.Add("SEMPosX", "SEMPosX");
  620. keyValues.Add("SEMPosY", "SEMPosY");
  621. for (int i = 0; i < strs.Count(); i++)
  622. {
  623. if (strs[i] == "ParticleCoordinate")
  624. {
  625. keyValues.Add("AbPosX", "PosX");
  626. keyValues.Add("AbPosY", "PosY");
  627. }
  628. if (strs[i] == "Area")
  629. {
  630. keyValues.Add("Area", table["str21"].ToString());
  631. }
  632. if (strs[i] == "EquivalentCircleDiameter")
  633. {
  634. keyValues.Add("Equivalent", table["str22"].ToString());
  635. }
  636. if (strs[i] == "MaxDiameter")
  637. {
  638. keyValues.Add("DMAX", table["str23"].ToString());
  639. }
  640. if (strs[i] == "MinDiameter")
  641. {
  642. keyValues.Add("DMIN", table["str24"].ToString());
  643. }
  644. if (strs[i] == "DiameterRatio")
  645. {
  646. keyValues.Add("DiameterRatio", table["str25"].ToString());
  647. }
  648. if (strs[i] == "FerretDiameter")
  649. {
  650. keyValues.Add("DFERET", table["str26"].ToString());
  651. }
  652. if (strs[i] == "PERP")
  653. {
  654. keyValues.Add("DPERP", table["str27"].ToString());
  655. }
  656. if (strs[i] == "PERI")
  657. {
  658. keyValues.Add("PERIMETER", table["str28"].ToString());
  659. }
  660. if (strs[i] == "INSCR")
  661. {
  662. keyValues.Add("DINSCR", table["str29"].ToString());
  663. }
  664. if (strs[i] == "MEAN")
  665. {
  666. keyValues.Add("DMEAN", table["str30"].ToString());
  667. }
  668. if (strs[i] == "ELONG")
  669. {
  670. keyValues.Add("DELONG", table["str31"].ToString());
  671. }
  672. if (strs[i] == "ASPECT_ELONG")
  673. {
  674. keyValues.Add("ASPECT_ELONG", table["str32"].ToString());
  675. }
  676. if (strs[i] == "Orientation")
  677. {
  678. keyValues.Add("ORIENTATION", table["str33"].ToString());
  679. }
  680. if (strs[i] == "XRayDataCount")
  681. {
  682. keyValues.Add("XRayDataCount", "XRay计数");
  683. }
  684. if (startFun == OTS_SysType_ID.TCCleannessA || startFun == OTS_SysType_ID.BatteryCleannessA)
  685. {
  686. if (strs[i] == "Hardness")
  687. {
  688. keyValues.Add("Hardness", table["str34"].ToString());
  689. }
  690. if (strs[i] == "Density")
  691. {
  692. keyValues.Add("Density", table["str35"].ToString());
  693. }
  694. if (strs[i] == "Electrical_conductivity")
  695. {
  696. keyValues.Add("Electrical_conductivity", table["str36"].ToString());
  697. }
  698. }
  699. }
  700. keyValues.Add("Element", "Element");
  701. return keyValues;
  702. }
  703. /// <summary>
  704. /// 设置DataGridView样式
  705. /// </summary>
  706. private void SetDataGridViewStyle()
  707. {
  708. //用户不能调整标题的高度
  709. dgV_ParticlesDevidePage.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  710. //用户不能调整 行高
  711. dgV_ParticlesDevidePage.AllowUserToResizeRows = false;
  712. //点击选择整行
  713. dgV_ParticlesDevidePage.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  714. //居中显示
  715. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  716. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  717. dgV_ParticlesDevidePage.DefaultCellStyle = dataGridViewCellStyle1;
  718. dgV_ParticlesDevidePage.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  719. //再次重覆禁用拖动表头高度,居然有效果了
  720. dgV_ParticlesDevidePage.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  721. //设置grid可以复制
  722. dgV_ParticlesDevidePage.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  723. //设置每列的宽度
  724. dgV_ParticlesDevidePage.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  725. dgV_ParticlesDevidePage.Columns[1].Width = 150;
  726. //设置序号列不排序
  727. dgV_ParticlesDevidePage.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  728. dgV_ParticlesDevidePage.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  729. //设置序号列不可以设置宽度
  730. dgV_ParticlesDevidePage.Columns[0].Resizable = DataGridViewTriState.False;
  731. dgV_ParticlesDevidePage.RowsDefaultCellStyle.BackColor = Color.Azure;
  732. }
  733. /// <summary>
  734. /// 计算颗粒中心的电镜坐标
  735. /// </summary>
  736. /// <param name="resultFile"></param>
  737. /// <param name="SEMPos"></param>
  738. /// <param name="ParticlePos"></param>
  739. /// <returns></returns>
  740. public static Point CalculateParticleCenterPosition(ResultFile resultFile, Point SEMPos, Point ParticlePos)
  741. {
  742. Point point = new Point();
  743. float ScanFieldSizeX = resultFile.GetScanFieldSizeX();
  744. string leftOrRight = resultFile.GetXAxisDir();
  745. string downOrUp = resultFile.GetYAxisDir();
  746. float ScanFieldSizeY = resultFile.GetScanFieldSizeY();
  747. float m_pixelSize = resultFile.GetPixelSize();
  748. if (leftOrRight == "RIGHT_TOWARD")
  749. {
  750. point.X = (int)(SEMPos.X - ScanFieldSizeX / 2 + ParticlePos.X * m_pixelSize);
  751. }
  752. else
  753. {
  754. point.X = (int)(SEMPos.X + ScanFieldSizeX / 2 - ParticlePos.X * m_pixelSize);
  755. }
  756. if (downOrUp == "UP_TOWARD")
  757. {
  758. point.Y = (int)(SEMPos.Y + ScanFieldSizeY / 2 - ParticlePos.Y * m_pixelSize);
  759. }
  760. else
  761. {
  762. point.Y = (int)(SEMPos.Y - ScanFieldSizeY / 2 + ParticlePos.Y * m_pixelSize);
  763. }
  764. return point;
  765. }
  766. #endregion
  767. #region 相关事件
  768. private void ToolStripMenuItem1_Click(object sender, EventArgs e)
  769. {
  770. //复制整个表
  771. CopyAll();
  772. }
  773. private void ToolStripMenuItem2_Click(object sender, EventArgs e)
  774. {
  775. //复制选择区域
  776. CopySelected();
  777. }
  778. /// <summary>
  779. /// 复制选择区域
  780. /// </summary>
  781. public void CopySelected()
  782. {
  783. //复制选择区域
  784. object oo = dgV_ParticlesDevidePage.GetClipboardContent();
  785. if (oo != null)
  786. Clipboard.SetDataObject(dgV_ParticlesDevidePage.GetClipboardContent());
  787. }
  788. /// <summary>
  789. /// 复制所有
  790. /// </summary>
  791. public void CopyAll()
  792. {
  793. dgV_ParticlesDevidePage.SelectAll();
  794. Clipboard.SetDataObject(dgV_ParticlesDevidePage.GetClipboardContent());
  795. }
  796. /// <summary>
  797. /// 以图像的方式将GridView进行截图
  798. /// </summary>
  799. public void CopyImage()
  800. {
  801. int height, width;
  802. width = dgV_ParticlesDevidePage.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) + 2;
  803. height = this.Height;
  804. Bitmap image = new Bitmap(width, height);
  805. dgV_ParticlesDevidePage.DrawToBitmap(image, new Rectangle(0, 0, width, height));
  806. Clipboard.SetImage(image);
  807. }
  808. private void toolStripMenuItem4_Click(object sender, EventArgs e)
  809. {
  810. //对gridview进行截图
  811. CopyImage();
  812. }
  813. private void dgV_ParticlesDevidePage_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  814. {
  815. //排序中
  816. if (e.Column.Tag != null && e.Column.Tag.ToString() == "NumericType")
  817. {
  818. e.SortResult = double.Parse(e.CellValue1.ToString()).CompareTo(double.Parse(e.CellValue2.ToString()));
  819. e.Handled = true;
  820. }
  821. }
  822. #endregion
  823. #region 连接电镜相关
  824. /// <summary>
  825. /// 移动SEM到指定位置线程函数
  826. /// </summary>
  827. private void ControlThread_GO(object in_obj)
  828. {
  829. if (m_mythread_state == false)
  830. {
  831. m_mythread_state = true;
  832. Point sem_point = (Point)in_obj;
  833. //第一步,连接电镜
  834. m_OTSIncAReportGridsFun.Connection_ForParticlesGrid();
  835. Thread.Sleep(500);
  836. //第二步,移动到指定位置,先读取再设置
  837. if (m_OTSIncAReportGridsFun.m_SEMConnectionState == true)
  838. {
  839. m_OTSIncAReportGridsFun.MoveSemToPointXY_ForParticlesGrid(sem_point.X, sem_point.Y);
  840. }
  841. Thread.Sleep(1500);
  842. m_mythread_state = false;
  843. }
  844. }
  845. #endregion
  846. private void ToolStripMenuItem5_Click(object sender, EventArgs e)
  847. {
  848. /*注意:多数据源情况下,只获取第一个数据源的选择了多行的情况下,只获取最后一个选择行的,没有办法,这是为了符合李阳博士提出的要求*/
  849. //先获取鼠标所选择的行里的颗粒的FieldID和ParticleID
  850. string i_ls_fieldid = "";
  851. string i_ls_particleid = "";
  852. int cou = dgV_ParticlesDevidePage.SelectedRows.Count;
  853. if (cou > 0)
  854. {
  855. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[cou - 1];
  856. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  857. List<string> list_str = (List<string>)ls_bp.Tag;
  858. if (list_str != null)
  859. {
  860. i_ls_fieldid = list_str[0];
  861. i_ls_particleid = list_str[1];
  862. }
  863. }
  864. ParticleData particleData = new ParticleData(result.FilePath);
  865. Particle particle = particleData.GetParticleByFidAndPid(i_ls_fieldid, i_ls_particleid);
  866. //取得Field的Position,然后执行线程移动SEM到当前Field的位置
  867. if (m_mythread == null)
  868. {
  869. return;
  870. }
  871. if (m_mythread.ThreadState == ThreadState.Running || m_mythread.ThreadState == ThreadState.WaitSleepJoin)
  872. {
  873. return;
  874. }
  875. if (m_mythread.ThreadState == ThreadState.Stopped)
  876. {
  877. m_mythread = new Thread(new ParameterizedThreadStart(ControlThread_GO));
  878. }
  879. Point point = CalculateParticleCenterPosition(result, new Point(particle.SEMPosX, particle.SEMPosY), new Point(particle.PosX, particle.PosY));
  880. //改为线程调用,先判断线程状态
  881. m_mythread.Start(point);
  882. }
  883. private void ToolStripMenuItem_exportimagefile_Click(object sender, EventArgs e)
  884. {
  885. FolderBrowserDialog fbd = new FolderBrowserDialog();
  886. if (fbd.ShowDialog() == DialogResult.OK)
  887. {
  888. m_imagefilepath = fbd.SelectedPath;
  889. for (int i = 0; i < dgV_ParticlesDevidePage.Rows.Count; i++)
  890. {
  891. Bitmap ls_bp = new Bitmap(1, 1);
  892. ls_bp = (Bitmap)dgV_ParticlesDevidePage.Rows[i].Cells[2].Value;
  893. ls_bp.Save(m_imagefilepath + "\\" + (i + 1).ToString() + ".jpg");
  894. }
  895. string str9 = table["str9"].ToString();
  896. MessageBox.Show(str9 + dgV_ParticlesDevidePage.Rows.Count.ToString());
  897. }
  898. }
  899. private void testToolStripMenuItem_Click(object sender, EventArgs e)
  900. {
  901. }
  902. /// <summary>
  903. /// 判断条件输入 前<后
  904. /// </summary>
  905. /// <param name="min"></param>
  906. /// <param name="max"></param>
  907. /// <returns></returns>
  908. bool CompareInput(string min, string max)
  909. {
  910. int imax = 0;
  911. int imin = 0;
  912. double dmax = 0;
  913. double dmin = 0;
  914. if (int.TryParse(max, out imax))
  915. {
  916. dmax = (double)imax;
  917. }
  918. else
  919. {
  920. dmax = Convert.ToDouble(max);
  921. }
  922. if (int.TryParse(min, out imin))
  923. {
  924. dmin = (double)imin;
  925. }
  926. else
  927. {
  928. dmin = Convert.ToDouble(min);
  929. }
  930. if (dmin <= dmax)
  931. {
  932. return true;
  933. }
  934. else
  935. {
  936. return false;
  937. }
  938. }
  939. private void btn_Sel_Click(object sender, EventArgs e)
  940. {
  941. condition = "";
  942. if (!string.IsNullOrWhiteSpace(tBx_AreaMin.Text))
  943. {
  944. double dnum = 0;
  945. int inum = 0;
  946. if (double.TryParse(tBx_AreaMin.Text, out dnum) && dnum >= 0)
  947. {
  948. condition += " and Area" + " > " + tBx_AreaMin.Text;
  949. }
  950. else if (int.TryParse(tBx_AreaMin.Text, out inum) && inum >= 0)
  951. {
  952. condition += " and Area" + " > " + tBx_AreaMin.Text;
  953. }
  954. else
  955. {
  956. MessageBox.Show(table["str10"].ToString());
  957. return;
  958. }
  959. }
  960. if (!string.IsNullOrWhiteSpace(Tbx_AreaMax.Text))
  961. {
  962. double dnum = 0;
  963. int inum = 0;
  964. if (double.TryParse(Tbx_AreaMax.Text, out dnum) && dnum >= 0)
  965. {
  966. condition += " and Area" + "<" + Tbx_AreaMax.Text;
  967. }
  968. else if (int.TryParse(Tbx_AreaMax.Text, out inum) && inum >= 0)
  969. {
  970. condition += " and Area" + "<" + Tbx_AreaMax.Text;
  971. }
  972. else
  973. {
  974. MessageBox.Show(table["str10"].ToString());
  975. return;
  976. }
  977. }
  978. if (!string.IsNullOrWhiteSpace(tBx_AreaMin.Text) && !string.IsNullOrWhiteSpace(Tbx_AreaMax.Text))
  979. {
  980. if (!CompareInput(tBx_AreaMin.Text, Tbx_AreaMax.Text))
  981. {
  982. MessageBox.Show(table["str11"].ToString());
  983. return;
  984. }
  985. }
  986. if (!string.IsNullOrWhiteSpace(tbx_DmaxMin.Text))
  987. {
  988. double dnum = 0;
  989. int inum = 0;
  990. if (double.TryParse(tbx_DmaxMin.Text, out dnum) && dnum >= 0)
  991. {
  992. condition += " and DMAX" + " > " + tbx_DmaxMin.Text;
  993. }
  994. else if (int.TryParse(tbx_DmaxMin.Text, out inum) && inum >= 0)
  995. {
  996. condition += " and DMAX" + " > " + tbx_DmaxMin.Text;
  997. }
  998. else
  999. {
  1000. MessageBox.Show(table["str10"].ToString());
  1001. return;
  1002. }
  1003. }
  1004. if (!string.IsNullOrWhiteSpace(tbx_DmaxMax.Text))
  1005. {
  1006. double dnum = 0;
  1007. int inum = 0;
  1008. if (double.TryParse(tbx_DmaxMax.Text, out dnum) && dnum > 0)
  1009. {
  1010. condition += " and DMAX" + "<" + tbx_DmaxMax.Text;
  1011. }
  1012. else if (int.TryParse(tbx_DmaxMax.Text, out inum) && inum >= 0)
  1013. {
  1014. condition += " and DMAX" + "<" + tbx_DmaxMax.Text;
  1015. }
  1016. else
  1017. {
  1018. MessageBox.Show(table["str10"].ToString());
  1019. return;
  1020. }
  1021. }
  1022. if (!string.IsNullOrWhiteSpace(tB_FieldId.Text))
  1023. {
  1024. int inum = 0;
  1025. if (int.TryParse(tB_FieldId.Text, out inum))
  1026. {
  1027. condition += " and FieldId =" + tB_FieldId.Text;
  1028. }
  1029. else
  1030. {
  1031. MessageBox.Show(table["str10"].ToString());
  1032. return;
  1033. }
  1034. }
  1035. if (!string.IsNullOrWhiteSpace(tB_ParticleId.Text))
  1036. {
  1037. int inum = 0;
  1038. if (int.TryParse(tB_ParticleId.Text, out inum))
  1039. {
  1040. condition += " and ParticleId =" + tB_ParticleId.Text;
  1041. }
  1042. else
  1043. {
  1044. MessageBox.Show(table["str10"].ToString());
  1045. return;
  1046. }
  1047. }
  1048. if (!string.IsNullOrWhiteSpace(tbx_DmaxMin.Text) && !string.IsNullOrWhiteSpace(tbx_DmaxMax.Text))
  1049. {
  1050. if (!CompareInput(tbx_DmaxMin.Text, tbx_DmaxMax.Text))
  1051. {
  1052. MessageBox.Show(table["str11"].ToString());
  1053. return;
  1054. }
  1055. }
  1056. if (!string.IsNullOrWhiteSpace(tbx_DferretMin.Text))
  1057. {
  1058. double dnum = 0;
  1059. int inum = 0;
  1060. if (double.TryParse(tbx_DferretMin.Text, out dnum) && dnum >= 0)
  1061. {
  1062. condition += " and DFERET" + ">" + tbx_DferretMin.Text;
  1063. }
  1064. else if (int.TryParse(Tbx_AreaMax.Text, out inum) && inum >= 0)
  1065. {
  1066. condition += " and DFERET" + ">" + tbx_DferretMin.Text;
  1067. }
  1068. else
  1069. {
  1070. MessageBox.Show(table["str10"].ToString());
  1071. return;
  1072. }
  1073. }
  1074. if (!string.IsNullOrWhiteSpace(tbx_DferretMax.Text))
  1075. {
  1076. double dnum = 0;
  1077. int inum = 0;
  1078. if (double.TryParse(tbx_DferretMax.Text, out dnum) && dnum >= 0)
  1079. {
  1080. condition += " and DFERET" + "<" + tbx_DferretMax.Text;
  1081. }
  1082. else if (int.TryParse(tbx_DferretMax.Text, out inum) && inum >= 0)
  1083. {
  1084. condition += " and DFERET" + "<" + tbx_DferretMax.Text;
  1085. }
  1086. else
  1087. {
  1088. MessageBox.Show(table["str10"].ToString());
  1089. return;
  1090. }
  1091. }
  1092. if (!string.IsNullOrWhiteSpace(tbx_DferretMin.Text) && !string.IsNullOrWhiteSpace(tbx_DferretMax.Text))
  1093. {
  1094. if (!CompareInput(tbx_DferretMin.Text, tbx_DferretMax.Text))
  1095. {
  1096. MessageBox.Show(table["str11"].ToString());
  1097. return;
  1098. }
  1099. }
  1100. if (!string.IsNullOrWhiteSpace(tbx_ECDMin.Text))
  1101. {
  1102. double dnum = 0;
  1103. int inum = 0;
  1104. if (double.TryParse(tbx_ECDMin.Text, out dnum) && dnum >= 0)
  1105. {
  1106. double area = Math.PI * dnum / 2 * dnum / 2;
  1107. condition += " and Area" + ">" + area.ToString();
  1108. }
  1109. else if (int.TryParse(tbx_ECDMin.Text, out inum) && inum >= 0)
  1110. {
  1111. double area = Math.PI * dnum / 2 * dnum / 2;
  1112. condition += " and Area" + ">" + area.ToString();
  1113. }
  1114. else
  1115. {
  1116. MessageBox.Show(table["str10"].ToString());
  1117. return;
  1118. }
  1119. }
  1120. if (!string.IsNullOrWhiteSpace(tbx_ECDMax.Text))
  1121. {
  1122. double dnum = 0; int inum = 0;
  1123. if (double.TryParse(tbx_ECDMax.Text, out dnum) && dnum >= 0)
  1124. {
  1125. double area = Math.PI * dnum / 2 * dnum / 2;
  1126. condition += " and Area" + "<" + area.ToString();
  1127. }
  1128. else if (int.TryParse(tbx_ECDMax.Text, out inum) && inum >= 0)
  1129. {
  1130. double area = Math.PI * dnum / 2 * dnum / 2;
  1131. condition += " and Area" + "<" + area.ToString();
  1132. }
  1133. else
  1134. {
  1135. MessageBox.Show(table["str10"].ToString());
  1136. return;
  1137. }
  1138. }
  1139. if (!string.IsNullOrWhiteSpace(tbx_ECDMin.Text) && !string.IsNullOrWhiteSpace(tbx_ECDMax.Text))
  1140. {
  1141. if (!CompareInput(tbx_ECDMin.Text, tbx_ECDMax.Text))
  1142. {
  1143. MessageBox.Show(table["str11"].ToString());
  1144. return;
  1145. }
  1146. }
  1147. if (!string.IsNullOrWhiteSpace(tbx_Type.Text))
  1148. {
  1149. string[] tr = tbx_Type.Text.Split('$');
  1150. condition += " and (";
  1151. for (int i = 0; i < tr.Length; i++)
  1152. {
  1153. if (i == 0)
  1154. {
  1155. condition += " TypeName = '" + tr[i] + "'";
  1156. }
  1157. else
  1158. {
  1159. condition += " or TypeName = '" + tr[i] + "'";
  1160. }
  1161. }
  1162. condition += ")";
  1163. }
  1164. if (m_frm_userprogress.IsDisposed)
  1165. {
  1166. ProgressStart();
  1167. }
  1168. UpdateDataGrid();
  1169. lnkFirst_Click(null, null);
  1170. SetDataGridViewStyle();
  1171. }
  1172. void ProgressStart()
  1173. {
  1174. #region 加载显示进度条部份
  1175. this.Cursor = Cursors.WaitCursor;
  1176. m_frm_userprogress = new Frm_UserProgress();
  1177. Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
  1178. if (ls_main_form == null)
  1179. {
  1180. m_frm_userprogress.Visible = false;
  1181. }
  1182. else
  1183. {
  1184. m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
  1185. m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 80, ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
  1186. m_frm_userprogress.Show();
  1187. m_frm_userprogress.SetProgressValueAndText(0, "Loading data of particles...");
  1188. }
  1189. #endregion
  1190. }
  1191. /// <summary>
  1192. /// 页面控件呈现
  1193. /// </summary>
  1194. private void DrawControl(bool callEvent)
  1195. {
  1196. RefreshGridView();
  1197. lblTotalCount.Text = RecordCount.ToString();
  1198. lblPageCount.Text = PageCount.ToString();
  1199. txtPageNum.Text = PageIndex.ToString();
  1200. SetFormCtrEnabled();
  1201. if (PageCount == 0 || PageCount == 1)//有且仅有一页
  1202. {
  1203. lnkFirst.Enabled = false;
  1204. lnkPrev.Enabled = false;
  1205. lnkNext.Enabled = false;
  1206. lnkLast.Enabled = false;
  1207. btnGo.Enabled = false;
  1208. }
  1209. else if (PageIndex == 1)//第一页
  1210. {
  1211. lnkFirst.Enabled = false;
  1212. lnkPrev.Enabled = false;
  1213. }
  1214. else if (PageIndex == PageCount)//最后一页
  1215. {
  1216. lnkNext.Enabled = false;
  1217. lnkLast.Enabled = false;
  1218. }
  1219. }
  1220. private void SetFormCtrEnabled()
  1221. {
  1222. lnkFirst.Enabled = true;
  1223. lnkPrev.Enabled = true;
  1224. lnkNext.Enabled = true;
  1225. lnkLast.Enabled = true;
  1226. btnGo.Enabled = true;
  1227. }
  1228. /// <summary>
  1229. /// 分页属性改变了。
  1230. /// </summary>
  1231. private void txtPageSize_TextChanged(object sender, EventArgs e)
  1232. {
  1233. int num = 0;
  1234. if (int.TryParse(txtPageNum.Text.Trim(), out num) && num > 0)
  1235. {
  1236. }
  1237. else { txtPageNum.Text = "1"; }
  1238. }
  1239. private void lnkFirst_Click(object sender, EventArgs e)
  1240. {
  1241. PageIndex = 1;
  1242. DrawControl(true);
  1243. }
  1244. private void lnkPrev_Click(object sender, EventArgs e)
  1245. {
  1246. PageIndex = Math.Max(1, PageIndex - 1);
  1247. DrawControl(true);
  1248. }
  1249. private void lnkNext_Click(object sender, EventArgs e)
  1250. {
  1251. PageIndex = Math.Min(PageCount, PageIndex + 1);
  1252. DrawControl(true);
  1253. }
  1254. private void lnkLast_Click(object sender, EventArgs e)
  1255. {
  1256. PageIndex = PageCount;
  1257. DrawControl(true);
  1258. }
  1259. /// <summary>
  1260. /// 跳转
  1261. /// </summary>
  1262. /// <param name="sender"></param>
  1263. /// <param name="e"></param>
  1264. private void btnGo_Click(object sender, EventArgs e)
  1265. {
  1266. int num = 0;
  1267. if (int.TryParse(txtPageNum.Text.Trim(), out num) && num > 0)
  1268. {
  1269. if (num > PageCount)
  1270. {
  1271. num = PageCount;
  1272. txtPageNum.Text = PageCount.ToString();
  1273. }
  1274. PageIndex = num;
  1275. DrawControl(true);
  1276. }
  1277. }
  1278. private void cbB_PageSize_SelectedIndexChanged(object sender, EventArgs e)
  1279. {
  1280. DisplayData();
  1281. }
  1282. private void EXCELToolStripMenuItem_Click(object sender, EventArgs e)
  1283. {
  1284. OTSIncAReportApp._1_UI.Control_Grids.SpectrumExportConfirmation sfd = new OTSIncAReportApp._1_UI.Control_Grids.SpectrumExportConfirmation();
  1285. if (sfd.ShowDialog() == DialogResult.OK)
  1286. {
  1287. Cursor = Cursors.WaitCursor;
  1288. if (m_frm_userprogress.IsDisposed)
  1289. {
  1290. ProgressStart();
  1291. }
  1292. IWorkbook workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(); //用于创建.xlsx office2007开始以后的
  1293. ISheet sheet;
  1294. FileStream fs = File.Create(sfd.FileName);
  1295. fs.Close();
  1296. sheet = workbook.CreateSheet("Particles");//创建工作表
  1297. ICellStyle cellStyle = workbook.CreateCellStyle();
  1298. cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
  1299. cellStyle.VerticalAlignment = VerticalAlignment.Center;
  1300. //设置上4边
  1301. cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
  1302. cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
  1303. cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
  1304. cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
  1305. //设置字符大小和颜色
  1306. IFont font = workbook.CreateFont();
  1307. font.FontName = "黑体";
  1308. font.FontHeightInPoints = 10;
  1309. cellStyle.SetFont(font);
  1310. //设置颗粒名列宽
  1311. sheet.SetColumnWidth(1, 30 * 256);//夹杂物名列宽
  1312. sheet.SetColumnWidth(2, 7 * 256);//图像列宽
  1313. IRow row;
  1314. ICell cell;
  1315. //插入表头
  1316. row = sheet.CreateRow(1);//从第15行添加一行
  1317. IDrawing patriarch;
  1318. patriarch = sheet.CreateDrawingPatriarch();
  1319. row.Height = 30 * 20;
  1320. for (int i_cell = 0; i_cell < dgV_ParticlesDevidePage.Columns.Count; i_cell++)
  1321. {
  1322. cell = row.CreateCell(i_cell);
  1323. cell.CellStyle = cellStyle;
  1324. cell.SetCellValue(dgV_ParticlesDevidePage.Columns[i_cell].HeaderText);
  1325. }
  1326. m_frm_userprogress.SetProgressValueAndText(0, "export:" + "0" + "/total:" + dgV_ParticlesDevidePage.Rows.Count);
  1327. IClientAnchor anchor;
  1328. int pictureIdx;
  1329. Bitmap bp;
  1330. byte[] bytes;
  1331. IPicture pict;
  1332. //插入表内容
  1333. for (int i_row = 0; i_row < dgV_ParticlesDevidePage.Rows.Count; i_row++)
  1334. {
  1335. if (dgV_ParticlesDevidePage.Rows.Count > 100)
  1336. {
  1337. if (i_row % (dgV_ParticlesDevidePage.Rows.Count / 100) == 0)
  1338. m_frm_userprogress.SetProgressValueAndText(i_row * 100 / dgV_ParticlesDevidePage.Rows.Count, "export:" + i_row + "/total:" + dgV_ParticlesDevidePage.Rows.Count);
  1339. }
  1340. row = sheet.CreateRow(2 + i_row);
  1341. row.Height = 45 * 20;
  1342. for (int i_cell = 0; i_cell < dgV_ParticlesDevidePage.Columns.Count; i_cell++)
  1343. {
  1344. cell = row.CreateCell(i_cell);
  1345. cell.CellStyle = cellStyle;
  1346. if (dgV_ParticlesDevidePage[i_cell, i_row].Value == null)
  1347. continue;
  1348. if (i_cell == 2)
  1349. {
  1350. if (sfd.IfExportPicture)
  1351. {
  1352. //颗粒图像列
  1353. bp = (Bitmap)dgV_ParticlesDevidePage.Rows[i_row].Cells[2].Value;
  1354. bytes = ImageConvertToBytes(bp);
  1355. //第二步,将图片添加到workbook中,指定图片的格式,返回图片所在workbook->paicture数组中的索引的地址,从1开始
  1356. pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
  1357. //第三步,在sheet中创建画布
  1358. //第四步,设置锚点,(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格行数,列数,终止单元格行数,列数)
  1359. anchor = patriarch.CreateAnchor(1, 1, 2, 2, i_cell, i_row + 2, i_cell + 1, i_row + 3);//终止比开始位置大1,会自动缩放到一个单元格内的
  1360. //第五步,创建图片
  1361. pict = patriarch.CreatePicture(anchor, pictureIdx);
  1362. }
  1363. }
  1364. else
  1365. {
  1366. //非图像列
  1367. double dval = 0;
  1368. if(double.TryParse(dgV_ParticlesDevidePage[i_cell, i_row].Value.ToString(), out dval))
  1369. {
  1370. cell.SetCellType(CellType.Numeric);
  1371. cell.SetCellValue(dval);
  1372. }
  1373. else
  1374. cell.SetCellValue(dgV_ParticlesDevidePage[i_cell, i_row].Value.ToString());
  1375. }
  1376. }
  1377. }
  1378. if (sfd.IfExportSpectrumData)
  1379. {
  1380. ISheet sheet2;
  1381. sheet2 = workbook.CreateSheet("Peak spectrum Data");//创建工作表
  1382. //插入表头
  1383. row = sheet2.CreateRow(1);
  1384. row.Height = 30 * 20;
  1385. cell = row.CreateCell(0);
  1386. cell.CellStyle = cellStyle;
  1387. cell.SetCellValue("rowid");
  1388. for (int i_cell = 1; i_cell < 2001; i_cell++)
  1389. {
  1390. cell = row.CreateCell(i_cell);
  1391. cell.CellStyle = cellStyle;
  1392. if (i_cell == 1)
  1393. {
  1394. cell.SetCellValue("PeakSpectrumData");
  1395. }
  1396. }
  1397. sheet2.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(1, 1, 1, 2000));
  1398. for (int j = 0; j < particles.Rows.Count; j++)
  1399. {
  1400. row = sheet2.CreateRow(2 + j);
  1401. cell = row.CreateCell(0);
  1402. cell.CellStyle = cellStyle;
  1403. cell.SetCellValue(j + 1);
  1404. var tmpPart = Particledata.GetParticleXrayDataByFidAndPid(particles.Rows[j]["fieldid"].ToString(), particles.Rows[j]["particleid"].ToString());
  1405. if (tmpPart != null)
  1406. {
  1407. if (tmpPart.XrayId > -1)
  1408. {
  1409. uint[] Analysis_xray = new uint[2000];
  1410. for (int i = 0; i < 2000; i++)
  1411. {
  1412. Analysis_xray[i] = BitConverter.ToUInt32(tmpPart.XRayData, i * 4);
  1413. cell = row.CreateCell(i + 1);
  1414. cell.CellStyle = cellStyle;
  1415. cell.SetCellValue(Analysis_xray[i]);
  1416. }
  1417. }
  1418. }
  1419. }
  1420. }
  1421. if (sfd.IfExportSpectrumConfirmation)
  1422. {
  1423. ISheet sheet3;
  1424. sheet3 = workbook.CreateSheet("Peak spectrum");
  1425. sheet3.SetColumnWidth(1, 200 * 256);//图像列宽
  1426. //插入表头
  1427. row = sheet3.CreateRow(1);
  1428. row.Height = 30 * 20;
  1429. cell = row.CreateCell(0);
  1430. cell.CellStyle = cellStyle;
  1431. cell.SetCellValue("rowid");
  1432. cell = row.CreateCell(1);
  1433. cell.CellStyle = cellStyle;
  1434. cell.SetCellValue("PeakSpectrum");
  1435. IDrawing drawing;
  1436. IClientAnchor anchor3;
  1437. for (int j = 0; j < particles.Rows.Count; j++)
  1438. {
  1439. row = sheet3.CreateRow(j + 2);
  1440. row.Height = 120 * 20;
  1441. cell = row.CreateCell(0);
  1442. cell.CellStyle = cellStyle;
  1443. cell.SetCellValue(j + 1);
  1444. cell = row.CreateCell(1);
  1445. cell = row.CreateCell(2);
  1446. cell = row.CreateCell(3);
  1447. drawing = sheet3.CreateDrawingPatriarch();
  1448. //锚点
  1449. anchor3 = drawing.CreateAnchor(0, 0, 0, 0, 1, j + 2, 2, j + 3);//XSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2);参数说明:dx1 dy1 起始单元格中的x,y坐标.dx2 dy2 结束单元格中的x,y坐标col1, row1 指定起始的单元格,下标从0开始col2, row2 指定结束的单元格,下标从0开始
  1450. CreateChart(drawing, sheet3, anchor3, j + 2);
  1451. }
  1452. }
  1453. //完成后,对Excel进行保存
  1454. FileStream file = new FileStream(sfd.FileName, FileMode.Create);
  1455. workbook.Write(file);
  1456. file.Close();
  1457. m_frm_userprogress.SetProgressValueAndText(100, "export:" + dgV_ParticlesDevidePage.Rows.Count + "/total:" + dgV_ParticlesDevidePage.Rows.Count);
  1458. //加载完成,关闭进度条
  1459. m_frm_userprogress.Close();
  1460. Cursor = Cursors.Default;
  1461. //导出完成后,打开Excel文件
  1462. if (File.Exists(sfd.FileName))
  1463. {
  1464. //打开刚才导出的文件
  1465. System.Diagnostics.Process.Start(sfd.FileName);
  1466. }
  1467. }
  1468. }
  1469. /// <summary>
  1470. /// 读取标准库的ClassifySTD表
  1471. /// </summary>
  1472. /// <param name="a_address"></param>
  1473. /// <returns></returns>
  1474. private DataTable ReadClassification(string a_address ,string STDName)
  1475. {
  1476. DataTable dt_STDGroups = new DataTable();
  1477. DataTable dt_ClassifySTD = new DataTable();
  1478. DataTable dt_IncAData = new DataTable();
  1479. var systype = m_ReportApp.m_RptConfigFile.Systype;
  1480. if (systype == OTS_SysType_ID.IncA)
  1481. {
  1482. dt_ClassifySTD.Columns.Add("STDId");
  1483. dt_ClassifySTD.Columns.Add("StrName");
  1484. dt_ClassifySTD.Columns.Add("Color");
  1485. dt_ClassifySTD.Columns.Add("KeyElementList");
  1486. dt_ClassifySTD.Columns.Add("SubElementList");
  1487. dt_ClassifySTD.Columns.Add("UsingImgPropertyList");
  1488. dt_ClassifySTD.Columns.Add("UsingOtherPropertyList");
  1489. dt_ClassifySTD.Columns.Add("Expression");
  1490. dt_ClassifySTD.Columns.Add("Hardness");
  1491. dt_ClassifySTD.Columns.Add("Density");
  1492. dt_ClassifySTD.Columns.Add("Electrical_conductivity");
  1493. dt_ClassifySTD.Columns.Add("BSE");
  1494. dt_ClassifySTD.Columns.Add("Formula");
  1495. dt_ClassifySTD.Columns.Add("Element");
  1496. dt_ClassifySTD.Columns.Add("IfElementAnalysis");
  1497. dt_ClassifySTD.Columns.Add("ListNum");
  1498. dt_ClassifySTD.Columns.Add("GroupId");
  1499. dt_ClassifySTD.Columns.Add("GroupName");
  1500. dt_ClassifySTD.Columns.Add("GroupColor");
  1501. DataTable da = Particledata.GetParticleListForParticlSizeID("area", "");
  1502. for (int i = 0; i < da.Rows.Count; i++)
  1503. {
  1504. if (Convert.ToInt64(da.Rows[i]["TypeId"]) > 9)
  1505. {
  1506. DataRow newRow = dt_ClassifySTD.NewRow();
  1507. newRow["STDId"] = da.Rows[i]["TypeId"];
  1508. newRow["StrName"] = da.Rows[i]["TypeName"];
  1509. newRow["Color"] = da.Rows[i]["TypeColor"];
  1510. newRow["GroupId"] = da.Rows[i]["GroupId"];
  1511. newRow["GroupName"] = da.Rows[i]["GroupName"];
  1512. newRow["GroupColor"] = da.Rows[i]["GroupColor"];
  1513. dt_ClassifySTD.Rows.Add(newRow);
  1514. }
  1515. }
  1516. }
  1517. else
  1518. {
  1519. SqLiteHelper sh_STDGroups = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
  1520. dt_STDGroups = sh_STDGroups.ExecuteQuery("select * from STDGroups");
  1521. SqLiteHelper sh_ClassifySTD = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
  1522. dt_ClassifySTD = sh_ClassifySTD.ExecuteQuery("select * from ClassifySTD");
  1523. dt_ClassifySTD.Columns.Add("GroupName");
  1524. dt_ClassifySTD.Columns.Add("GroupColor");
  1525. for (int i = 0; i < dt_ClassifySTD.Rows.Count; i++)
  1526. {
  1527. for (int a = 0; a < dt_STDGroups.Rows.Count; a++)
  1528. {
  1529. if (dt_ClassifySTD.Rows[i]["GroupId"].ToString() == dt_STDGroups.Rows[a]["id"].ToString())
  1530. {
  1531. dt_ClassifySTD.Rows[i]["GroupName"] = dt_STDGroups.Rows[a]["name"].ToString();
  1532. dt_ClassifySTD.Rows[i]["GroupColor"] = dt_STDGroups.Rows[a]["color"].ToString();
  1533. continue;
  1534. }
  1535. }
  1536. }
  1537. SqLiteHelper sh_Inclusion = new SqLiteHelper("data source='" + a_address + "\\FIELD_FILES\\Inclusion.db" + "'");
  1538. dt_IncAData = sh_Inclusion.ExecuteQuery("select * from IncAData");
  1539. for (int i = 0; i < dt_IncAData.Rows.Count; i++)
  1540. {
  1541. if (Convert.ToInt64(dt_IncAData.Rows[i]["TypeId"]) > 50000)
  1542. {
  1543. DataRow newRow = dt_ClassifySTD.NewRow();
  1544. newRow["STDId"] = dt_IncAData.Rows[i]["TypeId"];
  1545. newRow["StrName"] = dt_IncAData.Rows[i]["TypeName"];
  1546. newRow["Color"] = dt_IncAData.Rows[i]["TypeColor"];
  1547. newRow["GroupId"] = dt_IncAData.Rows[i]["GroupId"];
  1548. newRow["GroupName"] = dt_IncAData.Rows[i]["GroupName"];
  1549. newRow["GroupColor"] = dt_IncAData.Rows[i]["GroupColor"];
  1550. dt_ClassifySTD.Rows.Add(newRow);
  1551. }
  1552. }
  1553. }
  1554. DataRow newRowInvalid = dt_ClassifySTD.NewRow();
  1555. newRowInvalid["STDId"] = -1;
  1556. newRowInvalid["StrName"] = "Invalid";
  1557. newRowInvalid["Color"] = "#000000";
  1558. newRowInvalid["GroupId"] = -1;
  1559. newRowInvalid["GroupName"] = "Invalid";
  1560. newRowInvalid["GroupColor"] = "#000000";
  1561. dt_ClassifySTD.Rows.Add(newRowInvalid);
  1562. return dt_ClassifySTD;
  1563. }
  1564. private void ToolStripMenuItem3_Click(object sender, EventArgs e)
  1565. {
  1566. //如果没有选中颗粒退出
  1567. if (dgV_ParticlesDevidePage.SelectedRows.Count == 0)
  1568. {
  1569. return;
  1570. }
  1571. string CategoryName = "";
  1572. //循环选中颗粒
  1573. for (int i = 0; i < dgV_ParticlesDevidePage.SelectedRows.Count; i++)
  1574. {
  1575. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[i];
  1576. CategoryName = dgvr.Cells[1].Value.ToString();
  1577. }
  1578. string TypeId = "";
  1579. string TypeName = "";
  1580. string TypeColor = "";
  1581. string GroupName = "";
  1582. string GroupID = "";
  1583. string GroupColor = "";
  1584. string[] resulta = result.GetSTDName().Split('.');
  1585. DataTable data = ReadClassification(result.FilePath, resulta[0]);
  1586. ModifyCategoryForm modifyCategoryForm = new ModifyCategoryForm(data, CategoryName);
  1587. DialogResult result1 = modifyCategoryForm.ShowDialog();
  1588. if (modifyCategoryForm.DoYouWantToModifyIt)
  1589. {
  1590. TypeId = modifyCategoryForm.OutTypeAndName[0];
  1591. TypeName = modifyCategoryForm.OutTypeAndName[1];
  1592. TypeColor = modifyCategoryForm.OutTypeAndName[2];
  1593. GroupName = modifyCategoryForm.OutTypeAndName[3];
  1594. GroupID = modifyCategoryForm.OutTypeAndName[4];
  1595. GroupColor= modifyCategoryForm.OutTypeAndName[5];
  1596. List<string> strings = new List<string>();
  1597. strings.Add(TypeId);
  1598. strings.Add(TypeName);
  1599. strings.Add(TypeColor);
  1600. strings.Add(GroupName);
  1601. strings.Add(GroupID);
  1602. strings.Add(GroupColor);
  1603. if (dgV_ParticlesDevidePage.SelectedRows.Count == 1)
  1604. {
  1605. DialogResult result2 = MessageBox.Show("是否寻找相似颗粒并重命名?", "Tip", MessageBoxButtons.YesNo);
  1606. if (result2 == DialogResult.Yes)
  1607. {
  1608. int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
  1609. if (sel == (int)SelItem.MergeParticles)
  1610. {
  1611. return;
  1612. }
  1613. var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
  1614. uint[] Search_xray = new uint[2000];
  1615. if (SelectRows.Count != 0)
  1616. {
  1617. if (SelectRows.Count == 1)
  1618. {
  1619. DataGridViewRow dgvr = SelectRows[0];
  1620. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  1621. List<string> list_str = (List<string>)ls_bp.Tag;
  1622. uint[] Analysis_xray = new uint[2000];
  1623. int i_xray_id = 0;
  1624. List<Element> list_celementchemistryclr = new List<Element>();
  1625. ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
  1626. }
  1627. }
  1628. ListOfSimilarParticles Form_listOfSimilarParticles = new ListOfSimilarParticles(this, Search_xray, strings, m_ReportApp);
  1629. DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
  1630. if (result3 == DialogResult.OK)
  1631. {
  1632. }
  1633. else
  1634. {
  1635. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  1636. for (int i = 0; i < dgV_ParticlesDevidePage.SelectedRows.Count; i++)
  1637. {
  1638. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[i];
  1639. dgvr.Cells[1].Value = TypeName;
  1640. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  1641. List<string> list_str = (List<string>)ls_bp.Tag;
  1642. int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  1643. int i_ls_particleid = Convert.ToInt32(list_str[1]);
  1644. List<int> ints = new List<int>();
  1645. ints.Add(i_ls_fieldid);
  1646. ints.Add(i_ls_particleid);
  1647. var cmd = Particledata.GetUpdataAIncACmd(ints, strings);
  1648. cmdlist.Add(cmd);
  1649. }
  1650. Particledata.ExecuteNonQueryBatch(cmdlist);
  1651. }
  1652. }
  1653. else
  1654. {
  1655. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  1656. for (int i = 0; i < dgV_ParticlesDevidePage.SelectedRows.Count; i++)
  1657. {
  1658. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[i];
  1659. dgvr.Cells[1].Value = TypeName;
  1660. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  1661. List<string> list_str = (List<string>)ls_bp.Tag;
  1662. int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  1663. int i_ls_particleid = Convert.ToInt32(list_str[1]);
  1664. List<int> ints = new List<int>();
  1665. ints.Add(i_ls_fieldid);
  1666. ints.Add(i_ls_particleid);
  1667. var cmd = Particledata.GetUpdataAIncACmd(ints, strings);
  1668. cmdlist.Add(cmd);
  1669. }
  1670. Particledata.ExecuteNonQueryBatch(cmdlist);
  1671. }
  1672. }
  1673. else
  1674. {
  1675. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  1676. for (int i = 0; i < dgV_ParticlesDevidePage.SelectedRows.Count; i++)
  1677. {
  1678. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[i];
  1679. dgvr.Cells[1].Value = TypeName;
  1680. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  1681. List<string> list_str = (List<string>)ls_bp.Tag;
  1682. int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  1683. int i_ls_particleid = Convert.ToInt32(list_str[1]);
  1684. List<int> ints = new List<int>();
  1685. ints.Add(i_ls_fieldid);
  1686. ints.Add(i_ls_particleid);
  1687. var cmd = Particledata.GetUpdataAIncACmd(ints, strings);
  1688. cmdlist.Add(cmd);
  1689. }
  1690. Particledata.ExecuteNonQueryBatch(cmdlist);
  1691. }
  1692. UpdateDataGrid();
  1693. lnkFirst_Click(null, null);
  1694. SetDataGridViewStyle();
  1695. DataTable table = GetClassificationOfAllParticles();
  1696. if (table != null)
  1697. {
  1698. if (table.Rows.Count > 0)
  1699. {
  1700. foreach (DataRow row in table.Rows)
  1701. {
  1702. tbx_Type.Text += row["TypeName"].ToString() + '$';
  1703. }
  1704. }
  1705. if (tbx_Type.Text != "")
  1706. {
  1707. tbx_Type.Text = tbx_Type.Text.Remove(tbx_Type.Text.Length - 1);
  1708. }
  1709. }
  1710. dgV_ParticlesDevidePage.Focus();
  1711. }
  1712. }
  1713. void CreateChart(IDrawing drawing, ISheet sheet, IClientAnchor anchor, int rowid)
  1714. {
  1715. var chart = drawing.CreateChart(anchor) as XSSFChart;
  1716. //图表
  1717. var data = chart.ChartDataFactory.CreateLineChartData<double, double>(); //折线图
  1718. IChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom);
  1719. IValueAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left);
  1720. leftAxis.Crosses = AxisCrosses.AutoZero;
  1721. leftAxis.IsVisible = true;
  1722. bottomAxis.IsVisible = true;
  1723. //数据源
  1724. IChartDataSource<double> ys = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(rowid, rowid, 1, 2001));
  1725. Double[] doubles = new Double[2000];
  1726. for (int i = 0; i < 2000; i++)
  1727. {
  1728. doubles[i] = i;
  1729. }
  1730. IChartDataSource<double> xs = DataSources.FromArray(doubles);
  1731. //数据系列
  1732. var s1 = data.AddSeries(xs, ys);
  1733. }
  1734. /// <summary>
  1735. /// 将image转成bytes
  1736. /// </summary>
  1737. /// <param name="in_img"></param>
  1738. /// <returns></returns>
  1739. public byte[] ImageConvertToBytes(System.Drawing.Image in_img)
  1740. {
  1741. MemoryStream ms = new MemoryStream();
  1742. in_img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  1743. return ms.ToArray();
  1744. }
  1745. private void ToolStripMenuItem_Delete_Particle_Click(object sender, EventArgs e)
  1746. {
  1747. string path = result.FilePath;
  1748. ParticleData fielddata = new ParticleData(result.FilePath);
  1749. List<Particle> particles = fielddata.GetParticleAllList();
  1750. DialogResult dr = MessageBox.Show("Remove all these particles permanently?", "Tips", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1751. if (dr == DialogResult.OK)
  1752. {
  1753. List<Particle> list_Part = new List<Particle>();
  1754. for (int ii = 0; ii < dgV_ParticlesDevidePage.SelectedRows.Count; ii++)
  1755. {
  1756. DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[ii];
  1757. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  1758. List<string> list_str = (List<string>)ls_bp.Tag;
  1759. if (list_str != null)
  1760. {
  1761. int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  1762. int i_ls_particleid = Convert.ToInt32(list_str[1]);
  1763. foreach (Particle item in particles)
  1764. {
  1765. if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
  1766. {
  1767. if (DeleteParticlesFromSTDDb(item.ParticleId, item.FieldId))
  1768. {
  1769. for (int i = 0; i < particlesAll.Rows.Count; i++)
  1770. {
  1771. if (particlesAll.Rows[i]["Fieldid"].ToString() == item.FieldId.ToString() && particlesAll.Rows[i]["Particleid"].ToString() == item.ParticleId.ToString())
  1772. {
  1773. particlesAll.Rows.RemoveAt(i);
  1774. list_Part.Add(item);
  1775. }
  1776. }
  1777. }
  1778. else
  1779. {
  1780. MessageBox.Show("Delete failed");
  1781. }
  1782. break;
  1783. }
  1784. }
  1785. }
  1786. }
  1787. RecordCount = recordCount - dgV_ParticlesDevidePage.SelectedRows.Count;
  1788. lblTotalCount.Text = RecordCount.ToString();
  1789. foreach (DataGridViewRow Row in dgV_ParticlesDevidePage.SelectedRows)
  1790. {
  1791. dgV_ParticlesDevidePage.Rows.Remove(Row);
  1792. }
  1793. if (dgV_ParticlesDevidePage.Rows.Count == 0)
  1794. {
  1795. DisplayData();
  1796. }
  1797. for (int j = 0; j < dgV_ParticlesDevidePage.Rows.Count; j++)
  1798. {
  1799. dgV_ParticlesDevidePage.Rows[j].Cells[0].Value = (pageSize * (PageIndex - 1) + j + 1).ToString();
  1800. }
  1801. if (m_ReportApp.im_Control_DrawDistrbutionImageAndBSE != null)
  1802. {
  1803. m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.DeletesParticlesSynchronously(list_Part);
  1804. }
  1805. else
  1806. {
  1807. var _Control_DrawDistrbutionImageAndBSE = new OTSIncAReportGraph.Controls.Control_DrawDistrbutionImageAndBSE(m_ReportApp);
  1808. foreach (var p in list_Part)
  1809. {
  1810. _Control_DrawDistrbutionImageAndBSE.DeleteParticlesFromSTDDb(p.ParticleId, p.FieldId);
  1811. }
  1812. }
  1813. }
  1814. }
  1815. private bool DeleteParticlesFromSTDDb(int in_clr_tagid, int in_clr_fieldid)
  1816. {
  1817. bool DoesItExist = false;
  1818. for (int i = 1; i < 201; i++)
  1819. {
  1820. if (System.IO.Directory.Exists(result.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
  1821. {
  1822. DoesItExist = true;
  1823. break;
  1824. }
  1825. }
  1826. if (!DoesItExist)
  1827. {
  1828. //备份数据库
  1829. BackupDatabase();
  1830. }
  1831. DoesItExist = false;
  1832. //防止为空校验判断
  1833. if (result.GetList_OTSField() == null)
  1834. return false;
  1835. Particle particle = result.GetList_OTSField().Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
  1836. if (new ParticleData(result.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
  1837. {
  1838. return true;
  1839. }
  1840. else
  1841. {
  1842. return false;
  1843. }
  1844. }
  1845. private bool BackupDatabase()
  1846. {
  1847. //创建备份数据库文件夹
  1848. string sourcePath = result.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
  1849. string sourceName = "Inclusion.db";//源文件名称
  1850. string folderPath = result.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
  1851. string Fields = "";
  1852. for (int i = 1; i < 201; i++)
  1853. {
  1854. if (System.IO.Directory.Exists(folderPath + i.ToString()))
  1855. {
  1856. Fields = folderPath + i.ToString();
  1857. continue;
  1858. }
  1859. else
  1860. {
  1861. System.IO.Directory.CreateDirectory(folderPath + i.ToString());
  1862. Fields = folderPath + i.ToString();
  1863. break;
  1864. }
  1865. }
  1866. if (Fields == "")
  1867. {
  1868. return false;
  1869. }
  1870. //复制数据库文件
  1871. string targetPath = Path.Combine(Fields, sourceName);
  1872. FileInfo file = new FileInfo(sourcePath);
  1873. if (file.Exists)
  1874. {
  1875. file.CopyTo(targetPath, true);
  1876. }
  1877. return true;
  1878. }
  1879. private void DisplayData()
  1880. {
  1881. if (cbB_PageSize.SelectedItem.ToString() == "All")
  1882. {
  1883. pageSize = -1;
  1884. }
  1885. else
  1886. {
  1887. pageSize = int.Parse(cbB_PageSize.SelectedItem.ToString());
  1888. }
  1889. lnkFirst_Click(null, null);
  1890. SetDataGridViewStyle();
  1891. }
  1892. string ChangeHardnessColor(string Hardness)
  1893. {
  1894. string str = System.Text.RegularExpressions.Regex.Replace(Hardness, @"[^\d.\d]", "");
  1895. double hd;
  1896. if (double.TryParse(str, out hd))
  1897. {
  1898. if (hd >= 1000)
  1899. {
  1900. return "#FF0000";
  1901. }
  1902. else return "";
  1903. }
  1904. else
  1905. return "";
  1906. }
  1907. /// <summary>
  1908. ///
  1909. /// </summary>
  1910. /// <param name="str_resultPath"></param>
  1911. /// <param name="dataTable"></param>
  1912. /// <param name="vs"></param>
  1913. /// <param name="dt_FIeld"></param>
  1914. public void Out_MarkParticleRectangleOnFieldFile(string str_resultPath, DataTable dataTable, out List<string> vs, out DataTable dt_FIeld)
  1915. {
  1916. Init();
  1917. List<string> maxlength = new List<string>();
  1918. for (int i = 0; i < dataTable.Rows.Count; i++)
  1919. {
  1920. if (Convert.ToInt32(dataTable.Rows[i]["TypeId"]) > 9)
  1921. {
  1922. if (maxlength.Count < 10)
  1923. {
  1924. maxlength.Add(dataTable.Rows[i]["Fieldid"].ToString());
  1925. }
  1926. else
  1927. {
  1928. break;
  1929. }
  1930. }
  1931. }
  1932. List<string> max_list = maxlength.Distinct().ToList();
  1933. string str_path_FIELD_FILES = str_resultPath + "\\FIELD_FILES\\";
  1934. int intQuantity = 0;
  1935. dt_FIeld = new DataTable();
  1936. vs = new List<string>();
  1937. ResultFile resfile = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResultId()];
  1938. float PixelSize = resfile.GetPixelSize();
  1939. float ScanFieldSizeX = resfile.GetScanFieldSizeX();
  1940. int gauge = RulerSelection(ScanFieldSizeX);
  1941. float RulerPixels = gauge / PixelSize;
  1942. DataTable dt_AllParticle = fieldData.GetAllParticle_DataTable();
  1943. DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES);
  1944. if (theFolder.Exists)
  1945. {
  1946. DataTable dt = new DataTable();
  1947. dt.Columns.Add("fieldid");
  1948. dt.Columns.Add("id");
  1949. dt.Columns.Add("fieldName");
  1950. dt.Columns.Add("cunt", typeof(int));
  1951. dt.Columns.Add("fieldFullName");
  1952. for (int i = 0; i < max_list.Count; i++)
  1953. {
  1954. foreach (FileInfo nextifile in theFolder.GetFiles())
  1955. {
  1956. if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
  1957. {
  1958. string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
  1959. str_fieldid = str_fieldid.Substring(5, str_fieldid.Length - 5);//减去field字符长度
  1960. bool bl = false;
  1961. if (str_fieldid == max_list[i].ToString())
  1962. {
  1963. bl = true;
  1964. }
  1965. if (bl)
  1966. {
  1967. DataRow dr = dt.NewRow();
  1968. dr["fieldid"] = " fieldid = " + str_fieldid;
  1969. int drcunt = 0;
  1970. for (int ia = 0; ia < dataTable.Rows.Count; ia++)
  1971. {
  1972. if (dataTable.Rows[ia]["fieldid"].ToString() == str_fieldid.ToString())
  1973. {
  1974. drcunt++;
  1975. }
  1976. }
  1977. dr["cunt"] = drcunt;
  1978. dr["fieldName"] = nextifile.Name;
  1979. dr["fieldFullName"] = nextifile.FullName;
  1980. dr["id"] = str_fieldid;
  1981. dt.Rows.Add(dr);
  1982. }
  1983. }
  1984. }
  1985. }
  1986. dt_FIeld = dt.Copy();
  1987. dt_FIeld.Columns.Add("Field_pic", typeof(Bitmap));
  1988. for (int i = 0; i < dt_FIeld.Rows.Count; i++)
  1989. {
  1990. int drCount = 0;
  1991. for (int ia = 0; ia < dataTable.Rows.Count; ia++)
  1992. if (Convert.ToInt32(dt_FIeld.Rows[i]["id"]) == Convert.ToInt32(dataTable.Rows[ia]["fieldid"]))
  1993. drCount++;
  1994. if (drCount > 0)
  1995. {
  1996. vs.Add(dt_FIeld.Rows[i]["id"].ToString());
  1997. Image img = Image.FromFile(dt_FIeld.Rows[i]["fieldFullName"].ToString());
  1998. Bitmap ls_fieldbp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  1999. using (Graphics g = Graphics.FromImage(ls_fieldbp))
  2000. {
  2001. g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  2002. g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
  2003. g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
  2004. g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height));
  2005. }
  2006. img.Dispose();
  2007. img = null;
  2008. //循环将颗粒,进行标记到bitmap图上
  2009. DataRow[] drlist = dt_AllParticle.Select(dt_FIeld.Rows[i]["fieldid"].ToString());
  2010. if (drlist.Count() > 0)
  2011. intQuantity = intQuantity + 1;
  2012. for (int i_row = 0; i_row < drlist.Count(); i_row++)
  2013. {
  2014. string str_particleid = drlist[i_row]["particleid"].ToString();
  2015. string str_stdtypeid = drlist[i_row]["typeid"].ToString();
  2016. string str_offset_rect_X = drlist[i_row]["RectLeft"].ToString();
  2017. string str_offset_rect_Y = drlist[i_row]["RectTop"].ToString();
  2018. string str_offset_rect_Width = drlist[i_row]["RectWidth"].ToString();
  2019. string str_offset_rect_Height = drlist[i_row]["RectHeight"].ToString();
  2020. //确定需要标记颗粒的定位
  2021. Rectangle offset_rect = new Rectangle(Convert.ToInt32(str_offset_rect_X), Convert.ToInt32(str_offset_rect_Y),
  2022. Convert.ToInt32(str_offset_rect_Width), Convert.ToInt32(str_offset_rect_Height));
  2023. //向帧图进行标记颗粒位置
  2024. Graphics g = Graphics.FromImage(ls_fieldbp);
  2025. g.DrawRectangle(new Pen(Color.Aquamarine), offset_rect);
  2026. //判断是否超出了图像外面,是的话,让文字在左侧显示,默认在右侧显示
  2027. int ls_offsetx = offset_rect.X + offset_rect.Width;
  2028. if (ls_offsetx > ls_fieldbp.Width - 10)
  2029. {
  2030. ls_offsetx = offset_rect.X - 10;
  2031. }
  2032. g.DrawString(dt_FIeld.Rows[i]["id"].ToString() + "" + str_particleid.ToString(), new Font("黑体", 8), new SolidBrush(Color.Aqua), new PointF(ls_offsetx, offset_rect.Y));
  2033. var bitmap = DrawRuler(ls_fieldbp, (int)(RulerPixels / 2), 2, (gauge / 2).ToString() + "μm");
  2034. dt_FIeld.Rows[i]["Field_pic"] = bitmap;
  2035. }
  2036. }
  2037. }
  2038. }
  2039. GC.Collect();
  2040. GC.WaitForPendingFinalizers();
  2041. }
  2042. /// <summary>
  2043. /// 在图片上绘制标尺
  2044. /// </summary>
  2045. /// <param name="bitmap">图片</param>
  2046. /// <param name="LineLength">线长(像素)</param>
  2047. /// <param name="LineWidth">线宽(像素)</param>
  2048. /// <returns></returns>
  2049. private Bitmap DrawRuler(Bitmap bitmap, int LineLength, int LineWidth, string a_str)
  2050. {
  2051. if (bitmap == null)
  2052. throw new ArgumentNullException(nameof(bitmap));
  2053. // 创建一个新的Bitmap,并设置其大小与原图相同
  2054. Bitmap rgbBitmap = new Bitmap(bitmap.Width, bitmap.Height);
  2055. using (Graphics graphics = Graphics.FromImage(rgbBitmap))
  2056. {
  2057. // 将原图转换为RGB格式,并绘制到新的Bitmap上
  2058. graphics.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
  2059. Color color = FromHex("#00FF00");
  2060. //Color color = FromHex("#00FF00");
  2061. // 设置线条颜色和宽度
  2062. Pen pen = new Pen(color, LineWidth);
  2063. Font font = new Font("Arial", 20, GraphicsUnit.Pixel);
  2064. Brush brush = new SolidBrush(color);
  2065. StringFormat stringFormat = new StringFormat();
  2066. stringFormat.Alignment = StringAlignment.Center; // 居中对齐
  2067. stringFormat.LineAlignment = StringAlignment.Center; // 居中对齐行
  2068. // 绘制文字
  2069. SizeF textSize = Graphics.FromImage(bitmap).MeasureString(a_str, font);
  2070. PointF point = new PointF();
  2071. // 计算文本应该开始的位置,使其居中
  2072. point.X = (bitmap.Width - LineLength - 20) + ((LineLength - textSize.Width) / 2);
  2073. point.Y = bitmap.Height - 80;
  2074. graphics.DrawString(a_str, font, new SolidBrush(color), point);
  2075. graphics.DrawLine(pen, bitmap.Width - LineLength - 20, bitmap.Height - 40, bitmap.Width - 20, bitmap.Height - 40);
  2076. graphics.DrawLine(pen, bitmap.Width - LineLength - 20, bitmap.Height - 40, bitmap.Width - LineLength - 20, bitmap.Height - 50);
  2077. graphics.DrawLine(pen, bitmap.Width - 20, bitmap.Height - 40, bitmap.Width - 20, bitmap.Height - 50);
  2078. }
  2079. return rgbBitmap;
  2080. }
  2081. private static Color FromHex(string hex)
  2082. {
  2083. hex = hex.Replace("#", ""); // 移除 # 前缀
  2084. byte a = 255; // 默认Alpha值为255(不透明)
  2085. byte r = Convert.ToByte(hex.Substring(0, 2), 16);
  2086. byte g = Convert.ToByte(hex.Substring(2, 2), 16);
  2087. byte b = Convert.ToByte(hex.Substring(4, 2), 16);
  2088. return Color.FromArgb(a, r, g, b);
  2089. }
  2090. /// <summary>
  2091. /// 判断当前图片应该使用多大标尺
  2092. /// </summary>
  2093. /// <param name="a_value"> </param>
  2094. /// <returns></returns>
  2095. private int RulerSelection(float a_value)
  2096. {
  2097. int value = 0;
  2098. a_value = a_value / 2;
  2099. for (int i = 10; i < 5000; i += 5)
  2100. {
  2101. if (a_value < i)
  2102. {
  2103. value = i - 5;
  2104. break;
  2105. }
  2106. }
  2107. if (value == 0)
  2108. {
  2109. value = 5000;
  2110. }
  2111. return value;
  2112. }
  2113. private void dgV_ParticlesDevidePage_MouseDown(object sender, MouseEventArgs e)
  2114. {
  2115. //var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
  2116. //int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
  2117. //{
  2118. //if (sel != (int)SelItem.MergeParticles)
  2119. //{
  2120. // if (SelectRows != null && SelectRows.Count == 1)
  2121. // {
  2122. // DataGridViewRow dgvr = SelectRows[0];
  2123. // Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  2124. // List<string> list_str = (List<string>)ls_bp.Tag;
  2125. // }
  2126. ToolStripMenuItemDelete_Particle.Visible = true;
  2127. //}
  2128. //else
  2129. //{
  2130. // ToolStripMenuItemDelete_Particle.Visible = false;
  2131. //}
  2132. //}
  2133. }
  2134. private void btn_showconfig_Click(object sender, EventArgs e)
  2135. {
  2136. var p = particles; List<string> ele = new List<string>();
  2137. string elementsstr = "";
  2138. foreach (DataRow row in particles.Rows)
  2139. {
  2140. string[] strcbo = row["Element"].ToString().Split(';');
  2141. for (int j = 0; j < strcbo.Length; j++)
  2142. {
  2143. string[] str = strcbo[j].Split('-');
  2144. if (!ele.Contains(str[0]) && str[0] != "")
  2145. {
  2146. if (str[1] != "" && double.Parse(str[1]) != 0) //咨询demo后,元素含量返回值为零时一般去除此元素
  2147. { ele.Add(str[0]); }
  2148. }
  2149. }
  2150. }
  2151. foreach (var el in ele)
  2152. {
  2153. elementsstr += el.ToString() + ',';
  2154. }
  2155. if (elementsstr != "")
  2156. {
  2157. elementsstr = elementsstr.Remove(elementsstr.Length - 1, 1);
  2158. }
  2159. m_particlesGridDevidePageShowConfig = new ParticlesGridDevidePageShowConfig(m_ReportApp.m_RptConfigFile.Systype, elementsstr);
  2160. m_particlesGridDevidePageShowConfig.ShowDialog();
  2161. if (m_particlesGridDevidePageShowConfig.DialogResult == DialogResult.OK)
  2162. {
  2163. dgV_ParticlesDevidePage.Rows.Clear();
  2164. dgV_ParticlesDevidePage.Columns.Clear();
  2165. RefreshGridView();
  2166. SetDataGridViewStyle();
  2167. }
  2168. }
  2169. //private void SaveParticleslist_select()
  2170. //{
  2171. // ParticleData fielddata = new ParticleData(result.FilePath);
  2172. // List<Particle> particles = fielddata.GetParticleAllList();
  2173. // Particleslist_selecttodisplay.Clear();
  2174. // for (int l = 0; l < dgV_ParticlesDevidePage.SelectedRows.Count; l++)
  2175. // {
  2176. // //从事先加载的Bitmap对象的Tag中取出List<string>
  2177. // DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[l];
  2178. // Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  2179. // List<string> list_str = (List<string>)ls_bp.Tag;
  2180. // if (list_str != null)
  2181. // {
  2182. // int i_ls_fieldid = Convert.ToInt32(list_str[0]);
  2183. // int i_ls_particleid = Convert.ToInt32(list_str[1]);
  2184. // foreach (Particle item in particles)
  2185. // {
  2186. // if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
  2187. // {
  2188. // Particleslist_selecttodisplay.Add(item);
  2189. // break;
  2190. // }
  2191. // }
  2192. // }
  2193. // }
  2194. //}
  2195. //public List<Particle> GetParticleslist_select()
  2196. //{
  2197. // return Particleslist_selecttodisplay;
  2198. //}
  2199. private void dgV_ParticlesDevidePage_MouseUp(object sender, MouseEventArgs e)
  2200. {
  2201. ToolStripMenuItem_SimilarityReclassification.Enabled = false;
  2202. var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
  2203. if (SelectRows.Count != 0)
  2204. {
  2205. if (SelectRows.Count == 1)
  2206. {
  2207. DataGridViewRow dgvr = SelectRows[0];
  2208. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  2209. uint[] Search_xray = new uint[2000];
  2210. uint[] Analysis_xray = new uint[2000];
  2211. int i_xray_id = 0;
  2212. List<Element> list_celementchemistryclr = new List<Element>();
  2213. Particle particle=new Particle();
  2214. string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
  2215. DataRow[] drs = particles.Select(str);
  2216. DataRow row = drs[0];
  2217. string subt = row["SubParticles"].ToString();
  2218. if (subt != ""&& subt != null)
  2219. {
  2220. particle = Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray);
  2221. list_celementchemistryclr = particle.ElementList;
  2222. }
  2223. else
  2224. {
  2225. particle = ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
  2226. }
  2227. List<ShowElementInfo> list_showelementinfo = Particledata.GetShowElementInfos_ForMergeParticle(list_celementchemistryclr);
  2228. string str_IncAName = "";
  2229. str_IncAName = Convert.ToString(dgvr.Cells[1].Value);
  2230. if (particle == null)
  2231. {
  2232. return;
  2233. }
  2234. control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + " " + "DMAX:" + Math.Round(particle.DMAX, 2) + " " + "DELONG:" + Math.Round(particle.DELONG, 2) + " " + "DFERET:" + Math.Round(particle.DFERET, 2) + " " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + " " + "DMIN:" + Math.Round(particle.DMIN, 2) + " " + "DPERP:" + Math.Round(particle.DPERP, 2) + " " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + " " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
  2235. control_XRayTable1.Visible = true;
  2236. control_XRayTable1.SetXRayShowLineValue(null, Analysis_xray, list_showelementinfo);
  2237. control_XRayTable1.GBInfoStr = "";
  2238. control_XRayTable1.MaterialName = str_IncAName;
  2239. control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
  2240. if (subt == "" || subt == null)
  2241. {
  2242. Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particle.RectLeft), Y = Convert.ToInt32(particle.RectTop), Width = Convert.ToInt32(particle.RectWidth), Height = Convert.ToInt32(particle.RectHeight) };
  2243. Bitmap dpImage = ReportFun.GetBlackAndWhiteImage(particle);
  2244. string filePath = result.FilePath + "\\FIELD_FILES\\";
  2245. string imagePath = filePath + "Field" + dgvr.Cells["fieldid"].Value.ToString() + ".bmp";
  2246. Bitmap m_originalImage = DrawFunction.ReadImageFile(imagePath);
  2247. Bitmap bmap = fldImgAccess.GetBitmapByParticle(dpImage, rectangle);
  2248. Bitmap bmap1 = fldImgAccess.GetBitmapByParticle(m_originalImage, rectangle);
  2249. control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
  2250. Invalidate();
  2251. }
  2252. else
  2253. {
  2254. double xs = result.GetPixelSize();
  2255. int width = result.GetImageWidth();
  2256. int height = result.GetImageHeight();
  2257. int fldid= Convert.ToInt32(dgvr.Cells["fieldid"].Value);
  2258. int partid= Convert.ToInt32(dgvr.Cells["particleId"].Value);
  2259. var listseg = Particledata.GetSegmentData(fldid, partid);
  2260. string vs = "," + subt.Replace(':', '-') + ",";
  2261. DataTable dataTable = Particledata. GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
  2262. Bitmap bp = fldImgAccess.GetBitmapForBigBlackAndWhiteImage(subt, xs, result.FilePath, height, width,dataTable,listseg );
  2263. control_XRayTable1.SetBitmapOfPictureBox(ls_bp,bp);
  2264. Invalidate();
  2265. }
  2266. ToolStripMenuItem_SimilarityReclassification.Enabled = true;
  2267. }
  2268. //SaveParticleslist_select();
  2269. }
  2270. }
  2271. private void dgV_ParticlesDevidePage_KeyDown(object sender, KeyEventArgs e)
  2272. {
  2273. if (e.KeyData == Keys.Delete)
  2274. {
  2275. ToolStripMenuItem_Delete_Particle_Click(null, null);
  2276. }
  2277. }
  2278. private void dgV_ParticlesDevidePage_KeyUp(object sender, KeyEventArgs e)
  2279. {
  2280. if (e.KeyData == Keys.Down)
  2281. {
  2282. dgV_ParticlesDevidePage_MouseUp(null, null);
  2283. }
  2284. if (e.KeyData == Keys.Up)
  2285. {
  2286. dgV_ParticlesDevidePage_MouseUp(null, null);
  2287. }
  2288. }
  2289. private void tbx_Type_Click(object sender, EventArgs e)
  2290. {
  2291. ParticleClassificationSelect particleClassificationSelect = new ParticleClassificationSelect(this, tbx_Type.Text);
  2292. DialogResult result = particleClassificationSelect.ShowDialog();
  2293. if (result == DialogResult.OK)
  2294. {
  2295. condition = "";
  2296. tbx_Type.Text = particleClassificationSelect.ParticleClassificationSelected;
  2297. string[] tr = tbx_Type.Text.Split(',');
  2298. condition += " and (";
  2299. for (int i = 0; i < tr.Length; i++)
  2300. {
  2301. if (i == 0)
  2302. {
  2303. condition += " TypeName = '" + tr[i] + "'";
  2304. }
  2305. else
  2306. {
  2307. condition += " or TypeName = '" + tr[i] + "'";
  2308. }
  2309. }
  2310. condition += ")";
  2311. if (m_frm_userprogress.IsDisposed)
  2312. {
  2313. ProgressStart();
  2314. }
  2315. UpdateDataGrid();
  2316. lnkFirst_Click(null, null);
  2317. SetDataGridViewStyle();
  2318. }
  2319. }
  2320. private void btn_particletypesel_Click(object sender, EventArgs e)
  2321. {
  2322. ParticleClassificationSelect particleClassificationSelect = new ParticleClassificationSelect(this, tbx_Type.Text);
  2323. DialogResult result = particleClassificationSelect.ShowDialog();
  2324. if (result == DialogResult.OK)
  2325. {
  2326. condition = "";
  2327. tbx_Type.Text = "";
  2328. if (particleClassificationSelect.ParticleClassificationSelected != "")
  2329. {
  2330. tbx_Type.Text = particleClassificationSelect.ParticleClassificationSelected;
  2331. btn_Sel_Click(null, null);
  2332. }
  2333. }
  2334. }
  2335. public DataTable GetClassificationOfAllParticles()
  2336. {
  2337. string str = "";
  2338. int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
  2339. if (sel == (int)SelItem.analyticalParticle)
  2340. {
  2341. str = "where xrayid > -1 and typeid !=9 and typeid !=-1 and typeid !=4 and SubParticles is not 'IsSubParticle' ";
  2342. }
  2343. else if (sel == (int)SelItem.otherParticles)
  2344. {
  2345. str = "where SubParticles is not 'IsSubParticle'and(typeid =9 or typeid =-1 or typeid =4)";
  2346. }
  2347. else
  2348. {
  2349. }
  2350. DataTable table = Particledata.GetClassificationOfAllParticles(str);
  2351. return table;
  2352. }
  2353. private void 根据相似度批量修改ToolStripMenuItem_Click(object sender, EventArgs e)
  2354. {
  2355. //如果没有选中颗粒退出
  2356. if (dgV_ParticlesDevidePage.SelectedRows.Count != 1)
  2357. {
  2358. MessageBox.Show("Please select one row!");
  2359. return;
  2360. }
  2361. var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
  2362. uint[] Search_xray = new uint[2000];
  2363. DataGridViewRow dgvr = SelectRows[0];
  2364. Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
  2365. List<string> list_str = (List<string>)ls_bp.Tag;
  2366. uint[] Analysis_xray = new uint[2000];
  2367. int i_xray_id = 0;
  2368. List<Element> list_celementchemistryclr = new List<Element>();
  2369. string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
  2370. DataRow[] drs = particles.Select(str);
  2371. DataRow row = drs[0];
  2372. string subt = row["SubParticles"].ToString();
  2373. if (subt != "" && subt != null)
  2374. {
  2375. Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray);
  2376. }
  2377. else
  2378. {
  2379. ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
  2380. }
  2381. ListOfSimilarParticles Form_listOfSimilarParticles = new ListOfSimilarParticles(this, Search_xray, m_ReportApp);
  2382. DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
  2383. if (result3 == DialogResult.OK)
  2384. {
  2385. UpdateDataGrid();
  2386. lnkFirst_Click(null, null);
  2387. SetDataGridViewStyle();
  2388. DataTable table = GetClassificationOfAllParticles();
  2389. if (table != null)
  2390. {
  2391. if (table.Rows.Count > 0)
  2392. {
  2393. foreach (DataRow rw in table.Rows)
  2394. {
  2395. tbx_Type.Text += rw["TypeName"].ToString() + '$';
  2396. }
  2397. }
  2398. if (tbx_Type.Text != "")
  2399. {
  2400. tbx_Type.Text = tbx_Type.Text.Remove(tbx_Type.Text.Length - 1);
  2401. }
  2402. }
  2403. dgV_ParticlesDevidePage.Focus();
  2404. }
  2405. else
  2406. {
  2407. }
  2408. }
  2409. }
  2410. }