DisplayParticle.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. using OTSCommon.Model;
  2. using OTSIncAReportGraph.Class;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace OTSIncAReportGraph
  12. {
  13. /// <summary>
  14. /// Particle对象上操作状态的枚举,显示,不显示,已删除,已选择
  15. /// </summary>
  16. public enum PaintState
  17. {
  18. PAINT = 0,
  19. NOPAINT = 1,
  20. CONCISEPAINT=2,// display as a "+"
  21. }
  22. public enum DisplayState
  23. {
  24. DISPLAY = 0,
  25. NODISPLAY = 1,
  26. }
  27. /// <summary>
  28. /// Particle对象上操作xray的枚举状态,显示xray数据,不显示
  29. /// </summary>
  30. public enum ParticleShowXray
  31. {
  32. SELECTANDDISPLAYXRAY = 0,
  33. NODISPLAY = 1,
  34. }
  35. /// <summary>
  36. /// Segment对象绘制的枚举,以点绘制,还是以线绘制
  37. /// </summary>
  38. public enum SegmentShowMode
  39. {
  40. DRAWPOINT = 0,
  41. DRAWLINE = 1,
  42. }
  43. /// <summary>
  44. /// 颗粒类
  45. /// </summary>
  46. public class DisplayParticle : BaseObject, ICloneable, IComparable<DisplayParticle>
  47. {
  48. private const float m_zoom_displaymultiplier = 0.5f;
  49. public Particle objParticleData;
  50. private Guid m_id;
  51. private RectangleF m_rect;
  52. private PointF m_OTSPointF;
  53. private RectangleF m_small_rect;
  54. private bool m_isSelected_smallrect;
  55. private bool m_showSmallx;
  56. private bool m_isSelected;
  57. private bool m_isDeleted;
  58. private bool m_isMouseOver;
  59. private PaintState m_paintState = PaintState.PAINT;
  60. private ParticleShowXray m_operator_showxray = ParticleShowXray.NODISPLAY;//选定显示XRAY,不显示XRAY,默认应为(不显示XRAY)
  61. private bool m_isdragging;
  62. private PointF m_dragingpoint;
  63. private Color m_color;
  64. private Color m_backcolor;
  65. private GraphicsPath m_gpath;
  66. private List<DisplaySegment> m_listdsegment = new List<DisplaySegment>();
  67. private DisplayState m_displayState;
  68. private Image m_image;
  69. private string m_sort_type = "从大到小";
  70. private float m_f_size = 0;
  71. private string m_str_lj = "颗粒粒级";
  72. private string m_str_klzl = "颗粒种类";
  73. private string m_str_klfl = "颗粒分类";
  74. public int TypeId
  75. {
  76. get
  77. {
  78. return objParticleData.TypeId;
  79. }
  80. }
  81. //TypeName
  82. public string TypeName
  83. {
  84. get
  85. {
  86. return objParticleData.TypeName;
  87. }
  88. }
  89. //XRayId
  90. public int XRayId
  91. {
  92. get
  93. {
  94. return objParticleData.XrayId;
  95. }
  96. }
  97. public int SEMPosX
  98. {
  99. get
  100. {
  101. return objParticleData.SEMPosX;
  102. }
  103. set { objParticleData.SEMPosX = value; }
  104. }
  105. public int SEMPosY
  106. {
  107. get
  108. {
  109. return objParticleData.SEMPosY;
  110. }
  111. set { objParticleData.SEMPosY = value; }
  112. }
  113. public DisplayParticle()
  114. {
  115. m_id = System.Guid.NewGuid();
  116. }
  117. public DisplayParticle(Particle part)
  118. {
  119. m_id = System.Guid.NewGuid();
  120. objParticleData = part;
  121. this.Color = GetColorBySTDTypeIDForBSEAndSorImage(part.TypeColor, part.TypeId);
  122. }
  123. public DisplayParticle(List<DisplaySegment> in_list_segment, DisplayParticle in_particle)
  124. {
  125. objParticleData = in_particle.objParticleData;
  126. m_id = in_particle.m_id;
  127. m_paintState = in_particle.m_paintState;
  128. m_operator_showxray = in_particle.m_operator_showxray;
  129. foreach (DisplaySegment e in in_list_segment)
  130. {
  131. m_listdsegment.Add(e.Clone() as DisplaySegment);
  132. }
  133. }
  134. /// <summary>
  135. /// [目前也不使用该方法了,因为该方法每次排序都有不同的结果]多边形排序,按传入的sort_type的排序类型行排序,但需要两个list做一致性排序
  136. /// </summary>
  137. /// <param name="in_ap"></param>
  138. /// <returns></returns>
  139. public int CompareTo(DisplayParticle in_particle)
  140. {
  141. int r_b = 0;//排序返回值
  142. switch (m_sort_type)
  143. {
  144. case "从大到小":
  145. r_b = in_particle.m_f_size.CompareTo(this.m_f_size);
  146. break;
  147. case "从小到大":
  148. //与上面的从大到小正好相反即可
  149. r_b = in_particle.m_f_size.CompareTo(this.m_f_size);
  150. if (r_b == 1)
  151. r_b = -1;
  152. else
  153. r_b = 1;
  154. break;
  155. default:
  156. break;
  157. }
  158. return r_b;
  159. }
  160. public Color GetColorBySTDTypeIDForBSEAndSorImage(string in_partcolor, int in_stdtypeid)
  161. {
  162. Color ret_c = new Color();
  163. if (in_stdtypeid < 1000)
  164. {
  165. ret_c = GetColorByEnum(in_stdtypeid);
  166. }
  167. else if (in_stdtypeid >= 1000)
  168. {
  169. //大于等于1000,并且小于10000时,使用用户标准库来分析夹杂物名称
  170. if (!in_partcolor.Contains("#"))
  171. {
  172. ret_c = DrawFunction.colorHx16toRGB("#" + in_partcolor);//接收必须是#000000的格式
  173. }
  174. else
  175. {
  176. ret_c = DrawFunction.colorHx16toRGB(in_partcolor);//接收必须是#000000的格式
  177. }
  178. }
  179. return ret_c;
  180. }
  181. public Color GetColorByEnum(int STDID)
  182. {
  183. Color ret_c = new Color();
  184. switch (STDID)
  185. {
  186. case -1:
  187. //INVALID = -1,
  188. //stdName = "无效颗粒";
  189. ret_c = Color.Black;
  190. break;
  191. case 0:
  192. //small = 0;
  193. //stdName = "过小颗粒";
  194. ret_c = Color.Black;
  195. break;
  196. case 1:
  197. //OVERSIZE = 1,
  198. //stdName = "过大颗粒";
  199. ret_c = Color.Black;
  200. break;
  201. case 2:
  202. //AVE_GRAY_NOT_INRANRE = 2,
  203. //stdName = "亮度不在分析范围内的颗粒";
  204. ret_c = Color.Black;
  205. break;
  206. case 3:
  207. //SEARCH_X_RAY = 3,
  208. //stdName = "不进行搜索x-ray分析的颗粒";
  209. ret_c = Color.Black;
  210. break;
  211. case 4:
  212. //LOW_COUNT = 4,
  213. //stdName = "低x-ray计数颗粒";
  214. ret_c = Color.Black;
  215. break;
  216. case 5:
  217. //NO_INTEREST_ELEMENTS = 5,
  218. //stdName = "不含分析元素的颗粒";
  219. ret_c = Color.Black;
  220. break;
  221. case 6:
  222. //ALAYSIS_X_RAY = 6,
  223. //stdName = "不进行x-ray分析的颗粒";
  224. ret_c = Color.Black;
  225. break;
  226. case 7:
  227. //NOT_IDENTIFIED = 7,
  228. //stdName = "未识别颗粒";
  229. ret_c = Color.Black;
  230. break;
  231. case 8:
  232. //NOT_IDENTIFIED = 8,
  233. //stdName = "未识别颗粒";
  234. ret_c = Color.Black;
  235. break;
  236. case 9:
  237. //NOT_IDENTIFIED = 9,
  238. //stdName = "未识别颗粒";
  239. ret_c = Color.Black;
  240. break;
  241. default:
  242. ret_c = Color.Black;
  243. break;
  244. }
  245. return ret_c;
  246. }
  247. /// <summary>
  248. /// 克隆方法
  249. /// </summary>
  250. /// <returns></returns>
  251. public override object Clone()
  252. {
  253. var dp= new DisplayParticle(this.m_listdsegment, this);
  254. dp.m_image = this.m_image;
  255. return dp;
  256. }
  257. public PointF GetCenterPoint()
  258. {
  259. return new PointF(m_rect.X + m_rect.Width / 2, m_rect.Y + m_rect.Height / 2);
  260. }
  261. /// <summary>
  262. /// ID
  263. /// </summary>
  264. public override Guid guid
  265. {
  266. get { return m_id; }
  267. set { m_id = value; }
  268. }
  269. /// <summary>
  270. /// 颗粒的外边框大小
  271. /// </summary>
  272. public override RectangleF Rect
  273. {
  274. get { return m_rect; }
  275. set { m_rect = value; }
  276. }
  277. /// <summary>
  278. /// OTSPointF
  279. /// </summary>
  280. public override PointF OTSPointF
  281. {
  282. get { return m_OTSPointF; }
  283. set { m_OTSPointF = value; }
  284. }
  285. /// <summary>
  286. /// 颗粒里+号位置的外边框大小
  287. /// </summary>
  288. public RectangleF SmallRect
  289. {
  290. get { return m_small_rect; }
  291. set { m_small_rect = value; }
  292. }
  293. /// <summary>
  294. /// 颗粒是否被选择
  295. /// </summary>
  296. public override bool IsSelect
  297. {
  298. get { return m_isSelected; }
  299. set { m_isSelected = value; }
  300. }
  301. /// <summary>
  302. /// 该颗粒是否被设置成,选中状态
  303. /// </summary>
  304. public PaintState GetPaintState()
  305. {
  306. if (GetDisplayState() == DisplayState.NODISPLAY)
  307. {
  308. m_paintState = PaintState.NOPAINT;
  309. }
  310. return m_paintState;
  311. }
  312. /// <summary>
  313. /// 该颗粒是否被设置成,选中状态
  314. /// </summary>
  315. public void SetPaintState(PaintState value)
  316. { m_paintState = value; }
  317. /// <summary>
  318. /// 是否对该颗粒选定显示X-Ray能谱图
  319. /// </summary>
  320. public ParticleShowXray Operator_ShowXRay
  321. {
  322. get { return m_operator_showxray; }
  323. set { m_operator_showxray = value; }
  324. }
  325. /// <summary>
  326. /// 是否显示x号
  327. /// </summary>
  328. public bool IsShowSmallX
  329. {
  330. get { return m_showSmallx; }
  331. set { m_showSmallx = value; }
  332. }
  333. /// <summary>
  334. /// 颗粒的x-ray的点,是否被选择上了
  335. /// </summary>
  336. public bool IsSelectedSmallRect
  337. {
  338. get { return m_isSelected_smallrect; }
  339. set { m_isSelected_smallrect = value; }
  340. }
  341. /// <summary>
  342. /// 是否在被拖动
  343. /// </summary>
  344. public override bool IsDragging
  345. {
  346. get { return m_isdragging; }
  347. set { m_isdragging = value; }
  348. }
  349. /// <summary>
  350. /// 被拖动到的位置坐标
  351. /// </summary>
  352. public override PointF DraggingPoint
  353. {
  354. get { return m_dragingpoint; }
  355. set { m_dragingpoint = value; }
  356. }
  357. /// <summary>
  358. /// 线的颜色
  359. /// </summary>
  360. public override Color Color
  361. {
  362. get { return m_color; }
  363. set { m_color = value; }
  364. }
  365. /// <summary>
  366. /// 背景色
  367. /// </summary>
  368. public override Color BackColor
  369. {
  370. get { return m_backcolor; }
  371. set { m_backcolor = value; }
  372. }
  373. /// <summary>
  374. /// 多边形的图形路径边缘
  375. /// </summary>
  376. public override GraphicsPath GPath
  377. {
  378. get { return m_gpath; }
  379. set { m_gpath = value; }
  380. }
  381. /// <summary>
  382. /// 里面包含的多个线的集合
  383. /// </summary>
  384. public List<DisplaySegment> DSegments
  385. {
  386. get { return m_listdsegment; }
  387. set { m_listdsegment = value; }
  388. }
  389. /// <summary>
  390. /// 控制多边形在进行缩放到多少倍时进行显示
  391. /// </summary>
  392. public float Zoom_DisPlayThreshold
  393. {
  394. get { return m_zoom_displaymultiplier; }
  395. }
  396. /// <summary>
  397. /// 设置排序的类型
  398. /// </summary>
  399. public string SortType
  400. {
  401. get { return m_sort_type; }
  402. set { m_sort_type = value; }
  403. }
  404. /// <summary>
  405. /// 设置该多边形的尺寸大小
  406. /// </summary>
  407. public float FSize
  408. {
  409. get { return m_f_size; }
  410. set { m_f_size = value; }
  411. }
  412. /// <summary>
  413. /// 设置粒级
  414. /// </summary>
  415. public string ParticleLJ
  416. {
  417. get { return m_str_lj; }
  418. set { m_str_lj = value; }
  419. }
  420. /// <summary>
  421. /// 设置种类
  422. /// </summary>
  423. public string ParticleZL
  424. {
  425. get { return m_str_klzl; }
  426. set { m_str_klzl = value; }
  427. }
  428. /// <summary>
  429. /// 设置分类
  430. /// </summary>
  431. public string ParticleFL
  432. {
  433. get { return m_str_klfl; }
  434. set { m_str_klfl = value; }
  435. }
  436. /// <summary>
  437. /// 获取或设置该Particle对应底层的FieldID值
  438. /// </summary>
  439. public int FieldId
  440. {
  441. get { return objParticleData.FieldId; }
  442. }
  443. /// <summary>
  444. /// 获取或设置该Particle对应底层的ParticleID值
  445. /// </summary>
  446. public int ParticleId
  447. {
  448. get { return objParticleData.ParticleId; }
  449. }
  450. public bool IsDeleted { get => m_isDeleted; set => m_isDeleted = value; }
  451. public bool IsMouseOver { get => m_isMouseOver; set => m_isMouseOver = value; }
  452. public Image GetImage()
  453. {
  454. return m_image;
  455. }
  456. public void SetImage(Image value)
  457. {
  458. m_image = value;
  459. }
  460. public DisplayState GetDisplayState()
  461. {
  462. if (m_isDeleted)
  463. {
  464. m_displayState = DisplayState.NODISPLAY;
  465. }
  466. return m_displayState;
  467. }
  468. public void SetDisplayState(DisplayState value)
  469. {
  470. m_displayState = value;
  471. }
  472. /// <summary>
  473. /// 绘制函数
  474. /// </summary>
  475. /// <param name="e"></param>
  476. public override void OnPaint(PaintEventArgs e)
  477. {
  478. Graphics g = e.Graphics;
  479. //绘制鼠标移动到颗粒上时的边框,需要判断当前鼠标在颗粒上,及颗粒的操作为正常显示
  480. if (m_isMouseOver == true)
  481. {
  482. //如果有鼠标在该矩形上,那么进行描边
  483. ControlPaint.DrawBorder(g,
  484. Rectangle.Round(this.Rect),
  485. Color.Lime,
  486. 1,
  487. ButtonBorderStyle.Solid,
  488. Color.Lime,
  489. 1,
  490. ButtonBorderStyle.Solid,
  491. Color.Lime,
  492. 1,
  493. ButtonBorderStyle.Solid,
  494. Color.Lime,
  495. 1,
  496. ButtonBorderStyle.Solid);
  497. }
  498. if (GetPaintState() == PaintState.PAINT)
  499. {
  500. if (m_listdsegment.Count > 0)
  501. {
  502. DisplaySegment ds = m_listdsegment[0];
  503. if (ds.ShowMode == SegmentShowMode.DRAWPOINT)
  504. {
  505. try
  506. {
  507. e.Graphics.DrawImage(m_image, m_rect);
  508. }
  509. catch (Exception ex)
  510. {
  511. NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString());
  512. }
  513. }
  514. else
  515. {
  516. //调用绘制基本线
  517. foreach (DisplaySegment item in m_listdsegment)
  518. {
  519. item.OnPaint(e);
  520. }
  521. }
  522. }
  523. }
  524. if (GetPaintState() == PaintState.CONCISEPAINT)
  525. {
  526. g.DrawString("+", new Font("黑体", 6), new SolidBrush(Color.DarkSlateBlue), new PointF(m_small_rect.X, m_small_rect.Y));
  527. }
  528. if (m_isSelected)
  529. {
  530. //如果説该矩形被选择上了的话,那么也显示边框
  531. ControlPaint.DrawBorder(g,
  532. Rectangle.Round(this.Rect),
  533. Color.Blue,
  534. 1,
  535. ButtonBorderStyle.Solid,
  536. Color.Blue,
  537. 1,
  538. ButtonBorderStyle.Solid,
  539. Color.Blue,
  540. 1,
  541. ButtonBorderStyle.Solid,
  542. Color.Blue,
  543. 1,
  544. ButtonBorderStyle.Solid);
  545. }
  546. if (ParticleShowXray.SELECTANDDISPLAYXRAY == m_operator_showxray && PaintState.NOPAINT != GetPaintState())
  547. {
  548. //当鼠标在该颗粒上进行点击,则对颗粒状态更改为选定状态,用来显示X-ray能谱表
  549. ControlPaint.DrawBorder(g,
  550. Rectangle.Round(this.Rect),
  551. Color.DeepSkyBlue,
  552. 1,
  553. ButtonBorderStyle.Solid,
  554. Color.DeepSkyBlue,
  555. 1,
  556. ButtonBorderStyle.Solid,
  557. Color.DeepSkyBlue,
  558. 1,
  559. ButtonBorderStyle.Solid,
  560. Color.DeepSkyBlue,
  561. 1,
  562. ButtonBorderStyle.Solid);
  563. }
  564. }
  565. /// <summary>
  566. /// 从Line中获取矩形的边缘闭合路径
  567. /// </summary>
  568. /// <returns></returns>
  569. public GraphicsPath GetRegionFromDSegments()
  570. {
  571. GraphicsPath gpath = new GraphicsPath();
  572. List<PointF> list_leftpointf = new List<PointF>();
  573. List<PointF> list_rightpointf = new List<PointF>();
  574. //从y循环,这里假设y轴会按lines集合来计算,然后将所有的左x,和右x取出排成两个队列
  575. foreach (DisplaySegment ds in this.m_listdsegment)
  576. {
  577. list_leftpointf.Add(new PointF(ds.Rect.X, ds.Rect.Y));
  578. list_rightpointf.Add(new PointF(ds.Rect.X + ds.Rect.Width, ds.Rect.Y));
  579. }
  580. PointF[] lsp = new PointF[list_leftpointf.Count + list_rightpointf.Count];
  581. //再将两个x,y点依次添加到闭合路径中
  582. for (int i = 0; i < list_leftpointf.Count(); i++)
  583. {
  584. lsp[i] = list_leftpointf[i];
  585. }
  586. //右节点
  587. for (int i = 0; i < list_rightpointf.Count(); i++)
  588. {
  589. //这边倒着存入
  590. lsp[list_rightpointf.Count() + i] = list_rightpointf[list_rightpointf.Count() - i - 1];
  591. }
  592. //防止从低层拿到无数据的外边路径,在我的程序里却需要计算,而防止程序报死,这里做一下特殊处理。
  593. if (lsp.Count() >= 3)
  594. {
  595. gpath.AddPolygon(lsp);
  596. }
  597. else
  598. {
  599. //有时居然有颗粒,有没有segment的时候,防止报错
  600. if (this.DSegments.Count == 0)
  601. {
  602. lsp = new PointF[3] { new PointF(0, 0), new PointF(0, 0), new PointF(0, 0) };
  603. gpath.AddPolygon(lsp);
  604. return gpath;
  605. }
  606. //有2条数据
  607. if (lsp[1].X != 0 && lsp[1].Y != 0)
  608. {
  609. lsp = new PointF[3] { new PointF(lsp[0].X, lsp[0].Y), new PointF(lsp[1].X, lsp[1].Y), new PointF(lsp[1].X, lsp[1].Y) };
  610. }
  611. //有1条数据
  612. else if (lsp[0].X != 0 && lsp[0].Y != 0)
  613. {
  614. lsp = new PointF[3] { new PointF(lsp[0].X, lsp[0].Y), new PointF(lsp[0].X, lsp[0].Y), new PointF(lsp[0].X, lsp[0].Y) };
  615. }
  616. //剩下的情况
  617. else
  618. {
  619. lsp = new PointF[3] { new PointF(0, 0), new PointF(0, 0), new PointF(0,0) };
  620. }
  621. gpath.AddPolygon(lsp);
  622. }
  623. return gpath;
  624. }
  625. /// <summary>
  626. /// 从已经确定的外边框来计算出里面的+号小框位置
  627. /// </summary>
  628. /// <returns></returns>
  629. public RectangleF GetSmallRectangleFromRect()
  630. {
  631. RectangleF rect = new RectangleF();
  632. //用外边框的坐标,除2获得中心点,然后再分别+,- 4
  633. float x = 0, y = 0;
  634. x = m_rect.X + (m_rect.Width / 2);
  635. y = m_rect.Y + (m_rect.Height / 2);
  636. rect.X = x - 4;
  637. rect.Y = y - 4;
  638. rect.Width = 8;
  639. rect.Height = 4;
  640. return rect;
  641. }
  642. /// <summary>
  643. /// 根据该多边形所有包含的线长度,计算出,该多边形的面积大小
  644. /// </summary>
  645. /// <returns></returns>
  646. public float GetAreaFormSegments()
  647. {
  648. float f_size_sum = 0;
  649. foreach (DisplaySegment ls_ds in this.m_listdsegment)
  650. {
  651. f_size_sum = f_size_sum + ls_ds.Rect.Width;
  652. }
  653. return f_size_sum;
  654. }
  655. /// <summary>
  656. /// 从基本线中获取整个矩形的Rectangle
  657. /// </summary>
  658. /// <returns></returns>
  659. public RectangleF GetRectFromDSegment()
  660. {
  661. RectangleF rect = new RectangleF();
  662. float x1 = 0, y1 = 0;
  663. float i_width = 0, i_height = 0;
  664. //先从自身中初始化x,y,和宽,高
  665. if (this.m_listdsegment.Count > 0)
  666. {
  667. x1 = this.m_listdsegment[0].Rect.X;
  668. y1 = this.m_listdsegment[0].Rect.Y;
  669. i_width = x1 + this.m_listdsegment[0].Rect.Width;
  670. i_height = this.m_listdsegment[0].Rect.Y;
  671. }
  672. foreach (DisplaySegment ds in this.m_listdsegment)
  673. {
  674. //分别取出,最小的x,y,
  675. if (ds.Rect.X < x1)
  676. {
  677. x1 = ds.Rect.X;
  678. }
  679. if (ds.Rect.Y < y1)
  680. {
  681. y1 = ds.Rect.Y;
  682. }
  683. //最大的x,y
  684. if (ds.Rect.X + ds.Rect.Width > i_width)
  685. {
  686. i_width = ds.Rect.X + ds.Rect.Width;
  687. }
  688. if (ds.Rect.Y > i_height)
  689. {
  690. i_height = ds.Rect.Y;
  691. }
  692. }
  693. rect.X = x1 ;
  694. rect.Y = y1 ;
  695. rect.Width = i_width - rect.X ;
  696. rect.Height = i_height - rect.Y ;
  697. if (rect.Width < 1) rect.Width = 1;
  698. if (rect.Height < 1) rect.Height = 1;
  699. return rect;
  700. }
  701. }
  702. }