Skip to content

Commit

Permalink
Merge pull request #139 from orapps44/patch-4
Browse files Browse the repository at this point in the history
Update MaterialFloatingActionButton.cs
  • Loading branch information
leocb authored Feb 14, 2021
2 parents 632d148 + 8503c66 commit 740a376
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions MaterialSkin/Controls/MaterialFloatingActionButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class MaterialFloatingActionButton : Button, IMaterialControl
private const int FAB_MINI_ICON_MARGIN = 8;
private const int FAB_ICON_SIZE = 24;

private Boolean _mouseHover = false;

[DefaultValue(true)]
[Category("Material Skin"), DisplayName("Draw Shadows")]
[Description("Draw Shadows around control")]
Expand Down Expand Up @@ -55,10 +57,13 @@ public bool AnimateShowHideButton

private bool _animateShowButton;

[DefaultValue(false)]
[Category("Material Skin")]
[Description("Define icon to display")]
public Image Icon
{
get { return _icon; }
set { _icon = value; }
set { _icon = value; Refresh(); }
}

private Image _icon;
Expand Down Expand Up @@ -182,7 +187,7 @@ protected override void OnPaint(PaintEventArgs pevent)
DrawHelper.DrawRoundShadow(g, fabBounds);

// draw fab
g.FillEllipse(SkinManager.ColorScheme.AccentBrush, fabBounds);
g.FillEllipse(_mouseHover ? new SolidBrush(SkinManager.ColorScheme.AccentColor.Lighten(0.25f)) : SkinManager.ColorScheme.AccentBrush, fabBounds);

if (_animationManager.IsAnimating())
{
Expand Down Expand Up @@ -231,6 +236,27 @@ protected override void OnMouseClick(MouseEventArgs mevent)
_animationManager.StartNewAnimation(AnimationDirection.In, mevent.Location);
}

protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);

if (DesignMode)
return;

_mouseHover = ClientRectangle.Contains(e.Location);
Invalidate();
}

protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
if (DesignMode)
return;

_mouseHover = false;
Invalidate();
}

protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Expand Down

0 comments on commit 740a376

Please sign in to comment.