diff --git a/MaterialSkin/ColorScheme.cs b/MaterialSkin/ColorScheme.cs
index af25baf4..ce520ae7 100644
--- a/MaterialSkin/ColorScheme.cs
+++ b/MaterialSkin/ColorScheme.cs
@@ -4,23 +4,29 @@ namespace MaterialSkin
public class ColorScheme
{
- public readonly Color PrimaryColor, DarkPrimaryColor, LightPrimaryColor, AccentColor, TextColor;
+ public readonly Color PrimaryColor, DarkPrimaryColor, LightPrimaryColor, AccentColor, TextColor, SuccessColor, InfoColor, WarningColor, DangerColor;
public readonly Pen PrimaryPen, DarkPrimaryPen, LightPrimaryPen, AccentPen, TextPen;
public readonly Brush PrimaryBrush, DarkPrimaryBrush, LightPrimaryBrush, AccentBrush, TextBrush;
- public ColorScheme() : this(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE)
+ public ColorScheme() : this(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE, Primary.Green900, Primary.LightBlue900, Primary.Amber900, Primary.Red900)
{
}
- public ColorScheme(Primary primary, Primary darkPrimary, Primary lightPrimary, Accent accent, TextShade textShade)
+ public ColorScheme(Primary primary, Primary darkPrimary, Primary lightPrimary, Accent accent, TextShade textShade, Primary successColor = Primary.Green900, Primary infoColor = Primary.LightBlue900, Primary warningColor = Primary.Amber900, Primary dangerColor = Primary.Red900)
{
//Color
PrimaryColor = ((int)primary).ToColor();
DarkPrimaryColor = ((int)darkPrimary).ToColor();
LightPrimaryColor = ((int)lightPrimary).ToColor();
AccentColor = ((int)accent).ToColor();
+
+ SuccessColor = ((int)successColor).ToColor();
+ InfoColor = ((int)infoColor).ToColor();
+ WarningColor = ((int)warningColor).ToColor();
+ DangerColor = ((int)dangerColor).ToColor();
+
TextColor = ((int)textShade).ToColor();
//Pen
@@ -38,13 +44,19 @@ public ColorScheme(Primary primary, Primary darkPrimary, Primary lightPrimary, A
TextBrush = new SolidBrush(TextColor);
}
- public ColorScheme(int primary, int darkPrimary, int lightPrimary, int accent, TextShade textShade)
+ public ColorScheme(int primary, int darkPrimary, int lightPrimary, int accent, TextShade textShade, int successColor = (int)Primary.Green900, int infoColor = (int)Primary.LightBlue900, int warningColor = (int)Primary.Amber900, int dangerColor = (int)Primary.Red900)
{
//Color
- PrimaryColor = ((int)primary).ToColor();
- DarkPrimaryColor = ((int)darkPrimary).ToColor();
- LightPrimaryColor = ((int)lightPrimary).ToColor();
- AccentColor = ((int)accent).ToColor();
+ PrimaryColor = primary.ToColor();
+ DarkPrimaryColor = darkPrimary.ToColor();
+ LightPrimaryColor = lightPrimary.ToColor();
+ AccentColor = accent.ToColor();
+
+ SuccessColor = successColor.ToColor();
+ InfoColor = infoColor.ToColor();
+ WarningColor = warningColor.ToColor();
+ DangerColor = dangerColor.ToColor();
+
TextColor = ((int)textShade).ToColor();
//Pen
@@ -62,13 +74,26 @@ public ColorScheme(int primary, int darkPrimary, int lightPrimary, int accent, T
TextBrush = new SolidBrush(TextColor);
}
- public ColorScheme(Color primary, Color darkPrimary, Color lightPrimary, Color accent, TextShade textShade)
+ ///
+ /// Sets color scheme for the theme
+ ///
+ /// If null is set to default value
+ /// If null is set to default value
+ /// If null is set to default value
+ /// If null is set to default value
+ public ColorScheme(Color primary, Color darkPrimary, Color lightPrimary, Color accent, TextShade textShade, Color? successColor = null, Color? infoColor = null, Color? warningColor = null, Color? dangerColor = null)
{
//Color
PrimaryColor = primary;
DarkPrimaryColor = darkPrimary;
LightPrimaryColor = lightPrimary;
AccentColor = accent;
+
+ SuccessColor = successColor ?? Color.Green;
+ InfoColor = infoColor ?? Color.Cyan;
+ WarningColor = warningColor ?? Color.Goldenrod;
+ DangerColor = dangerColor ?? Color.Red;
+
TextColor = ((int)textShade).ToColor();
//Pen
diff --git a/MaterialSkin/Controls/MaterialButton.cs b/MaterialSkin/Controls/MaterialButton.cs
index 0dd9d164..e9ef9f07 100644
--- a/MaterialSkin/Controls/MaterialButton.cs
+++ b/MaterialSkin/Controls/MaterialButton.cs
@@ -24,7 +24,7 @@ public class MaterialButton : Button, IMaterialControl
// icons
private TextureBrush iconsBrushes;
-
+
///
/// Gets or sets the Depth
///
@@ -50,6 +50,17 @@ public enum MaterialButtonType
Contained
}
+ public enum MaterialButtonColorType
+ {
+ Primary,
+ Secondary,
+ Tertiary,
+ Success,
+ Info,
+ Warning,
+ Danger
+ }
+
public enum MaterialButtonDensity
{
Default,
@@ -62,7 +73,7 @@ public enum MaterialButtonDensity
[Category("Material Skin")]
public bool UseAccentColor
{
- get { return useAccentColor; }
+ get => useAccentColor;
set { useAccentColor = value; Invalidate(); }
}
@@ -72,7 +83,7 @@ public bool UseAccentColor
///
public bool HighEmphasis
{
- get { return highEmphasis; }
+ get => highEmphasis;
set { highEmphasis = value; Invalidate(); }
}
@@ -81,28 +92,36 @@ public bool HighEmphasis
[Description("Draw Shadows around control")]
public bool DrawShadows
{
- get { return drawShadows; }
+ get => drawShadows;
set { drawShadows = value; Invalidate(); }
}
[Category("Material Skin")]
+ [Description("Sets the type of the button")]
public MaterialButtonType Type
{
- get { return type; }
+ get => type;
set { type = value; preProcessIcons(); Invalidate(); }
}
+ [Category("Material Skin"), DefaultValue(MaterialButtonColorType.Primary), Description("Sets button color, works only when UseAccentColor is false")]
+ public MaterialButtonColorType ColorType
+ {
+ get => colorType;
+ set { colorType = value; preProcessIcons(); Invalidate(); }
+ }
+
[Category("Material Skin")]
///
/// Gets or sets a value indicating button density
///
public MaterialButtonDensity Density
{
- get { return _density; }
- set
- {
+ get => _density;
+ set
+ {
_density = value;
- if (_density== MaterialButtonDensity.Dense)
+ if (_density == MaterialButtonDensity.Dense)
Size = new Size(Size.Width, HEIGHTDENSE);
else
Size = new Size(Size.Width, HEIGHTDEFAULT);
@@ -198,7 +217,9 @@ private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPai
private bool highEmphasis;
private bool useAccentColor;
private MaterialButtonType type;
+ private MaterialButtonColorType colorType;
private MaterialButtonDensity _density;
+ private int radius;
[Category("Material Skin")]
///
@@ -206,7 +227,7 @@ private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPai
///
public Image Icon
{
- get { return _icon; }
+ get => _icon;
set
{
_icon = value;
@@ -221,6 +242,24 @@ public Image Icon
}
}
+ [Category("Material Skin"), DefaultValue(4), Description("Sets the border radius in px")]
+ public int Radius
+ {
+ get => radius;
+ set
+ {
+ if (value <= 0)
+ value = 4;
+
+ if ((Math.Min(Width, Height) / 2) < value)
+ value = (Math.Min(Width, Height) / 2);
+
+ radius = value;
+
+ Invalidate();
+ }
+ }
+
[DefaultValue(true)]
public override bool AutoSize
{
@@ -237,6 +276,7 @@ public MaterialButton()
HighEmphasis = true;
UseAccentColor = false;
Type = MaterialButtonType.Contained;
+ ColorType = MaterialButtonColorType.Primary;
Density = MaterialButtonDensity.Default;
NoAccentTextColor = Color.Empty;
CharacterCasing = CharacterCasingEnum.Upper;
@@ -274,6 +314,7 @@ public MaterialButton()
AutoSize = true;
Margin = new Padding(4, 6, 4, 6);
Padding = new Padding(0);
+ Radius = radius <= 0 ? 4 : radius;
}
///
@@ -281,11 +322,11 @@ public MaterialButton()
///
public override string Text
{
- get { return base.Text; }
+ get => base.Text;
set
{
base.Text = value;
- if (!String.IsNullOrEmpty(value))
+ if (!string.IsNullOrEmpty(value))
_textSize = CreateGraphics().MeasureString(value.ToUpper(), SkinManager.getFontByType(MaterialSkinManager.fontType.Button));
else
{
@@ -316,7 +357,7 @@ private void drawShadowOnParent(object sender, PaintEventArgs e)
Graphics gp = e.Graphics;
Rectangle rect = new Rectangle(Location, ClientRectangle.Size);
gp.SmoothingMode = SmoothingMode.AntiAlias;
- DrawHelper.DrawSquareShadow(gp, rect);
+ DrawHelper.DrawSquareShadow(gp, rect, Radius);
}
private void preProcessIcons()
@@ -325,7 +366,7 @@ private void preProcessIcons()
int newWidth, newHeight;
//Resize icon if greater than ICON_SIZE
- if (Icon.Width> ICON_SIZE || Icon.Height > ICON_SIZE)
+ if (Icon.Width > ICON_SIZE || Icon.Height > ICON_SIZE)
{
//calculate aspect ratio
float aspect = Icon.Width / (float)Icon.Height;
@@ -394,12 +435,13 @@ private void preProcessIcons()
}
// added processed image to brush for drawing
- TextureBrush textureBrushGray = new TextureBrush(bgray);
-
- textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
+ TextureBrush textureBrushGray = new TextureBrush(bgray)
+ {
+ WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp
+ };
// Translate the brushes to the correct positions
- var iconRect = new Rectangle(8, (Height/2 - ICON_SIZE / 2), ICON_SIZE, ICON_SIZE);
+ Rectangle iconRect = new Rectangle(8, (Height / 2 - ICON_SIZE / 2), ICON_SIZE, ICON_SIZE);
textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - IconResized.Width / 2,
iconRect.Y + iconRect.Height / 2 - IconResized.Height / 2);
@@ -413,7 +455,7 @@ private void preProcessIcons()
/// The pevent
protected override void OnPaint(PaintEventArgs pevent)
{
- var g = pevent.Graphics;
+ Graphics g = pevent.Graphics;
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
g.SmoothingMode = SmoothingMode.AntiAlias;
@@ -427,10 +469,10 @@ protected override void OnPaint(PaintEventArgs pevent)
RectangleF buttonRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size);
buttonRectF.X -= 0.5f;
buttonRectF.Y -= 0.5f;
- GraphicsPath buttonPath = DrawHelper.CreateRoundRect(buttonRectF, 4);
+ GraphicsPath buttonPath = DrawHelper.CreateRoundRect(buttonRectF, Radius);
// button shadow (blend with form shadow)
- DrawHelper.DrawSquareShadow(g, ClientRectangle);
+ DrawHelper.DrawSquareShadow(g, ClientRectangle, Radius);
if (Type == MaterialButtonType.Contained)
{
@@ -446,9 +488,42 @@ protected override void OnPaint(PaintEventArgs pevent)
// High emphasis
else if (HighEmphasis)
{
- g.FillPath(UseAccentColor ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, buttonPath);
+ Brush usedBrush = SkinManager.ColorScheme.AccentBrush;
+
+ if (!UseAccentColor)
+ {
+ switch (ColorType)
+ {
+ case MaterialButtonColorType.Primary:
+ usedBrush = SkinManager.ColorScheme.PrimaryBrush;
+ break;
+ case MaterialButtonColorType.Secondary:
+ usedBrush = SkinManager.ColorScheme.DarkPrimaryBrush;
+ break;
+ case MaterialButtonColorType.Tertiary:
+ usedBrush = SkinManager.ColorScheme.LightPrimaryBrush;
+ break;
+ case MaterialButtonColorType.Success:
+ usedBrush = new SolidBrush(SkinManager.ColorScheme.SuccessColor);
+ break;
+ case MaterialButtonColorType.Info:
+ usedBrush = new SolidBrush(SkinManager.ColorScheme.InfoColor);
+ break;
+ case MaterialButtonColorType.Warning:
+ usedBrush = new SolidBrush(SkinManager.ColorScheme.WarningColor);
+ break;
+ case MaterialButtonColorType.Danger:
+ usedBrush = new SolidBrush(SkinManager.ColorScheme.DangerColor);
+ break;
+ default:
+ usedBrush = SkinManager.ColorScheme.PrimaryBrush;
+ break;
+ }
+ }
+
+ g.FillPath(usedBrush, buttonPath);
}
- // Mormal
+ // Normal
else
{
using (SolidBrush normalBrush = new SolidBrush(SkinManager.BackgroundColor))
@@ -462,15 +537,42 @@ protected override void OnPaint(PaintEventArgs pevent)
g.Clear(Parent.BackColor);
}
+ #region get hover/focus color
+ Color hoverFocusColor = Color.Transparent;
+ if (UseAccentColor)
+ {
+ if (HighEmphasis && Type == MaterialButtonType.Contained)
+ {
+ // Contained with Emphasis - with accent
+ hoverFocusColor = SkinManager.ColorScheme.AccentColor.Lighten(0.5f);
+ }
+ else
+ {
+ // Not Contained Or Low Emphasis - with accent
+ hoverFocusColor = SkinManager.ColorScheme.AccentColor;
+ }
+ }
+ else
+ {
+ if (Type == MaterialButtonType.Contained && HighEmphasis)
+ {
+ // Contained with Emphasis without accent
+ hoverFocusColor = GetColorByType().Lighten(0.5f);
+ }
+ else
+ {
+ // Normal or Emphasis without accent
+ hoverFocusColor = GetColorByType();
+ }
+ }
+ #endregion
+
//Hover
if (hoverAnimProgress > 0)
{
using (SolidBrush hoverBrush = new SolidBrush(Color.FromArgb(
- (int)(HighEmphasis && Type == MaterialButtonType.Contained ? hoverAnimProgress * 80 : hoverAnimProgress * SkinManager.BackgroundHoverColor.A), (UseAccentColor ? (HighEmphasis && Type == MaterialButtonType.Contained ?
- SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Contained with Emphasis - with accent
- SkinManager.ColorScheme.AccentColor) : // Not Contained Or Low Emphasis - with accent
- (Type == MaterialButtonType.Contained && HighEmphasis ? SkinManager.ColorScheme.LightPrimaryColor : // Contained with Emphasis without accent
- SkinManager.ColorScheme.PrimaryColor)).RemoveAlpha()))) // Normal or Emphasis without accent
+ (int)(HighEmphasis && Type == MaterialButtonType.Contained ? hoverAnimProgress * 80 : hoverAnimProgress * SkinManager.BackgroundHoverColor.A),
+ hoverFocusColor.RemoveAlpha())))
{
g.FillPath(hoverBrush, buttonPath);
}
@@ -480,11 +582,8 @@ protected override void OnPaint(PaintEventArgs pevent)
if (focusAnimProgress > 0)
{
using (SolidBrush focusBrush = new SolidBrush(Color.FromArgb(
- (int)(HighEmphasis && Type == MaterialButtonType.Contained ? focusAnimProgress * 80 : focusAnimProgress * SkinManager.BackgroundFocusColor.A), (UseAccentColor ? (HighEmphasis && Type == MaterialButtonType.Contained ?
- SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Contained with Emphasis - with accent
- SkinManager.ColorScheme.AccentColor) : // Not Contained Or Low Emphasis - with accent
- (Type == MaterialButtonType.Contained && HighEmphasis ? SkinManager.ColorScheme.LightPrimaryColor : // Contained with Emphasis without accent
- SkinManager.ColorScheme.PrimaryColor)).RemoveAlpha()))) // Normal or Emphasis without accent
+ (int)(HighEmphasis && Type == MaterialButtonType.Contained ? focusAnimProgress * 80 : focusAnimProgress * SkinManager.BackgroundFocusColor.A),
+ hoverFocusColor.RemoveAlpha())))
{
g.FillPath(focusBrush, buttonPath);
}
@@ -492,7 +591,21 @@ protected override void OnPaint(PaintEventArgs pevent)
if (Type == MaterialButtonType.Outlined)
{
- using (Pen outlinePen = new Pen(Enabled ? SkinManager.DividersAlternativeColor : SkinManager.DividersColor, 1))
+ Color outColor = SkinManager.DividersColor;
+ if (Enabled)
+ {
+ if (UseAccentColor)
+ outColor = SkinManager.ColorScheme.AccentColor;
+ else if (highEmphasis)
+ {
+ outColor = GetColorByType();
+ }
+
+ if (outColor == SkinManager.DividersColor)
+ outColor = SkinManager.DividersAlternativeColor;
+ }
+
+ using (Pen outlinePen = new Pen(outColor, 1))
{
buttonRectF.X += 0.5f;
buttonRectF.Y += 0.5f;
@@ -503,21 +616,51 @@ protected override void OnPaint(PaintEventArgs pevent)
//Ripple
if (_animationManager.IsAnimating())
{
- g.Clip = new Region(buttonRectF);
- for (var i = 0; i < _animationManager.GetAnimationCount(); i++)
+ //g.Clip = new Region(buttonRectF);
+ g.Clip = new Region(buttonPath);
+ for (int i = 0; i < _animationManager.GetAnimationCount(); i++)
{
- var animationValue = _animationManager.GetProgress(i);
- var animationSource = _animationManager.GetSource(i);
-
- using (Brush rippleBrush = new SolidBrush(
- Color.FromArgb((int)(100 - (animationValue * 100)), // Alpha animation
- (Type == MaterialButtonType.Contained && HighEmphasis ? (UseAccentColor ?
- 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
+ double animationValue = _animationManager.GetProgress(i);
+ Point animationSource = _animationManager.GetSource(i);
+
+ Color rippleColor;
+ if (Type == MaterialButtonType.Contained && HighEmphasis)
+ {
+ if (UseAccentColor)
+ {
+ // Emphasis with accent
+ rippleColor = SkinManager.ColorScheme.AccentColor.Lighten(0.5f);
+ }
+ else
+ {
+ // Emphasis
+ rippleColor = GetColorByType();
+ }
+ }
+ else
+ {
+ if (UseAccentColor)
+ {
+ // Normal with accent
+ rippleColor = SkinManager.ColorScheme.AccentColor;
+ }
+ else
+ {
+ if (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT)
+ {
+ rippleColor = GetColorByType();
+ }
+ else
+ {
+ rippleColor = GetColorByType().Lighten(0.5f);
+ }
+ }
+ }
+
+ using (Brush rippleBrush = new SolidBrush(Color.FromArgb((int)(100 - (animationValue * 100)), // Alpha animation
+ rippleColor))) // Normal
{
- var rippleSize = (int)(animationValue * Width * 2);
+ int rippleSize = (int)(animationValue * Width * 2);
g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
}
}
@@ -525,21 +668,60 @@ protected override void OnPaint(PaintEventArgs pevent)
}
//Text
- var textRect = ClientRectangle;
+ Rectangle textRect = ClientRectangle;
if (Icon != null)
{
textRect.Width -= 8 + ICON_SIZE + 4 + 8; // left padding + icon width + space between Icon and Text + right padding
textRect.X += 8 + ICON_SIZE + 4; // left padding + icon width + space between Icon and Text
}
-
+ /*
Color textColor = Enabled ? (HighEmphasis ? (Type == MaterialButtonType.Text || Type == MaterialButtonType.Outlined) ?
UseAccentColor ? SkinManager.ColorScheme.AccentColor : // Outline or Text and accent and emphasis
- NoAccentTextColor == Color.Empty ?
+ NoAccentTextColor == Color.Empty ?
SkinManager.ColorScheme.PrimaryColor : // Outline or Text and emphasis
NoAccentTextColor : // User defined Outline or Text and emphasis
SkinManager.ColorScheme.TextColor : // Contained and Emphasis
SkinManager.TextHighEmphasisColor) : // Cointained and accent
SkinManager.TextDisabledOrHintColor; // Disabled
+ */
+ Color textColor = SkinManager.TextDisabledOrHintColor;
+ if (Enabled)
+ {
+ if (HighEmphasis)
+ {
+ if ((Type == MaterialButtonType.Text || Type == MaterialButtonType.Outlined))
+ {
+ if (UseAccentColor)
+ {
+ textColor = SkinManager.ColorScheme.AccentColor;
+ // Outline or Text and accent and emphasis
+ }
+ else
+ {
+ if (NoAccentTextColor == Color.Empty)
+ {
+ //Outline or Text and emphasis no accent
+ textColor = GetColorByType();
+ }
+ else
+ {
+ //User defined Outline or Text and emphasis
+ textColor = NoAccentTextColor;
+ }
+ }
+ }
+ else
+ {
+ //Contained and Emphasis
+ textColor = SkinManager.ColorScheme.TextColor;
+ }
+ }
+ else
+ {
+ //Cointained and accent
+ textColor = SkinManager.TextHighEmphasisColor;
+ }
+ }
using (NativeTextRenderer NativeText = new NativeTextRenderer(g))
{
@@ -554,7 +736,7 @@ protected override void OnPaint(PaintEventArgs pevent)
}
//Icon
- var iconRect = new Rectangle(8, (Height / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE);
+ Rectangle iconRect = new Rectangle(8, (Height / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE);
if (string.IsNullOrEmpty(Text))
{
@@ -568,6 +750,29 @@ protected override void OnPaint(PaintEventArgs pevent)
}
}
+ private Color GetColorByType()
+ {
+ switch (ColorType)
+ {
+ case MaterialButtonColorType.Primary:
+ return SkinManager.ColorScheme.PrimaryColor;
+ case MaterialButtonColorType.Secondary:
+ return SkinManager.ColorScheme.DarkPrimaryColor;
+ case MaterialButtonColorType.Tertiary:
+ return SkinManager.ColorScheme.LightPrimaryColor;
+ case MaterialButtonColorType.Success:
+ return SkinManager.ColorScheme.SuccessColor;
+ case MaterialButtonColorType.Info:
+ return SkinManager.ColorScheme.InfoColor;
+ case MaterialButtonColorType.Warning:
+ return SkinManager.ColorScheme.WarningColor;
+ case MaterialButtonColorType.Danger:
+ return SkinManager.ColorScheme.DangerColor;
+ default:
+ return SkinManager.ColorScheme.LightPrimaryColor;
+ }
+ }
+
///
/// The GetPreferredSize
///
@@ -587,7 +792,7 @@ public override Size GetPreferredSize(Size proposedSize)
Size s = base.GetPreferredSize(proposedSize);
// Provides extra space for proper padding for content
- var extra = 16;
+ int extra = 16;
if (Icon != null)
{
@@ -607,7 +812,7 @@ public override Size GetPreferredSize(Size proposedSize)
s.Width += extra;
s.Height = HEIGHTDEFAULT;
}
- if (Icon != null && Text.Length==0 && s.Width < MINIMUMWIDTHICONONLY) s.Width = MINIMUMWIDTHICONONLY;
+ if (Icon != null && Text.Length == 0 && s.Width < MINIMUMWIDTHICONONLY) s.Width = MINIMUMWIDTHICONONLY;
else if (s.Width < MINIMUMWIDTH) s.Width = MINIMUMWIDTH;
return s;
diff --git a/MaterialSkin/DrawHelper.cs b/MaterialSkin/DrawHelper.cs
index efc1eb1c..1a9f1247 100644
--- a/MaterialSkin/DrawHelper.cs
+++ b/MaterialSkin/DrawHelper.cs
@@ -19,7 +19,7 @@ internal static class DrawHelper
/// The
public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius)
{
- var gp = new GraphicsPath();
+ GraphicsPath gp = new GraphicsPath();
gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);
gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
@@ -59,11 +59,11 @@ public static GraphicsPath CreateRoundRect(RectangleF rect, float radius)
/// The
public static Color BlendColor(Color backgroundColor, Color frontColor, double blend)
{
- var ratio = blend / 255d;
- var invRatio = 1d - ratio;
- var r = (int)((backgroundColor.R * invRatio) + (frontColor.R * ratio));
- var g = (int)((backgroundColor.G * invRatio) + (frontColor.G * ratio));
- var b = (int)((backgroundColor.B * invRatio) + (frontColor.B * ratio));
+ double ratio = blend / 255d;
+ double invRatio = 1d - ratio;
+ int r = (int)((backgroundColor.R * invRatio) + (frontColor.R * ratio));
+ int g = (int)((backgroundColor.G * invRatio) + (frontColor.G * ratio));
+ int b = (int)((backgroundColor.B * invRatio) + (frontColor.B * ratio));
return Color.FromArgb(r, g, b);
}
@@ -78,20 +78,20 @@ public static Color BlendColor(Color backgroundColor, Color frontColor)
return BlendColor(backgroundColor, frontColor, frontColor.A);
}
- public static void DrawSquareShadow(Graphics g, Rectangle bounds)
+ public static void DrawSquareShadow(Graphics g, Rectangle bounds, int radius = 4)
{
using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0)))
{
GraphicsPath path;
- path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 3.5f, bounds.Y - 1.5f, bounds.Width + 6, bounds.Height + 6), 8);
+ path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 3.5f, bounds.Y - 1.5f, bounds.Width + 6, bounds.Height + 6), radius * 1.5f);
g.FillPath(shadowBrush, path);
- path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 2.5f, bounds.Y - 1.5f, bounds.Width + 4, bounds.Height + 4), 6);
+ path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 2.5f, bounds.Y - 1.5f, bounds.Width + 4, bounds.Height + 4), radius * 1.25f);
g.FillPath(shadowBrush, path);
- path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 1.5f, bounds.Y - 0.5f, bounds.Width + 2, bounds.Height + 2), 4);
+ path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 1.5f, bounds.Y - 0.5f, bounds.Width + 2, bounds.Height + 2), radius);
g.FillPath(shadowBrush, path);
- path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 1.5f, bounds.Width + 0, bounds.Height + 0), 4);
+ path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 1.5f, bounds.Width + 0, bounds.Height + 0), radius);
g.FillPath(shadowBrush, path);
- path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 2.5f, bounds.Width + 0, bounds.Height + 0), 4);
+ path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 2.5f, bounds.Width + 0, bounds.Height + 0), radius);
g.FillPath(shadowBrush, path);
path.Dispose();
}
diff --git a/MaterialSkin/MaterialSkinManager.cs b/MaterialSkin/MaterialSkinManager.cs
index 22ea8509..a25731c0 100644
--- a/MaterialSkin/MaterialSkinManager.cs
+++ b/MaterialSkin/MaterialSkinManager.cs
@@ -35,7 +35,7 @@ public class MaterialSkinManager
private MaterialSkinManager()
{
Theme = Themes.LIGHT;
- ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE);
+ ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE, Primary.Green700, Primary.Cyan700, Primary.Yellow700, Primary.Red700);
// Create and cache Roboto fonts
// Thanks https://www.codeproject.com/Articles/42041/How-to-Use-a-Font-Without-Installing-it
@@ -235,7 +235,7 @@ public enum Themes : byte
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;
-
+
// Switch
public Color SwitchOffColor => Theme == Themes.LIGHT ? CHECKBOX_OFF_DARK : CHECKBOX_OFF_LIGHT; // yes, I re-use the checkbox color, sue me
public Color SwitchOffThumbColor => Theme == Themes.LIGHT ? SWITCH_OFF_THUMB_LIGHT : SWITCH_OFF_THUMB_DARK;
@@ -319,7 +319,7 @@ public Font getFontByType(fontType type)
case fontType.Subtitle2:
return new Font(RobotoFontFamilies["Roboto_Medium"], 14f, FontStyle.Bold, GraphicsUnit.Pixel);
-
+
case fontType.SubtleEmphasis:
return new Font(RobotoFontFamilies["Roboto"], 12f, FontStyle.Italic, GraphicsUnit.Pixel);