DockPanelSkin.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:DockPanelSkin.cs
  5. * 2.功能描述:类文件
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2014/09/01 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.ComponentModel;
  12. using System.Drawing;
  13. using System.Drawing.Drawing2D;
  14. namespace Dongke.IBOSS.PRD.Basics.DockPanel
  15. {
  16. #region DockPanelSkin classes
  17. /// <summary>
  18. /// The skin to use when displaying the DockPanel.
  19. /// The skin allows custom gradient color schemes to be used when drawing the
  20. /// DockStrips and Tabs.
  21. /// </summary>
  22. [TypeConverter(typeof(DockPanelSkinConverter))]
  23. public class DockPanelSkin
  24. {
  25. private AutoHideStripSkin m_autoHideStripSkin = new AutoHideStripSkin();
  26. private DockPaneStripSkin m_dockPaneStripSkin = new DockPaneStripSkin();
  27. /// <summary>
  28. /// The skin used to display the auto hide strips and tabs.
  29. /// </summary>
  30. public AutoHideStripSkin AutoHideStripSkin
  31. {
  32. get
  33. {
  34. return m_autoHideStripSkin;
  35. }
  36. set
  37. {
  38. m_autoHideStripSkin = value;
  39. }
  40. }
  41. /// <summary>
  42. /// The skin used to display the Document and ToolWindow style DockStrips and Tabs.
  43. /// </summary>
  44. public DockPaneStripSkin DockPaneStripSkin
  45. {
  46. get
  47. {
  48. return m_dockPaneStripSkin;
  49. }
  50. set
  51. {
  52. m_dockPaneStripSkin = value;
  53. }
  54. }
  55. }
  56. /// <summary>
  57. /// The skin used to display the auto hide strip and tabs.
  58. /// </summary>
  59. [TypeConverter(typeof(AutoHideStripConverter))]
  60. public class AutoHideStripSkin
  61. {
  62. private DockPanelGradient m_dockStripGradient = new DockPanelGradient();
  63. private TabGradient m_TabGradient = new TabGradient();
  64. private Font m_textFont = SystemFonts.MenuFont;
  65. /// <summary>
  66. /// The gradient color skin for the DockStrips.
  67. /// </summary>
  68. public DockPanelGradient DockStripGradient
  69. {
  70. get
  71. {
  72. return m_dockStripGradient;
  73. }
  74. set
  75. {
  76. m_dockStripGradient = value;
  77. }
  78. }
  79. /// <summary>
  80. /// The gradient color skin for the Tabs.
  81. /// </summary>
  82. public TabGradient TabGradient
  83. {
  84. get
  85. {
  86. return m_TabGradient;
  87. }
  88. set
  89. {
  90. m_TabGradient = value;
  91. }
  92. }
  93. /// <summary>
  94. /// Font used in AutoHideStrip elements.
  95. /// </summary>
  96. [DefaultValue(typeof(SystemFonts), "MenuFont")]
  97. public Font TextFont
  98. {
  99. get
  100. {
  101. return m_textFont;
  102. }
  103. set
  104. {
  105. m_textFont = value;
  106. }
  107. }
  108. }
  109. /// <summary>
  110. /// The skin used to display the document and tool strips and tabs.
  111. /// </summary>
  112. [TypeConverter(typeof(DockPaneStripConverter))]
  113. public class DockPaneStripSkin
  114. {
  115. private DockPaneStripGradient m_DocumentGradient = new DockPaneStripGradient();
  116. private DockPaneStripToolWindowGradient m_ToolWindowGradient = new DockPaneStripToolWindowGradient();
  117. private Font m_textFont = SystemFonts.MenuFont;
  118. /// <summary>
  119. /// The skin used to display the Document style DockPane strip and tab.
  120. /// </summary>
  121. public DockPaneStripGradient DocumentGradient
  122. {
  123. get
  124. {
  125. return m_DocumentGradient;
  126. }
  127. set
  128. {
  129. m_DocumentGradient = value;
  130. }
  131. }
  132. /// <summary>
  133. /// The skin used to display the ToolWindow style DockPane strip and tab.
  134. /// </summary>
  135. public DockPaneStripToolWindowGradient ToolWindowGradient
  136. {
  137. get
  138. {
  139. return m_ToolWindowGradient;
  140. }
  141. set
  142. {
  143. m_ToolWindowGradient = value;
  144. }
  145. }
  146. /// <summary>
  147. /// Font used in DockPaneStrip elements.
  148. /// </summary>
  149. [DefaultValue(typeof(SystemFonts), "MenuFont")]
  150. public Font TextFont
  151. {
  152. get
  153. {
  154. return m_textFont;
  155. }
  156. set
  157. {
  158. m_textFont = value;
  159. }
  160. }
  161. }
  162. /// <summary>
  163. /// The skin used to display the DockPane ToolWindow strip and tab.
  164. /// </summary>
  165. [TypeConverter(typeof(DockPaneStripGradientConverter))]
  166. public class DockPaneStripToolWindowGradient : DockPaneStripGradient
  167. {
  168. private TabGradient m_activeCaptionGradient = new TabGradient();
  169. private TabGradient m_inactiveCaptionGradient = new TabGradient();
  170. /// <summary>
  171. /// The skin used to display the active ToolWindow caption.
  172. /// </summary>
  173. public TabGradient ActiveCaptionGradient
  174. {
  175. get
  176. {
  177. return m_activeCaptionGradient;
  178. }
  179. set
  180. {
  181. m_activeCaptionGradient = value;
  182. }
  183. }
  184. /// <summary>
  185. /// The skin used to display the inactive ToolWindow caption.
  186. /// </summary>
  187. public TabGradient InactiveCaptionGradient
  188. {
  189. get
  190. {
  191. return m_inactiveCaptionGradient;
  192. }
  193. set
  194. {
  195. m_inactiveCaptionGradient = value;
  196. }
  197. }
  198. }
  199. /// <summary>
  200. /// The skin used to display the DockPane strip and tab.
  201. /// </summary>
  202. [TypeConverter(typeof(DockPaneStripGradientConverter))]
  203. public class DockPaneStripGradient
  204. {
  205. private DockPanelGradient m_dockStripGradient = new DockPanelGradient();
  206. private TabGradient m_activeTabGradient = new TabGradient();
  207. private TabGradient m_inactiveTabGradient = new TabGradient();
  208. /// <summary>
  209. /// The gradient color skin for the DockStrip.
  210. /// </summary>
  211. public DockPanelGradient DockStripGradient
  212. {
  213. get
  214. {
  215. return m_dockStripGradient;
  216. }
  217. set
  218. {
  219. m_dockStripGradient = value;
  220. }
  221. }
  222. /// <summary>
  223. /// The skin used to display the active DockPane tabs.
  224. /// </summary>
  225. public TabGradient ActiveTabGradient
  226. {
  227. get
  228. {
  229. return m_activeTabGradient;
  230. }
  231. set
  232. {
  233. m_activeTabGradient = value;
  234. }
  235. }
  236. /// <summary>
  237. /// The skin used to display the inactive DockPane tabs.
  238. /// </summary>
  239. public TabGradient InactiveTabGradient
  240. {
  241. get
  242. {
  243. return m_inactiveTabGradient;
  244. }
  245. set
  246. {
  247. m_inactiveTabGradient = value;
  248. }
  249. }
  250. }
  251. /// <summary>
  252. /// The skin used to display the dock pane tab
  253. /// </summary>
  254. [TypeConverter(typeof(DockPaneTabGradientConverter))]
  255. public class TabGradient : DockPanelGradient
  256. {
  257. private Color m_textColor = SystemColors.ControlText;
  258. /// <summary>
  259. /// The text color.
  260. /// </summary>
  261. [DefaultValue(typeof(SystemColors), "ControlText")]
  262. public Color TextColor
  263. {
  264. get
  265. {
  266. return m_textColor;
  267. }
  268. set
  269. {
  270. m_textColor = value;
  271. }
  272. }
  273. }
  274. /// <summary>
  275. /// The gradient color skin.
  276. /// </summary>
  277. [TypeConverter(typeof(DockPanelGradientConverter))]
  278. public class DockPanelGradient
  279. {
  280. private Color m_startColor = SystemColors.Control;
  281. private Color m_endColor = SystemColors.Control;
  282. private LinearGradientMode m_linearGradientMode = LinearGradientMode.Horizontal;
  283. /// <summary>
  284. /// The beginning gradient color.
  285. /// </summary>
  286. [DefaultValue(typeof(SystemColors), "Control")]
  287. public Color StartColor
  288. {
  289. get
  290. {
  291. return m_startColor;
  292. }
  293. set
  294. {
  295. m_startColor = value;
  296. }
  297. }
  298. /// <summary>
  299. /// The ending gradient color.
  300. /// </summary>
  301. [DefaultValue(typeof(SystemColors), "Control")]
  302. public Color EndColor
  303. {
  304. get
  305. {
  306. return m_endColor;
  307. }
  308. set
  309. {
  310. m_endColor = value;
  311. }
  312. }
  313. /// <summary>
  314. /// The gradient mode to display the colors.
  315. /// </summary>
  316. [DefaultValue(LinearGradientMode.Horizontal)]
  317. public LinearGradientMode LinearGradientMode
  318. {
  319. get
  320. {
  321. return m_linearGradientMode;
  322. }
  323. set
  324. {
  325. m_linearGradientMode = value;
  326. }
  327. }
  328. }
  329. #endregion
  330. #region Converters
  331. public class DockPanelSkinConverter : ExpandableObjectConverter
  332. {
  333. public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
  334. {
  335. if (destinationType == typeof(DockPanelSkin))
  336. return true;
  337. return base.CanConvertTo(context, destinationType);
  338. }
  339. public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
  340. {
  341. if (destinationType == typeof(String) && value is DockPanelSkin)
  342. {
  343. return "DockPanelSkin";
  344. }
  345. return base.ConvertTo(context, culture, value, destinationType);
  346. }
  347. }
  348. public class DockPanelGradientConverter : ExpandableObjectConverter
  349. {
  350. public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
  351. {
  352. if (destinationType == typeof(DockPanelGradient))
  353. return true;
  354. return base.CanConvertTo(context, destinationType);
  355. }
  356. public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
  357. {
  358. if (destinationType == typeof(String) && value is DockPanelGradient)
  359. {
  360. return "DockPanelGradient";
  361. }
  362. return base.ConvertTo(context, culture, value, destinationType);
  363. }
  364. }
  365. public class AutoHideStripConverter : ExpandableObjectConverter
  366. {
  367. public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
  368. {
  369. if (destinationType == typeof(AutoHideStripSkin))
  370. return true;
  371. return base.CanConvertTo(context, destinationType);
  372. }
  373. public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
  374. {
  375. if (destinationType == typeof(String) && value is AutoHideStripSkin)
  376. {
  377. return "AutoHideStripSkin";
  378. }
  379. return base.ConvertTo(context, culture, value, destinationType);
  380. }
  381. }
  382. public class DockPaneStripConverter : ExpandableObjectConverter
  383. {
  384. public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
  385. {
  386. if (destinationType == typeof(DockPaneStripSkin))
  387. return true;
  388. return base.CanConvertTo(context, destinationType);
  389. }
  390. public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
  391. {
  392. if (destinationType == typeof(String) && value is DockPaneStripSkin)
  393. {
  394. return "DockPaneStripSkin";
  395. }
  396. return base.ConvertTo(context, culture, value, destinationType);
  397. }
  398. }
  399. public class DockPaneStripGradientConverter : ExpandableObjectConverter
  400. {
  401. public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
  402. {
  403. if (destinationType == typeof(DockPaneStripGradient))
  404. return true;
  405. return base.CanConvertTo(context, destinationType);
  406. }
  407. public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
  408. {
  409. if (destinationType == typeof(String) && value is DockPaneStripGradient)
  410. {
  411. return "DockPaneStripGradient";
  412. }
  413. return base.ConvertTo(context, culture, value, destinationType);
  414. }
  415. }
  416. public class DockPaneTabGradientConverter : ExpandableObjectConverter
  417. {
  418. public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
  419. {
  420. if (destinationType == typeof(TabGradient))
  421. return true;
  422. return base.CanConvertTo(context, destinationType);
  423. }
  424. public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
  425. {
  426. TabGradient val = value as TabGradient;
  427. if (destinationType == typeof(String) && val != null)
  428. {
  429. return "DockPaneTabGradient";
  430. }
  431. return base.ConvertTo(context, culture, value, destinationType);
  432. }
  433. }
  434. #endregion
  435. }