UIStyleUtils.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. using System.Drawing;
  2. using FastReport.DevComponents.DotNetBar;
  3. using FastReport.DevComponents.DotNetBar.Rendering;
  4. using FastReport.DevComponents.AdvTree;
  5. namespace FastReport.Utils
  6. {
  7. /// <summary>
  8. /// The style of FastReport user interface.
  9. /// </summary>
  10. public enum UIStyle
  11. {
  12. /// <summary>
  13. /// Specifies the Microsoft Office 2003 style (blue).
  14. /// </summary>
  15. Office2003,
  16. /// <summary>
  17. /// Specifies the Microsoft Office 2007 style (blue).
  18. /// </summary>
  19. Office2007Blue,
  20. /// <summary>
  21. /// Specifies the Microsoft Office 2007 style (silver).
  22. /// </summary>
  23. Office2007Silver,
  24. /// <summary>
  25. /// Specifies the Microsoft Office 2007 style (black).
  26. /// </summary>
  27. Office2007Black,
  28. /// <summary>
  29. /// Specifies the Office 2010 (Blue) style.
  30. /// </summary>
  31. Office2010Blue,
  32. /// <summary>
  33. /// Specifies the Office 2010 (Silver) style.
  34. /// </summary>
  35. Office2010Silver,
  36. /// <summary>
  37. /// Specifies the Office 2010 (Black) style.
  38. /// </summary>
  39. Office2010Black,
  40. /// <summary>
  41. /// Specifies the Office 2013 style.
  42. /// </summary>
  43. Office2013,
  44. /// <summary>
  45. /// Specifies the Microsoft Visual Studio 2005 style.
  46. /// </summary>
  47. VisualStudio2005,
  48. /// <summary>
  49. /// Specifies the Visual Studio 2010 style.
  50. /// </summary>
  51. VisualStudio2010,
  52. /// <summary>
  53. /// Specifies the Visual Studio 2012 (Light) style.
  54. /// </summary>
  55. VisualStudio2012Light,
  56. /// <summary>
  57. /// Specifies the Microsoft Vista style (black).
  58. /// </summary>
  59. VistaGlass
  60. }
  61. /// <summary>
  62. /// Contains conversion methods between FastReport's UIStyle to various enums.
  63. /// </summary>
  64. public static class UIStyleUtils
  65. {
  66. /// <summary>
  67. /// Contains visual style names.
  68. /// </summary>
  69. public static readonly string[] UIStyleNames = new string[] {
  70. "Office 2003",
  71. "Office 2007 Blue",
  72. "Office 2007 Silver",
  73. "Office 2007 Black",
  74. "Office 2010 Blue",
  75. "Office 2010 Silver",
  76. "Office 2010 Black",
  77. "Office 2013",
  78. "VisualStudio 2005",
  79. "VisualStudio 2010",
  80. "VisualStudio 2012",
  81. "VistaGlass"
  82. };
  83. internal static bool IsOffice2007Scheme(UIStyle style)
  84. {
  85. return style == UIStyle.Office2007Blue ||
  86. style == UIStyle.Office2007Silver ||
  87. style == UIStyle.Office2007Black ||
  88. style == UIStyle.Office2010Blue ||
  89. style == UIStyle.Office2010Silver ||
  90. style == UIStyle.Office2010Black ||
  91. style == UIStyle.VistaGlass;
  92. }
  93. /// <summary>
  94. /// Converts FastReport's UIStyle to eDotNetBarStyle.
  95. /// </summary>
  96. /// <param name="style">Style to convert.</param>
  97. /// <returns>Value of eDotNetBarStyle type.</returns>
  98. public static eDotNetBarStyle GetDotNetBarStyle(UIStyle style)
  99. {
  100. switch (style)
  101. {
  102. case UIStyle.VisualStudio2005:
  103. return eDotNetBarStyle.VS2005;
  104. case UIStyle.Office2003:
  105. return eDotNetBarStyle.Office2003;
  106. case UIStyle.Office2007Blue:
  107. ((Office2007Renderer)GlobalManager.Renderer).ColorTable = new Office2007ColorTable(eOffice2007ColorScheme.Blue);
  108. return eDotNetBarStyle.Office2007;
  109. case UIStyle.Office2007Silver:
  110. ((Office2007Renderer)GlobalManager.Renderer).ColorTable = new Office2007ColorTable(eOffice2007ColorScheme.Silver);
  111. return eDotNetBarStyle.Office2007;
  112. case UIStyle.Office2007Black:
  113. ((Office2007Renderer)GlobalManager.Renderer).ColorTable = new Office2007ColorTable(eOffice2007ColorScheme.Black);
  114. return eDotNetBarStyle.Office2007;
  115. case UIStyle.Office2010Blue:
  116. ((Office2007Renderer)GlobalManager.Renderer).ColorTable = new Office2010ColorTable(eOffice2010ColorScheme.Blue);
  117. return eDotNetBarStyle.Office2010;
  118. case UIStyle.Office2010Silver:
  119. ((Office2007Renderer)GlobalManager.Renderer).ColorTable = new Office2010ColorTable(eOffice2010ColorScheme.Silver);
  120. return eDotNetBarStyle.Office2010;
  121. case UIStyle.Office2010Black:
  122. ((Office2007Renderer)GlobalManager.Renderer).ColorTable = new Office2010ColorTable(eOffice2010ColorScheme.Black);
  123. return eDotNetBarStyle.Office2010;
  124. case UIStyle.VistaGlass:
  125. ((Office2007Renderer)GlobalManager.Renderer).ColorTable = new Office2007ColorTable(eOffice2007ColorScheme.VistaGlass);
  126. return eDotNetBarStyle.Office2007;
  127. }
  128. return eDotNetBarStyle.StyleManagerControlled;
  129. }
  130. /// <summary>
  131. /// Converts FastReport's UIStyle to eTabStripStyle.
  132. /// </summary>
  133. /// <param name="style">Style to convert.</param>
  134. /// <returns>Value of eTabStripStyle type.</returns>
  135. public static eTabStripStyle GetTabStripStyle(UIStyle style)
  136. {
  137. switch (style)
  138. {
  139. case UIStyle.VisualStudio2005:
  140. return eTabStripStyle.VS2005Document;
  141. case UIStyle.Office2003:
  142. return eTabStripStyle.Office2003;
  143. case UIStyle.Office2007Blue:
  144. case UIStyle.Office2007Silver:
  145. case UIStyle.Office2007Black:
  146. case UIStyle.VistaGlass:
  147. return eTabStripStyle.Office2007Document;
  148. case UIStyle.Office2010Black:
  149. case UIStyle.Office2010Blue:
  150. case UIStyle.Office2010Silver:
  151. case UIStyle.VisualStudio2010:
  152. return eTabStripStyle.Office2007Dock;
  153. }
  154. return eTabStripStyle.Metro;
  155. }
  156. /// <summary>
  157. /// Converts FastReport's UIStyle to eTabStripStyle.
  158. /// </summary>
  159. /// <param name="style">Style to convert.</param>
  160. /// <returns>Value of eTabStripStyle type.</returns>
  161. public static eTabStripStyle GetTabStripStyle1(UIStyle style)
  162. {
  163. switch (style)
  164. {
  165. case UIStyle.VisualStudio2005:
  166. return eTabStripStyle.VS2005;
  167. case UIStyle.Office2003:
  168. return eTabStripStyle.Office2003;
  169. case UIStyle.Office2007Blue:
  170. case UIStyle.Office2007Silver:
  171. case UIStyle.Office2007Black:
  172. case UIStyle.VistaGlass:
  173. return eTabStripStyle.Office2007Dock;
  174. case UIStyle.Office2010Black:
  175. case UIStyle.Office2010Blue:
  176. case UIStyle.Office2010Silver:
  177. case UIStyle.VisualStudio2010:
  178. return eTabStripStyle.Office2007Dock;
  179. }
  180. return eTabStripStyle.Metro;
  181. }
  182. /// <summary>
  183. /// Converts FastReport's UIStyle to eOffice2007ColorScheme.
  184. /// </summary>
  185. /// <param name="style">Style to convert.</param>
  186. /// <returns>Value of eOffice2007ColorScheme type.</returns>
  187. public static eOffice2007ColorScheme GetOffice2007ColorScheme(UIStyle style)
  188. {
  189. switch (style)
  190. {
  191. case UIStyle.Office2007Blue:
  192. case UIStyle.Office2010Blue:
  193. return eOffice2007ColorScheme.Blue;
  194. case UIStyle.Office2007Silver:
  195. case UIStyle.Office2010Silver:
  196. return eOffice2007ColorScheme.Silver;
  197. case UIStyle.Office2007Black:
  198. case UIStyle.Office2010Black:
  199. return eOffice2007ColorScheme.Black;
  200. case UIStyle.VistaGlass:
  201. return eOffice2007ColorScheme.VistaGlass;
  202. }
  203. return eOffice2007ColorScheme.Blue;
  204. }
  205. /// <summary>
  206. /// Converts FastReport's UIStyle to eColorSchemeStyle.
  207. /// </summary>
  208. /// <param name="style">Style to convert.</param>
  209. /// <returns>Value of eColorSchemeStyle type.</returns>
  210. public static eColorSchemeStyle GetColorSchemeStyle(UIStyle style)
  211. {
  212. switch (style)
  213. {
  214. case UIStyle.Office2003:
  215. return eColorSchemeStyle.Office2003;
  216. case UIStyle.VisualStudio2005:
  217. return eColorSchemeStyle.VS2005;
  218. }
  219. return eColorSchemeStyle.Office2007;
  220. }
  221. /// <summary>
  222. /// Returns app workspace color for the given style.
  223. /// </summary>
  224. /// <param name="style">UI style.</param>
  225. /// <returns>The color.</returns>
  226. public static Color GetAppWorkspaceColor(UIStyle style)
  227. {
  228. switch (style)
  229. {
  230. case UIStyle.Office2003:
  231. return Color.FromArgb(144, 153, 174);
  232. case UIStyle.Office2007Blue:
  233. return Color.FromArgb(101, 145, 205);
  234. case UIStyle.Office2007Silver:
  235. return Color.FromArgb(156, 160, 167);
  236. case UIStyle.Office2007Black:
  237. return Color.FromArgb(90, 90, 90);
  238. case UIStyle.Office2010Blue:
  239. return Color.FromArgb(101, 145, 205);
  240. case UIStyle.Office2010Silver:
  241. return Color.FromArgb(156, 160, 167);
  242. case UIStyle.Office2010Black:
  243. return Color.FromArgb(90, 90, 90);
  244. case UIStyle.VistaGlass:
  245. return Color.FromArgb(90, 90, 90);
  246. }
  247. return Color.FromArgb(239, 239, 242);
  248. }
  249. /// <summary>
  250. /// Returns control color for the given style.
  251. /// </summary>
  252. /// <param name="style">UI style.</param>
  253. /// <returns>The color.</returns>
  254. public static Color GetControlColor(UIStyle style)
  255. {
  256. switch (style)
  257. {
  258. case UIStyle.Office2003:
  259. return Color.FromArgb(182, 208, 248);
  260. case UIStyle.Office2007Blue:
  261. return Color.FromArgb(180, 212, 255);
  262. case UIStyle.Office2007Silver:
  263. return Color.FromArgb(215, 214, 228);
  264. case UIStyle.Office2007Black:
  265. return Color.FromArgb(204, 207, 212);
  266. case UIStyle.Office2010Blue:
  267. return Color.FromArgb(215, 228, 242);
  268. case UIStyle.Office2010Silver:
  269. return Color.FromArgb(229, 233, 237);
  270. case UIStyle.Office2010Black:
  271. return Color.FromArgb(200, 200, 200);
  272. case UIStyle.VisualStudio2010:
  273. return Color.FromArgb(188, 199, 216);
  274. case UIStyle.VisualStudio2012Light:
  275. return Color.FromArgb(230, 231, 232);
  276. case UIStyle.VistaGlass:
  277. return Color.FromArgb(218, 224, 239);
  278. }
  279. return GetAppWorkspaceColor(style);
  280. }
  281. }
  282. }