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

Fix MaterialComboBox disabled mode colors #257

Merged
merged 1 commit into from
Oct 21, 2021
Merged
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
23 changes: 17 additions & 6 deletions MaterialSkin/Controls/MaterialComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ protected override void OnPaint(PaintEventArgs pevent)
SkinManager.BackgroundDisabledBrush // Disabled
, ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y);

//Set color and brush
Color SelectedColor = new Color();
if (UseAccent)
SelectedColor = SkinManager.ColorScheme.AccentColor;
else
SelectedColor = SkinManager.ColorScheme.PrimaryColor;
SolidBrush SelectedBrush = new SolidBrush(SelectedColor);

// Create and Draw the arrow
System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath();
PointF TopRight = new PointF(this.Width - 0.5f - SkinManager.FORM_PADDING, (this.Height >> 1) - 2.5f);
Expand All @@ -171,7 +179,11 @@ protected override void OnPaint(PaintEventArgs pevent)
pth.AddLine(TopRight, MidBottom);

g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.FillPath((SolidBrush)(DroppedDown || Focused ? UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush : SkinManager.TextHighEmphasisBrush), pth);
g.FillPath((SolidBrush)(Enabled ? DroppedDown || Focused ?
SelectedBrush : //DroppedDown or Focused
SkinManager.TextHighEmphasisBrush : //Not DroppedDown and not Focused
new SolidBrush(DrawHelper.BlendColor(SkinManager.TextHighEmphasisColor, SkinManager.SwitchOffDisabledThumbColor, 197)) //Disabled
), pth);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

// HintText
Expand All @@ -195,7 +207,7 @@ protected override void OnPaint(PaintEventArgs pevent)
// bottom line
if (DroppedDown || Focused)
{
g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, 0, LINE_Y, Width, 2);
g.FillRectangle(SelectedBrush, 0, LINE_Y, Width, 2);
}
}
else
Expand All @@ -217,7 +229,7 @@ protected override void OnPaint(PaintEventArgs pevent)
// Line Animation
int LineAnimationWidth = (int)(Width * animationProgress);
int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2);
g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2);
g.FillRectangle(SelectedBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2);
}

// Calc text Rect
Expand Down Expand Up @@ -251,9 +263,8 @@ protected override void OnPaint(PaintEventArgs pevent)
NativeText.DrawTransparentText(
Hint,
SkinManager.getTextBoxFontBySize(hintTextSize),
Enabled ? DroppedDown || Focused ? UseAccent ?
SkinManager.ColorScheme.AccentColor : // Focus Accent
SkinManager.ColorScheme.PrimaryColor : // Focus Primary
Enabled ? DroppedDown || Focused ?
SelectedColor : // Focus
SkinManager.TextMediumEmphasisColor : // not focused
SkinManager.TextDisabledOrHintColor, // Disabled
hintRect.Location,
Expand Down