StyleFactory.cs

Description du code

StyleFactory.cs est un fichier du projet BrolDev.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/broldev/src/.

Projet BrolDev : Librairie de composants réutilisables pour les applications BrolDev en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using be.gaudry.model.enums;
  5. using Chaliy.Windows.Forms;
  6.  
  7. namespace be.gaudry.view.style
  8. {
  9. public sealed class StyleFactory
  10. {
  11.  
  12. #region declarations
  13. private ToolStripRenderer toolStripRenderer;
  14. private ProfessionalColorTable colorTable;
  15. private CustomSystemColors customSystemColors;
  16. //private ButtonRenderer buttonRenderer;
  17. private BORDER_STYLE borderStyle;
  18. private STYLE style;
  19. #endregion
  20.  
  21. #region singleton
  22.  
  23. static readonly StyleFactory instance=new StyleFactory();
  24.  
  25. // Explicit static constructor to tell C# compiler
  26. // not to mark type as beforefieldinit
  27. static StyleFactory()
  28. {
  29. }
  30.  
  31. public static StyleFactory Instance
  32. {
  33. get
  34. {
  35. return instance;
  36. }
  37. }
  38. /*
  39.   private static StyleFactory instance = null;
  40.   private static readonly object padlock = new object();
  41.   private static StyleFactory Instance
  42.   {
  43.   get
  44.   {
  45.   lock (padlock)
  46.   {
  47.   if (instance == null)
  48.   {
  49.   instance = new StyleFactory();
  50.   }
  51.   return instance;
  52.   }
  53.   }
  54.   }*/
  55.  
  56.  
  57. private StyleFactory()
  58. {
  59. Console.WriteLine("new styleFactory");
  60. customSystemColors = new CustomSystemColors();
  61. borderStyle = BORDER_STYLE.Groove;
  62. initStyle(STYLE.Office2007);
  63. }
  64. #endregion
  65.  
  66. #region factory properties
  67. public static void setStyle(STYLE style)
  68. {
  69. Instance.initStyle(style);
  70. }
  71. public static STYLE getStyle()
  72. {
  73. return Instance.style;
  74. }
  75. public static BORDER_STYLE BorderStyle
  76. {
  77. get { return Instance.borderStyle; }
  78. set { Instance.borderStyle = value; }
  79. }
  80. public static ToolStripRenderer ToolStripRenderer
  81. {
  82. get { return Instance.toolStripRenderer; }
  83. }
  84. public static ProfessionalColorTable ProfessionalColorTable
  85. {
  86. get { return Instance.colorTable; }
  87. }
  88. public static CustomSystemColors CustomSystemColors
  89. {
  90. get { return Instance.customSystemColors; }
  91. }
  92. /*public static void setStyle(Control control)
  93.   {
  94.   StyleFactory styleFactory = Instance;
  95.   control.BackColor = styleFactory.customSystemColors.Control;
  96.   control.ForeColor = styleFactory.customSystemColors.ControlText;
  97.   }*/
  98. #endregion
  99.  
  100. #region instance public methods and properties
  101. /// <summary>
  102. /// Used to attach or detach control update methods when a modification occurs on one of the renderers.
  103. /// </summary>
  104. public event System.EventHandler onRendererChanged;
  105. #endregion
  106.  
  107. #region private methods
  108. private void initStyle(STYLE style)
  109. {
  110. this.style = style;
  111.  
  112. customSystemColors.ActiveBorder = SystemColors.ActiveBorder;
  113. customSystemColors.ActiveCaption = SystemColors.ActiveCaption;
  114. customSystemColors.InactiveCaption = SystemColors.InactiveCaption;
  115. customSystemColors.GradientActiveCaption = SystemColors.GradientActiveCaption;
  116. customSystemColors.ActiveCaptionText = SystemColors.ActiveCaptionText;
  117.  
  118. customSystemColors.ControlLightLight = SystemColors.ControlLightLight;
  119.  
  120. customSystemColors.Control = SystemColors.Control;
  121. customSystemColors.ControlText = SystemColors.ControlText;
  122. customSystemColors.Menu = SystemColors.Menu;
  123.  
  124. switch (style)
  125. {
  126. case STYLE.Aero:
  127. case STYLE.Classic:
  128. case STYLE.HomeStead:
  129. case STYLE.MediaCenter:
  130. case STYLE.Metallic:
  131. case STYLE.NormalColor:
  132. colorTable = new ProfessionalColorTableFactory(style);
  133. toolStripRenderer = new ToolStripProfessionalRenderer(Instance.colorTable);
  134. break;
  135. case STYLE.Grey3D:
  136. colorTable = new ControlStyleColors();
  137. toolStripRenderer = new ToolStripProfessionalRenderer(Instance.colorTable);
  138. break;
  139. case STYLE.Office2007:
  140. colorTable = new Office2007Renderer.Office2007ColorTable();
  141. toolStripRenderer = new Office2007Renderer.Office2007Renderer();
  142.  
  143. customSystemColors.Control = Color.LightSteelBlue;
  144. customSystemColors.ControlText = Color.DarkSlateBlue;
  145.  
  146. customSystemColors.ControlLightLight = Color.WhiteSmoke;
  147.  
  148. customSystemColors.ActiveBorder = Color.DarkSlateBlue;
  149. customSystemColors.GradientActiveCaption = Color.OrangeRed;
  150. customSystemColors.ActiveCaption = Color.Orange;
  151. customSystemColors.ActiveCaptionText = Color.Black;
  152. break;
  153. /*case STYLE.Orange:
  154.   colorTable = new OrangeStyleColors();
  155.   toolStripRenderer = new ToolStripProfessionalRenderer(Instance.colorTable);
  156.   break;*/
  157. case STYLE.ReBar:
  158. colorTable = new ProfessionalColorTableFactory(STYLE.NormalColor);
  159. toolStripRenderer = new RebarRenderer();
  160. break;
  161. default:
  162. colorTable = new Office2007Renderer.Office2007ColorTable();
  163. toolStripRenderer = new Office2007Renderer.Office2007Renderer();
  164. break;
  165. }
  166. ToolStripManager.Renderer = toolStripRenderer;
  167. //forces update on all observers controls
  168. be.gaudry.observer.StaticObservable.notify(
  169. new be.gaudry.observer.Notification(
  170. be.gaudry.observer.Notification.VERBOSE.debug,
  171. "R mod",
  172. string.Format(
  173. "New renderer : {0}",
  174. EnumHelper.GetDescription(style)
  175. ),
  176. this
  177. ));
  178. if(onRendererChanged!=null)
  179. {
  180. onRendererChanged(this, null);
  181. }
  182. }
  183. #endregion
  184.  
  185. #region ProfessionalColorTable properties
  186. /*
  187.   #region ButtonPressed
  188.   /// <summary>
  189.   /// Gets the starting color of the gradient used when the button is pressed down.
  190.   /// </summary>
  191.   public static Color ButtonPressedGradientBegin
  192.   {
  193.   get { return ColorTable.ButtonPressedGradientBegin; }
  194.   }
  195.  
  196.   /// <summary>
  197.   /// Gets the end color of the gradient used when the button is pressed down.
  198.   /// </summary>
  199.   public static Color ButtonPressedGradientEnd
  200.   {
  201.   get { return ColorTable.ButtonPressedEnd; }
  202.   }
  203.  
  204.   /// <summary>
  205.   /// Gets the middle color of the gradient used when the button is pressed down.
  206.   /// </summary>
  207.   public static Color ButtonPressedGradientMiddle
  208.   {
  209.   get { return ColorTable.ButtonPressedMiddle; }
  210.   }
  211.   #endregion
  212.  
  213.   #region ButtonSelected
  214.   /// <summary>
  215.   /// Gets the starting color of the gradient used when the button is selected.
  216.   /// </summary>
  217.   public static Color ButtonSelectedGradientBegin
  218.   {
  219.   get { return ColorTable.ButtonSelectedBegin; }
  220.   }
  221.  
  222.   /// <summary>
  223.   /// Gets the end color of the gradient used when the button is selected.
  224.   /// </summary>
  225.   public static Color ButtonSelectedGradientEnd
  226.   {
  227.   get { return ColorTable.ButtonSelectedEnd; }
  228.   }
  229.  
  230.   /// <summary>
  231.   /// Gets the middle color of the gradient used when the button is selected.
  232.   /// </summary>
  233.   public static Color ButtonSelectedGradientMiddle
  234.   {
  235.   get { return ColorTable.ButtonSelectedMiddle; }
  236.   }
  237.  
  238.   /// <summary>
  239.   /// Gets the border color to use with ButtonSelectedHighlight.
  240.   /// </summary>
  241.   public static Color ButtonSelectedHighlightBorder
  242.   {
  243.   get { return ColorTable.ButtonBorder; }
  244.   }
  245.   #endregion
  246.  
  247.   #region Check
  248.   /// <summary>
  249.   /// Gets the solid color to use when the check box is selected and gradients are being used.
  250.   /// </summary>
  251.   public static Color CheckBackground
  252.   {
  253.   get { return ColorTable.CcheckBack; }
  254.   }
  255.   #endregion
  256.  
  257.   #region Grip
  258.   /// <summary>
  259.   /// Gets the color to use for shadow effects on the grip or move handle.
  260.   /// </summary>
  261.   public static Color GripDark
  262.   {
  263.   get { return ColorTable.CgripDark; }
  264.   }
  265.  
  266.   /// <summary>
  267.   /// Gets the color to use for highlight effects on the grip or move handle.
  268.   /// </summary>
  269.   public static Color GripLight
  270.   {
  271.   get { return ColorTable.CgripLight; }
  272.   }
  273.   #endregion
  274.  
  275.   #region ImageMargin
  276.   /// <summary>
  277.   /// Gets the starting color of the gradient used in the image margin of a ToolStripDropDownMenu.
  278.   /// </summary>
  279.   public static Color ImageMarginGradientBegin
  280.   {
  281.   get { return ColorTable.CimageMargin; }
  282.   }
  283.   #endregion
  284.  
  285.   #region MenuBorder
  286.   /// <summary>
  287.   /// Gets the border color or a MenuStrip.
  288.   /// </summary>
  289.   public static Color MenuBorder
  290.   {
  291.   get { return ColorTable.CmenuBorder; }
  292.   }
  293.   #endregion
  294.  
  295.   #region MenuItem
  296.   /// <summary>
  297.   /// Gets the starting color of the gradient used when a top-level ToolStripMenuItem is pressed down.
  298.   /// </summary>
  299.   public static Color MenuItemPressedGradientBegin
  300.   {
  301.   get { return ColorTable.CtoolStripBegin; }
  302.   }
  303.  
  304.   /// <summary>
  305.   /// Gets the end color of the gradient used when a top-level ToolStripMenuItem is pressed down.
  306.   /// </summary>
  307.   public static Color MenuItemPressedGradientEnd
  308.   {
  309.   get { return ColorTable.CtoolStripEnd; }
  310.   }
  311.  
  312.   /// <summary>
  313.   /// Gets the middle color of the gradient used when a top-level ToolStripMenuItem is pressed down.
  314.   /// </summary>
  315.   public static Color MenuItemPressedGradientMiddle
  316.   {
  317.   get { return ColorTable.CtoolStripMiddle; }
  318.   }
  319.  
  320.   /// <summary>
  321.   /// Gets the starting color of the gradient used when the ToolStripMenuItem is selected.
  322.   /// </summary>
  323.   public static Color MenuItemSelectedGradientBegin
  324.   {
  325.   get { return ColorTable.CmenuItemSelectedBegin; }
  326.   }
  327.  
  328.   /// <summary>
  329.   /// Gets the end color of the gradient used when the ToolStripMenuItem is selected.
  330.   /// </summary>
  331.   public static Color MenuItemSelectedGradientEnd
  332.   {
  333.   get { return ColorTable.CmenuItemSelectedEnd; }
  334.   }
  335.   #endregion
  336.  
  337.   #region MenuStrip
  338.   /// <summary>
  339.   /// Gets the starting color of the gradient used in the MenuStrip.
  340.   /// </summary>
  341.   public static Color MenuStripGradientBegin
  342.   {
  343.   get { return ColorTable.CmenuToolBack; }
  344.   }
  345.  
  346.   /// <summary>
  347.   /// Gets the end color of the gradient used in the MenuStrip.
  348.   /// </summary>
  349.   public static Color MenuStripGradientEnd
  350.   {
  351.   get { return ColorTable.CmenuToolBack; }
  352.   }
  353.   #endregion
  354.  
  355.   #region OverflowButton
  356.   /// <summary>
  357.   /// Gets the starting color of the gradient used in the ToolStripOverflowButton.
  358.   /// </summary>
  359.   public static Color OverflowButtonGradientBegin
  360.   {
  361.   get { return ColorTable.CoverflowBegin; }
  362.   }
  363.  
  364.   /// <summary>
  365.   /// Gets the end color of the gradient used in the ToolStripOverflowButton.
  366.   /// </summary>
  367.   public static Color OverflowButtonGradientEnd
  368.   {
  369.   get { return ColorTable.CoverflowEnd; }
  370.   }
  371.  
  372.   /// <summary>
  373.   /// Gets the middle color of the gradient used in the ToolStripOverflowButton.
  374.   /// </summary>
  375.   public static Color OverflowButtonGradientMiddle
  376.   {
  377.   get { return ColorTable.CoverflowMiddle; }
  378.   }
  379.   #endregion
  380.  
  381.   #region RaftingContainer
  382.   /// <summary>
  383.   /// Gets the starting color of the gradient used in the ToolStripContainer.
  384.   /// </summary>
  385.   public static Color RaftingContainerGradientBegin
  386.   {
  387.   get { return ColorTable.CmenuToolBack; }
  388.   }
  389.  
  390.   /// <summary>
  391.   /// Gets the end color of the gradient used in the ToolStripContainer.
  392.   /// </summary>
  393.   public static Color RaftingContainerGradientEnd
  394.   {
  395.   get { return ColorTable.CmenuToolBack; }
  396.   }
  397.   #endregion
  398.  
  399.   #region Separator
  400.   /// <summary>
  401.   /// Gets the color to use to for shadow effects on the ToolStripSeparator.
  402.   /// </summary>
  403.   public static Color SeparatorDark
  404.   {
  405.   get { return ColorTable.CseparatorDark; }
  406.   }
  407.  
  408.   /// <summary>
  409.   /// Gets the color to use to for highlight effects on the ToolStripSeparator.
  410.   /// </summary>
  411.   public static Color SeparatorLight
  412.   {
  413.   get { return ColorTable.CseparatorLight; }
  414.   }
  415.   #endregion
  416.  
  417.   #region StatusStrip
  418.   /// <summary>
  419.   /// Gets the starting color of the gradient used on the StatusStrip.
  420.   /// </summary>
  421.   public static Color StatusStripGradientBegin
  422.   {
  423.   get { return ColorTable.CstatusStripLight; }
  424.   }
  425.  
  426.   /// <summary>
  427.   /// Gets the end color of the gradient used on the StatusStrip.
  428.   /// </summary>
  429.   public static Color StatusStripGradientEnd
  430.   {
  431.   get { return ColorTable.CstatusStripDark; }
  432.   }
  433.   #endregion
  434.  
  435.   #region ToolStrip
  436.   /// <summary>
  437.   /// Gets the border color to use on the bottom edge of the ToolStrip.
  438.   /// </summary>
  439.   public static Color ToolStripBorder
  440.   {
  441.   get { return ColorTable.CtoolStripBorder; }
  442.   }
  443.  
  444.   /// <summary>
  445.   /// Gets the starting color of the gradient used in the ToolStripContentPanel.
  446.   /// </summary>
  447.   public static Color ToolStripContentPanelGradientBegin
  448.   {
  449.   get { return ColorTable.CtoolStripContentEnd; }
  450.   }
  451.  
  452.   /// <summary>
  453.   /// Gets the end color of the gradient used in the ToolStripContentPanel.
  454.   /// </summary>
  455.   public static Color ToolStripContentPanelGradientEnd
  456.   {
  457.   get { return ColorTable.CmenuToolBack; }
  458.   }
  459.  
  460.   /// <summary>
  461.   /// Gets the solid background color of the ToolStripDropDown.
  462.   /// </summary>
  463.   public static Color ToolStripDropDownBackground
  464.   {
  465.   get { return ColorTable.CcontextMenuBack; }
  466.   }
  467.  
  468.   /// <summary>
  469.   /// Gets the starting color of the gradient used in the ToolStrip background.
  470.   /// </summary>
  471.   public static Color ToolStripGradientBegin
  472.   {
  473.   get { return ColorTable.CtoolStripBegin; }
  474.   }
  475.  
  476.   /// <summary>
  477.   /// Gets the end color of the gradient used in the ToolStrip background.
  478.   /// </summary>
  479.   public static Color ToolStripGradientEnd
  480.   {
  481.   get { return ColorTable.CtoolStripEnd; }
  482.   }
  483.  
  484.   /// <summary>
  485.   /// Gets the middle color of the gradient used in the ToolStrip background.
  486.   /// </summary>
  487.   public static Color ToolStripGradientMiddle
  488.   {
  489.   get { return ColorTable.CtoolStripMiddle; }
  490.   }
  491.  
  492.   /// <summary>
  493.   /// Gets the starting color of the gradient used in the ToolStripPanel.
  494.   /// </summary>
  495.   public static Color ToolStripPanelGradientBegin
  496.   {
  497.   get { return ColorTable.CmenuToolBack; }
  498.   }
  499.  
  500.   /// <summary>
  501.   /// Gets the end color of the gradient used in the ToolStripPanel.
  502.   /// </summary>
  503.   public static Color ToolStripPanelGradientEnd
  504.   {
  505.   get { return ColorTable.CmenuToolBack; }
  506.   }
  507.   #endregion
  508.   */
  509. #endregion
  510.  
  511. }
  512. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/style/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1730788824 05/11/2024 07:40:24
| _vista0 octets1541007202 31/10/2018 18:33:22
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/style/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csOffice2007Renderer.cs58.44 Ko31/10/2018 18:33:16-refusé-
Afficher le fichier .cs|.csStyleHelper.cs1.44 Ko31/10/2018 18:33:16-refusé-
Afficher le fichier .cs|.csProfessionalColorTableFactory.cs57.94 Ko31/10/2018 18:33:16-refusé-
Afficher le fichier .cs|.csControlStyleColors.cs4.76 Ko31/10/2018 18:33:15-refusé-
Afficher le fichier .cs|.csCustomSystemColors.cs14.28 Ko31/10/2018 18:33:15-refusé-
Afficher le fichier .cs|.csStyleFactory.cs18.11 Ko31/10/2018 18:33:16-refusé-
Afficher le fichier .cs|.csRebarRenderer.cs11.97 Ko31/10/2018 18:33:16-refusé-
Afficher le fichier .cs|.csOrangeStyleColors.cs14.47 Ko31/10/2018 18:33:16-refusé-
Afficher le fichier .cs|.csOffice2007ColorTable.cs13.46 Ko31/10/2018 18:33:15-refusé-
Afficher le fichier .cs|.csXpStyle.cs1.42 Ko31/10/2018 18:33:16-refusé-
Afficher le fichier .cs|.csOffice2007Helpers.cs4.16 Ko31/10/2018 18:33:15-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

Version en cache

05/11/2024 07:40:24 Cette version de la page est en cache (à la date du 05/11/2024 07:40:24) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.

Document créé le 16/10/2009, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/cs-broldev-source-rf-view/style//StyleFactory.cs.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.