Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to create a custom theme #69

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MaterialSkin/Controls/MaterialButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the check, use EnabledLightTheme

{
var rippleSize = (int)(animationValue * Width * 2);
g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
Expand Down
4 changes: 2 additions & 2 deletions MaterialSkin/Controls/MaterialCheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down
10 changes: 4 additions & 6 deletions MaterialSkin/Controls/MaterialDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this check, just use EnabledLightTheme instead


g.SetClip(_drawerItemPaths[_baseTabControl.SelectedIndex]);
g.FillEllipse(rippleBrush, new Rectangle(_animationSource.X + dx - (rSize / 2), _animationSource.Y - rSize / 2, rSize, rSize));
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, keep the check, use EnabledLightTheme

g.FillPath(bgBrush, _drawerItemPaths[currentTabIndex]);
bgBrush.Dispose();

Expand Down
4 changes: 2 additions & 2 deletions MaterialSkin/Controls/MaterialRadioButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions MaterialSkin/Controls/MaterialSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
3 changes: 3 additions & 0 deletions MaterialSkin/MaterialSkin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Themes\Theme.cs" />
<Compile Include="Themes\ThemeDark.cs" />
<Compile Include="Themes\ThemeLight.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Controls\FlexibleMaterialDialog.resx">
Expand Down
Loading