Jump to content

Hello,

 

I found this Material theme for Winform made in c# called MaterialSkin https://github.com/IgnaceMaes/MaterialSkin which is a dead project but it still got a lot of stuff.

So I wanted to add disabled color to the background of the Raised buttons as there are none from before.

 

So since they are following Google's Material design I'm also doing that.

 

In MaterialSkinManager.cs I added this to the rasied button section

 

private static readonly Color RAISED_BUTTON_DISABLEDBACKGROUND = Color.FromArgb(12.PercentageToColorComponent(), 0xFFFFFF.ToColor());
private static readonly Brush RAISED_BUTTON_DISABLEDBACKGROUND_BRUSH = new SolidBrush(RAISED_BUTTON_DISABLEDBACKGROUND);

public Brush GetRaisedDisabledButtonBackgroundBrush()
{
  return RAISED_BUTTON_DISABLEDBACKGROUND_BRUSH;
}

Now in MaterialRaisedButton.cs there is this section

using (var backgroundPath = DrawHelper.CreateRoundRect(ClientRectangle.X,
                                                       ClientRectangle.Y,
                                                       ClientRectangle.Width - 1,
                                                       ClientRectangle.Height - 1,
                                                       1f))
{
  g.FillPath(Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetRaisedButtonBackgroundBrush(), backgroundPath);
}

So I tried to change it to this

 

g.FillPath(Primary ? SkinManager.ColorScheme.PrimaryBrush : (Enabled ? SkinManager.GetRaisedButtonBackgroundBrush() : SkinManager.GetRaisedDisabledButtonBackgroundBrush()), backgroundPath);

But it still does not change, so I noticed the Primary part here and I just wanted to try see what the color looked like hardcoded so I did this

g.FillPath(SkinManager.GetRaisedDisabledButtonBackgroundBrush(), backgroundPath);

But then all buttons disappears.

 

Anyone who would like to help on this?

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/888041-c-winform-materialskin-help-needed/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×