Skip to content

Commit

Permalink
Merged IgnaceMaes#87, fixed window toolbox hovering, improved sample …
Browse files Browse the repository at this point in the history
…form
  • Loading branch information
IgnaceMaes committed Aug 4, 2016
1 parent 8fa1e7d commit f041d7d
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 145 deletions.
14 changes: 7 additions & 7 deletions MaterialSkin/Controls/MaterialFlatButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected override void OnPaint(PaintEventArgs pevent)
}

//Icon
Rectangle iconRect = new Rectangle(4, 6, 24, 24);
Rectangle iconRect = new Rectangle(8, 6, 24, 24);

if (String.IsNullOrEmpty(Text))
// Center Icon
Expand All @@ -122,16 +122,16 @@ protected override void OnPaint(PaintEventArgs pevent)
// Resize and move Text container
//

// First 4: left padding
// First 8: left padding
// 24: icon width
// Second 4: space between Icon and Text
// Third 4: right padding
textRect.Width -= 4 + 24 + 4 + 4;
// Third 8: right padding
textRect.Width -= 8 + 24 + 4 + 8;

// First 4: left padding
// First 8: left padding
// 24: icon width
// Second 4: space between Icon and Text
textRect.X += 4 + 24 + 4;
textRect.X += 8 + 24 + 4;
}

g.DrawString(
Expand All @@ -151,7 +151,7 @@ private Size GetPreferredSize()
public override Size GetPreferredSize(Size proposedSize)
{
// Provides extra space for proper padding for content
int extra = 8;
int extra = 16;

if (Icon != null)
// 24 is for icon size
Expand Down
10 changes: 5 additions & 5 deletions MaterialSkin/Controls/MaterialForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,35 +364,35 @@ private void UpdateButtons(MouseEventArgs e, bool up = false)
else
buttonState = ButtonState.None;
}
else if (up)
else
{
if (showMin && !showMax && maxButtonBounds.Contains(e.Location))
{
buttonState = ButtonState.MinOver;

if (oldState == ButtonState.MinDown)
if (oldState == ButtonState.MinDown && up)
WindowState = FormWindowState.Minimized;
}
else if (showMin && showMax && minButtonBounds.Contains(e.Location))
{
buttonState = ButtonState.MinOver;

if (oldState == ButtonState.MinDown)
if (oldState == ButtonState.MinDown && up)
WindowState = FormWindowState.Minimized;
}
else if (MaximizeBox && ControlBox && maxButtonBounds.Contains(e.Location))
{
buttonState = ButtonState.MaxOver;

if (oldState == ButtonState.MaxDown)
if (oldState == ButtonState.MaxDown && up)
MaximizeWindow(!Maximized);

}
else if (ControlBox && xButtonBounds.Contains(e.Location))
{
buttonState = ButtonState.XOver;

if (oldState == ButtonState.XDown)
if (oldState == ButtonState.XDown && up)
Close();
}
else buttonState = ButtonState.None;
Expand Down
14 changes: 7 additions & 7 deletions MaterialSkin/Controls/MaterialRaisedButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected override void OnPaint(PaintEventArgs pevent)
}

//Icon
Rectangle iconRect = new Rectangle(4, 6, 24, 24);
Rectangle iconRect = new Rectangle(8, 6, 24, 24);

if (string.IsNullOrEmpty(Text))
// Center Icon
Expand All @@ -118,16 +118,16 @@ protected override void OnPaint(PaintEventArgs pevent)
// Resize and move Text container
//

// First 4: left padding
// First 8: left padding
// 24: icon width
// Second 4: space between Icon and Text
// Third 4: right padding
textRect.Width -= 4 + 24 + 4 + 4;
// Third 8: right padding
textRect.Width -= 8 + 24 + 4 + 8;

// First 4: left padding
// First 8: left padding
// 24: icon width
// Second 4: space between Icon and Text
textRect.X += 4 + 24 + 4;
textRect.X += 8 + 24 + 4;
}

g.DrawString(
Expand All @@ -146,7 +146,7 @@ private Size GetPreferredSize()
public override Size GetPreferredSize(Size proposedSize)
{
// Provides extra space for proper padding for content
int extra = 8;
int extra = 16;

if (Icon != null)
// 24 is for icon size
Expand Down
Loading

0 comments on commit f041d7d

Please sign in to comment.