Added BorderColor option to ColorButton

This commit is contained in:
Jaex 2018-04-24 11:13:23 +03:00
parent f342308c34
commit d146ab68d5
2 changed files with 14 additions and 4 deletions

View file

@ -88,8 +88,9 @@ private void PrepareRecentColors()
{
Color = new HSB(i / 32d, 1d, 1d),
Size = new Size(16, 16),
Offset = 2,
Margin = new Padding(0),
Offset = 0,
BorderColor = Color.FromArgb(100, 100, 100),
Margin = new Padding(1),
ManualButtonClick = true
};

View file

@ -51,6 +51,9 @@ public Color Color
}
}
[DefaultValue(typeof(Color), "DarkGray")]
public Color BorderColor { get; set; } = Color.DarkGray;
[DefaultValue(3)]
public int Offset { get; set; } = 3;
@ -85,7 +88,10 @@ public void ShowColorDialog()
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
if (Offset > 0)
{
base.OnPaint(pevent);
}
int boxSize = ClientRectangle.Height - Offset * 2;
Rectangle boxRectangle = new Rectangle(ClientRectangle.Width - Offset - boxSize, Offset, boxSize, boxSize);
@ -108,7 +114,10 @@ protected override void OnPaint(PaintEventArgs pevent)
}
}
g.DrawRectangleProper(Pens.DarkGray, boxRectangle);
using (Pen borderPen = new Pen(BorderColor))
{
g.DrawRectangleProper(borderPen, boxRectangle);
}
}
}
}