/OpenNETCF.Drawing/OpenNETCF.Drawing/SystemColorsEx.cs

https://github.com/ctacke/sdf · C# · 676 lines · 487 code · 54 blank · 135 comment · 279 complexity · 64f7eb45779e2fda4825253504fcb4e6 MD5 · raw file

  1. using System.Runtime.InteropServices;
  2. using System.Diagnostics;
  3. using System.Drawing;
  4. using System;
  5. namespace OpenNETCF.Drawing {
  6. /// <summary>
  7. ///
  8. /// </summary>
  9. public static class SystemColorsHelper {
  10. #region SetSchemeByName
  11. #region SchemeName
  12. /// <summary>
  13. /// System Color scheme names
  14. /// </summary>
  15. public enum SchemeName {
  16. /// <summary>
  17. /// Brick
  18. /// </summary>
  19. Brick = 1,
  20. /// <summary>
  21. /// Desert
  22. /// </summary>
  23. Desert,
  24. /// <summary>
  25. /// Eggplant
  26. /// </summary>
  27. Eggplant,
  28. /// <summary>
  29. /// High-Contrast Black
  30. /// </summary>
  31. HighContrastBlack,
  32. /// <summary>
  33. /// High-Contrast White
  34. /// </summary>
  35. HighContrastWhite,
  36. /// <summary>
  37. /// Lilac
  38. /// </summary>
  39. Lilac = 6,
  40. //Maple
  41. //Marine
  42. //Rose
  43. /// <summary>
  44. /// Spruce
  45. /// </summary>
  46. Spruce = 10,
  47. /// <summary>
  48. /// Storm
  49. /// </summary>
  50. Storm = 11,
  51. //Wheat
  52. /// <summary>
  53. /// Windows Standard
  54. /// </summary>
  55. WindowsStandard = 13
  56. }
  57. #endregion
  58. /// <summary>
  59. /// Sets the current system color scheme
  60. /// </summary>
  61. /// <param name="aSchemeName"></param>
  62. public static void SetSchemeByName(SchemeName aSchemeName) {
  63. if ((int)aSchemeName < 1 || (int)aSchemeName > 13) {
  64. throw new ApplicationException("Please use the enum and don't make up values");
  65. }
  66. Int32[] el = {0 | SYS_COLOR_INDEX_FLAG, 1 | SYS_COLOR_INDEX_FLAG, 2 | SYS_COLOR_INDEX_FLAG, 3 | SYS_COLOR_INDEX_FLAG, 4 | SYS_COLOR_INDEX_FLAG, 5 | SYS_COLOR_INDEX_FLAG, 6 | SYS_COLOR_INDEX_FLAG, 7 | SYS_COLOR_INDEX_FLAG, 8 | SYS_COLOR_INDEX_FLAG, 9 | SYS_COLOR_INDEX_FLAG, 10 | SYS_COLOR_INDEX_FLAG, 11 | SYS_COLOR_INDEX_FLAG, 12 | SYS_COLOR_INDEX_FLAG, 13 | SYS_COLOR_INDEX_FLAG, 14 | SYS_COLOR_INDEX_FLAG, 15 | SYS_COLOR_INDEX_FLAG, 16 | SYS_COLOR_INDEX_FLAG, 17 | SYS_COLOR_INDEX_FLAG, 18 | SYS_COLOR_INDEX_FLAG, 19 | SYS_COLOR_INDEX_FLAG, 20 | SYS_COLOR_INDEX_FLAG, 21 | SYS_COLOR_INDEX_FLAG, 22 | SYS_COLOR_INDEX_FLAG, 23 | SYS_COLOR_INDEX_FLAG, 24 | SYS_COLOR_INDEX_FLAG, 25 | SYS_COLOR_INDEX_FLAG, 26 | SYS_COLOR_INDEX_FLAG, 27 | SYS_COLOR_INDEX_FLAG, 28 | SYS_COLOR_INDEX_FLAG};
  67. Int32[] rgbs = GetArrayOfRGBs(aSchemeName);
  68. if (SetSysColors(29, el, rgbs) == false) {
  69. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  70. }
  71. // write name to registry
  72. string n;
  73. if (aSchemeName == SchemeName.HighContrastBlack) {
  74. n = "High Contrast Black";
  75. } else if (aSchemeName == SchemeName.HighContrastWhite) {
  76. n = "High Contrast White";
  77. } else if (aSchemeName == SchemeName.WindowsStandard) {
  78. n = "Windows Standard";
  79. } else {
  80. n = aSchemeName.ToString();
  81. }
  82. // TODO write to registry the name (key: HKEY_CURRENT_USER\ControlPanel\Appearance name:Current)
  83. }
  84. private static Int32[] GetArrayOfRGBs(SchemeName aSchemeName) {
  85. if (aSchemeName == SchemeName.Brick) {
  86. return GetBrick();
  87. } else if (aSchemeName == SchemeName.Desert) {
  88. return GetDesert();
  89. } else if (aSchemeName == SchemeName.Eggplant) {
  90. return GetEggplant();
  91. } else if (aSchemeName == SchemeName.HighContrastBlack) {
  92. return GetHighContrastBlack();
  93. } else if (aSchemeName == SchemeName.HighContrastWhite) {
  94. return GetHighContrastWhite();
  95. } else if (aSchemeName == SchemeName.Lilac) {
  96. return GetLilac();
  97. } else if (aSchemeName == SchemeName.Spruce) {
  98. return GetSpruce();
  99. } else if (aSchemeName == SchemeName.Storm) {
  100. return GetStorm();
  101. } else if (aSchemeName == SchemeName.WindowsStandard) {
  102. return GetWindowsStandard();
  103. }else{
  104. throw new NotSupportedException();
  105. }
  106. //Case SchemeName.Maple, SchemeName.Marine, SchemeName.Rose, SchemeName.Wheat
  107. // Throw New NotSupportedException("Maple, Marine, Rose requires non-zero alpha")
  108. }
  109. private static Int32[] GetEggplant() {
  110. return new Int32[]{BitConverter.ToInt32(new byte[]{213, 231, 211, 0}, 0), BitConverter.ToInt32(new byte[]{64, 0, 64, 0}, 0), BitConverter.ToInt32(new byte[]{77, 0, 77, 0}, 0), BitConverter.ToInt32(new byte[]{165, 80, 141, 0}, 0), BitConverter.ToInt32(new byte[]{91, 152, 86, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{91, 152, 86, 0}, 0), BitConverter.ToInt32(new byte[]{91, 152, 86, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{55, 92, 52, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{91, 152, 86, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{120, 82, 109, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{79, 79, 79, 0}, 0), BitConverter.ToInt32(new byte[]{160, 201, 156, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{128, 0, 128, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{91, 152, 86, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  111. }
  112. private static Int32[] GetHighContrastBlack() {
  113. return new Int32[]{BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{128, 0, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 128, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  114. }
  115. private static Int32[] GetHighContrastWhite() {
  116. return new Int32[]{BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  117. }
  118. private static Int32[] GetLilac() {
  119. return new Int32[]{BitConverter.ToInt32(new byte[]{163, 168, 217, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{90, 78, 177, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{163, 168, 217, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{163, 168, 217, 0}, 0), BitConverter.ToInt32(new byte[]{163, 168, 217, 0}, 0), BitConverter.ToInt32(new byte[]{90, 78, 177, 0}, 0), BitConverter.ToInt32(new byte[]{90, 78, 177, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{163, 168, 217, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{105, 105, 105, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{216, 168, 236, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{163, 168, 217, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  120. }
  121. private static Int32[] GetSpruce() {
  122. return new Int32[]{BitConverter.ToInt32(new byte[]{208, 227, 211, 0}, 0), BitConverter.ToInt32(new byte[]{46, 88, 46, 0}, 0), BitConverter.ToInt32(new byte[]{89, 151, 100, 0}, 0), BitConverter.ToInt32(new byte[]{127, 127, 127, 0}, 0), BitConverter.ToInt32(new byte[]{162, 200, 169, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{162, 200, 169, 0}, 0), BitConverter.ToInt32(new byte[]{162, 200, 169, 0}, 0), BitConverter.ToInt32(new byte[]{208, 227, 211, 0}, 0), BitConverter.ToInt32(new byte[]{89, 151, 100, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{162, 200, 169, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{99, 165, 99, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{208, 227, 211, 0}, 0), BitConverter.ToInt32(new byte[]{208, 227, 211, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{162, 200, 169, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  123. }
  124. private static Int32[] GetStorm() {
  125. return new Int32[]{BitConverter.ToInt32(new byte[]{231, 231, 231, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 47, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{160, 160, 160, 0}, 0), BitConverter.ToInt32(new byte[]{160, 160, 160, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 102, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{160, 160, 160, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{36, 36, 36, 0}, 0), BitConverter.ToInt32(new byte[]{231, 231, 231, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{128, 0, 128, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{160, 160, 160, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  126. }
  127. private static Int32[] GetWindowsStandard() {
  128. return new Int32[]{BitConverter.ToInt32(new byte[]{224, 224, 224, 0}, 0), BitConverter.ToInt32(new byte[]{58, 110, 165, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 128, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 128, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{223, 223, 223, 0}, 0), BitConverter.ToInt32(new byte[]{128, 0, 128, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{192, 192, 192, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  129. }
  130. private static Int32[] GetBrick() {
  131. return new Int32[]{BitConverter.ToInt32(new byte[]{232, 231, 221, 0}, 0), BitConverter.ToInt32(new byte[]{155, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{128, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{141, 137, 97, 0}, 0), BitConverter.ToInt32(new byte[]{162, 157, 117, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{225, 224, 210, 0}, 0), BitConverter.ToInt32(new byte[]{163, 158, 118, 0}, 0), BitConverter.ToInt32(new byte[]{163, 158, 118, 0}, 0), BitConverter.ToInt32(new byte[]{225, 224, 210, 0}, 0), BitConverter.ToInt32(new byte[]{141, 137, 97, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{163, 158, 118, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{225, 224, 210, 0}, 0), BitConverter.ToInt32(new byte[]{232, 231, 221, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{128, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{225, 224, 210, 0}, 0), BitConverter.ToInt32(new byte[]{159, 155, 115, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  132. }
  133. private static Int32[] GetDesert() {
  134. return new Int32[]{BitConverter.ToInt32(new byte[]{234, 230, 221, 0}, 0), BitConverter.ToInt32(new byte[]{162, 141, 104, 0}, 0), BitConverter.ToInt32(new byte[]{0, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{162, 141, 104, 0}, 0), BitConverter.ToInt32(new byte[]{204, 194, 173, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{204, 194, 173, 0}, 0), BitConverter.ToInt32(new byte[]{204, 194, 173, 0}, 0), BitConverter.ToInt32(new byte[]{162, 141, 104, 0}, 0), BitConverter.ToInt32(new byte[]{0, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{204, 194, 173, 0}, 0), BitConverter.ToInt32(new byte[]{128, 128, 128, 0}, 0), BitConverter.ToInt32(new byte[]{162, 141, 104, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{234, 230, 221, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{255, 255, 255, 0}, 0), BitConverter.ToInt32(new byte[]{204, 194, 173, 0}, 0), BitConverter.ToInt32(new byte[]{0, 0, 0, 0}, 0), BitConverter.ToInt32(new byte[]{16, 132, 208, 0}, 0), BitConverter.ToInt32(new byte[]{181, 181, 181, 0}, 0)};
  135. }
  136. #endregion
  137. #region Consts
  138. private const Int32 SYS_COLOR_INDEX_FLAG = 0x40000000;
  139. private const Int32 COLOR_SCROLLBAR = 0 | SYS_COLOR_INDEX_FLAG;
  140. private const Int32 COLOR_BACKGROUND = 1 | SYS_COLOR_INDEX_FLAG; //COLOR_DESKTOP
  141. private const Int32 COLOR_ACTIVECAPTION = 2 | SYS_COLOR_INDEX_FLAG;
  142. private const Int32 COLOR_INACTIVECAPTION = 3 | SYS_COLOR_INDEX_FLAG;
  143. private const Int32 COLOR_MENU = 4 | SYS_COLOR_INDEX_FLAG;
  144. private const Int32 COLOR_WINDOW = 5 | SYS_COLOR_INDEX_FLAG;
  145. private const Int32 COLOR_WINDOWFRAME = 6 | SYS_COLOR_INDEX_FLAG;
  146. private const Int32 COLOR_MENUTEXT = 7 | SYS_COLOR_INDEX_FLAG;
  147. private const Int32 COLOR_WINDOWTEXT = 8 | SYS_COLOR_INDEX_FLAG;
  148. private const Int32 COLOR_CAPTIONTEXT = 9 | SYS_COLOR_INDEX_FLAG;
  149. private const Int32 COLOR_ACTIVEBORDER = 10 | SYS_COLOR_INDEX_FLAG;
  150. private const Int32 COLOR_INACTIVEBORDER = 11 | SYS_COLOR_INDEX_FLAG;
  151. private const Int32 COLOR_APPWORKSPACE = 12 | SYS_COLOR_INDEX_FLAG;
  152. private const Int32 COLOR_HIGHLIGHT = 13 | SYS_COLOR_INDEX_FLAG;
  153. private const Int32 COLOR_HIGHLIGHTTEXT = 14 | SYS_COLOR_INDEX_FLAG;
  154. private const Int32 COLOR_BTNFACE = 15 | SYS_COLOR_INDEX_FLAG; //COLOR_3DFACE
  155. private const Int32 COLOR_BTNSHADOW = 16 | SYS_COLOR_INDEX_FLAG; //COLOR_3DSHADOW
  156. private const Int32 COLOR_GRAYTEXT = 17 | SYS_COLOR_INDEX_FLAG;
  157. private const Int32 COLOR_BTNTEXT = 18 | SYS_COLOR_INDEX_FLAG;
  158. private const Int32 COLOR_INACTIVECAPTIONTEXT = 19 | SYS_COLOR_INDEX_FLAG;
  159. private const Int32 COLOR_BTNHIGHLIGHT = 20 | SYS_COLOR_INDEX_FLAG; //COLOR_3DHIGHLIGHT, COLOR_3DHILIGHT, COLOR_BTNHILIGHT
  160. private const Int32 COLOR_3DDKSHADOW = 21 | SYS_COLOR_INDEX_FLAG;
  161. private const Int32 COLOR_3DLIGHT = 22 | SYS_COLOR_INDEX_FLAG;
  162. private const Int32 COLOR_INFOTEXT = 23 | SYS_COLOR_INDEX_FLAG;
  163. private const Int32 COLOR_INFOBK = 24 | SYS_COLOR_INDEX_FLAG;
  164. private const Int32 COLOR_STATIC = 25 | SYS_COLOR_INDEX_FLAG;
  165. private const Int32 COLOR_STATICTEXT = 26 | SYS_COLOR_INDEX_FLAG;
  166. private const Int32 COLOR_GRADIENTACTIVECAPTION = 27 | SYS_COLOR_INDEX_FLAG;
  167. private const Int32 COLOR_GRADIENTINACTIVECAPTION = 28 | SYS_COLOR_INDEX_FLAG;
  168. #endregion
  169. #region pinvokes
  170. [DllImport("coredll.dll", SetLastError=true)]
  171. private static extern bool SetSysColors(Int32 cElements, Int32[] lpaElements, Int32[] lpaRgbValues);
  172. [DllImport("coredll.dll", SetLastError=true)]
  173. private static extern Int32 GetSysColor(Int32 nIndex);
  174. #endregion
  175. #region Properties
  176. /// <summary>
  177. /// Gets a Color structure that is the lightest color in the color gradient of an active window's title bar.
  178. /// </summary>
  179. public static Color GradientActiveCaption {
  180. get {
  181. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_GRADIENTACTIVECAPTION));
  182. return c;
  183. }
  184. set {
  185. if (SetSysColors(1, new Int32[]{COLOR_GRADIENTACTIVECAPTION}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  186. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  187. }
  188. }
  189. }
  190. /// <summary>
  191. /// Gets a Color structure that is the lightest color in the color gradient of an inactive window's title bar.
  192. /// </summary>
  193. public static Color GradientInactiveCaption {
  194. get {
  195. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_GRADIENTINACTIVECAPTION));
  196. return c;
  197. }
  198. set {
  199. if (SetSysColors(1, new Int32[]{COLOR_GRADIENTINACTIVECAPTION}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  200. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  201. }
  202. }
  203. }
  204. /// <summary>
  205. /// Gets a Color structure that is the color of the active window's border.
  206. /// </summary>
  207. public static Color ActiveBorder {
  208. get {
  209. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_ACTIVEBORDER));
  210. Trace.Assert(SystemColors.ActiveBorder.R == c.R && SystemColors.ActiveBorder.G == c.G && SystemColors.ActiveBorder.B == c.B && SystemColors.ActiveBorder.A == c.A);
  211. return c;
  212. }
  213. set {
  214. if (SetSysColors(1, new Int32[]{COLOR_ACTIVEBORDER}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  215. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  216. }
  217. }
  218. }
  219. /// <summary>
  220. /// Gets a Color structure that is the color of the application workspace.
  221. /// </summary>
  222. public static Color AppWorkspace {
  223. get {
  224. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_APPWORKSPACE));
  225. Trace.Assert(SystemColors.AppWorkspace.R == c.R && SystemColors.AppWorkspace.G == c.G && SystemColors.AppWorkspace.B == c.B && SystemColors.AppWorkspace.A == c.A);
  226. return c;
  227. }
  228. set {
  229. if (SetSysColors(1, new Int32[]{COLOR_APPWORKSPACE}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  230. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  231. }
  232. }
  233. }
  234. /// <summary>
  235. /// Gets a Color structure that is the face color of a 3-D element.
  236. /// </summary>
  237. public static Color Control {
  238. get {
  239. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_BTNFACE));
  240. Trace.Assert(SystemColors.Control.R == c.R && SystemColors.Control.G == c.G && SystemColors.Control.B == c.B && SystemColors.Control.A == c.A);
  241. return c;
  242. }
  243. set {
  244. if (SetSysColors(1, new Int32[]{COLOR_BTNFACE}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  245. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  246. }
  247. }
  248. }
  249. /// <summary>
  250. /// Gets a Color structure that is the light color of a 3-D element.
  251. /// </summary>
  252. public static Color ControlLight {
  253. get {
  254. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_3DLIGHT));
  255. Trace.Assert(SystemColors.ControlLight.R == c.R && SystemColors.ControlLight.G == c.G && SystemColors.ControlLight.B == c.B && SystemColors.ControlLight.A == c.A);
  256. return c;
  257. }
  258. set {
  259. if (SetSysColors(1, new Int32[]{COLOR_3DLIGHT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  260. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  261. }
  262. }
  263. }
  264. /// <summary>
  265. /// Gets a Color structure that is the highlight color of a 3-D element.
  266. /// </summary>
  267. public static Color ControlLightLight {
  268. get {
  269. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_BTNHIGHLIGHT));
  270. Trace.Assert(SystemColors.ControlLightLight.R == c.R && SystemColors.ControlLightLight.G == c.G && SystemColors.ControlLightLight.B == c.B && SystemColors.ControlLightLight.A == c.A);
  271. return c;
  272. }
  273. set {
  274. if (SetSysColors(1, new Int32[]{COLOR_BTNHIGHLIGHT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  275. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  276. }
  277. }
  278. }
  279. /// <summary>
  280. /// Gets a Color structure that is the shadow color of a 3-D element.
  281. /// </summary>
  282. public static Color ControlDark {
  283. get {
  284. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_BTNSHADOW));
  285. Trace.Assert(SystemColors.ControlDark.R == c.R && SystemColors.ControlDark.G == c.G && SystemColors.ControlDark.B == c.B && SystemColors.ControlDark.A == c.A);
  286. return c;
  287. }
  288. set {
  289. if (SetSysColors(1, new Int32[]{COLOR_BTNSHADOW}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  290. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  291. }
  292. }
  293. }
  294. /// <summary>
  295. /// Gets a Color structure that is the dark shadow color of a 3-D element.
  296. /// </summary>
  297. public static Color ControlDarkDark {
  298. get {
  299. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_3DDKSHADOW));
  300. Trace.Assert(SystemColors.ControlDarkDark.R == c.R && SystemColors.ControlDarkDark.G == c.G && SystemColors.ControlDarkDark.B == c.B && SystemColors.ControlDarkDark.A == c.A);
  301. return c;
  302. }
  303. set {
  304. if (SetSysColors(1, new Int32[]{COLOR_3DDKSHADOW}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  305. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  306. }
  307. }
  308. }
  309. /// <summary>
  310. /// Gets a Color structure that is the color of the background of a scroll bar.
  311. /// </summary>
  312. public static Color ScrollBar {
  313. get {
  314. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_SCROLLBAR));
  315. Trace.Assert(SystemColors.ScrollBar.R == c.R && SystemColors.ScrollBar.G == c.G && SystemColors.ScrollBar.B == c.B && SystemColors.ScrollBar.A == c.A);
  316. return c;
  317. }
  318. set {
  319. if (SetSysColors(1, new Int32[]{COLOR_SCROLLBAR}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  320. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  321. }
  322. }
  323. }
  324. /// <summary>
  325. /// Gets a Color structure that is the color of a window frame.
  326. /// </summary>
  327. public static Color WindowFrame {
  328. get {
  329. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_WINDOWFRAME));
  330. Trace.Assert(SystemColors.WindowFrame.R == c.R && SystemColors.WindowFrame.G == c.G && SystemColors.WindowFrame.B == c.B && SystemColors.WindowFrame.A == c.A);
  331. return c;
  332. }
  333. set {
  334. if (SetSysColors(1, new Int32[]{COLOR_WINDOWFRAME}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  335. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  336. }
  337. }
  338. }
  339. /// <summary>
  340. /// Gets a Color structure that is the color used to designate a hot-tracked item.
  341. /// </summary>
  342. public static Color HotTrack {
  343. get {
  344. Color c = DialogBoxText;
  345. Trace.Assert(SystemColors.HotTrack.R == c.R && SystemColors.HotTrack.G == c.G && SystemColors.HotTrack.B == c.B && SystemColors.HotTrack.A == c.A);
  346. return c;
  347. }
  348. set {
  349. DialogBoxText = value;
  350. }
  351. }
  352. /// <summary>
  353. /// Gets a Color structure that is the color of an inactive window's border.
  354. /// </summary>
  355. public static Color InactiveBorder {
  356. get {
  357. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_INACTIVEBORDER));
  358. Trace.Assert(SystemColors.InactiveBorder.R == c.R && SystemColors.InactiveBorder.G == c.G && SystemColors.InactiveBorder.B == c.B && SystemColors.InactiveBorder.A == c.A);
  359. return c;
  360. }
  361. set {
  362. if (SetSysColors(1, new Int32[]{COLOR_INACTIVEBORDER}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  363. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  364. }
  365. }
  366. }
  367. /// <summary>
  368. /// Gets a Color structure that is the color of the background of a ToolTip.
  369. /// </summary>
  370. public static Color Info {
  371. get {
  372. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_INFOBK));
  373. Trace.Assert(SystemColors.Info.R == c.R && SystemColors.Info.G == c.G && SystemColors.Info.B == c.B && SystemColors.Info.A == c.A);
  374. return c;
  375. }
  376. set {
  377. if (SetSysColors(1, new Int32[]{COLOR_INFOBK}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  378. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  379. }
  380. }
  381. }
  382. /// <summary>
  383. /// Gets a Color structure that is the color of the text of a ToolTip.
  384. /// </summary>
  385. public static Color InfoText {
  386. get {
  387. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_INFOTEXT));
  388. Trace.Assert(SystemColors.InfoText.R == c.R && SystemColors.InfoText.G == c.G && SystemColors.InfoText.B == c.B && SystemColors.InfoText.A == c.A);
  389. return c;
  390. }
  391. set {
  392. if (SetSysColors(1, new Int32[]{COLOR_INFOTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  393. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  394. }
  395. }
  396. }
  397. /// <summary>
  398. /// Gets a Color structure that is the color of the background of the active window's title bar.
  399. /// </summary>
  400. public static Color ActiveCaption {
  401. get {
  402. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_ACTIVECAPTION));
  403. Trace.Assert(SystemColors.ActiveCaption.R == c.R && SystemColors.ActiveCaption.G == c.G && SystemColors.ActiveCaption.B == c.B && SystemColors.ActiveCaption.A == c.A);
  404. return c;
  405. }
  406. set {
  407. if (SetSysColors(1, new Int32[]{COLOR_ACTIVECAPTION}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  408. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  409. }
  410. }
  411. }
  412. /// <summary>
  413. /// Gets a Color structure that is the color of the text in the active window's title bar.
  414. /// </summary>
  415. public static Color ActiveCaptionText {
  416. get {
  417. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_CAPTIONTEXT));
  418. Trace.Assert(SystemColors.ActiveCaptionText.R == c.R && SystemColors.ActiveCaptionText.G == c.G && SystemColors.ActiveCaptionText.B == c.B && SystemColors.ActiveCaptionText.A == c.A);
  419. return c;
  420. }
  421. set {
  422. if (SetSysColors(1, new Int32[]{COLOR_CAPTIONTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  423. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  424. }
  425. }
  426. }
  427. /// <summary>
  428. /// Gets a Color structure that is the color of text in a 3-D element.
  429. /// </summary>
  430. public static Color ControlText {
  431. get {
  432. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_BTNTEXT));
  433. Trace.Assert(SystemColors.ControlText.R == c.R && SystemColors.ControlText.G == c.G && SystemColors.ControlText.B == c.B && SystemColors.ControlText.A == c.A);
  434. return c;
  435. }
  436. set {
  437. if (SetSysColors(1, new Int32[]{COLOR_BTNTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  438. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  439. }
  440. }
  441. }
  442. /// <summary>
  443. /// Gets a Color structure that is the color of the desktop.
  444. /// </summary>
  445. public static Color Desktop {
  446. get {
  447. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_BACKGROUND));
  448. Trace.Assert(SystemColors.Desktop.R == c.R && SystemColors.Desktop.G == c.G && SystemColors.Desktop.B == c.B && SystemColors.Desktop.A == c.A);
  449. return c;
  450. }
  451. set {
  452. if (SetSysColors(1, new Int32[]{COLOR_BACKGROUND}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  453. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  454. }
  455. }
  456. }
  457. /// <summary>
  458. /// Gets a Color structure that is the color of the background of a Dialog.
  459. /// </summary>
  460. public static Color DialogBackground {
  461. get {
  462. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_STATIC));
  463. return c;
  464. }
  465. set {
  466. if (SetSysColors(1, new Int32[]{COLOR_STATIC}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  467. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  468. }
  469. }
  470. }
  471. /// <summary>
  472. /// Gets a Color structure that is the color of text on a Dialog.
  473. /// </summary>
  474. public static Color DialogBoxText {
  475. get {
  476. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_STATICTEXT));
  477. return c;
  478. }
  479. set {
  480. if (SetSysColors(1, new Int32[]{COLOR_STATICTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  481. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  482. }
  483. }
  484. }
  485. /// <summary>
  486. /// Gets a Color structure that is the color of dimmed text.
  487. /// </summary>
  488. public static Color GrayText {
  489. get {
  490. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_GRAYTEXT));
  491. Trace.Assert(SystemColors.GrayText.R == c.R && SystemColors.GrayText.G == c.G && SystemColors.GrayText.B == c.B && SystemColors.GrayText.A == c.A);
  492. return c;
  493. }
  494. set {
  495. if (SetSysColors(1, new Int32[]{COLOR_GRAYTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  496. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  497. }
  498. }
  499. }
  500. /// <summary>
  501. /// Gets a Color structure that is the color of the background of an inactive window's title bar.
  502. /// </summary>
  503. public static Color InactiveCaption {
  504. get {
  505. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_INACTIVECAPTION));
  506. Trace.Assert(SystemColors.InactiveCaption.R == c.R && SystemColors.InactiveCaption.G == c.G && SystemColors.InactiveCaption.B == c.B && SystemColors.InactiveCaption.A == c.A);
  507. return c;
  508. }
  509. set {
  510. if (SetSysColors(1, new Int32[]{COLOR_INACTIVECAPTION}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  511. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  512. }
  513. }
  514. }
  515. /// <summary>
  516. /// Gets a Color structure that is the color of the text in an inactive window's title bar.
  517. /// </summary>
  518. public static Color InactiveCaptionText {
  519. get {
  520. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_INACTIVECAPTIONTEXT));
  521. Trace.Assert(SystemColors.InactiveCaptionText.R == c.R && SystemColors.InactiveCaptionText.G == c.G && SystemColors.InactiveCaptionText.B == c.B && SystemColors.InactiveCaptionText.A == c.A);
  522. return c;
  523. }
  524. set {
  525. if (SetSysColors(1, new Int32[]{COLOR_INACTIVECAPTIONTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  526. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  527. }
  528. }
  529. }
  530. /// <summary>
  531. /// Gets a Color structure that is the color of a menu's background.
  532. /// </summary>
  533. public static Color Menu {
  534. get {
  535. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_MENU));
  536. Trace.Assert(SystemColors.Menu.R == c.R && SystemColors.Menu.G == c.G && SystemColors.Menu.B == c.B && SystemColors.Menu.A == c.A);
  537. return c;
  538. }
  539. set {
  540. if (SetSysColors(1, new Int32[]{COLOR_MENU}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  541. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  542. }
  543. }
  544. }
  545. /// <summary>
  546. /// Gets a Color structure that is the color of a menu's text.
  547. /// </summary>
  548. public static Color MenuText {
  549. get {
  550. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_MENUTEXT));
  551. Trace.Assert(SystemColors.MenuText.R == c.R && SystemColors.MenuText.G == c.G && SystemColors.MenuText.B == c.B && SystemColors.MenuText.A == c.A);
  552. return c;
  553. }
  554. set {
  555. if (SetSysColors(1, new Int32[]{COLOR_MENUTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  556. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  557. }
  558. }
  559. }
  560. /// <summary>
  561. /// Gets a Color structure that is the color of the background of selected items.
  562. /// </summary>
  563. public static Color Highlight {
  564. get {
  565. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_HIGHLIGHT));
  566. Trace.Assert(SystemColors.Highlight.R == c.R && SystemColors.Highlight.G == c.G && SystemColors.Highlight.B == c.B && SystemColors.Highlight.A == c.A);
  567. return c;
  568. }
  569. set {
  570. if (SetSysColors(1, new Int32[]{COLOR_HIGHLIGHT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  571. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  572. }
  573. }
  574. }
  575. /// <summary>
  576. /// Gets a Color structure that is the color of the text of selected items.
  577. /// </summary>
  578. public static Color HighlightText {
  579. get {
  580. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_HIGHLIGHTTEXT));
  581. Trace.Assert(SystemColors.HighlightText.R == c.R && SystemColors.HighlightText.G == c.G && SystemColors.HighlightText.B == c.B && SystemColors.HighlightText.A == c.A);
  582. return c;
  583. }
  584. set {
  585. if (SetSysColors(1, new Int32[]{COLOR_HIGHLIGHTTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  586. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  587. }
  588. }
  589. }
  590. /// <summary>
  591. /// Gets a Color structure that is the color of the background in the client area of a window.
  592. /// </summary>
  593. public static Color Window {
  594. get {
  595. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_WINDOW));
  596. Trace.Assert(SystemColors.Window.R == c.R && SystemColors.Window.G == c.G && SystemColors.Window.B == c.B && SystemColors.Window.A == c.A);
  597. return c;
  598. }
  599. set {
  600. if (SetSysColors(1, new Int32[]{COLOR_WINDOW}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  601. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  602. }
  603. }
  604. }
  605. /// <summary>
  606. /// Gets a Color structure that is the color of the text in the client area of a window.
  607. /// </summary>
  608. public static Color WindowText {
  609. get {
  610. Color c = ColorTranslator.FromWin32(GetSysColor(COLOR_WINDOWTEXT));
  611. Trace.Assert(SystemColors.WindowText.R == c.R && SystemColors.WindowText.G == c.G && SystemColors.WindowText.B == c.B && SystemColors.WindowText.A == c.A);
  612. return c;
  613. }
  614. set {
  615. if (SetSysColors(1, new Int32[]{COLOR_WINDOWTEXT}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
  616. throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
  617. }
  618. }
  619. }
  620. #endregion
  621. }
  622. }