ThemedColors.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System.Windows.Forms;
  2. using System.Windows.Forms.VisualStyles;
  3. using System.Drawing;
  4. namespace UAS_SOP
  5. {
  6. class ThemedColors
  7. {
  8. #region " Variables and Constants "
  9. private const string NormalColor = "NormalColor";
  10. private const string HomeStead = "HomeStead";
  11. private const string Metallic = "Metallic";
  12. private const string NoTheme = "NoTheme";
  13. private static Color[] _toolBorder;
  14. #endregion
  15. #region " Properties "
  16. public static int CurrentThemeIndex
  17. {
  18. get
  19. {
  20. return ThemedColors.GetCurrentThemeIndex();
  21. }
  22. }
  23. public static string CurrentThemeName
  24. {
  25. get
  26. {
  27. return ThemedColors.GetCurrentThemeName();
  28. }
  29. }
  30. public static Color ToolBorder
  31. {
  32. get
  33. {
  34. return ThemedColors._toolBorder[ThemedColors.CurrentThemeIndex];
  35. }
  36. }
  37. #endregion
  38. #region " Constructors "
  39. private ThemedColors()
  40. {
  41. }
  42. static ThemedColors()
  43. {
  44. Color[] colorArray1;
  45. colorArray1 = new Color[] { Color.FromArgb(127, 157, 185), Color.FromArgb(164, 185, 127), Color.FromArgb(165, 172, 178), Color.FromArgb(132, 130, 132) };
  46. ThemedColors._toolBorder = colorArray1;
  47. }
  48. #endregion
  49. private static int GetCurrentThemeIndex()
  50. {
  51. int theme = (int)ColorScheme.NoTheme;
  52. if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser && Application.RenderWithVisualStyles)
  53. {
  54. switch (VisualStyleInformation.ColorScheme)
  55. {
  56. case NormalColor:
  57. theme = (int)ColorScheme.NormalColor;
  58. break;
  59. case HomeStead:
  60. theme = (int)ColorScheme.HomeStead;
  61. break;
  62. case Metallic:
  63. theme = (int)ColorScheme.Metallic;
  64. break;
  65. default:
  66. theme = (int)ColorScheme.NoTheme;
  67. break;
  68. }
  69. }
  70. return theme;
  71. }
  72. private static string GetCurrentThemeName()
  73. {
  74. string theme = NoTheme;
  75. if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser && Application.RenderWithVisualStyles)
  76. {
  77. theme = VisualStyleInformation.ColorScheme;
  78. }
  79. return theme;
  80. }
  81. public enum ColorScheme
  82. {
  83. NormalColor = 0,
  84. HomeStead = 1,
  85. Metallic = 2,
  86. NoTheme = 3
  87. }
  88. }
  89. }