diff --git a/MaterialSkin/Controls/MaterialButton.cs b/MaterialSkin/Controls/MaterialButton.cs
index bfda5089..a0b5bfcb 100644
--- a/MaterialSkin/Controls/MaterialButton.cs
+++ b/MaterialSkin/Controls/MaterialButton.cs
@@ -312,7 +312,7 @@ protected override void OnPaint(PaintEventArgs pevent)
SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Emphasis with accent
SkinManager.ColorScheme.LightPrimaryColor) : // Emphasis
(UseAccentColor ? SkinManager.ColorScheme.AccentColor : // Normal with accent
- SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : SkinManager.ColorScheme.LightPrimaryColor))))) // Normal
+ SkinManager.Theme.RippleColor))))) // Normal
{
var rippleSize = (int)(animationValue * Width * 2);
g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
diff --git a/MaterialSkin/Controls/MaterialCheckBox.cs b/MaterialSkin/Controls/MaterialCheckBox.cs
index 06e5fb18..49b0cc43 100644
--- a/MaterialSkin/Controls/MaterialCheckBox.cs
+++ b/MaterialSkin/Controls/MaterialCheckBox.cs
@@ -133,7 +133,7 @@ protected override void OnPaint(PaintEventArgs pevent)
int rippleSize = (int)(rippleHeight * (0.7 + (0.3 * animationValue)));
using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * animationValue),
- !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : brush.Color))) // no animation
+ !Checked ? SkinManager.Theme.SwitchRippleColor : brush.Color))) // no animation
{
g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
}
@@ -147,7 +147,7 @@ protected override void OnPaint(PaintEventArgs pevent)
double animationValue = _rippleAM.GetProgress(i);
int rippleSize = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.7 + (0.3 * animationValue))) : rippleHeight;
- using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : brush.Color)))
+ using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? SkinManager.Theme.SwitchRippleColor : brush.Color)))
{
g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
}
diff --git a/MaterialSkin/Controls/MaterialDrawer.cs b/MaterialSkin/Controls/MaterialDrawer.cs
index c4fcd7f2..4fa18c64 100644
--- a/MaterialSkin/Controls/MaterialDrawer.cs
+++ b/MaterialSkin/Controls/MaterialDrawer.cs
@@ -189,7 +189,7 @@ private void preProcessIcons()
return;
// Calculate lightness and color
- float l = UseColors ? SkinManager.ColorScheme.TextColor.R / 255 : SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? 0f : 1f;
+ float l = UseColors ? SkinManager.ColorScheme.TextColor.R / 255 : SkinManager.Theme.DrawerLightness;
float r = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.R : SkinManager.ColorScheme.PrimaryColor.R) / 255f;
float g = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.G : SkinManager.ColorScheme.PrimaryColor.G) / 255f;
float b = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.B : SkinManager.ColorScheme.PrimaryColor.B) / 255f;
@@ -440,8 +440,7 @@ protected override void OnPaint(PaintEventArgs e)
{
var rippleBrush = new SolidBrush(Color.FromArgb((int)(70 - (clickAnimProgress * 70)),
UseColors ? SkinManager.ColorScheme.AccentColor : // Using colors
- SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : // light theme
- SkinManager.ColorScheme.LightPrimaryColor)); // dark theme
+ SkinManager.Theme.RippleColor));
g.SetClip(_drawerItemPaths[_baseTabControl.SelectedIndex]);
g.FillEllipse(rippleBrush, new Rectangle(_animationSource.X + dx - (rSize / 2), _animationSource.Y - rSize / 2, rSize, rSize));
@@ -457,9 +456,8 @@ protected override void OnPaint(PaintEventArgs e)
// Background
Brush bgBrush = new SolidBrush(Color.FromArgb(CalculateAlpha(60, 0, currentTabIndex, clickAnimProgress, 1 - showHideAnimProgress),
UseColors ? _backgroundWithAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.LightPrimaryColor : // using colors
- _backgroundWithAccent ? SkinManager.ColorScheme.AccentColor : // defaul accent
- SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : // default light
- SkinManager.ColorScheme.LightPrimaryColor)); // default dark
+ _backgroundWithAccent ? SkinManager.ColorScheme.AccentColor : // defaul accent
+ SkinManager.Theme.RippleColor)); // default dark
g.FillPath(bgBrush, _drawerItemPaths[currentTabIndex]);
bgBrush.Dispose();
diff --git a/MaterialSkin/Controls/MaterialRadioButton.cs b/MaterialSkin/Controls/MaterialRadioButton.cs
index 661796cd..ba29bba8 100644
--- a/MaterialSkin/Controls/MaterialRadioButton.cs
+++ b/MaterialSkin/Controls/MaterialRadioButton.cs
@@ -150,7 +150,7 @@ protected override void OnPaint(PaintEventArgs pevent)
int rippleSize = (int)(rippleHeight * (0.7 + (0.3 * animationValue)));
using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * animationValue),
- !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor)))
+ !Checked ? SkinManager.Theme.SwitchRippleColor : RadioColor)))
{
g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1));
}
@@ -164,7 +164,7 @@ protected override void OnPaint(PaintEventArgs pevent)
double animationValue = _rippleAM.GetProgress(i);
int rippleSize = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.7 + (0.3 * animationValue))) : rippleHeight;
- using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor)))
+ using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? SkinManager.Theme.SwitchRippleColor : RadioColor)))
{
g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1));
}
diff --git a/MaterialSkin/Controls/MaterialSwitch.cs b/MaterialSkin/Controls/MaterialSwitch.cs
index 28d78bdc..48f8c5e8 100644
--- a/MaterialSkin/Controls/MaterialSwitch.cs
+++ b/MaterialSkin/Controls/MaterialSwitch.cs
@@ -159,8 +159,8 @@ protected override void OnPaint(PaintEventArgs pevent)
int rippleSize = (Height % 2 == 0) ? Height - 2 : Height - 3;
Color rippleColor = Color.FromArgb(40, // color alpha
- Checked ? SkinManager.ColorScheme.AccentColor : // On color
- (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White)); // Off color
+ Checked ? SkinManager.ColorScheme.AccentColor : // On color
+ SkinManager.Theme.SwitchRippleColor); // Off color
if (Ripple && _rippleAM.IsAnimating())
{
diff --git a/MaterialSkin/MaterialSkin.csproj b/MaterialSkin/MaterialSkin.csproj
index 9ac8960a..91feb549 100644
--- a/MaterialSkin/MaterialSkin.csproj
+++ b/MaterialSkin/MaterialSkin.csproj
@@ -119,6 +119,9 @@
True
True
+
+
+
diff --git a/MaterialSkin/MaterialSkinManager.cs b/MaterialSkin/MaterialSkinManager.cs
index eb6802c7..973d0b76 100644
--- a/MaterialSkin/MaterialSkinManager.cs
+++ b/MaterialSkin/MaterialSkinManager.cs
@@ -1,7 +1,8 @@
namespace MaterialSkin
{
using MaterialSkin.Controls;
- using MaterialSkin.Properties;
+ using MaterialSkin.Properties;
+ using MaterialSkin.Themes;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -33,8 +34,8 @@ public class MaterialSkinManager
// Constructor
private MaterialSkinManager()
- {
- Theme = Themes.LIGHT;
+ {
+ Theme = new ThemeLight(this);
ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE);
// Create and cache Roboto fonts
@@ -89,9 +90,9 @@ private MaterialSkinManager()
}
// Themes
- private Themes _theme;
+ private Theme _theme;
- public Themes Theme
+ public Theme Theme
{
get { return _theme; }
set
@@ -102,6 +103,39 @@ public Themes Theme
}
}
+ private Theme _themeLight, _themeDark;
+
+ public bool EnabledLightTheme { get; private set; }
+
+ public void SetThemes(Theme themeLight, Theme themeDark, bool defaultLight) {
+ _themeLight = themeLight;
+ _themeDark = themeDark;
+ EnabledLightTheme = defaultLight;
+ Theme = EnabledLightTheme ? _themeLight : _themeDark;
+ }
+
+ public enum ThemeSelector {
+ Opposite,
+ Light,
+ Dark
+ }
+
+ public void SwitchTheme(ThemeSelector selector) {
+ switch (selector) {
+ case ThemeSelector.Light:
+ EnabledLightTheme = true;
+ break;
+ case ThemeSelector.Dark:
+ EnabledLightTheme = false;
+ break;
+ case ThemeSelector.Opposite:
+ EnabledLightTheme = !EnabledLightTheme;
+ break;
+ }
+ Theme = EnabledLightTheme ? _themeLight : _themeDark;
+ }
+
+
private ColorScheme _colorScheme;
public ColorScheme ColorScheme
@@ -115,138 +149,55 @@ public ColorScheme ColorScheme
}
}
- public enum Themes : byte
- {
- LIGHT,
- DARK
- }
-
- // Text
- private static readonly Color TEXT_HIGH_EMPHASIS_LIGHT = Color.FromArgb(222, 255, 255, 255); // Alpha 87%
-
- private static readonly Brush TEXT_HIGH_EMPHASIS_LIGHT_BRUSH = new SolidBrush(TEXT_HIGH_EMPHASIS_LIGHT);
- private static readonly Color TEXT_HIGH_EMPHASIS_DARK = Color.FromArgb(222, 0, 0, 0); // Alpha 87%
- private static readonly Brush TEXT_HIGH_EMPHASIS_DARK_BRUSH = new SolidBrush(TEXT_HIGH_EMPHASIS_DARK);
-
- private static readonly Color TEXT_MEDIUM_EMPHASIS_LIGHT = Color.FromArgb(153, 255, 255, 255); // Alpha 60%
- private static readonly Brush TEXT_MEDIUM_EMPHASIS_LIGHT_BRUSH = new SolidBrush(TEXT_MEDIUM_EMPHASIS_LIGHT);
- private static readonly Color TEXT_MEDIUM_EMPHASIS_DARK = Color.FromArgb(153, 0, 0, 0); // Alpha 60%
- private static readonly Brush TEXT_MEDIUM_EMPHASIS_DARK_BRUSH = new SolidBrush(TEXT_MEDIUM_EMPHASIS_DARK);
-
- private static readonly Color TEXT_DISABLED_OR_HINT_LIGHT = Color.FromArgb(97, 255, 255, 255); // Alpha 38%
- private static readonly Brush TEXT_DISABLED_OR_HINT_LIGHT_BRUSH = new SolidBrush(TEXT_DISABLED_OR_HINT_LIGHT);
- private static readonly Color TEXT_DISABLED_OR_HINT_DARK = Color.FromArgb(97, 0, 0, 0); // Alpha 38%
- private static readonly Brush TEXT_DISABLED_OR_HINT_DARK_BRUSH = new SolidBrush(TEXT_DISABLED_OR_HINT_DARK);
-
- // Dividers and thin lines
- private static readonly Color DIVIDERS_LIGHT = Color.FromArgb(30, 255, 255, 255); // Alpha 30%
-
- private static readonly Brush DIVIDERS_LIGHT_BRUSH = new SolidBrush(DIVIDERS_LIGHT);
- private static readonly Color DIVIDERS_DARK = Color.FromArgb(30, 0, 0, 0); // Alpha 30%
- private static readonly Brush DIVIDERS_DARK_BRUSH = new SolidBrush(DIVIDERS_DARK);
- private static readonly Color DIVIDERS_ALTERNATIVE_LIGHT = Color.FromArgb(153, 255, 255, 255); // Alpha 60%
- private static readonly Brush DIVIDERS_ALTERNATIVE_LIGHT_BRUSH = new SolidBrush(DIVIDERS_ALTERNATIVE_LIGHT);
- private static readonly Color DIVIDERS_ALTERNATIVE_DARK = Color.FromArgb(153, 0, 0, 0); // Alpha 60%
- private static readonly Brush DIVIDERS_ALTERNATIVE_DARK_BRUSH = new SolidBrush(DIVIDERS_ALTERNATIVE_DARK);
-
- // Checkbox / Radio / Switches
- private static readonly Color CHECKBOX_OFF_LIGHT = Color.FromArgb(138, 0, 0, 0);
-
- private static readonly Brush CHECKBOX_OFF_LIGHT_BRUSH = new SolidBrush(CHECKBOX_OFF_LIGHT);
- private static readonly Color CHECKBOX_OFF_DARK = Color.FromArgb(179, 255, 255, 255);
- private static readonly Brush CHECKBOX_OFF_DARK_BRUSH = new SolidBrush(CHECKBOX_OFF_DARK);
- private static readonly Color CHECKBOX_OFF_DISABLED_LIGHT = Color.FromArgb(66, 0, 0, 0);
- private static readonly Brush CHECKBOX_OFF_DISABLED_LIGHT_BRUSH = new SolidBrush(CHECKBOX_OFF_DISABLED_LIGHT);
- private static readonly Color CHECKBOX_OFF_DISABLED_DARK = Color.FromArgb(77, 255, 255, 255);
- private static readonly Brush CHECKBOX_OFF_DISABLED_DARK_BRUSH = new SolidBrush(CHECKBOX_OFF_DISABLED_DARK);
-
- // Switch specific
- private static readonly Color SWITCH_OFF_THUMB_LIGHT = Color.FromArgb(255, 255, 255, 255);
-
- private static readonly Color SWITCH_OFF_THUMB_DARK = Color.FromArgb(255, 190, 190, 190);
- private static readonly Color SWITCH_OFF_TRACK_LIGHT = Color.FromArgb(100, 0, 0, 0);
- private static readonly Color SWITCH_OFF_TRACK_DARK = Color.FromArgb(100, 255, 255, 255);
- private static readonly Color SWITCH_OFF_DISABLED_THUMB_LIGHT = Color.FromArgb(255, 230, 230, 230);
- private static readonly Color SWITCH_OFF_DISABLED_THUMB_DARK = Color.FromArgb(255, 150, 150, 150);
-
- // Generic back colors - for user controls
- private static readonly Color BACKGROUND_LIGHT = Color.FromArgb(255, 255, 255, 255);
-
- private static readonly Brush BACKGROUND_LIGHT_BRUSH = new SolidBrush(BACKGROUND_LIGHT);
- private static readonly Color BACKGROUND_DARK = Color.FromArgb(255, 80, 80, 80);
- private static readonly Brush BACKGROUND_DARK_BRUSH = new SolidBrush(BACKGROUND_DARK);
- private static readonly Color BACKGROUND_ALTERNATIVE_LIGHT = Color.FromArgb(10, 0, 0, 0);
- private static readonly Brush BACKGROUND_ALTERNATIVE_LIGHT_BRUSH = new SolidBrush(BACKGROUND_ALTERNATIVE_LIGHT);
- private static readonly Color BACKGROUND_ALTERNATIVE_DARK = Color.FromArgb(10, 255, 255, 255);
- private static readonly Brush BACKGROUND_ALTERNATIVE_DARK_BRUSH = new SolidBrush(BACKGROUND_ALTERNATIVE_DARK);
- private static readonly Color BACKGROUND_HOVER_LIGHT = Color.FromArgb(20, 0, 0, 0);
- private static readonly Brush BACKGROUND_HOVER_LIGHT_BRUSH = new SolidBrush(BACKGROUND_HOVER_LIGHT);
- private static readonly Color BACKGROUND_HOVER_DARK = Color.FromArgb(20, 255, 255, 255);
- private static readonly Brush BACKGROUND_HOVER_DARK_BRUSH = new SolidBrush(BACKGROUND_HOVER_DARK);
- private static readonly Color BACKGROUND_FOCUS_LIGHT = Color.FromArgb(30, 0, 0, 0);
- private static readonly Brush BACKGROUND_FOCUS_LIGHT_BRUSH = new SolidBrush(BACKGROUND_FOCUS_LIGHT);
- private static readonly Color BACKGROUND_FOCUS_DARK = Color.FromArgb(30, 255, 255, 255);
- private static readonly Brush BACKGROUND_FOCUS_DARK_BRUSH = new SolidBrush(BACKGROUND_FOCUS_DARK);
- private static readonly Color BACKGROUND_DISABLED_LIGHT = Color.FromArgb(25, 0, 0, 0);
- private static readonly Brush BACKGROUND_DISABLED_LIGHT_BRUSH = new SolidBrush(BACKGROUND_DISABLED_LIGHT);
- private static readonly Color BACKGROUND_DISABLED_DARK = Color.FromArgb(25, 255, 255, 255);
- private static readonly Brush BACKGROUND_DISABLED_DARK_BRUSH = new SolidBrush(BACKGROUND_DISABLED_DARK);
-
- // Backdrop colors - for containers, like forms or panels
- private static readonly Color BACKDROP_LIGHT = Color.FromArgb(255, 242, 242, 242);
-
- private static readonly Brush BACKDROP_LIGHT_BRUSH = new SolidBrush(BACKGROUND_LIGHT);
- private static readonly Color BACKDROP_DARK = Color.FromArgb(255, 50, 50, 50);
- private static readonly Brush BACKDROP_DARK_BRUSH = new SolidBrush(BACKGROUND_DARK);
// Getters - Using these makes handling the dark theme switching easier
// Text
- public Color TextHighEmphasisColor => Theme == Themes.LIGHT ? TEXT_HIGH_EMPHASIS_DARK : TEXT_HIGH_EMPHASIS_LIGHT;
+ public Color TextHighEmphasisColor => Theme.TextHighEmphasisColor;
- public Brush TextHighEmphasisBrush => Theme == Themes.LIGHT ? TEXT_HIGH_EMPHASIS_DARK_BRUSH : TEXT_HIGH_EMPHASIS_LIGHT_BRUSH;
- public Color TextMediumEmphasisColor => Theme == Themes.LIGHT ? TEXT_MEDIUM_EMPHASIS_DARK : TEXT_MEDIUM_EMPHASIS_LIGHT;
- public Brush TextMediumEmphasisBrush => Theme == Themes.LIGHT ? TEXT_MEDIUM_EMPHASIS_DARK_BRUSH : TEXT_MEDIUM_EMPHASIS_LIGHT_BRUSH;
- public Color TextDisabledOrHintColor => Theme == Themes.LIGHT ? TEXT_DISABLED_OR_HINT_DARK : TEXT_DISABLED_OR_HINT_LIGHT;
- public Brush TextDisabledOrHintBrush => Theme == Themes.LIGHT ? TEXT_DISABLED_OR_HINT_DARK_BRUSH : TEXT_DISABLED_OR_HINT_LIGHT_BRUSH;
+ public Brush TextHighEmphasisBrush => Theme.TextHighEmphasisBrush;
+ public Color TextMediumEmphasisColor => Theme.TextMediumEmphasisColor;
+ public Brush TextMediumEmphasisBrush => Theme.TextMediumEmphasisBrush;
+ public Color TextDisabledOrHintColor => Theme.TextDisabledOrHintColor;
+ public Brush TextDisabledOrHintBrush => Theme.TextDisabledOrHintBrush;
// Divider
- public Color DividersColor => Theme == Themes.LIGHT ? DIVIDERS_DARK : DIVIDERS_LIGHT;
+ public Color DividersColor => Theme.DividersColor;
- public Brush DividersBrush => Theme == Themes.LIGHT ? DIVIDERS_DARK_BRUSH : DIVIDERS_LIGHT_BRUSH;
- public Color DividersAlternativeColor => Theme == Themes.LIGHT ? DIVIDERS_ALTERNATIVE_DARK : DIVIDERS_ALTERNATIVE_LIGHT;
- public Brush DividersAlternativeBrush => Theme == Themes.LIGHT ? DIVIDERS_ALTERNATIVE_DARK_BRUSH : DIVIDERS_ALTERNATIVE_LIGHT_BRUSH;
+ public Brush DividersBrush => Theme.DividersBrush;
+ public Color DividersAlternativeColor => Theme.DividersAlternativeColor;
+ public Brush DividersAlternativeBrush => Theme.DividersAlternativeBrush;
// Checkbox / Radio / Switch
- public Color CheckboxOffColor => Theme == Themes.LIGHT ? CHECKBOX_OFF_LIGHT : CHECKBOX_OFF_DARK;
+ public Color CheckboxOffColor => Theme.CheckboxOffColor;
- public Brush CheckboxOffBrush => Theme == Themes.LIGHT ? CHECKBOX_OFF_LIGHT_BRUSH : CHECKBOX_OFF_DARK_BRUSH;
- public Color CheckBoxOffDisabledColor => Theme == Themes.LIGHT ? CHECKBOX_OFF_DISABLED_LIGHT : CHECKBOX_OFF_DISABLED_DARK;
- public Brush CheckBoxOffDisabledBrush => Theme == Themes.LIGHT ? CHECKBOX_OFF_DISABLED_LIGHT_BRUSH : CHECKBOX_OFF_DISABLED_DARK_BRUSH;
+ public Brush CheckboxOffBrush => Theme.CheckboxOffBrush;
+ public Color CheckBoxOffDisabledColor => Theme.CheckBoxOffDisabledColor;
+ public Brush CheckBoxOffDisabledBrush => Theme.CheckBoxOffDisabledBrush;
// Switch
- public Color SwitchOffColor => Theme == Themes.LIGHT ? CHECKBOX_OFF_DARK : CHECKBOX_OFF_LIGHT;
+ public Color SwitchOffColor => Theme.SwitchOffColor;
- public Color SwitchOffThumbColor => Theme == Themes.LIGHT ? SWITCH_OFF_THUMB_LIGHT : SWITCH_OFF_THUMB_DARK;
- public Color SwitchOffTrackColor => Theme == Themes.LIGHT ? SWITCH_OFF_TRACK_LIGHT : SWITCH_OFF_TRACK_DARK;
- public Color SwitchOffDisabledThumbColor => Theme == Themes.LIGHT ? SWITCH_OFF_DISABLED_THUMB_LIGHT : SWITCH_OFF_DISABLED_THUMB_DARK;
+ public Color SwitchOffThumbColor => Theme.SwitchOffThumbColor;
+ public Color SwitchOffTrackColor => Theme.SwitchOffTrackColor;
+ public Color SwitchOffDisabledThumbColor => Theme.SwitchOffDisabledThumbColor;
// Control Back colors
- public Color BackgroundColor => Theme == Themes.LIGHT ? BACKGROUND_LIGHT : BACKGROUND_DARK;
+ public Color BackgroundColor => Theme.BackgroundColor;
- public Brush BackgroundBrush => Theme == Themes.LIGHT ? BACKGROUND_LIGHT_BRUSH : BACKGROUND_DARK_BRUSH;
- public Color BackgroundAlternativeColor => Theme == Themes.LIGHT ? BACKGROUND_ALTERNATIVE_LIGHT : BACKGROUND_ALTERNATIVE_DARK;
- public Brush BackgroundAlternativeBrush => Theme == Themes.LIGHT ? BACKGROUND_ALTERNATIVE_LIGHT_BRUSH : BACKGROUND_ALTERNATIVE_DARK_BRUSH;
- public Color BackgroundDisabledColor => Theme == Themes.LIGHT ? BACKGROUND_DISABLED_LIGHT : BACKGROUND_DISABLED_DARK;
- public Brush BackgroundDisabledBrush => Theme == Themes.LIGHT ? BACKGROUND_DISABLED_LIGHT_BRUSH : BACKGROUND_DISABLED_DARK_BRUSH;
- public Color BackgroundHoverColor => Theme == Themes.LIGHT ? BACKGROUND_HOVER_LIGHT : BACKGROUND_HOVER_DARK;
- public Brush BackgroundHoverBrush => Theme == Themes.LIGHT ? BACKGROUND_HOVER_LIGHT_BRUSH : BACKGROUND_HOVER_DARK_BRUSH;
- public Color BackgroundFocusColor => Theme == Themes.LIGHT ? BACKGROUND_FOCUS_LIGHT : BACKGROUND_FOCUS_DARK;
- public Brush BackgroundFocusBrush => Theme == Themes.LIGHT ? BACKGROUND_FOCUS_LIGHT_BRUSH : BACKGROUND_FOCUS_DARK_BRUSH;
+ public Brush BackgroundBrush => Theme.BackgroundBrush;
+ public Color BackgroundAlternativeColor => Theme.BackgroundAlternativeColor;
+ public Brush BackgroundAlternativeBrush => Theme.BackgroundAlternativeBrush;
+ public Color BackgroundDisabledColor => Theme.BackgroundDisabledColor;
+ public Brush BackgroundDisabledBrush => Theme.BackgroundDisabledBrush;
+ public Color BackgroundHoverColor => Theme.BackgroundHoverColor;
+ public Brush BackgroundHoverBrush => Theme.BackgroundHoverBrush;
+ public Color BackgroundFocusColor => Theme.BackgroundFocusColor;
+ public Brush BackgroundFocusBrush => Theme.BackgroundFocusBrush;
// Backdrop color
- public Color BackdropColor => Theme == Themes.LIGHT ? BACKDROP_LIGHT : BACKDROP_DARK;
+ public Color BackdropColor => Theme.BackdropColor;
- public Brush BackdropBrush => Theme == Themes.LIGHT ? BACKDROP_LIGHT_BRUSH : BACKDROP_DARK_BRUSH;
+ public Brush BackdropBrush => Theme.BackdropBrush;
// Font Handling
public enum fontType
diff --git a/MaterialSkin/Themes/Theme.cs b/MaterialSkin/Themes/Theme.cs
new file mode 100644
index 00000000..074d8898
--- /dev/null
+++ b/MaterialSkin/Themes/Theme.cs
@@ -0,0 +1,164 @@
+using System.Drawing;
+
+namespace MaterialSkin.Themes {
+
+ public class Theme {
+
+ // Text
+
+ private Color textHighEmphasisColor;
+ public Color TextHighEmphasisColor {
+ get => textHighEmphasisColor;
+ set {
+ textHighEmphasisColor = value;
+ TextHighEmphasisBrush = new SolidBrush(value);
+ }
+ }
+ public Brush TextHighEmphasisBrush { get; set; }
+
+ private Color textMediumEmphasisColor;
+ public Color TextMediumEmphasisColor {
+ get => textMediumEmphasisColor;
+ set {
+ textMediumEmphasisColor = value;
+ TextMediumEmphasisBrush = new SolidBrush(value);
+ }
+ }
+ public Brush TextMediumEmphasisBrush { get; set; }
+
+ private Color textDisabledOrHintColor;
+ public Color TextDisabledOrHintColor {
+ get => textDisabledOrHintColor;
+ set {
+ textDisabledOrHintColor = value;
+ TextDisabledOrHintBrush = new SolidBrush(value);
+ }
+ }
+ public Brush TextDisabledOrHintBrush { get; set; }
+
+ // Divider
+
+ private Color dividersColor;
+ public Color DividersColor {
+ get => dividersColor;
+ set {
+ dividersColor = value;
+ DividersBrush = new SolidBrush(value);
+ }
+ }
+ public Brush DividersBrush { get; set; }
+
+ private Color dividersAlternativeColor;
+ public Color DividersAlternativeColor {
+ get => dividersAlternativeColor;
+ set {
+ dividersAlternativeColor = value;
+ DividersAlternativeBrush = new SolidBrush(value);
+ }
+ }
+ public Brush DividersAlternativeBrush { get; set; }
+
+ // Checkbox / Radio / Switch
+
+ private Color checkboxOffColor;
+ public Color CheckboxOffColor {
+ get => checkboxOffColor;
+ set {
+ checkboxOffColor = value;
+ CheckboxOffBrush = new SolidBrush(value);
+ }
+ }
+ public Brush CheckboxOffBrush { get; set; }
+
+ private Color checkBoxOffDisabledColor;
+ public Color CheckBoxOffDisabledColor {
+ get => checkBoxOffDisabledColor;
+ set {
+ checkBoxOffDisabledColor = value;
+ CheckBoxOffDisabledBrush = new SolidBrush(value);
+ }
+ }
+ public Brush CheckBoxOffDisabledBrush { get; set; }
+
+ // Switch
+
+ public Color SwitchOffColor { get; set; }
+
+ public Color SwitchOffThumbColor { get; set; }
+ public Color SwitchOffTrackColor { get; set; }
+ public Color SwitchOffDisabledThumbColor { get; set; }
+
+ // Control Back colors
+
+ private Color backgroundColor;
+ public Color BackgroundColor {
+ get => backgroundColor;
+ set {
+ backgroundColor = value;
+ BackgroundBrush = new SolidBrush(value);
+ }
+ }
+ public Brush BackgroundBrush { get; set; }
+
+ private Color backgroundAlternativeColor;
+ public Color BackgroundAlternativeColor {
+ get => backgroundAlternativeColor;
+ set {
+ backgroundAlternativeColor = value;
+ BackgroundAlternativeBrush = new SolidBrush(value);
+ }
+ }
+ public Brush BackgroundAlternativeBrush { get; set; }
+
+ private Color backgroundDisabledColor;
+ public Color BackgroundDisabledColor {
+ get => backgroundDisabledColor;
+ set {
+ backgroundDisabledColor = value;
+ BackgroundDisabledBrush = new SolidBrush(value);
+ }
+ }
+ public Brush BackgroundDisabledBrush { get; set; }
+
+ private Color backgroundHoverColor;
+ public Color BackgroundHoverColor {
+ get => backgroundHoverColor;
+ set {
+ backgroundHoverColor = value;
+ BackgroundHoverBrush = new SolidBrush(value);
+ }
+ }
+ public Brush BackgroundHoverBrush { get; set; }
+
+ private Color backgroundFocusColor;
+ public Color BackgroundFocusColor {
+ get => backgroundFocusColor;
+ set {
+ backgroundFocusColor = value;
+ BackgroundFocusBrush = new SolidBrush(value);
+ }
+ }
+ public Brush BackgroundFocusBrush { get; set; }
+
+ // Backdrop color
+
+ private Color backdropColor;
+ public Color BackdropColor {
+ get => backdropColor;
+ set {
+ backdropColor = value;
+ BackdropBrush = new SolidBrush(value);
+ }
+ }
+ public Brush BackdropBrush { get; set; }
+
+ // for controls
+
+ public virtual Color RippleColor { get; set; }
+
+ public Color SwitchRippleColor { get; set; }
+
+ public float DrawerLightness { get; set; }
+
+ }
+}
diff --git a/MaterialSkin/Themes/ThemeDark.cs b/MaterialSkin/Themes/ThemeDark.cs
new file mode 100644
index 00000000..9dfe8e3e
--- /dev/null
+++ b/MaterialSkin/Themes/ThemeDark.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Drawing;
+
+namespace MaterialSkin.Themes {
+
+ public class ThemeDark : Theme {
+
+ private readonly MaterialSkinManager skinManager;
+
+ public ThemeDark(MaterialSkinManager skinManager) {
+ this.skinManager = skinManager;
+
+ // Text
+ TextHighEmphasisColor = Color.FromArgb(222, 255, 255, 255); // Alpha 87%
+ TextMediumEmphasisColor = Color.FromArgb(153, 255, 255, 255); // Alpha 60%
+ TextDisabledOrHintColor = Color.FromArgb(97, 255, 255, 255); // Alpha 38%
+
+ // Divider
+ DividersColor = Color.FromArgb(30, 255, 255, 255); // Alpha 30%
+ DividersAlternativeColor = Color.FromArgb(153, 255, 255, 255); // Alpha 60%
+
+ // Checkbox / Radio / Switch
+ CheckboxOffColor = Color.FromArgb(179, 255, 255, 255);
+ CheckBoxOffDisabledColor = Color.FromArgb(77, 255, 255, 255);
+
+ // Switch
+ SwitchOffColor = Color.FromArgb(138, 0, 0, 0);
+
+ SwitchOffThumbColor = Color.FromArgb(255, 190, 190, 190);
+ SwitchOffTrackColor = Color.FromArgb(100, 255, 255, 255);
+ SwitchOffDisabledThumbColor = Color.FromArgb(255, 150, 150, 150);
+
+ // Control Back colors
+ BackgroundColor = Color.FromArgb(255, 80, 80, 80);
+ BackgroundAlternativeColor = Color.FromArgb(10, 255, 255, 255);
+ BackgroundDisabledColor = Color.FromArgb(25, 255, 255, 255);
+ BackgroundHoverColor = Color.FromArgb(20, 255, 255, 255);
+ BackgroundFocusColor = Color.FromArgb(30, 255, 255, 255);
+
+ // Backdrop colors - for containers, like forms or panels
+ BackdropColor = Color.FromArgb(255, 50, 50, 50);
+ BackdropBrush = new SolidBrush(BackgroundColor); // not a bug?
+
+ // for controls
+ SwitchRippleColor = Color.White;
+ DrawerLightness = 1f;
+ }
+
+
+ public override Color RippleColor {
+ get => skinManager.ColorScheme.LightPrimaryColor;
+ set => throw new InvalidOperationException();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/MaterialSkin/Themes/ThemeLight.cs b/MaterialSkin/Themes/ThemeLight.cs
new file mode 100644
index 00000000..9a0b64c6
--- /dev/null
+++ b/MaterialSkin/Themes/ThemeLight.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Drawing;
+
+namespace MaterialSkin.Themes {
+
+ public class ThemeLight : Theme {
+
+ private readonly MaterialSkinManager skinManager;
+
+ public ThemeLight(MaterialSkinManager skinManager) {
+ this.skinManager = skinManager;
+
+ // Text
+ TextHighEmphasisColor = Color.FromArgb(222, 0, 0, 0); // Alpha 87%
+ TextMediumEmphasisColor = Color.FromArgb(153, 0, 0, 0); // Alpha 60%
+ TextDisabledOrHintColor = Color.FromArgb(97, 0, 0, 0); // Alpha 38%
+
+ // Divider
+ DividersColor = Color.FromArgb(30, 0, 0, 0); // Alpha 30%
+ DividersAlternativeColor = Color.FromArgb(153, 0, 0, 0); // Alpha 60%
+
+ // Checkbox / Radio / Switch
+ CheckboxOffColor = Color.FromArgb(138, 0, 0, 0);
+ CheckBoxOffDisabledColor = Color.FromArgb(66, 0, 0, 0);
+
+ // Switch
+ SwitchOffColor = Color.FromArgb(179, 255, 255, 255);
+
+ SwitchOffThumbColor = Color.FromArgb(255, 255, 255, 255);
+ SwitchOffTrackColor = Color.FromArgb(100, 0, 0, 0);
+ SwitchOffDisabledThumbColor = Color.FromArgb(255, 230, 230, 230);
+
+ // Control Back colors
+ BackgroundColor = Color.FromArgb(255, 255, 255, 255);
+ BackgroundAlternativeColor = Color.FromArgb(10, 0, 0, 0);
+ BackgroundDisabledColor = Color.FromArgb(25, 0, 0, 0);
+ BackgroundHoverColor = Color.FromArgb(20, 0, 0, 0);
+ BackgroundFocusColor = Color.FromArgb(30, 0, 0, 0);
+
+ // Backdrop colors - for containers, like forms or panels
+ BackdropColor = Color.FromArgb(255, 242, 242, 242);
+ BackdropBrush = new SolidBrush(BackgroundColor); // not a bug?
+
+ // for controls
+ SwitchRippleColor = Color.Black;
+ DrawerLightness = 0f;
+ }
+
+
+ public override Color RippleColor {
+ get => skinManager.ColorScheme.PrimaryColor;
+ set => throw new InvalidOperationException();
+ }
+
+ }
+}
diff --git a/MaterialSkinExample/MainForm.cs b/MaterialSkinExample/MainForm.cs
index f47d18f6..af136c50 100644
--- a/MaterialSkinExample/MainForm.cs
+++ b/MaterialSkinExample/MainForm.cs
@@ -1,5 +1,6 @@
using MaterialSkin;
using MaterialSkin.Controls;
+using MaterialSkin.Themes;
using System;
using System.Text;
using System.Windows.Forms;
@@ -22,9 +23,9 @@ public MainForm()
materialSkinManager.EnforceBackcolorOnAllComponents = true;
// MaterialSkinManager properties
- materialSkinManager.AddFormToManage(this);
- materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
- materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE);
+ materialSkinManager.AddFormToManage(this);
+ materialSkinManager.SetThemes(new ThemeLight(materialSkinManager), new ThemeDark(materialSkinManager), true);
+ materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE);
// Add dummy data to the listview
seedListView();
@@ -60,8 +61,8 @@ private void seedListView()
}
private void materialButton1_Click(object sender, EventArgs e)
- {
- materialSkinManager.Theme = materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? MaterialSkinManager.Themes.LIGHT : MaterialSkinManager.Themes.DARK;
+ {
+ materialSkinManager.SwitchTheme(MaterialSkinManager.ThemeSelector.Opposite);
updateColor();
}
@@ -82,9 +83,9 @@ private void updateColor()
{
case 0:
materialSkinManager.ColorScheme = new ColorScheme(
- materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal500 : Primary.Indigo500,
- materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal700 : Primary.Indigo700,
- materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal200 : Primary.Indigo100,
+ !materialSkinManager.EnabledLightTheme ? Primary.Teal500 : Primary.Indigo500,
+ !materialSkinManager.EnabledLightTheme ? Primary.Teal700 : Primary.Indigo700,
+ !materialSkinManager.EnabledLightTheme ? Primary.Teal200 : Primary.Indigo100,
Accent.Pink200,
TextShade.WHITE);
break;
diff --git a/README.md b/README.md
index 2b04b1fc..d206ec30 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,7 @@ There are a few methods to add this lib:
#### The Easy way
-Search for MaterialSkin.2 on the Nuget Package manager inside VisualStudio and add it to your project.
+Search for **MaterialSkin.2** on the Nuget Package manager inside VisualStudio and add it to your project.
#### Manual way
@@ -89,11 +89,11 @@ Download the precompiled DLL available on the releases section and add it as a e
#### Compile from the latest master
-Clone the project from GitHub, then add the MaterialSkin.csproj to your own solution, then add it as a project reference on your project.
+Clone the project from GitHub, then add the `MaterialSkin.csproj` to your own solution, then add it as a project reference on your project.
### 2. Add the MaterialSkin components to your ToolBox
-Simply drag the MaterialSkin.dll file into your IDE's ToolBox and all the controls should be added there.
+Simply drag the `MaterialSkin.dll` file into your IDE's ToolBox and all the controls should be added there.
### 3. Inherit from MaterialForm
@@ -125,7 +125,7 @@ public Form1()
var materialSkinManager = MaterialSkinManager.Instance;
materialSkinManager.AddFormToManage(this);
- materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
+ materialSkinManager.Theme = new ThemeLight(materialSkinManager);
materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
}
```
@@ -140,12 +140,14 @@ Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim SkinManager As MaterialSkinManager = MaterialSkinManager.Instance
SkinManager.AddFormToManage(Me)
- SkinManager.Theme = MaterialSkinManager.Themes.LIGHT
+ SkinManager.Theme = New ThemeLight(SkinManager)
SkinManager.ColorScheme = New ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE)
End Sub
End Class
```
+For switching themes (light and dark), see the `MaterialSkinExample` project.
+
---
## Material Design in WPF