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

Update MaterialForm.cs #127

Merged
merged 1 commit into from
Jan 17, 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
22 changes: 21 additions & 1 deletion MaterialSkin/Controls/MaterialForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ private enum ButtonState
XOver,
MaxOver,
MinOver,
DrawerOver,
XDown,
MaxDown,
MinDown,
DrawerDown,
None
}

Expand All @@ -158,6 +160,7 @@ private enum ButtonState
private Rectangle _maxButtonBounds;
private Rectangle _xButtonBounds;
private Rectangle _actionBarBounds;
private Rectangle _drawerButtonBounds;

public Rectangle UserArea
{
Expand Down Expand Up @@ -680,6 +683,8 @@ private void UpdateButtons(MouseEventArgs e, bool up = false)
_buttonState = ButtonState.MaxDown;
else if (ControlBox && _xButtonBounds.Contains(e.Location))
_buttonState = ButtonState.XDown;
else if (_drawerButtonBounds.Contains(e.Location))
_buttonState = ButtonState.DrawerDown;
else
_buttonState = ButtonState.None;
}
Expand Down Expand Up @@ -713,8 +718,16 @@ private void UpdateButtons(MouseEventArgs e, bool up = false)
if (oldState == ButtonState.XDown && up)
Close();
}
else if (_drawerButtonBounds.Contains(e.Location))
{
_buttonState = ButtonState.DrawerOver;
Cursor = Cursors.Hand;
}
else
{
Cursor = Cursors.Default;
_buttonState = ButtonState.None;
}
}

if (oldState != _buttonState)
Expand Down Expand Up @@ -799,6 +812,7 @@ protected override void OnResize(EventArgs e)
_xButtonBounds = new Rectangle((Width) - STATUS_BAR_BUTTON_WIDTH, 0, STATUS_BAR_BUTTON_WIDTH, STATUS_BAR_HEIGHT);
_statusBarBounds = new Rectangle(0, 0, Width, STATUS_BAR_HEIGHT);
_actionBarBounds = new Rectangle(0, STATUS_BAR_HEIGHT, Width, ACTION_BAR_HEIGHT);
_drawerButtonBounds = new Rectangle(SkinManager.FORM_PADDING / 2, STATUS_BAR_HEIGHT, 24 + SkinManager.FORM_PADDING + SkinManager.FORM_PADDING / 2, ACTION_BAR_HEIGHT);
}

protected override void OnPaint(PaintEventArgs e)
Expand Down Expand Up @@ -895,6 +909,12 @@ protected override void OnPaint(PaintEventArgs e)
// Drawer Icon
if (DrawerTabControl != null)
{
if (_buttonState == ButtonState.DrawerOver)
g.FillRectangle(hoverBrush, _drawerButtonBounds);

if (_buttonState == ButtonState.DrawerDown)
g.FillRectangle(downBrush, _drawerButtonBounds);

_drawerIconRect = new Rectangle(SkinManager.FORM_PADDING / 2, STATUS_BAR_HEIGHT, 24 + SkinManager.FORM_PADDING + SkinManager.FORM_PADDING / 2, ACTION_BAR_HEIGHT);
// Ripple
if (_clickAnimManager.IsAnimating())
Expand Down Expand Up @@ -995,4 +1015,4 @@ public bool PreFilterMessage(ref Message m)
return false;
}
}
}
}