DisplayParticle.cs 23 KB

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