Sprite.Property.13.References.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Drawing2D;
  4. using System.Windows.Forms;
  5. using Microsoft.Drawing;
  6. namespace Microsoft.Windows.Forms
  7. {
  8. public partial class Sprite
  9. {
  10. //当前状态的背景色
  11. private Color? m_CurrentBackColor;
  12. /// <summary>
  13. /// 当前状态的背景色
  14. /// </summary>
  15. internal Color CurrentBackColor
  16. {
  17. get
  18. {
  19. if (this.m_CurrentBackColor == null)
  20. {
  21. switch (this.m_State)
  22. {
  23. case State.Normal:
  24. this.m_CurrentBackColor = this.m_BackColor;
  25. break;
  26. case State.Hovered:
  27. case State.HoveredFocused:
  28. this.m_CurrentBackColor = this.m_BackColorHovered;
  29. break;
  30. case State.Pressed:
  31. case State.PressedFocused:
  32. this.m_CurrentBackColor = this.m_BackColorPressed;
  33. break;
  34. case State.NormalFocused:
  35. this.m_CurrentBackColor = this.m_BackColorFocused;
  36. break;
  37. case State.Disabled:
  38. this.m_CurrentBackColor = this.m_BackColorDisabled;
  39. break;
  40. case State.Hidden:
  41. this.m_CurrentBackColor = Color.Empty;
  42. break;
  43. case State.Highlight:
  44. this.m_CurrentBackColor = this.m_BackColorHighlight;
  45. break;
  46. default:
  47. this.m_CurrentBackColor = this.m_BackColor;
  48. break;
  49. }
  50. }
  51. return this.m_CurrentBackColor.Value;
  52. }
  53. }
  54. //背景色是否反向绘制
  55. private bool? m_CurrentBackColorReverse;
  56. /// <summary>
  57. /// 背景色是否反向绘制
  58. /// </summary>
  59. internal bool CurrentBackColorReverse
  60. {
  61. get
  62. {
  63. if (this.m_CurrentBackColorReverse == null)
  64. {
  65. this.m_CurrentBackColorReverse = (this.m_BackColorAlign == TabAlignment.Right || this.m_BackColorAlign == TabAlignment.Bottom);
  66. }
  67. return this.m_CurrentBackColorReverse.Value;
  68. }
  69. }
  70. //背景色渐变模式
  71. private LinearGradientMode? m_CurrentBackColorMode;
  72. /// <summary>
  73. /// 背景色渐变模式
  74. /// </summary>
  75. internal LinearGradientMode CurrentBackColorMode
  76. {
  77. get
  78. {
  79. if (this.m_CurrentBackColorMode == null)
  80. {
  81. this.m_CurrentBackColorMode = (this.m_BackColorAlign == TabAlignment.Left || this.m_BackColorAlign == TabAlignment.Right) ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical;
  82. }
  83. return this.m_CurrentBackColorMode.Value;
  84. }
  85. }
  86. //背景色限制区域的矩形
  87. private Rectangle? m_CurrentBackColorPathRect;
  88. /// <summary>
  89. /// 背景色限制区域的矩形
  90. /// </summary>
  91. internal Rectangle CurrentBackColorPathRect
  92. {
  93. get
  94. {
  95. if (this.m_CurrentBackColorPathRect == null)
  96. {
  97. Rectangle rect = this.m_BackColorRect;
  98. //左侧
  99. if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Left) != 0)
  100. {
  101. rect.X += 2;
  102. rect.Width -= 2;
  103. }
  104. else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Left) != 0)
  105. {
  106. rect.X += 1;
  107. rect.Width -= 1;
  108. }
  109. //上边
  110. if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Top) != 0)
  111. {
  112. rect.Y += 2;
  113. rect.Height -= 2;
  114. }
  115. else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Top) != 0)
  116. {
  117. rect.Y += 1;
  118. rect.Height -= 1;
  119. }
  120. //右边
  121. if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Right) != 0)
  122. {
  123. rect.Width -= 2;
  124. }
  125. else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Right) != 0)
  126. {
  127. rect.Width -= 1;
  128. }
  129. //下边
  130. if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
  131. {
  132. rect.Height -= 2;
  133. }
  134. else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
  135. {
  136. rect.Height -= 1;
  137. }
  138. RectangleEx.MakeNotEmpty(ref rect);
  139. this.m_CurrentBackColorPathRect = rect;
  140. this.m_Graphics.SetClip(this.m_CurrentBackColorPathRect.Value, CombineMode.Intersect);//设置剪切区
  141. }
  142. return this.m_CurrentBackColorPathRect.Value;
  143. }
  144. }
  145. //背景色限制区域的矩形(要Fill的Path)
  146. private GraphicsPath m_CurrentBackColorPath;
  147. /// <summary>
  148. /// 背景色限制区域的矩形(要Fill的Path)
  149. /// </summary>
  150. internal GraphicsPath CurrentBackColorPath
  151. {
  152. get
  153. {
  154. if (this.IsDisposed)
  155. throw new ObjectDisposedException(base.GetType().ToString());
  156. if (this.m_CurrentBackColorPath == null)
  157. {
  158. this.m_CurrentBackColorPath = RenderEngine.CreateGraphicsPath(this.CurrentBackColorPathRect, this.m_RoundCornerStyle, this.m_RoundStyle, this.m_RoundRadius, false);
  159. }
  160. return this.m_CurrentBackColorPath;
  161. }
  162. }
  163. //背景色画刷矩形
  164. private Rectangle? m_CurrentBackColorBrushRect;
  165. /// <summary>
  166. /// 背景色画刷矩形
  167. /// </summary>
  168. internal Rectangle CurrentBackColorBrushRect
  169. {
  170. get
  171. {
  172. if (this.m_CurrentBackColorBrushRect == null)
  173. {
  174. Rectangle rect = RectangleEx.Inflate(this.CurrentBackColorPathRect, this.m_BackColorAlign, 1, 1);
  175. RectangleEx.MakeNotEmpty(ref rect);
  176. this.m_CurrentBackColorBrushRect = rect;
  177. }
  178. return this.m_CurrentBackColorBrushRect.Value;
  179. }
  180. }
  181. //当前背景图
  182. private Image m_CurrentBackgroundImage;
  183. /// <summary>
  184. /// 当前背景图
  185. /// </summary>
  186. internal Image CurrentBackgroundImage
  187. {
  188. get
  189. {
  190. if (this.m_CurrentBackgroundImage == null)
  191. {
  192. switch (this.m_State)
  193. {
  194. case State.Normal:
  195. this.m_CurrentBackgroundImage = this.m_BackgroundImage;
  196. break;
  197. case State.Hovered:
  198. case State.HoveredFocused:
  199. this.m_CurrentBackgroundImage = this.m_BackgroundImageHovered ?? this.m_BackgroundImage;
  200. break;
  201. case State.Pressed:
  202. case State.PressedFocused:
  203. this.m_CurrentBackgroundImage = this.m_BackgroundImagePressed ?? this.m_BackgroundImage;
  204. break;
  205. case State.NormalFocused:
  206. this.m_CurrentBackgroundImage = this.m_BackgroundImageFocused ?? this.m_BackgroundImage;
  207. break;
  208. case State.Disabled:
  209. this.m_CurrentBackgroundImage = this.m_BackgroundImageDisabled ?? this.m_BackgroundImage;
  210. break;
  211. case State.Hidden:
  212. this.m_CurrentBackgroundImage = null;
  213. break;
  214. case State.Highlight:
  215. this.m_CurrentBackgroundImage = this.m_BackgroundImageHighlight ?? this.m_BackgroundImage;
  216. break;
  217. default:
  218. this.m_CurrentBackgroundImage = this.m_BackgroundImage;
  219. break;
  220. }
  221. }
  222. return this.m_CurrentBackgroundImage;
  223. }
  224. }
  225. //背景图绘制矩形
  226. private Rectangle? m_CurrentBackgroundImageRect;
  227. /// <summary>
  228. /// 背景图绘制矩形
  229. /// </summary>
  230. internal Rectangle CurrentBackgroundImageRect
  231. {
  232. get
  233. {
  234. if (this.m_CurrentBackgroundImageRect == null)
  235. {
  236. Rectangle rect = this.m_BackgroundImageRect;
  237. RectangleEx.MakeNotEmpty(ref rect);
  238. this.m_CurrentBackgroundImageRect = rect;
  239. }
  240. return this.m_CurrentBackgroundImageRect.Value;
  241. }
  242. }
  243. //当前九宫格背景图
  244. private Image m_CurrentBackgroundImage9;
  245. /// <summary>
  246. /// 当前九宫格背景图
  247. /// </summary>
  248. internal Image CurrentBackgroundImage9
  249. {
  250. get
  251. {
  252. if (this.m_CurrentBackgroundImage9 == null)
  253. {
  254. switch (this.m_State)
  255. {
  256. case State.Normal:
  257. this.m_CurrentBackgroundImage9 = this.m_BackgroundImage9;
  258. break;
  259. case State.Hovered:
  260. case State.HoveredFocused:
  261. this.m_CurrentBackgroundImage9 = this.m_BackgroundImage9Hovered ?? this.m_BackgroundImage9;
  262. break;
  263. case State.Pressed:
  264. case State.PressedFocused:
  265. this.m_CurrentBackgroundImage9 = this.m_BackgroundImage9Pressed ?? this.m_BackgroundImage9;
  266. break;
  267. case State.NormalFocused:
  268. this.m_CurrentBackgroundImage9 = this.m_BackgroundImage9Focused ?? this.m_BackgroundImage9;
  269. break;
  270. case State.Disabled:
  271. this.m_CurrentBackgroundImage9 = this.m_BackgroundImage9Disabled ?? this.m_BackgroundImage9;
  272. break;
  273. case State.Hidden:
  274. this.m_CurrentBackgroundImage9 = null;
  275. break;
  276. case State.Highlight:
  277. this.m_CurrentBackgroundImage9 = this.m_BackgroundImage9Highlight ?? this.m_BackgroundImage9;
  278. break;
  279. default:
  280. this.m_CurrentBackgroundImage9 = this.m_BackgroundImage9;
  281. break;
  282. }
  283. }
  284. return this.m_CurrentBackgroundImage9;
  285. }
  286. }
  287. //九宫格背景图绘制矩形
  288. private Rectangle? m_CurrentBackgroundImage9Rect;
  289. /// <summary>
  290. /// 九宫格背景图绘制矩形
  291. /// </summary>
  292. internal Rectangle CurrentBackgroundImage9Rect
  293. {
  294. get
  295. {
  296. if (this.m_CurrentBackgroundImage9Rect == null)
  297. {
  298. Rectangle rect = this.m_BackgroundImage9Rect;
  299. RectangleEx.MakeNotEmpty(ref rect);
  300. this.m_CurrentBackgroundImage9Rect = rect;
  301. }
  302. return this.m_CurrentBackgroundImage9Rect.Value;
  303. }
  304. }
  305. //当前边框颜色
  306. private Color? m_CurrentBorderColor;
  307. /// <summary>
  308. /// 当前边框颜色
  309. /// </summary>
  310. internal Color CurrentBorderColor
  311. {
  312. get
  313. {
  314. if (this.m_CurrentBorderColor == null)
  315. {
  316. switch (this.m_State)
  317. {
  318. case State.Normal:
  319. this.m_CurrentBorderColor = this.m_BorderColor;
  320. break;
  321. case State.Hovered:
  322. case State.HoveredFocused:
  323. this.m_CurrentBorderColor = this.m_BorderColorHovered;
  324. break;
  325. case State.Pressed:
  326. case State.PressedFocused:
  327. this.m_CurrentBorderColor = this.m_BorderColorPressed;
  328. break;
  329. case State.NormalFocused:
  330. this.m_CurrentBorderColor = this.m_BorderColorFocused;
  331. break;
  332. case State.Disabled:
  333. this.m_CurrentBorderColor = this.m_BorderColorDisabled;
  334. break;
  335. case State.Hidden:
  336. this.m_CurrentBorderColor = Color.Empty;
  337. break;
  338. case State.Highlight:
  339. this.m_CurrentBorderColor = this.m_BorderColorHighlight;
  340. break;
  341. default:
  342. this.m_CurrentBorderColor = this.m_BorderColor;
  343. break;
  344. }
  345. }
  346. return this.m_CurrentBorderColor.Value;
  347. }
  348. }
  349. //边框路径矩形
  350. private Rectangle? m_CurrentBorderPathRect;
  351. /// <summary>
  352. /// 边框路径矩形
  353. /// </summary>
  354. internal Rectangle CurrentBorderPathRect
  355. {
  356. get
  357. {
  358. if (this.m_CurrentBorderPathRect == null)
  359. {
  360. Rectangle rect = this.m_BorderColorRect;
  361. rect.Width--;
  362. rect.Height--;
  363. this.m_CurrentBorderPathRect = rect;
  364. }
  365. return this.m_CurrentBorderPathRect.Value;
  366. }
  367. }
  368. //边框画刷矩形
  369. private Rectangle? m_CurrentBorderBrushRect;
  370. /// <summary>
  371. /// 边框画刷矩形
  372. /// </summary>
  373. internal Rectangle CurrentBorderBrushRect
  374. {
  375. get
  376. {
  377. if (this.m_CurrentBorderBrushRect == null)
  378. {
  379. this.m_CurrentBorderBrushRect = RectangleEx.Inflate(this.CurrentBorderPathRect, this.m_BackColorAlign, 1, 1);
  380. }
  381. return this.m_CurrentBorderBrushRect.Value;
  382. }
  383. }
  384. //当前内边框颜色
  385. private Color? m_CurrentInnerBorderColor;
  386. /// <summary>
  387. /// 当前内边框颜色
  388. /// </summary>
  389. internal Color CurrentInnerBorderColor
  390. {
  391. get
  392. {
  393. if (this.m_CurrentInnerBorderColor == null)
  394. {
  395. switch (this.m_State)
  396. {
  397. case State.Normal:
  398. this.m_CurrentInnerBorderColor = this.m_InnerBorderColor;
  399. break;
  400. case State.Hovered:
  401. case State.HoveredFocused:
  402. this.m_CurrentInnerBorderColor = this.m_InnerBorderColorHovered;
  403. break;
  404. case State.Pressed:
  405. case State.PressedFocused:
  406. this.m_CurrentInnerBorderColor = this.m_InnerBorderColorPressed;
  407. break;
  408. case State.NormalFocused:
  409. this.m_CurrentInnerBorderColor = this.m_InnerBorderColorFocused;
  410. break;
  411. case State.Disabled:
  412. this.m_CurrentInnerBorderColor = this.m_InnerBorderColorDisabled;
  413. break;
  414. case State.Hidden:
  415. this.m_CurrentInnerBorderColor = Color.Empty;
  416. break;
  417. case State.Highlight:
  418. this.m_CurrentInnerBorderColor = this.m_InnerBorderColorHighlight;
  419. break;
  420. default:
  421. this.m_CurrentInnerBorderColor = this.m_InnerBorderColor;
  422. break;
  423. }
  424. }
  425. return this.m_CurrentInnerBorderColor.Value;
  426. }
  427. }
  428. //内边框路径矩形
  429. private Rectangle? m_CurrentInnerBorderPathRect;
  430. /// <summary>
  431. /// 内边框路径矩形
  432. /// </summary>
  433. internal Rectangle CurrentInnerBorderPathRect
  434. {
  435. get
  436. {
  437. if (this.m_CurrentInnerBorderPathRect == null)
  438. {
  439. Rectangle rect = this.CurrentBorderPathRect;
  440. if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Left) != 0)
  441. {
  442. rect.X++;
  443. rect.Width--;
  444. }
  445. if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Top) != 0)
  446. {
  447. rect.Y++;
  448. rect.Height--;
  449. }
  450. if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Right) != 0)
  451. {
  452. rect.Width--;
  453. }
  454. if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
  455. {
  456. rect.Height--;
  457. }
  458. this.m_CurrentInnerBorderPathRect = rect;
  459. }
  460. return this.m_CurrentInnerBorderPathRect.Value;
  461. }
  462. }
  463. //内边框画刷矩形
  464. private Rectangle? m_CurrentInnerBorderBrushRect;
  465. /// <summary>
  466. /// 内边框画刷矩形
  467. /// </summary>
  468. internal Rectangle CurrentInnerBorderBrushRect
  469. {
  470. get
  471. {
  472. if (this.m_CurrentInnerBorderBrushRect == null)
  473. {
  474. this.m_CurrentInnerBorderBrushRect = RectangleEx.Inflate(this.CurrentInnerBorderPathRect, this.m_BackColorAlign, 1, 1);
  475. }
  476. return this.m_CurrentInnerBorderBrushRect.Value;
  477. }
  478. }
  479. //字符串绘制区域矩形,传递进来的值
  480. private Rectangle? m_CurrentStringClientRect;
  481. /// <summary>
  482. /// 字符串绘制区域矩形,传递进来的值
  483. /// </summary>
  484. internal Rectangle CurrentStringClientRect
  485. {
  486. get
  487. {
  488. if (this.m_CurrentStringClientRect == null)
  489. {
  490. this.m_CurrentStringClientRect = this.m_StringRect;
  491. }
  492. return this.m_CurrentStringClientRect.Value;
  493. }
  494. }
  495. //字符串实际绘制区域矩形,减去边距并偏移
  496. private Rectangle? m_CurrentStringRect;
  497. /// <summary>
  498. /// 字符串实际绘制区域矩形,减去边距并偏移
  499. /// </summary>
  500. internal Rectangle CurrentStringRect
  501. {
  502. get
  503. {
  504. if (this.m_CurrentStringRect == null)
  505. {
  506. Rectangle rect = RectangleEx.Subtract(this.CurrentStringClientRect, this.m_Padding);
  507. rect.Offset(this.m_TextOffset);
  508. this.m_CurrentStringRect = rect;
  509. }
  510. return this.m_CurrentStringRect.Value;
  511. }
  512. }
  513. //字符串路径的矩形
  514. private Rectangle? m_CurrentStringPathRect;
  515. /// <summary>
  516. /// 字符串路径的矩形
  517. /// </summary>
  518. internal Rectangle CurrentStringPathRect
  519. {
  520. get
  521. {
  522. if (this.m_CurrentStringPathRect == null)
  523. {
  524. return Rectangle.Empty;
  525. }
  526. return this.m_CurrentStringPathRect.Value;
  527. }
  528. }
  529. //字符串大小
  530. private Size? m_CurrentStringSize;
  531. /// <summary>
  532. /// 字符串大小
  533. /// </summary>
  534. internal Size CurrentStringSize
  535. {
  536. get
  537. {
  538. if (this.m_CurrentStringSize == null)
  539. {
  540. return Size.Empty;
  541. }
  542. return this.m_CurrentStringSize.Value;
  543. }
  544. }
  545. //文本图片绘制区域矩形,传递进来的值
  546. private Rectangle? m_CurrentTextImageClientRect;
  547. /// <summary>
  548. /// 文本图片绘制区域矩形,传递进来的值
  549. /// </summary>
  550. internal Rectangle CurrentTextImageClientRect
  551. {
  552. get
  553. {
  554. if (this.m_CurrentTextImageClientRect == null)
  555. {
  556. this.m_CurrentTextImageClientRect = this.m_TextImageRect;
  557. }
  558. return this.m_CurrentTextImageClientRect.Value;
  559. }
  560. }
  561. //可以容纳文本图片的矩形区域
  562. private Rectangle? m_CurrentTextImagePreferredRect;
  563. /// <summary>
  564. /// 可以容纳文本图片的矩形区域
  565. /// </summary>
  566. internal Rectangle CurrentTextImagePreferredRect
  567. {
  568. get
  569. {
  570. if (this.m_CurrentTextImagePreferredRect == null)
  571. {
  572. Rectangle imageRect = this.CurrentImagePreferredRect;
  573. Rectangle textRect = this.CurrentTextPreferredRect;
  574. if (imageRect.Width == 0 || imageRect.Height == 0)
  575. this.m_CurrentTextImagePreferredRect = textRect;
  576. else if (textRect.Width == 0 || textRect.Height == 0)
  577. this.m_CurrentTextImagePreferredRect = imageRect;
  578. else
  579. this.m_CurrentTextImagePreferredRect = Rectangle.Union(imageRect, textRect);
  580. }
  581. return this.m_CurrentTextImagePreferredRect.Value;
  582. }
  583. }
  584. //可以容纳文本的矩形区域
  585. private Rectangle? m_CurrentTextPreferredRect;
  586. /// <summary>
  587. /// 可以容纳文本的矩形区域
  588. /// </summary>
  589. internal Rectangle CurrentTextPreferredRect
  590. {
  591. get
  592. {
  593. if (this.m_CurrentTextPreferredRect == null)
  594. {
  595. this.m_CurrentTextPreferredRect = Rectangle.Empty;
  596. }
  597. return this.m_CurrentTextPreferredRect.Value;
  598. }
  599. private set
  600. {
  601. switch (this.m_State)
  602. {
  603. case State.Normal:
  604. this.m_CurrentTextPreferredRect = value;
  605. break;
  606. case State.Hovered:
  607. case State.HoveredFocused:
  608. this.m_CurrentTextPreferredRect = RectangleEx.Offset(value, this.TextOffsetHovered);
  609. break;
  610. case State.Pressed:
  611. case State.PressedFocused:
  612. this.m_CurrentTextPreferredRect = RectangleEx.Offset(value, this.TextOffsetPressed);
  613. break;
  614. case State.NormalFocused:
  615. this.m_CurrentTextPreferredRect = RectangleEx.Offset(value, this.TextOffsetFocused);
  616. break;
  617. case State.Disabled:
  618. this.m_CurrentTextPreferredRect = RectangleEx.Offset(value, this.TextOffsetDisabled);
  619. break;
  620. case State.Hidden:
  621. this.m_CurrentTextPreferredRect = value;
  622. break;
  623. case State.Highlight:
  624. this.m_CurrentTextPreferredRect = RectangleEx.Offset(value, this.TextOffsetHighlight);
  625. break;
  626. default:
  627. this.m_CurrentTextPreferredRect = value;
  628. break;
  629. }
  630. }
  631. }
  632. //当前前景色
  633. private Color? m_CurrentForeColor;
  634. /// <summary>
  635. /// 当前前景色
  636. /// </summary>
  637. internal Color CurrentForeColor
  638. {
  639. get
  640. {
  641. if (this.m_CurrentForeColor == null)
  642. {
  643. switch (this.m_State)
  644. {
  645. case State.Normal:
  646. this.m_CurrentForeColor = this.m_ForeColor;
  647. break;
  648. case State.Hovered:
  649. case State.HoveredFocused:
  650. this.m_CurrentForeColor = this.m_ForeColorHovered;
  651. break;
  652. case State.Pressed:
  653. case State.PressedFocused:
  654. this.m_CurrentForeColor = this.m_ForeColorPressed;
  655. break;
  656. case State.NormalFocused:
  657. this.m_CurrentForeColor = this.m_ForeColorFocused;
  658. break;
  659. case State.Disabled:
  660. this.m_CurrentForeColor = (this.m_TextGrayOnDisabled ? RenderEngine.GetGrayColor(this.CurrentBackColor) : this.m_ForeColorDisabled);
  661. break;
  662. case State.Hidden:
  663. this.m_CurrentForeColor = Color.Empty;
  664. break;
  665. case State.Highlight:
  666. this.m_CurrentForeColor = this.m_ForeColorHighlight;
  667. break;
  668. default:
  669. this.m_CurrentForeColor = this.m_ForeColor;
  670. break;
  671. }
  672. }
  673. return this.m_CurrentForeColor.Value;
  674. }
  675. }
  676. //可以容纳图片的矩形区域
  677. private Rectangle? m_CurrentImagePreferredRect;
  678. /// <summary>
  679. /// 可以容纳图片的矩形区域
  680. /// </summary>
  681. internal Rectangle CurrentImagePreferredRect
  682. {
  683. get
  684. {
  685. if (this.m_CurrentImagePreferredRect == null)
  686. {
  687. this.m_CurrentImagePreferredRect = Rectangle.Empty;
  688. }
  689. return this.m_CurrentImagePreferredRect.Value;
  690. }
  691. private set
  692. {
  693. switch (this.m_State)
  694. {
  695. case State.Normal:
  696. this.m_CurrentImagePreferredRect = value;
  697. break;
  698. case State.Hovered:
  699. case State.HoveredFocused:
  700. this.m_CurrentImagePreferredRect = RectangleEx.Offset(value, this.ImageOffsetHovered);
  701. break;
  702. case State.Pressed:
  703. case State.PressedFocused:
  704. this.m_CurrentImagePreferredRect = RectangleEx.Offset(value, this.ImageOffsetPressed);
  705. break;
  706. case State.NormalFocused:
  707. this.m_CurrentImagePreferredRect = RectangleEx.Offset(value, this.ImageOffsetFocused);
  708. break;
  709. case State.Disabled:
  710. this.m_CurrentImagePreferredRect = RectangleEx.Offset(value, this.ImageOffsetDisabled);
  711. break;
  712. case State.Hidden:
  713. this.m_CurrentImagePreferredRect = value;
  714. break;
  715. case State.Highlight:
  716. this.m_CurrentImagePreferredRect = RectangleEx.Offset(value, this.ImageOffsetHighlight);
  717. break;
  718. default:
  719. this.m_CurrentImagePreferredRect = value;
  720. break;
  721. }
  722. }
  723. }
  724. //当前图片
  725. private Image m_CurrentImage;
  726. /// <summary>
  727. /// 当前图片
  728. /// </summary>
  729. internal Image CurrentImage
  730. {
  731. get
  732. {
  733. if (this.m_CurrentImage == null)
  734. {
  735. switch (this.m_State)
  736. {
  737. case State.Normal:
  738. this.m_CurrentImage = this.m_Image;
  739. break;
  740. case State.Hovered:
  741. case State.HoveredFocused:
  742. this.m_CurrentImage = this.m_ImageHovered ?? this.m_Image;
  743. break;
  744. case State.Pressed:
  745. case State.PressedFocused:
  746. this.m_CurrentImage = this.m_ImagePressed ?? this.m_Image;
  747. break;
  748. case State.NormalFocused:
  749. this.m_CurrentImage = this.m_ImageFocused ?? this.m_Image;
  750. break;
  751. case State.Disabled:
  752. this.m_CurrentImage = this.m_ImageDisabled ?? this.m_Image;
  753. break;
  754. case State.Hidden:
  755. this.m_CurrentImage = null;
  756. break;
  757. case State.Highlight:
  758. this.m_CurrentImage = this.m_ImageHighlight ?? this.m_Image;
  759. break;
  760. default:
  761. this.m_CurrentImage = this.m_Image;
  762. break;
  763. }
  764. }
  765. return this.m_CurrentImage;
  766. }
  767. }
  768. //当前直线颜色
  769. private Color? m_CurrentLineColor;
  770. /// <summary>
  771. /// 当前直线颜色
  772. /// </summary>
  773. internal Color CurrentLineColor
  774. {
  775. get
  776. {
  777. if (this.m_CurrentLineColor == null)
  778. {
  779. switch (this.m_State)
  780. {
  781. case State.Normal:
  782. this.m_CurrentLineColor = this.m_LineColor;
  783. break;
  784. case State.Hovered:
  785. case State.HoveredFocused:
  786. this.m_CurrentLineColor = this.m_LineColorHovered;
  787. break;
  788. case State.Pressed:
  789. case State.PressedFocused:
  790. this.m_CurrentLineColor = this.m_LineColorPressed;
  791. break;
  792. case State.NormalFocused:
  793. this.m_CurrentLineColor = this.m_LineColorFocused;
  794. break;
  795. case State.Disabled:
  796. this.m_CurrentLineColor = this.m_LineColorDisabled;
  797. break;
  798. case State.Hidden:
  799. this.m_CurrentLineColor = Color.Empty;
  800. break;
  801. case State.Highlight:
  802. this.m_CurrentLineColor = this.m_LineColorHighlight;
  803. break;
  804. default:
  805. this.m_CurrentLineColor = this.m_LineColor;
  806. break;
  807. }
  808. }
  809. return this.m_CurrentLineColor.Value;
  810. }
  811. }
  812. }
  813. }