ColorScheme.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using System;
  2. using System.Drawing;
  3. namespace LYFZ.ComponentLibrary
  4. {
  5. public enum EnmColorScheme
  6. {
  7. Purple,
  8. Green,
  9. }
  10. /// <summary>
  11. /// This class works as a common point for all the controls to
  12. /// implement the color scheme
  13. /// </summary>
  14. internal class ColorScheme
  15. {
  16. private EnmColorScheme oClrScheme;
  17. public ColorScheme(EnmColorScheme aoColorScheme)
  18. {
  19. //
  20. // TODO: Add constructor logic here
  21. //
  22. oClrScheme = aoColorScheme;
  23. }
  24. ///<summary>
  25. /// This method sets the values of different color properties
  26. /// for controls of IGradientButtonColor Type
  27. /// </summary>
  28. internal void SetColorScheme(IGradientButtonColor aCtrl)
  29. {
  30. switch(oClrScheme)
  31. {
  32. case EnmColorScheme.Green:
  33. //=========================================================
  34. //Setting color properties of button control for
  35. //Green color scheme
  36. //---------------------------------------------------------
  37. aCtrl.BackgroundBottomColor = Color.FromArgb(193, 201, 140);
  38. aCtrl.BackgroundTopColor = Color.FromArgb(230, 233, 208);
  39. aCtrl.BorderBottomColor = Color.FromArgb(230, 233, 208);
  40. aCtrl.BorderTopColor = Color.FromArgb(193, 201, 140);
  41. aCtrl.DefaultBorderColor = Color.FromArgb(167, 168, 127);
  42. aCtrl.DisabledFontColor = Color.FromArgb(156, 147, 113);
  43. aCtrl.DisbaledBottomColor = Color.FromArgb(209, 215, 170);
  44. aCtrl.DisabledTopColor = Color.FromArgb(240, 242, 227);
  45. aCtrl.FontColor = Color.FromArgb(105, 110, 26);
  46. aCtrl.PressedFontColor = Color.Black;
  47. break;
  48. //---------------------------------------------------------
  49. case EnmColorScheme.Purple:
  50. //=========================================================
  51. //Setting color properties of button control for
  52. //Purple color scheme
  53. //---------------------------------------------------------
  54. aCtrl.BackgroundBottomColor = Color.FromArgb(183, 157, 206);
  55. aCtrl.BackgroundTopColor = Color.FromArgb(231, 222, 239);
  56. aCtrl.BorderBottomColor = Color.FromArgb(224, 215, 233);
  57. aCtrl.BorderTopColor = Color.FromArgb(193, 157, 206);
  58. aCtrl.DefaultBorderColor = Color.FromArgb(132, 100, 161);
  59. aCtrl.DisabledFontColor = Color.FromArgb(143, 116, 156);
  60. aCtrl.DisbaledBottomColor = Color.FromArgb(209, 192, 210);
  61. aCtrl.DisabledTopColor = Color.FromArgb(237, 231, 230);
  62. aCtrl.FontColor = Color.FromArgb(74, 30, 115);
  63. aCtrl.PressedFontColor = Color.Black;
  64. break;
  65. //---------------------------------------------------------
  66. //---------------------------------------------------------
  67. }
  68. }
  69. ///<summary>
  70. /// This method sets the values of different color properties
  71. /// for controls of IGradientContainer Type
  72. ///</summary>
  73. internal void SetColorScheme(IGradientContainer aCtrl)
  74. {
  75. switch(oClrScheme)
  76. {
  77. case EnmColorScheme.Green:
  78. //=========================================================
  79. // Setting color properties of container control for
  80. // Green color scheme
  81. //---------------------------------------------------------
  82. aCtrl.FontColor = Color.FromArgb(57, 66, 1);
  83. aCtrl.ShadowColor = Color.FromArgb(142, 143, 116);
  84. aCtrl.BorderTopColor = Color.FromArgb(225, 225, 183);
  85. aCtrl.BorderBottomColor = Color.FromArgb(167, 168, 127);
  86. aCtrl.BackgroundTopColor = Color.FromArgb(245, 243, 219);
  87. aCtrl.BackgroundBottomColor = Color.FromArgb(214, 209, 153);
  88. break;
  89. //---------------------------------------------------------
  90. case EnmColorScheme.Purple:
  91. //=========================================================
  92. // Setting color properties of container control for
  93. // Purple color scheme
  94. //---------------------------------------------------------
  95. aCtrl.FontColor = Color.FromArgb(137, 101, 163);
  96. aCtrl.ShadowColor = Color.FromArgb(110, 92, 121);
  97. aCtrl.BorderTopColor = Color.FromArgb(234, 218, 245);
  98. aCtrl.BorderBottomColor = Color.FromArgb(191, 161, 211);
  99. aCtrl.BackgroundTopColor = Color.FromArgb(251, 246, 255);
  100. aCtrl.BackgroundBottomColor = Color.FromArgb(241, 229, 249);
  101. break;
  102. //---------------------------------------------------------
  103. default:
  104. // For container control if other than Purple or Green
  105. // any other value is selected it throws an exception
  106. throw new InvalidColorSchemeException();
  107. }
  108. }
  109. }
  110. ///<summary>
  111. /// This class define the exception which is thrown on invalid selection
  112. ///</summary>
  113. public class InvalidColorSchemeException : Exception
  114. {
  115. public InvalidColorSchemeException():base("Color Scheme Not Supported")
  116. {
  117. }
  118. }
  119. ///<summary>
  120. /// This interface defines properties
  121. /// for control that have diffrent colors
  122. /// is disabled mode i.e. ElongatedButton
  123. ///</summary>
  124. internal interface IGradientDisabledColor
  125. {
  126. Color DisabledFontColor{get; set;}
  127. Color DisbaledBottomColor{get;set;}
  128. Color DisabledTopColor{get;set;}
  129. }
  130. ///<summary>
  131. /// This interface defines property
  132. /// for the color of the text on
  133. /// the control
  134. ///</summary>
  135. internal interface IFontColor
  136. {
  137. Color FontColor{get;set;}
  138. }
  139. ///<summary>
  140. /// This interface defines properties
  141. /// to set the control background
  142. /// Gradient's top color and bottom color
  143. ///</summary>
  144. internal interface IGradientBackgroundColor
  145. {
  146. Color BackgroundBottomColor{get;set;}
  147. Color BackgroundTopColor{get;set;}
  148. }
  149. ///<summary>
  150. /// This interface defines properties
  151. /// to set control's Gradient Border's
  152. /// Top color and Bottom Color
  153. ///</summary>
  154. internal interface IGradientBorderColor
  155. {
  156. Color BorderTopColor{get;set;}
  157. Color BorderBottomColor {get;set;}
  158. }
  159. ///<summary>
  160. /// This interface combines the interfaces
  161. /// needed for button controls and add button
  162. /// specific properties
  163. ///</summary>
  164. internal interface IGradientButtonColor:
  165. IFontColor, IGradientDisabledColor,
  166. IGradientBackgroundColor, IGradientBorderColor
  167. {
  168. Color PressedFontColor{get;set;}
  169. Color DefaultBorderColor{get;set;}
  170. }
  171. ///<summary>
  172. /// This interface combines the interfaces
  173. /// needed for container controls and add
  174. /// container specific property
  175. ///</summary>
  176. internal interface IGradientContainer:
  177. IFontColor, IGradientBackgroundColor,
  178. IGradientBorderColor
  179. {
  180. Color ShadowColor{get;set;}
  181. }
  182. }