mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added hover effect to color button
This commit is contained in:
parent
fe11870abb
commit
c3a6cc05e5
2 changed files with 31 additions and 2 deletions
|
@ -90,9 +90,10 @@ private void PrepareRecentColors()
|
|||
{
|
||||
Color = HelpersOptions.RecentColors[i],
|
||||
Size = new Size(16, 16),
|
||||
Offset = 0,
|
||||
BorderColor = Color.FromArgb(100, 100, 100),
|
||||
Margin = new Padding(1),
|
||||
BorderColor = Color.FromArgb(100, 100, 100),
|
||||
Offset = 0,
|
||||
HoverEffect = true,
|
||||
ManualButtonClick = true
|
||||
};
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
@ -57,9 +58,14 @@ public Color Color
|
|||
[DefaultValue(3)]
|
||||
public int Offset { get; set; } = 3;
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool HoverEffect { get; set; } = false;
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool ManualButtonClick { get; set; }
|
||||
|
||||
private bool isMouseHover;
|
||||
|
||||
protected void OnColorChanged(Color color)
|
||||
{
|
||||
if (ColorChanged != null)
|
||||
|
@ -86,6 +92,20 @@ public void ShowColorDialog()
|
|||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(EventArgs e)
|
||||
{
|
||||
isMouseHover = true;
|
||||
|
||||
base.OnMouseEnter(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
isMouseHover = false;
|
||||
|
||||
base.OnMouseLeave(e);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pevent)
|
||||
{
|
||||
if (Offset > 0)
|
||||
|
@ -114,6 +134,14 @@ protected override void OnPaint(PaintEventArgs pevent)
|
|||
}
|
||||
}
|
||||
|
||||
if (HoverEffect && isMouseHover)
|
||||
{
|
||||
using (Brush hoverBrush = new SolidBrush(Color.FromArgb(100, 255, 255, 255)))
|
||||
{
|
||||
g.FillRectangle(hoverBrush, boxRectangle);
|
||||
}
|
||||
}
|
||||
|
||||
using (Pen borderPen = new Pen(BorderColor))
|
||||
{
|
||||
g.DrawRectangleProper(borderPen, boxRectangle);
|
||||
|
|
Loading…
Reference in a new issue