ParticlesGridDevidePage.cs 89 KB

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