Control_DrawDistrbutionSortImage.cs 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794
  1. using OTSIncAReportApp.DataOperation.Model;
  2. using OTSIncAReportApp.OTSSampleReportInfo;
  3. using OTSIncAReportApp.SysMgrTools;
  4. using OTSIncAReportGraph.Class;
  5. using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
  6. using OTSIncAReportMailInterface;
  7. using OTSPeriodicTable;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Drawing.Drawing2D;
  13. using System.Linq;
  14. using System.Threading;
  15. using System.Windows.Forms;
  16. namespace OTSIncAReportGraph.Controls
  17. {
  18. public partial class Control_DrawDistrbutionSortImage : UserControl
  19. {
  20. #region 变量定义
  21. //这里要做成控件,不要是窗体
  22. public List<BaseObject> m_list_baseobject = null;
  23. //多边形的分栏,list
  24. public List<SortParticleDistribution> m_list_sortparticledistribution = null;
  25. //多边形的分栏list,的原先值,用于缩放拖动等计算使用
  26. public List<SortParticleDistribution> m_old_list_sortparticledistribution = null;
  27. //记录操作记录类
  28. List<HistoryApolygon> m_list_historyapolygon = null;
  29. //操作历史类,当前操作到的id
  30. private int m_operator_currentid = 0;
  31. //背景矩形
  32. private RectangleF m_backrectf = new RectangleF();
  33. //记录原值,背景矩形
  34. private RectangleF m_old_backrectf = new RectangleF();
  35. //单一Field视域,屏幕像素的宽高
  36. public RectangleF m_OneField_Screen_BackRectf = new RectangleF();
  37. //单一Field视域,OTS物理像素的宽高
  38. public RectangleF m_OneField_OTS_Rectf = new RectangleF();
  39. //是否使用矩形进行多选操作
  40. private bool m_is_multiselect_rectangle = false;
  41. //是否使用圆形进行多选操作
  42. private bool m_is_multiselect_ellipse = false;
  43. //是否可以进行绘制,提供给矩形多选与圆形多选使用的临时变量
  44. private bool m_is_multiselect_onpaint = false;
  45. //进行选择的矩形范围
  46. private RectangleF m_multiselect_rect = new RectangleF();
  47. //在进行拖选前鼠标记录的点
  48. private PointF m_beforemultiselect_point = new PointF();
  49. //是否拖动
  50. private bool m_isDrag = false;
  51. //拖动前的坐标记录
  52. private PointF m_beforedrag_pointf = new PointF();
  53. //记录鼠标拖选完成后形成的路径
  54. private GraphicsPath m_selectmulti_gpath = new GraphicsPath();
  55. //缩放的增大缩小的增量
  56. private float m_f_zoom_increment = 0.1f;
  57. //缩放的基数,临时变量
  58. private float m_f_widthandheight_js = 0;
  59. //与原先缩放的记录数
  60. public float m_f_zoom_record = 1;
  61. //最大缩放倍数
  62. private float m_f_zoom_max = 4f;
  63. //最小缩放倍数
  64. private float m_f_zoom_mix = 0.5f;
  65. //标尺的大小记录
  66. public float m_f_ruler_size = 100;
  67. //标尺原先大小的记录,参与计算
  68. private float m_f_old_ruler_size = 100;
  69. //每像素代表的尺寸大小,还不知道在哪里进行计算
  70. public float m_f_onepixel_size = 4.5f;
  71. //提供鼠标在右下角显示的文本,左侧
  72. private string m_str_mouseshow_left = "";
  73. //提供鼠标在右下角显示的文本,右侧
  74. private string m_str_mouseshow_right = "";
  75. //分栏网格边框的颜色
  76. private Color m_c_ColumnRectangleColor = Color.LightSteelBlue;
  77. //日志文件名
  78. const String m_csFileName = "OTSReportAppLog";
  79. //底层封装类
  80. OTSIncAReportFun m_OTSIncAReportFun = null;
  81. //鼠标移动经过的颗粒对象,临时存放,用来记录是否要显示xray与隐藏xray
  82. DParticle m_move_dparticle = null;
  83. //保存数据源名称
  84. private string m_showsourcename = "";
  85. //保存数据源的ID
  86. private int m_datasourceid = 0;
  87. //记录当前鼠标位置对应SEM电镜的位置
  88. Point m_sem_mouse_now_point = new Point();
  89. //移动SEM到指定位置发生线程
  90. private Thread m_mythread;
  91. //记录线程是否已经运行完成的状态
  92. private bool m_mythread_state = false;
  93. private bool m_KeyDownControl = false;
  94. /// <summary>
  95. /// 当前正在显示的数据源名称,用来与框架调用条件判断使用
  96. /// </summary>
  97. public string ShowSourceName
  98. {
  99. set { m_showsourcename = value; }
  100. get { return m_showsourcename; }
  101. }
  102. /// <summary>
  103. /// 当前正在显示的数据源ID
  104. /// </summary>
  105. public int DataSourceID
  106. {
  107. set { m_datasourceid = value; }
  108. get { return m_datasourceid; }
  109. }
  110. /// <summary>
  111. /// 返回当前缩放的大小因数
  112. /// </summary>
  113. public float FZOOMRecord
  114. {
  115. get { return m_f_zoom_record; }
  116. set { m_f_zoom_record = value; }
  117. }
  118. //进度条窗体
  119. public Frm_UserProgress m_frm_userprogress;
  120. /// <summary>
  121. /// 是否显示过小颗粒
  122. /// </summary>
  123. public bool bShowSmallParticle = false;
  124. OTSSampleMeaInfo m_list_cgriddataclr = null;
  125. public OTSIncAReportApp.frmReportApp m_ReportApp;
  126. //国际化存储信息
  127. Hashtable table;
  128. ResultFile resultFile = null;
  129. #endregion
  130. #region 构造函数及窗体加载
  131. /// <summary>
  132. /// 排序图构造函数
  133. /// </summary>
  134. /// <param name="in_sec">传入,委托类对象</param>
  135. /// <param name="in_Cotsreportprojfilemgrclr">传入,项目管理类对象</param>
  136. /// <param name="in_cotsreportprojfileclr">传入,项目类对象</param>
  137. /// <param name="in_csmplmsrresultfilemgrclr">传入,文件管理类对象</param>
  138. /// <param name="in_csmplmsrresultfileclr">传入,文件类对象</param>
  139. public Control_DrawDistrbutionSortImage(OTSIncAReportApp.frmReportApp ReportApp)
  140. {
  141. m_list_baseobject = new List<BaseObject>();
  142. m_list_historyapolygon = new List<HistoryApolygon>();
  143. m_list_sortparticledistribution = new List<SortParticleDistribution>();
  144. m_old_list_sortparticledistribution = new List<SortParticleDistribution>();
  145. m_mythread_state = false;
  146. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  147. m_frm_userprogress = new Frm_UserProgress();
  148. m_ReportApp = ReportApp;
  149. resultFile = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult];
  150. //初始化底层操作类
  151. m_OTSIncAReportFun = new OTSIncAReportFun(this, resultFile);
  152. InitializeComponent();
  153. #region 国际化语言
  154. Language lan = new Language(this);
  155. table = lan.GetNameTable(this.Name);
  156. #endregion
  157. }
  158. private void Control_DrawDistrbutionSortImage_Load(object sender, EventArgs e)
  159. {
  160. //向父窗体注册键盘按键事件
  161. this.Parent.KeyDown += new KeyEventHandler(Control_DrawDistrbutionSortImage_KeyDown);
  162. this.Parent.KeyUp += new KeyEventHandler(Control_DrawDistrbutionSortImage_KeyUp);
  163. //设置鼠标为等待样式
  164. //m_sec.SendCall("设置鼠标样式", "", "WaitCursor");
  165. //显示进度条,计算进度条应该显示的位置和宽度
  166. Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
  167. m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
  168. m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 80, ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
  169. m_frm_userprogress.Show();
  170. m_frm_userprogress.SetProgressValueAndText(0, table["str1"].ToString());
  171. //调用填充排序图颗粒数据,总过程方法
  172. m_OTSIncAReportFun.GetDistrbutionSortImage_Total(m_ReportApp);
  173. //设置双缓冲
  174. SetDoubleBufferByIsDraw();
  175. //设置标尺
  176. //根据f_onepixel_size计算出要显示出100um的实际宽度
  177. double d_onefixel_width = 100 / m_f_onepixel_size;
  178. if (d_onefixel_width == 0)
  179. {
  180. this.control_Ruler1.Visible = false;
  181. }
  182. else
  183. {
  184. //将标尺定位到合理的位置上
  185. this.control_Ruler1.Location = new Point(10, MyPrimaryScreen.WorkingArea.Height - 300);
  186. this.control_Ruler1.Visible = true;
  187. this.control_Ruler1.SetValue(m_f_ruler_size, m_f_onepixel_size);
  188. }
  189. //加载时将背景rect设置与整个窗体一边大小
  190. m_backrectf = this.ClientRectangle; //该背景大小并未与实际获得像素的进行关联,这里注意一下,回头观察是否需要改进掉
  191. m_old_backrectf = m_backrectf;
  192. //进入时首先对XRayTable进行隐藏
  193. control_XRayTable1.Visible = false;
  194. //设置鼠标为默认
  195. //m_sec.SendCall("设置鼠标样式", "", "Default");
  196. m_frm_userprogress.SetProgressValueAndText(100, table["str2"].ToString());
  197. //加载完成,关闭进度条
  198. m_frm_userprogress.Close();
  199. }
  200. #endregion
  201. #region 获取数据及初始化数据等
  202. private void ClassifyDParticleGrid()
  203. {
  204. //-------------------这里开始对分布图的颗粒信息,位置大小等重新进行计算-----------------------------------------------------
  205. //初始化分栏的大小,及多少个分栏。
  206. //模拟数据,分别将<=1和>1 and <=2和 >2 and <=3的颗粒数据分成三组,进行显示
  207. SortParticleDistribution sortparticledistribution = new SortParticleDistribution();
  208. sortparticledistribution.RectF = new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, 800, this.ClientRectangle.Height);
  209. sortparticledistribution.ShowStr = "AAAA的颗粒[尺寸<=1的颗粒]";
  210. sortparticledistribution.Size_Min = 0;
  211. sortparticledistribution.Size_Max = 1;
  212. SortParticleDistribution sortparticledistribution2 = new SortParticleDistribution();
  213. sortparticledistribution2.RectF = new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, 800, this.ClientRectangle.Height);
  214. sortparticledistribution2.ShowStr = "BBBBB的颗粒[尺寸<2的颗粒]";
  215. sortparticledistribution2.Size_Min = 0;
  216. sortparticledistribution2.Size_Max = 1;
  217. SortParticleDistribution sortparticledistribution3 = new SortParticleDistribution();
  218. sortparticledistribution3.RectF = new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, 800, this.ClientRectangle.Height);
  219. sortparticledistribution3.ShowStr = "CCCCC的颗粒[尺寸<3的颗粒]";
  220. sortparticledistribution3.Size_Min = 0;
  221. sortparticledistribution3.Size_Max = 1;
  222. //筛选并进行装载
  223. foreach (DParticle ls_dp in m_list_baseobject)
  224. {
  225. if (ls_dp.Zoom_DisPlayMultiplier <= 1f)
  226. {
  227. DParticle sort_dp = ls_dp.Clone() as DParticle;
  228. sort_dp.Rect = sort_dp.GetRectFromDSegment();
  229. sortparticledistribution.List_DParticle.Add(sort_dp);
  230. }
  231. if (ls_dp.Zoom_DisPlayMultiplier > 1f && ls_dp.Zoom_DisPlayMultiplier <= 1.5f)
  232. {
  233. DParticle sort_dp = ls_dp.Clone() as DParticle;
  234. sort_dp.Rect = sort_dp.GetRectFromDSegment();
  235. sortparticledistribution2.List_DParticle.Add(sort_dp);
  236. }
  237. if (ls_dp.Zoom_DisPlayMultiplier > 1.5f && ls_dp.Zoom_DisPlayMultiplier <= 2f)
  238. {
  239. DParticle sort_dp = ls_dp.Clone() as DParticle;
  240. sort_dp.Rect = sort_dp.GetRectFromDSegment();
  241. sortparticledistribution3.List_DParticle.Add(sort_dp);
  242. }
  243. }
  244. //这里计算每个Grid所在的坐标位置,第二个跟在第一个y轴下面,第三个跟在第二个y轴下面,依此类推
  245. sortparticledistribution.RectF = new RectangleF(sortparticledistribution.RectF.X,
  246. sortparticledistribution.RectF.Y,
  247. sortparticledistribution.RectF.Width,
  248. sortparticledistribution.GetSortGridHeight());
  249. sortparticledistribution2.RectF = new RectangleF(sortparticledistribution2.RectF.X,
  250. sortparticledistribution.RectF.Y + sortparticledistribution.RectF.Height + sortparticledistribution2.RectF.Y - 10,/*-5是为了分栏边框不开缝*/
  251. sortparticledistribution2.RectF.Width,
  252. sortparticledistribution2.GetSortGridHeight());
  253. sortparticledistribution3.RectF = new RectangleF(sortparticledistribution3.RectF.X,
  254. sortparticledistribution2.RectF.Y + sortparticledistribution2.RectF.Height + sortparticledistribution3.RectF.Y - 10,
  255. sortparticledistribution3.RectF.Width,
  256. sortparticledistribution3.GetSortGridHeight());
  257. m_list_sortparticledistribution.Clear();
  258. m_old_list_sortparticledistribution.Clear();
  259. m_list_sortparticledistribution.Add(sortparticledistribution);
  260. m_list_sortparticledistribution.Add(sortparticledistribution2);
  261. m_list_sortparticledistribution.Add(sortparticledistribution3);
  262. //分类完成后,对颗粒重新进行摆放,包括重新计算里面的线,和计算里面多边形的外矩形,+号位置等
  263. sortparticledistribution.SortDParticle(m_f_zoom_record);
  264. sortparticledistribution2.SortDParticle(m_f_zoom_record);
  265. sortparticledistribution3.SortDParticle(m_f_zoom_record);
  266. //记录原值,从这里继续,clone未完成
  267. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  268. {
  269. SortParticleDistribution old_sortparticledistribution = ls_sortparticledistribution.Clone() as SortParticleDistribution;
  270. m_old_list_sortparticledistribution.Add(old_sortparticledistribution);
  271. foreach (DParticle ls_dp in old_sortparticledistribution.List_DParticle)
  272. {
  273. ls_dp.Rect = ls_dp.GetRectFromDSegment();
  274. }
  275. }
  276. //--------------------------------分类排序颗粒结束-----------------------------------------------------
  277. }
  278. /// <summary>
  279. /// 获取随机的颜色
  280. /// </summary>
  281. /// <returns></returns>
  282. public Color GetRandomColor()
  283. {
  284. int R = new Random((int)DateTime.Now.Ticks).Next(255);
  285. int G = new Random((int)DateTime.Now.Ticks).Next(255);
  286. int B = new Random((int)DateTime.Now.Ticks).Next(255);
  287. B = (R + G > 400) ? R + G - 400 : B;//0 : 380 - R - G;
  288. B = (B > 255) ? 255 : B;
  289. return Color.FromArgb(R, G, B);
  290. }
  291. /// <summary>
  292. /// 随机获取一个多边形
  293. /// </summary>
  294. /// <param name="x"></param>
  295. /// <param name="y"></param>
  296. /// <param name="width"></param>
  297. /// <param name="height"></param>
  298. /// <returns></returns>
  299. public DParticle GetRondemDParticle(int x, int y, int width, int height, int r)
  300. {
  301. DParticle ls_dp = new DParticle();
  302. for (int i = 0; i < height; i++)
  303. {
  304. DSegment ls_ds = new DSegment();
  305. ls_ds.Color = GetRandomColor();
  306. //随机生成x坐标偏移,和宽度
  307. Random rd = new Random((int)DateTime.Now.Ticks);
  308. int a = rd.Next(1);
  309. if (a == 0)
  310. {
  311. int n = rd.Next(r);
  312. x = x + n;
  313. width = width + n;
  314. }
  315. else
  316. {
  317. int n = rd.Next(r);
  318. x = -+n;
  319. width = width - n;
  320. }
  321. ls_ds.Rect = new Rectangle(x, y + i, width, 1);//高度是1的线段
  322. ls_dp.DSegments.Add(ls_ds);
  323. }
  324. return ls_dp;
  325. }
  326. #endregion
  327. #region 设置双缓冲
  328. /// <summary>
  329. /// 设置双缓冲
  330. /// </summary>
  331. public void SetDoubleBufferByIsDraw()
  332. {
  333. SetStyle(ControlStyles.UserPaint, true);
  334. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  335. this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 双缓冲
  336. SetStyle(ControlStyles.UserMouse, true);//执行自己的鼠标行为,这个打开后,在win7下鼠标操作明显改善
  337. }
  338. #endregion
  339. #region 绘制函数
  340. protected override void OnPaint(PaintEventArgs e)//处理重绘情况
  341. {
  342. #region //填充个背景色矩形-----------------------------------------------
  343. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  344. {
  345. SolidBrush b = new SolidBrush(Color.White);
  346. e.Graphics.FillRectangle(b, ls_sortparticledistribution.RectF);
  347. //绘制矩形的外边框
  348. ControlPaint.DrawBorder(e.Graphics, Rectangle.Round(ls_sortparticledistribution.RectF),
  349. m_c_ColumnRectangleColor,
  350. 3,
  351. ButtonBorderStyle.Solid,
  352. m_c_ColumnRectangleColor,
  353. 3,
  354. ButtonBorderStyle.Solid,
  355. m_c_ColumnRectangleColor,
  356. 3,
  357. ButtonBorderStyle.Solid,
  358. m_c_ColumnRectangleColor,
  359. 3,
  360. ButtonBorderStyle.Solid);
  361. }
  362. #endregion
  363. #region //计算并进行绘制部份------------------------------------
  364. //绘制完缩放的图形后,将基数变回,否则会一直刷新无限变大变小
  365. if (m_f_widthandheight_js != 0)
  366. {
  367. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  368. {
  369. //缩放完成,重新计算颗粒的矩形,和边缘路径,这里应该写成,判断 如果有进行了缩放的操作后,再进行重新的计算
  370. foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
  371. {
  372. DParticle dp = (DParticle)item;
  373. //获取矩形的rectangle
  374. dp.Rect = dp.GetRectFromDSegment();
  375. //通过line获取路径边缘
  376. dp.GPath = dp.GetRegionFromDSegments();
  377. //重新计算小矩形边框
  378. dp.SmallRect = dp.GetSmallRectangleFromRect();
  379. }
  380. }
  381. m_f_widthandheight_js = 0;
  382. }
  383. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  384. {
  385. //开始向下传递并进行绘制
  386. foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
  387. {
  388. DParticle dp = (DParticle)item;
  389. if (dp.Operator != ParticleOperator.DELETED)
  390. item.OnPaint(e);
  391. }
  392. }
  393. #endregion
  394. #region //判断是否使用了矩形或圆形工具进行多选,是的话,那么这里就开始绘制------------------------
  395. if (true == m_is_multiselect_onpaint)
  396. {
  397. if (true == m_is_multiselect_rectangle && m_multiselect_rect.Width > 0 && m_multiselect_rect.Height > 0)
  398. {
  399. Graphics g = e.Graphics;
  400. //绘制矩形
  401. g.DrawRectangle(new Pen(Color.Blue), m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
  402. //半透明画刷
  403. SolidBrush brush = new SolidBrush(Color.FromArgb(50, Color.SkyBlue));
  404. //填充选择矩形
  405. g.FillRectangle(brush, m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
  406. }
  407. if (true == m_is_multiselect_ellipse && m_multiselect_rect.Width > 0 && m_multiselect_rect.Height > 0)
  408. {
  409. Graphics g = e.Graphics;
  410. //绘制圆形
  411. g.DrawEllipse(new Pen(Color.Blue), m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
  412. //半透明画刷
  413. SolidBrush brush = new SolidBrush(Color.FromArgb(50, Color.SkyBlue));
  414. //填充选择圆形
  415. g.FillEllipse(brush, m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
  416. }
  417. }
  418. #endregion
  419. #region 分栏Grid的标签文本透明文字实现
  420. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  421. {
  422. SolidBrush b = new SolidBrush(Color.White);
  423. string str_show = ls_sortparticledistribution.ShowStr;
  424. SizeF sif = e.Graphics.MeasureString(str_show, new Font("宋体", 9));
  425. e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(125, m_c_ColumnRectangleColor)), ls_sortparticledistribution.RectF.X + ls_sortparticledistribution.RectF.Width - sif.Width - 3, ls_sortparticledistribution.RectF.Y, sif.Width, sif.Height + 3);
  426. e.Graphics.DrawString(str_show, new Font("宋体", 9), new SolidBrush(Color.Black), ls_sortparticledistribution.RectF.X + ls_sortparticledistribution.RectF.Width - sif.Width - 3, ls_sortparticledistribution.RectF.Y + 3);
  427. }
  428. #endregion
  429. }
  430. #endregion
  431. #region 鼠标操作相关事件
  432. protected override void OnMouseWheel(MouseEventArgs e)
  433. {
  434. //实现直接滚动,进行拖动,按下ctrl进行滚动,是缩放
  435. if (e.Delta > 0)
  436. {
  437. if (m_KeyDownControl == false)
  438. {
  439. OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y, e.Delta));
  440. OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y, e.Delta));
  441. OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y + 30, e.Delta));
  442. OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y, e.Delta));
  443. }
  444. else
  445. {
  446. if (m_f_zoom_record <= m_f_zoom_max)
  447. {
  448. //放大
  449. ZoomIn();
  450. }
  451. }
  452. }
  453. else
  454. {
  455. if (m_KeyDownControl == false)
  456. {
  457. OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y, e.Delta));
  458. OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y, e.Delta));
  459. OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y - 30, e.Delta));
  460. OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, e.X, e.Y, e.Delta));
  461. }
  462. else
  463. {
  464. if (m_f_zoom_record >= m_f_zoom_mix)
  465. {
  466. //缩小
  467. ZoomOut();
  468. }
  469. }
  470. }
  471. Invalidate();
  472. }
  473. /// <summary>
  474. /// 放大
  475. /// </summary>
  476. private void ZoomIn()
  477. {
  478. #region //图形缩放计算部份-------放大------------//是放大
  479. m_f_widthandheight_js = m_f_zoom_increment;
  480. for (int x = 0; x < m_list_sortparticledistribution.Count(); x++)
  481. {
  482. SortParticleDistribution ls_sortparticledistribution = m_list_sortparticledistribution[x];
  483. SortParticleDistribution old_ls_sortparticledstribution = m_old_list_sortparticledistribution[x];
  484. //先计算Grid的背景矩形
  485. ls_sortparticledistribution.RectF = new RectangleF(ls_sortparticledistribution.RectF.X + old_ls_sortparticledstribution.RectF.X * m_f_zoom_increment,
  486. ls_sortparticledistribution.RectF.Y + old_ls_sortparticledstribution.RectF.Y * m_f_zoom_increment,
  487. ls_sortparticledistribution.RectF.Width + Convert.ToInt32(old_ls_sortparticledstribution.RectF.Width * m_f_zoom_increment),
  488. ls_sortparticledistribution.RectF.Height + Convert.ToInt32(old_ls_sortparticledstribution.RectF.Height * m_f_zoom_increment));
  489. for (int y = 0; y < ls_sortparticledistribution.List_DParticle.Count(); y++)
  490. {
  491. DParticle ls_dp = ls_sortparticledistribution.List_DParticle[y];
  492. DParticle old_ls_dp = m_old_list_sortparticledistribution[x].List_DParticle[y];
  493. for (int z = 0; z < ls_dp.DSegments.Count(); z++)
  494. {
  495. DSegment ds = ls_dp.DSegments[z];
  496. DSegment old_ds = old_ls_dp.DSegments[z];
  497. ds.PenWidthAndHeight = ds.PenWidthAndHeight + old_ds.PenWidthAndHeight
  498. * m_f_zoom_increment;
  499. ds.Rect = new RectangleF(ds.Rect.X + old_ds.Rect.X * m_f_zoom_increment, ds.Rect.Y + old_ds.Rect.Y * m_f_zoom_increment,
  500. ds.Rect.Width + old_ds.Rect.Width * m_f_zoom_increment, ds.Rect.Height + old_ds.Rect.Height * m_f_zoom_increment);
  501. }
  502. //设置缩放到多少倍时进行显示
  503. if (ls_dp.Zoom_DisPlayMultiplier <= m_f_zoom_record)
  504. {
  505. ls_dp.Zoom_DisPlay = true;
  506. }
  507. else
  508. {
  509. ls_dp.Zoom_DisPlay = false;
  510. }
  511. }
  512. }
  513. m_f_zoom_record = m_f_zoom_record + m_f_zoom_increment;
  514. m_f_zoom_record = float.Parse(m_f_zoom_record.ToString("#0.0")); //四舍五入,保留一位小数,如果不这样,float会不附合规则
  515. #endregion
  516. #region 计算标尺尺寸部份-----放大------
  517. m_f_ruler_size = m_f_ruler_size + Convert.ToInt32(m_f_old_ruler_size * m_f_zoom_increment);
  518. control_Ruler1.SetValue(m_f_ruler_size, m_f_onepixel_size);
  519. #endregion
  520. }
  521. /// <summary>
  522. /// 缩小
  523. /// </summary>
  524. private void ZoomOut()
  525. {
  526. #region //图形缩放计算部份------缩小--------------------
  527. m_f_widthandheight_js = -m_f_zoom_increment;
  528. for (int x = 0; x < m_list_sortparticledistribution.Count(); x++)
  529. {
  530. SortParticleDistribution ls_sortparticledistribution = m_list_sortparticledistribution[x];
  531. SortParticleDistribution old_ls_sortparticledistribution = m_old_list_sortparticledistribution[x];
  532. //先计算Grid的背景矩形
  533. ls_sortparticledistribution.RectF = new RectangleF(ls_sortparticledistribution.RectF.X + old_ls_sortparticledistribution.RectF.X * -m_f_zoom_increment,
  534. ls_sortparticledistribution.RectF.Y + old_ls_sortparticledistribution.RectF.Y * -m_f_zoom_increment,
  535. ls_sortparticledistribution.RectF.Width + Convert.ToInt32(old_ls_sortparticledistribution.RectF.Width * -m_f_zoom_increment),
  536. ls_sortparticledistribution.RectF.Height + Convert.ToInt32(old_ls_sortparticledistribution.RectF.Height * -m_f_zoom_increment));
  537. for (int y = 0; y < ls_sortparticledistribution.List_DParticle.Count(); y++)
  538. {
  539. DParticle ls_dp = ls_sortparticledistribution.List_DParticle[y];
  540. DParticle old_ls_dp = m_old_list_sortparticledistribution[x].List_DParticle[y];
  541. for (int z = 0; z < ls_dp.DSegments.Count(); z++)
  542. {
  543. DSegment ds = ls_dp.DSegments[z];
  544. DSegment old_ds = old_ls_dp.DSegments[z];
  545. ds.PenWidthAndHeight = ds.PenWidthAndHeight + old_ds.PenWidthAndHeight
  546. * -m_f_zoom_increment;
  547. ds.Rect = new RectangleF(ds.Rect.X + old_ds.Rect.X * -m_f_zoom_increment, ds.Rect.Y + old_ds.Rect.Y * -m_f_zoom_increment,
  548. ds.Rect.Width + old_ds.Rect.Width * -m_f_zoom_increment, ds.Rect.Height + old_ds.Rect.Height * -m_f_zoom_increment);
  549. }
  550. //设置缩放到多少倍时进行显示
  551. if (ls_dp.Zoom_DisPlayMultiplier <= m_f_zoom_record)
  552. {
  553. ls_dp.Zoom_DisPlay = true;
  554. }
  555. else
  556. {
  557. ls_dp.Zoom_DisPlay = false;
  558. }
  559. }
  560. }
  561. m_f_zoom_record = m_f_zoom_record - m_f_zoom_increment;
  562. m_f_zoom_record = float.Parse(m_f_zoom_record.ToString("#0.0")); //四舍五入,保留一位小数,如果不这样,float会不附合规则
  563. #endregion
  564. #region 计算标尺尺寸部份-----缩小------f_onepixel_size,是不是该乘以rulerwidth是实际的长度
  565. m_f_ruler_size = m_f_ruler_size + Convert.ToInt32(m_f_old_ruler_size * -m_f_zoom_increment);
  566. control_Ruler1.SetValue(m_f_ruler_size, m_f_onepixel_size);
  567. #endregion
  568. }
  569. private void Control_DrawDistrbutionSortImage_KeyDown(object sender, KeyEventArgs e)
  570. {
  571. //判断是否按下了ctrl键
  572. if (e.KeyCode == Keys.ControlKey)
  573. {
  574. m_KeyDownControl = true;
  575. }
  576. }
  577. private void Control_DrawDistrbutionSortImage_KeyUp(object sender, KeyEventArgs e)
  578. {
  579. //判断是否按下了ctrl键
  580. if (e.KeyCode == Keys.ControlKey)
  581. {
  582. m_KeyDownControl = false;
  583. }
  584. }
  585. protected override void OnMouseDown(MouseEventArgs e)
  586. {
  587. if (e.Button == MouseButtons.Left)
  588. {
  589. this.Cursor = Cursors.Hand;
  590. //是否可以按矩形进行选取,如果选择了矩形或圆形多选后
  591. if (true == m_is_multiselect_rectangle || true == m_is_multiselect_ellipse)
  592. {
  593. m_multiselect_rect.Width = 0;
  594. m_multiselect_rect.Height = 0;
  595. m_is_multiselect_onpaint = true;
  596. m_beforemultiselect_point = e.Location;
  597. }
  598. //在进行多选时,不让其拖动
  599. if (false == m_is_multiselect_onpaint)
  600. {
  601. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  602. {
  603. foreach (DParticle ls_dp in ls_sortparticledistribution.List_DParticle)
  604. {
  605. ls_dp.IsDragging = true;
  606. ls_dp.DraggingPoint = e.Location;
  607. }
  608. }
  609. }
  610. m_isDrag = true;
  611. m_beforedrag_pointf = e.Location;
  612. }
  613. Invalidate();
  614. }
  615. protected override void OnMouseUp(MouseEventArgs e)
  616. {
  617. if (e.Button == MouseButtons.Left)
  618. {
  619. this.Cursor = Cursors.Default;
  620. //还原多选变量
  621. if (true == m_is_multiselect_onpaint)
  622. {
  623. //首先清除掉所有已经选择的项
  624. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  625. {
  626. foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
  627. {
  628. if (dp.Operator == ParticleOperator.SELECTED)
  629. {
  630. dp.Operator = ParticleOperator.DISPLAY;
  631. }
  632. }
  633. }
  634. //然后在这里判断都有哪些颗粒所有的point点,是否在选取的图形graphicsPath闭合路径中
  635. //首先先将选取的图形填充成graphicsPath
  636. if (m_multiselect_rect.Width > 0 && m_multiselect_rect.Height > 0)
  637. {
  638. GraphicsPath ls_gpath = new GraphicsPath();
  639. ls_gpath.AddRectangle(m_multiselect_rect);
  640. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  641. {
  642. foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
  643. {
  644. if (dp.Operator != ParticleOperator.NODISPLAY && dp.Operator != ParticleOperator.DELETED)//不显示的和删除状态的不让进行选择
  645. {
  646. PointF[] lspointf = dp.GPath.PathPoints;
  647. for (int i = 0; i < lspointf.Count(); i++)
  648. {
  649. if (true == WhetherInRange(ls_gpath.PathPoints, lspointf[i]))
  650. {
  651. //选择到了该路径,那么就选取该图像
  652. dp.Operator = ParticleOperator.SELECTED;
  653. }
  654. }
  655. }
  656. }
  657. }
  658. }
  659. //这里恢复默认值
  660. m_multiselect_rect.Width = 0;
  661. m_multiselect_rect.Height = 0;
  662. m_is_multiselect_onpaint = false;
  663. m_is_multiselect_ellipse = false;
  664. m_is_multiselect_rectangle = false;
  665. //将排列图选择的颗粒传送给报告框架中
  666. SelectParticleListSendToReportFrame();
  667. }
  668. //在进行多选时,不让其拖动
  669. if (false == m_is_multiselect_onpaint)
  670. {
  671. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  672. {
  673. foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
  674. {
  675. if (true == item.IsDragging)
  676. {
  677. item.IsSelect = false;
  678. item.IsDragging = false;
  679. item.DraggingPoint = Point.Empty;
  680. }
  681. }
  682. }
  683. m_isDrag = false;
  684. //在颗粒上点击,则对该颗粒附加显示x-ray的状态,同时将其它颗粒上显示x-ray的状态全部去掉。
  685. if (false == m_isDrag)
  686. {
  687. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  688. {
  689. foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
  690. {
  691. PointF[] lspointf = dp.GPath.PathPoints;
  692. if (true == WhetherInRange(lspointf, new Point(e.X, e.Y)))
  693. {
  694. //选择到了该路径,那么就选取该图像b
  695. dp.Operator_ShowXRay = ParticleOperatorShowXray.SELECTANDDISPLAYXRAY;
  696. }
  697. else
  698. {
  699. dp.Operator_ShowXRay = ParticleOperatorShowXray.NODISPLAY;
  700. }
  701. }
  702. }
  703. }
  704. }
  705. }
  706. //右键菜单控件
  707. CMenuStrip.Items[0].Tag = "";
  708. CMenuStrip.Items[0].Enabled = false;
  709. CMenuStrip.Items[1].Tag = "";
  710. CMenuStrip.Items[1].Enabled = false;
  711. CMenuStrip.Items[2].Tag = "";
  712. CMenuStrip.Items[2].Enabled = false;
  713. CMenuStrip.Items[3].Tag = "";
  714. CMenuStrip.Items[3].Enabled = false;
  715. CMenuStrip.Items[4].Tag = "";
  716. CMenuStrip.Items[4].Enabled = false;
  717. if (e.Button == MouseButtons.Right)
  718. {
  719. //这个判断右键菜单加在这里,也不知道对不对
  720. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  721. {
  722. foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
  723. {
  724. if (true == WhetherInRange(item.GPath.PathPoints, e.Location))
  725. {
  726. DParticle dp = (DParticle)item;
  727. if (dp.Operator == ParticleOperator.DISPLAY || dp.Operator == ParticleOperator.SELECTED)
  728. {
  729. CMenuStrip.Items[0].Enabled = true;
  730. CMenuStrip.Items[0].Tag = dp;
  731. CMenuStrip.Items[1].Enabled = true;
  732. if (dp.Operator == ParticleOperator.SELECTED)
  733. {
  734. CMenuStrip.Items[1].Text = "取消颗粒选择";
  735. }
  736. else
  737. {
  738. CMenuStrip.Items[1].Text = "选择颗粒";
  739. }
  740. CMenuStrip.Items[2].Enabled = true;
  741. CMenuStrip.Items[3].Enabled = true;
  742. //线程未执行完成,则不让再进行选择,右键移动到SEM位置的菜单选项
  743. if (m_mythread_state == false)
  744. CMenuStrip.Items[4].Enabled = true;
  745. else
  746. CMenuStrip.Items[4].Enabled = false;
  747. ////获取当前颗粒的OTS坐标
  748. //Point ls_otspoint = m_OTSIncAReportFun.GetOTSPointFromOld_list_sortparticledistribution(dp.CLRFieldID, dp.CLRTagID, this);
  749. ////再将该OTS坐标转成SEM坐标
  750. //Point ls_sempoint = m_OTSIncAReportFun.ChangeOTSToSemCoord(ls_otspoint);
  751. //m_sem_mouse_now_point = ls_sempoint;
  752. ////当移动到某个颗粒后,在屏幕右下角应该显示的是该颗粒的SEM坐标,而不显示鼠标位置
  753. //m_str_mouseshow_left = "视域位置:" + ls_sempoint.X.ToString() + ":" + ls_sempoint.Y.ToString();
  754. m_sem_mouse_now_point = new Point(dp.SEMPosX, dp.SEMPosY);
  755. m_str_mouseshow_left = "颗粒SEM位置:" + dp.SEMPosX.ToString() + ":" + dp.SEMPosY.ToString();
  756. //获取颜色方法1,使用API来获取当前鼠标指向位置的颜色值-------------------------------------------
  757. Graphics g = Graphics.FromHwnd(this.Handle);
  758. IntPtr hdc = g.GetHdc();
  759. uint u_color = 0;
  760. try
  761. {
  762. u_color = DrawFuncation.GetPixel(hdc, e.X, e.Y);
  763. }
  764. catch
  765. { }
  766. Color ls_c = Color.FromArgb
  767. (
  768. (int)(u_color << 24 >> 24),
  769. (int)(u_color << 16 >> 24),
  770. (int)(u_color << 8 >> 24)
  771. );
  772. m_str_mouseshow_right = "灰度#" + ls_c.R.ToString();
  773. // 这里发送消息
  774. m_ReportApp.mouseMatter.Text = m_str_mouseshow_right;
  775. m_ReportApp.RSGrayVal.Text = m_str_mouseshow_left;
  776. }
  777. }
  778. }
  779. }
  780. }
  781. Invalidate();
  782. }
  783. protected override void OnMouseMove(MouseEventArgs e)
  784. {
  785. //如果是进行多选的话
  786. if (true == m_is_multiselect_onpaint)
  787. {
  788. if (e.Location.X > m_beforemultiselect_point.X && e.Location.Y > m_beforemultiselect_point.Y)
  789. {
  790. //右下拖动
  791. m_multiselect_rect = new RectangleF(m_beforemultiselect_point, new SizeF(e.Location.X - m_beforemultiselect_point.X, e.Location.Y - m_beforemultiselect_point.Y));
  792. }
  793. if (e.Location.X < m_beforemultiselect_point.X && e.Location.Y < m_beforemultiselect_point.Y)
  794. {
  795. //左上拖动
  796. PointF lspointf = new PointF(e.Location.X, e.Location.Y);
  797. m_multiselect_rect = new RectangleF(lspointf, new SizeF(m_beforemultiselect_point.X - e.Location.X, m_beforemultiselect_point.Y - e.Location.Y));
  798. }
  799. if (e.Location.X > m_beforemultiselect_point.X && e.Location.Y < m_beforemultiselect_point.Y)
  800. {
  801. //右上,这种画法,需要将左下,右上两点转换成左上,右下
  802. PointF left_pointf = new PointF(m_beforemultiselect_point.X, e.Location.Y);
  803. PointF right_pointf = new PointF(e.Location.X, m_beforemultiselect_point.Y);
  804. m_multiselect_rect = new RectangleF(left_pointf, new SizeF(right_pointf.X - left_pointf.X, right_pointf.Y - left_pointf.Y));
  805. }
  806. if (e.Location.X < m_beforemultiselect_point.X && e.Location.Y > m_beforemultiselect_point.Y)
  807. {
  808. //左下,这种画法,需要将左下,右上两点转换成左上,右下
  809. PointF left_pointf = new PointF(e.Location.X, m_beforemultiselect_point.Y);
  810. PointF right_pointf = new PointF(m_beforemultiselect_point.X, e.Location.Y);
  811. m_multiselect_rect = new RectangleF(left_pointf, new SizeF(right_pointf.X - left_pointf.X, right_pointf.Y - left_pointf.Y));
  812. }
  813. }
  814. //判断没有在进行多选状态时,在进行多选时,不让其拖动
  815. if (false == m_is_multiselect_onpaint)
  816. {
  817. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  818. {
  819. foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
  820. {
  821. DParticle dp = (DParticle)item;
  822. //在计算前,先重新对颗粒的边缘进行计算,防止错误
  823. dp.GPath = dp.GetRegionFromDSegments();
  824. if (true == WhetherInRange(dp.GPath.PathPoints, e.Location))
  825. {
  826. if (dp.Operator == ParticleOperator.DISPLAY)
  827. {
  828. dp.IsMouseMove = true;
  829. //显示xray图
  830. if (control_XRayTable1.Visible == false)
  831. ShowXRay(dp);
  832. }
  833. }
  834. else
  835. {
  836. dp.IsMouseMove = false;
  837. //移动在颗粒外面时,要判断,Operator_ShowXray不为选下显示XRAY时,才对XRay进行隐藏
  838. if (dp.Operator_ShowXRay != ParticleOperatorShowXray.SELECTANDDISPLAYXRAY)
  839. {
  840. //隐藏x-ray能谱图
  841. HideXRay(dp);
  842. }
  843. }
  844. if (true == item.IsDragging)
  845. {
  846. //再将里面的线也进行计算坐标
  847. foreach (DSegment ds in dp.DSegments)
  848. {
  849. ds.Rect = new RectangleF(
  850. ds.Rect.X + e.X - item.DraggingPoint.X, //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
  851. ds.Rect.Y + e.Y - item.DraggingPoint.Y,
  852. ds.Rect.Width,
  853. ds.Rect.Height);
  854. ds.DraggingPoint = e.Location;
  855. }
  856. item.DraggingPoint = e.Location;
  857. //获取矩形的rectangle
  858. dp.Rect = dp.GetRectFromDSegment();
  859. //通过line获取路径边缘
  860. dp.GPath = dp.GetRegionFromDSegments();
  861. //重新计算小矩形边框
  862. dp.SmallRect = dp.GetSmallRectangleFromRect();
  863. }
  864. }
  865. }
  866. //如果在拖动中
  867. if (true == m_isDrag)
  868. {
  869. //同样重新计算backrectf的坐标
  870. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  871. {
  872. ls_sortparticledistribution.RectF = new RectangleF(ls_sortparticledistribution.RectF.Location.X + e.X - m_beforedrag_pointf.X,
  873. ls_sortparticledistribution.RectF.Location.Y + e.Y - m_beforedrag_pointf.Y, ls_sortparticledistribution.RectF.Width, ls_sortparticledistribution.RectF.Height);
  874. }
  875. m_beforedrag_pointf = e.Location;
  876. }
  877. }
  878. #region 向报告程序右下角,传送鼠标颗粒等相关信息
  879. //然后这里还要将鼠标移动经过的过程,传输给reportapp中,为了能让reportapp能显示出来
  880. //如果前面鼠标没有移动到颗粒的位置上,str_mouseshow_left=="",所以再取显示鼠标的位置信息
  881. m_str_mouseshow_left = "无";
  882. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  883. {
  884. foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
  885. {
  886. DParticle dp = (DParticle)item;
  887. if (true == WhetherInRange(dp.GPath.PathPoints, e.Location))
  888. {
  889. if (dp.Operator == ParticleOperator.DISPLAY)
  890. {
  891. ////获取当前颗粒的OTS坐标
  892. //Point ls_otspoint = m_OTSIncAReportFun.GetOTSPointFromOld_list_sortparticledistribution(dp.CLRFieldID, dp.CLRTagID, this);
  893. ////再将该OTS坐标转成SEM坐标
  894. //Point ls_sempoint = m_OTSIncAReportFun.ChangeOTSToSemCoord(ls_otspoint);
  895. //m_sem_mouse_now_point = ls_sempoint;
  896. ////当移动到某个颗粒后,在屏幕右下角应该显示的是该颗粒的SEM坐标,而不显示鼠标位置
  897. //m_str_mouseshow_left = "视域位置:" + ls_sempoint.X.ToString() + ":" + ls_sempoint.Y.ToString();
  898. m_sem_mouse_now_point = new Point(dp.SEMPosX, dp.SEMPosY);
  899. m_str_mouseshow_left = "颗粒SEM位置:" + dp.SEMPosX.ToString() + ":" + dp.SEMPosY.ToString();
  900. }
  901. }
  902. }
  903. }
  904. //获取颜色方法1,使用API来获取当前鼠标指向位置的颜色值-------------------------------------------
  905. Graphics g = Graphics.FromHwnd(this.Handle);
  906. IntPtr hdc = g.GetHdc();
  907. uint u_color = 0;
  908. try
  909. {
  910. u_color = DrawFuncation.GetPixel(hdc, e.X, e.Y);
  911. }
  912. catch
  913. { }
  914. Color ls_c = Color.FromArgb
  915. (
  916. (int)(u_color << 24 >> 24),
  917. (int)(u_color << 16 >> 24),
  918. (int)(u_color << 8 >> 24)
  919. );
  920. m_str_mouseshow_right = "灰度#" + ls_c.R.ToString();
  921. // 这里发送消息
  922. m_ReportApp.mouseMatter.Text = m_str_mouseshow_right;
  923. m_ReportApp.RSGrayVal.Text = m_str_mouseshow_left;
  924. #endregion
  925. Invalidate();
  926. }
  927. #endregion
  928. #region 自定义功能函数
  929. /// <summary>
  930. /// 复制图像
  931. /// </summary>
  932. private void CopyImage()
  933. {
  934. int height, width;
  935. width = this.Width;
  936. height = this.Height;
  937. Bitmap image = new Bitmap(width, height);
  938. this.DrawToBitmap(image, new Rectangle(0, 0, width, height));
  939. Clipboard.SetImage(image);
  940. }
  941. /// <summary>
  942. /// 移动SEM到指定位置线程函数
  943. /// </summary>
  944. private void Thread_GO(object in_obj)
  945. {
  946. if (m_mythread_state == false)
  947. {
  948. m_mythread_state = true;
  949. Point sem_point = (Point)in_obj;
  950. //第一步,连接电镜
  951. m_OTSIncAReportFun.ConnectToSEM();
  952. Thread.Sleep(500);
  953. //第二步,移动到指定位置,先读取再设置
  954. if (m_OTSIncAReportFun.m_SEMConnectionState == true)
  955. {
  956. m_OTSIncAReportFun.MoveSemToPointXY(sem_point.X, sem_point.Y);
  957. }
  958. Thread.Sleep(1500);
  959. //第三步,断开电镜连接
  960. m_OTSIncAReportFun.DisConnectSEM();
  961. //Thread.Sleep(1000);
  962. m_mythread_state = false;
  963. }
  964. }
  965. /// <summary>
  966. /// 显示x-ray能谱图
  967. /// </summary>
  968. /// <param name="in_dparticle"></param>
  969. private void ShowXRay(DParticle in_dparticle)
  970. {
  971. //显示xray相关信息
  972. uint[] Search_xray = new uint[2000];
  973. uint[] Analysis_xray = new uint[2000];
  974. //
  975. int i_xray_id = 0;
  976. List<Element> list_celementchemistryclr = new List<Element>();
  977. //获取Xray数据
  978. m_OTSIncAReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(in_dparticle.CLRTagID, in_dparticle.CLRFieldID, out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
  979. //get CElementChemistryClr list
  980. List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
  981. for (int i = 0; i < list_celementchemistryclr.Count; i++)
  982. {
  983. ShowElementInfo ls_sei = new ShowElementInfo();
  984. ls_sei.ElementName = list_celementchemistryclr[i].Name;
  985. ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
  986. ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByYsm(CListPeriodic.GetListPeriodic(), ls_sei.ElementName).SX1);
  987. list_showelementinfo.Add(ls_sei);
  988. }
  989. //获取使用标准库的名称,也许这个也不是很正确??
  990. string str_stdname = "";
  991. string str_IncALibName = "";
  992. List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 9 };
  993. List<string> NameList = new List<string>() { "过小颗粒", "过大颗粒", "亮度不在分析范围内的颗粒", "低计数率颗粒", "不含分析元素的颗粒", "未识别颗粒" };
  994. if (in_dparticle.STDTypeID < 1000)
  995. {
  996. int index = FLID.IndexOf(in_dparticle.TypeId);
  997. if (index == -1)
  998. {
  999. index = 5;
  1000. }
  1001. //小于1000,使用系统默认分类
  1002. str_IncALibName = NameList[index];
  1003. str_stdname = "默认标准库";
  1004. }
  1005. else if (in_dparticle.STDTypeID >= 1000 && in_dparticle.STDTypeID < 10000)
  1006. {
  1007. //大于等于1000,并且小于10000时,使用系统数据库中夹杂物来分析
  1008. str_IncALibName = in_dparticle.TypeName;
  1009. str_stdname = "用户定义标准库";
  1010. }
  1011. else if (in_dparticle.STDTypeID > 10000)
  1012. {
  1013. //大于10000时,使用用户标准库来分析夹杂物名称
  1014. str_IncALibName = in_dparticle.TypeName;
  1015. if (str_stdname == "")
  1016. str_stdname = "系统标准库";
  1017. }
  1018. //获取数据后,需要对xraytable设置
  1019. control_XRayTable1.Visible = false;
  1020. control_XRayTable1.SetXRayShowLineValue(Search_xray, Analysis_xray, list_showelementinfo);
  1021. //control_XRayTable1.GoodName = str_IncALibName + "(" + in_dparticle.STDTypeID.ToString() + ")";//杂夹物
  1022. control_XRayTable1.GoodName = str_IncALibName;//杂夹物
  1023. control_XRayTable1.STDName = str_stdname;//标准库
  1024. control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
  1025. control_XRayTable1.Visible = true;
  1026. //将显示xray的dparticle记录给全局变量
  1027. m_move_dparticle = in_dparticle;
  1028. this.Refresh();
  1029. }
  1030. /// <summary>
  1031. /// 隐藏x-ray能谱图
  1032. /// </summary>
  1033. private void HideXRay(DParticle in_dparticle)
  1034. {
  1035. if (m_move_dparticle == null)
  1036. return;
  1037. else if (m_move_dparticle.ID == in_dparticle.ID)
  1038. {
  1039. //如果是刚才移动过的颗粒的话,那么这里再对xray进行隐藏
  1040. control_XRayTable1.Visible = false;
  1041. }
  1042. }
  1043. /// <summary>
  1044. /// 封装,将排列图中的颗粒list传送给报告项目框架中
  1045. /// </summary>
  1046. private void SelectParticleListSendToReportFrame()
  1047. {
  1048. //先获取排列图中,有哪些颗粒已经被选择上了
  1049. m_ReportApp.SelectedParticles = m_OTSIncAReportFun.GetSelectedParticleList_ForDrawDistrbutionSortImage();
  1050. }
  1051. /// <summary>
  1052. /// 设置当前对哪些颗粒进行设置为选择状态
  1053. /// </summary>
  1054. /// <param name="in_list_cotsparticleclr"></param>
  1055. public void SetSelectParticle(List<Particle> in_list_cotsparticleclr)
  1056. {
  1057. if (in_list_cotsparticleclr == null)
  1058. {
  1059. return;
  1060. }
  1061. if (in_list_cotsparticleclr.Count == 0)
  1062. {
  1063. return;
  1064. }
  1065. foreach (SortParticleDistribution spd in m_list_sortparticledistribution)
  1066. {
  1067. foreach (DParticle ls_dp in spd.List_DParticle)
  1068. {
  1069. //只有显示状态,才可以切换到选择状态,考虑可能会出现如果在条件选择成不显示状态下,如果被选择了,是不是就强制切换成了选择状态
  1070. if (ls_dp.Operator == ParticleOperator.DISPLAY)
  1071. {
  1072. for (int i = 0; i < in_list_cotsparticleclr.Count; i++)
  1073. {
  1074. if (in_list_cotsparticleclr[i].ParticleId == ls_dp.CLRTagID
  1075. && in_list_cotsparticleclr[i].FieldId == ls_dp.CLRFieldID)
  1076. {
  1077. ls_dp.Operator = ParticleOperator.SELECTED;
  1078. }
  1079. }
  1080. }
  1081. }
  1082. }
  1083. }
  1084. /// <summary>
  1085. /// 按框架传入的底层计算结果,重新对颗粒进行区分显示
  1086. /// </summary>
  1087. /// <param name="in_cgriddataclr"></param>
  1088. public void Control_DrawDistrbutionSortImage_ByQuery(OTSIncAReportApp.OTSSampleReportInfo.OTSSampleMeaInfo in_list_cgriddataclr)
  1089. {
  1090. m_list_cgriddataclr = in_list_cgriddataclr;
  1091. m_OTSIncAReportFun.GetDistrbutionSortimage_ByQuery(in_list_cgriddataclr);
  1092. }
  1093. /// <summary>
  1094. /// 判断该点是否在多边形的范围内
  1095. /// </summary>
  1096. /// <param name="inPoints"></param>
  1097. /// <param name="WhetherPoint"></param>
  1098. /// <returns></returns>
  1099. private bool WhetherInRange(PointF[] inPoints, Point WhetherPoint)
  1100. {
  1101. bool b_inrange = false;
  1102. GraphicsPath myGraphicsPath = new GraphicsPath();
  1103. Region myRegion = new Region();
  1104. myGraphicsPath.Reset();
  1105. myGraphicsPath.AddPolygon(inPoints);
  1106. myRegion.MakeEmpty();
  1107. myRegion.Union(myGraphicsPath);
  1108. //返回判断点是否在多边形里
  1109. b_inrange = myRegion.IsVisible(WhetherPoint);
  1110. return b_inrange;
  1111. }
  1112. /// <summary>
  1113. /// 判断该点是否在多边形的范围内的float版本重载
  1114. /// </summary>
  1115. /// <param name="inPoints"></param>
  1116. /// <param name="WhetherPoint"></param>
  1117. /// <returns></returns>
  1118. private bool WhetherInRange(PointF[] inPoints, PointF WhetherPoint)
  1119. {
  1120. bool b_inrange = false;
  1121. GraphicsPath myGraphicsPath = new GraphicsPath();
  1122. Region myRegion = new Region();
  1123. myGraphicsPath.Reset();
  1124. myGraphicsPath.AddPolygon(inPoints);
  1125. myRegion.MakeEmpty();
  1126. myRegion.Union(myGraphicsPath);
  1127. //返回判断点是否在多边形里
  1128. b_inrange = myRegion.IsVisible(WhetherPoint);
  1129. return b_inrange;
  1130. }
  1131. /// <summary>
  1132. /// 重做删除
  1133. /// </summary>
  1134. public void ReDo()
  1135. {
  1136. //如果已经是最后一条了,那么不可以再进行重做操作
  1137. if (m_list_historyapolygon.Count() < 1)
  1138. return;
  1139. HistoryApolygon hap = m_list_historyapolygon[m_operator_currentid];
  1140. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  1141. {
  1142. foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
  1143. {
  1144. if (hap.APolygonID == dp.ID)
  1145. {
  1146. dp.Operator = hap.Operator;
  1147. }
  1148. }
  1149. }
  1150. if (m_operator_currentid < m_list_historyapolygon.Count - 1)
  1151. m_operator_currentid = m_operator_currentid + 1;
  1152. }
  1153. /// <summary>
  1154. /// 撤消删除
  1155. /// </summary>
  1156. public void UnDo()
  1157. {
  1158. //首先找到历史操作记录类最后一项,然后取出颗粒操作的id,及颗粒最后的操作类型,还原成oldoperator状态
  1159. if (m_list_historyapolygon.Count() < 1)
  1160. return;
  1161. HistoryApolygon hap = m_list_historyapolygon[m_operator_currentid];
  1162. foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
  1163. {
  1164. foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
  1165. {
  1166. if (hap.APolygonID == dp.ID)
  1167. {
  1168. dp.Operator = hap.OldOperator;
  1169. }
  1170. }
  1171. }
  1172. if (m_operator_currentid != 0)
  1173. {
  1174. m_operator_currentid = m_operator_currentid - 1;
  1175. }
  1176. }
  1177. /// <summary>
  1178. /// 是否显示标尺控件,自动切换显示与不显示
  1179. /// </summary>
  1180. /// <param name="b_show"></param>
  1181. public void ShowRulerControl()
  1182. {
  1183. control_Ruler1.Visible = !control_Ruler1.Visible;
  1184. }
  1185. /// <summary>
  1186. /// 是否显示标尺控件,带参重载
  1187. /// </summary>
  1188. /// <param name="b_show"></param>
  1189. public void ShowRulerControl(bool b_show)
  1190. {
  1191. control_Ruler1.Visible = b_show;
  1192. }
  1193. /// <summary>
  1194. /// 设置显示BSE原图,还是显示排序图带有标准库的
  1195. /// </summary>
  1196. /// <param name="in_b">false为显示原bse图像,true为显示带有标准库代表色的图像</param>
  1197. public void ShowMode(bool in_b)
  1198. {
  1199. if (in_b == false)
  1200. {
  1201. foreach (SortParticleDistribution item in m_list_sortparticledistribution)
  1202. {
  1203. foreach (DParticle ls_dp in item.List_DParticle)
  1204. {
  1205. foreach (DSegment ls_ds in ls_dp.DSegments)
  1206. {
  1207. ls_ds.ShowMode = SegmentShowMode.DRAWPOINT;
  1208. }
  1209. }
  1210. }
  1211. }
  1212. else
  1213. {
  1214. foreach (SortParticleDistribution item in m_list_sortparticledistribution)
  1215. {
  1216. foreach (DParticle ls_dp in item.List_DParticle)
  1217. {
  1218. foreach (DSegment ls_ds in ls_dp.DSegments)
  1219. {
  1220. ls_ds.ShowMode = SegmentShowMode.DRAWLINE;
  1221. }
  1222. }
  1223. }
  1224. }
  1225. this.Invalidate();
  1226. }
  1227. /// <summary>
  1228. /// 对颗粒进行排序
  1229. /// </summary>
  1230. /// <param name="in_list_baseobject"></param>
  1231. /// <param name="str_sort">排序的方法,从小到到,小大到小</param>
  1232. public void SortDParticleBySize(List<BaseObject> in_list_baseobject, string str_sort)
  1233. {
  1234. List<DParticle> list_dp1 = new List<DParticle>();
  1235. foreach (DParticle ls_dp in in_list_baseobject)
  1236. {
  1237. DParticle dp1 = ls_dp.Clone() as DParticle;
  1238. list_dp1.Add(dp1);
  1239. }
  1240. in_list_baseobject.Clear();
  1241. if (str_sort == "从小到大")
  1242. {
  1243. int icount = list_dp1.Count();
  1244. for (int i = 0; i < icount; i++)
  1245. {
  1246. float f_min_size = 10000000;
  1247. string str_jlguid = "";
  1248. DParticle ls_dp = new DParticle();
  1249. foreach (DParticle ls_del_dp in list_dp1)
  1250. {
  1251. ls_del_dp.FSize = ls_del_dp.GetSizeFormSegmentsAllWidth();
  1252. if (f_min_size > ls_del_dp.FSize)
  1253. {
  1254. f_min_size = ls_del_dp.FSize;
  1255. str_jlguid = ls_del_dp.ID;
  1256. ls_dp = ls_del_dp;
  1257. }
  1258. }
  1259. list_dp1.Remove(ls_dp);
  1260. in_list_baseobject.Add(ls_dp);
  1261. }
  1262. }
  1263. else if (str_sort == "从大到小")
  1264. {
  1265. int icount = list_dp1.Count();
  1266. for (int i = 0; i < icount; i++)
  1267. {
  1268. float f_max_size = 0;
  1269. string str_jlguid = "";
  1270. DParticle ls_dp = new DParticle();
  1271. foreach (DParticle ls_del_dp in list_dp1)
  1272. {
  1273. ls_del_dp.FSize = ls_del_dp.GetSizeFormSegmentsAllWidth();
  1274. if (f_max_size < ls_del_dp.FSize)
  1275. {
  1276. f_max_size = ls_del_dp.FSize;
  1277. str_jlguid = ls_del_dp.ID;
  1278. ls_dp = ls_del_dp;
  1279. }
  1280. }
  1281. list_dp1.Remove(ls_dp);
  1282. ls_dp.Rect = ls_dp.GetRectFromDSegment();
  1283. in_list_baseobject.Add(ls_dp);
  1284. }
  1285. }
  1286. }
  1287. /// <summary>
  1288. /// 从大到小进行对多边形,进行排序
  1289. /// </summary>
  1290. public void SortApolygonBySize_FromBigToSmall()
  1291. {
  1292. SortDParticleBySize(m_list_baseobject, "从大到小");
  1293. m_f_zoom_increment = 0.1f;
  1294. m_f_widthandheight_js = 0;
  1295. m_f_zoom_record = 1;
  1296. m_f_ruler_size = 100;
  1297. ClassifyDParticleGrid();
  1298. }
  1299. /// <summary>
  1300. /// 从小到大对多边形进行排序
  1301. /// </summary>
  1302. public void SortApolygonBySize_FromSmallToBig()
  1303. {
  1304. SortDParticleBySize(m_list_baseobject, "从小到大");
  1305. m_f_zoom_increment = 0.1f;
  1306. m_f_widthandheight_js = 0;
  1307. m_f_zoom_record = 1;
  1308. m_f_ruler_size = 100;
  1309. ClassifyDParticleGrid();
  1310. }
  1311. //测试回头去掉,记录哪些颗粒被选择,保存成clr的list形式,回头需要时再传给底层
  1312. public void test_selected()
  1313. {
  1314. m_OTSIncAReportFun.GetSelectedParticleList_ForDrawDistrbutionSortImage();
  1315. }
  1316. /// <summary>
  1317. /// 是否进行矩形多选操作
  1318. /// </summary>
  1319. public void MultiSelect_Rectangle()
  1320. {
  1321. if (m_is_multiselect_ellipse == true)
  1322. {
  1323. m_is_multiselect_ellipse = false;
  1324. }
  1325. m_is_multiselect_rectangle = true;
  1326. }
  1327. /// <summary>
  1328. /// 是否进行圆形多选操作
  1329. /// </summary>
  1330. public void MultiSelect_Ellipse()
  1331. {
  1332. if (m_is_multiselect_rectangle == true)
  1333. {
  1334. m_is_multiselect_rectangle = false;
  1335. }
  1336. m_is_multiselect_ellipse = true;
  1337. }
  1338. /// <summary>
  1339. /// 禁止多选工具的使用
  1340. /// </summary>
  1341. public void MultiSelect_Ban()
  1342. {
  1343. m_is_multiselect_ellipse = false;
  1344. m_is_multiselect_rectangle = false;
  1345. }
  1346. /// <summary>
  1347. /// 对选择的多边形进行反选操作
  1348. /// </summary>
  1349. public void ReverSeSelection()
  1350. {
  1351. foreach (SortParticleDistribution aag in m_list_sortparticledistribution)
  1352. {
  1353. foreach (DParticle dp in aag.List_DParticle)
  1354. {
  1355. if (ParticleOperator.DISPLAY == dp.Operator)
  1356. {
  1357. dp.Operator = ParticleOperator.SELECTED;
  1358. }
  1359. else if (ParticleOperator.SELECTED == dp.Operator)
  1360. {
  1361. dp.Operator = ParticleOperator.DISPLAY;
  1362. }
  1363. }
  1364. }
  1365. //将排列图选择的颗粒传送给报告框架中
  1366. SelectParticleListSendToReportFrame();
  1367. this.Invalidate();
  1368. }
  1369. /// <summary>
  1370. /// 取消所有的颗粒的选择状态
  1371. /// </summary>
  1372. public void DeselectAllParticle()
  1373. {
  1374. foreach (SortParticleDistribution aag in m_list_sortparticledistribution)
  1375. {
  1376. foreach (DParticle dp in aag.List_DParticle)
  1377. {
  1378. if (ParticleOperator.SELECTED == dp.Operator)
  1379. {
  1380. dp.Operator = ParticleOperator.DISPLAY;
  1381. }
  1382. }
  1383. }
  1384. //将排列图选择的颗粒传送给报告框架中
  1385. SelectParticleListSendToReportFrame();
  1386. this.Invalidate();
  1387. }
  1388. /// <summary>
  1389. /// 将整个图像拷贝到内存中
  1390. /// </summary>
  1391. public void CopyToBitmap()
  1392. {
  1393. Bitmap bp = new Bitmap(this.Size.Width, this.Size.Height);
  1394. this.DrawToBitmap(bp, new Rectangle(0, 0, this.Size.Width, this.Size.Height));
  1395. Clipboard.SetImage(bp);
  1396. }
  1397. #endregion
  1398. #region 鼠标菜单右键
  1399. private void ToolStripMenuItem_id_Click(object sender, EventArgs e)
  1400. {
  1401. //ID
  1402. DParticle dp = (DParticle)CMenuStrip.Items[0].Tag;
  1403. MessageBox.Show(dp.ID.ToString());
  1404. }
  1405. private void ToolStripMenuItem_selected_Click(object sender, EventArgs e)
  1406. {
  1407. //选择
  1408. DParticle dp = (DParticle)CMenuStrip.Items[0].Tag;
  1409. if (ParticleOperator.SELECTED == dp.Operator)
  1410. {
  1411. dp.Operator = ParticleOperator.DISPLAY;
  1412. CMenuStrip.Items[1].Text = "选择颗粒";
  1413. control_XRayTable1.Visible = false;
  1414. }
  1415. else
  1416. {
  1417. dp.Operator = ParticleOperator.SELECTED;
  1418. CMenuStrip.Items[1].Text = "取消颗粒选择";
  1419. }
  1420. //将排列图选择的颗粒传送给报告框架中
  1421. SelectParticleListSendToReportFrame();
  1422. }
  1423. private void ToolStripMenuItem_delete_Click(object sender, EventArgs e)
  1424. {
  1425. //删除颗粒
  1426. DParticle dp = (DParticle)CMenuStrip.Items[0].Tag;
  1427. //同样,要在历史操作记录类中,添加记录,好可以进行撤消操作
  1428. HistoryApolygon hApolygon = new HistoryApolygon();
  1429. hApolygon.APolygonID = dp.ID;
  1430. hApolygon.Operator = ParticleOperator.DELETED;
  1431. hApolygon.OldOperator = dp.Operator;
  1432. hApolygon.ID = m_list_historyapolygon.Count;
  1433. m_list_historyapolygon.Add(hApolygon);
  1434. m_operator_currentid = hApolygon.ID;//当前操作到的历史操作记录
  1435. //设置颗粒的状态为已经被删除
  1436. dp.Operator = ParticleOperator.DELETED;
  1437. }
  1438. private void ToolStripMenuItem_movesempoint_Click(object sender, EventArgs e)
  1439. {
  1440. //移动SEM到指定位置
  1441. if (m_mythread == null)
  1442. {
  1443. return;
  1444. }
  1445. if (m_mythread.ThreadState == ThreadState.Running || m_mythread.ThreadState == ThreadState.WaitSleepJoin)
  1446. {
  1447. return;
  1448. }
  1449. if (m_mythread.ThreadState == ThreadState.Stopped)
  1450. {
  1451. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  1452. }
  1453. if (m_sem_mouse_now_point.X != 0 && m_sem_mouse_now_point.Y != 0)
  1454. {
  1455. //改为线程调用,先判断线程状态
  1456. m_mythread.Start(new Point(m_sem_mouse_now_point.X, m_sem_mouse_now_point.Y));
  1457. }
  1458. }
  1459. //复制图像
  1460. private void ToolStripMenuItem_copyimage_Click(object sender, EventArgs e)
  1461. {
  1462. CopyImage();
  1463. }
  1464. //显示过小颗粒
  1465. private void ToolStripMenuItemShowSmallParticle_Click(object sender, EventArgs e)
  1466. {
  1467. if (bShowSmallParticle == false)
  1468. {
  1469. bShowSmallParticle = true;
  1470. CMenuStrip.Items[6].Text = "不显示过小颗粒";
  1471. }
  1472. else
  1473. {
  1474. bShowSmallParticle = false;
  1475. CMenuStrip.Items[6].Text = "显示过小颗粒";
  1476. }
  1477. //缩放的增大缩小的增量
  1478. m_f_zoom_increment = 0.1f;
  1479. //缩放的基数,临时变量
  1480. m_f_widthandheight_js = 0;
  1481. //与原先缩放的记录数
  1482. m_f_zoom_record = 1;
  1483. //最大缩放倍数
  1484. m_f_zoom_max = 4f;
  1485. //最小缩放倍数
  1486. m_f_zoom_mix = 0.5f;
  1487. //标尺的大小记录
  1488. m_f_ruler_size = 100;
  1489. //标尺原先大小的记录,参与计算
  1490. m_f_old_ruler_size = 100;
  1491. //每像素代表的尺寸大小,还不知道在哪里进行计算
  1492. m_f_onepixel_size = 4.5f;
  1493. //提供鼠标在右下角显示的文本,左侧
  1494. m_str_mouseshow_left = "";
  1495. //提供鼠标在右下角显示的文本,右侧
  1496. m_str_mouseshow_right = "";
  1497. //分栏网格边框的颜色
  1498. m_c_ColumnRectangleColor = Color.LightSteelBlue;
  1499. //记录操作记录类
  1500. m_list_historyapolygon = null;
  1501. //操作历史类,当前操作到的id
  1502. m_operator_currentid = 0;
  1503. m_list_baseobject = new List<BaseObject>();
  1504. m_list_historyapolygon = new List<HistoryApolygon>();
  1505. m_list_sortparticledistribution = new List<SortParticleDistribution>();
  1506. m_old_list_sortparticledistribution = new List<SortParticleDistribution>();
  1507. m_mythread_state = false;
  1508. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  1509. m_frm_userprogress = new Frm_UserProgress();
  1510. Control_DrawDistrbutionSortImage_Load(null, null);
  1511. m_OTSIncAReportFun.GetDistrbutionSortimage_ByQuery(m_list_cgriddataclr);
  1512. }
  1513. #endregion
  1514. }
  1515. }