SVN-Revision: r880
This commit is contained in:
wyf
2025-07-23 01:19:33 +00:00
parent 443703f29c
commit 0d0cc46910
9 changed files with 225 additions and 121 deletions
+9 -19
View File
@@ -20,7 +20,7 @@ namespace Lskj.Main.Control
/* —— 状态 —— */
private bool _isHover;
private Image _imgDefault, _imgHover;
private Image _imgDefault, _imgHover, _imgBorderHover;
private int _radius = 10;
/* —— 外部信息 —— */
@@ -65,6 +65,7 @@ namespace Lskj.Main.Control
{ _imgDefault = img; btn_icon.BackgroundImage = img; }
public void SetMenuHoverImg(Image img) => _imgHover = img;
public void SetMenuHoverBorderImg(Image img) => _imgBorderHover = img;
public void SetMenuNum(int num)
{
@@ -95,6 +96,8 @@ namespace Lskj.Main.Control
set => CornerRadius = value;
}
public Button GetButton() => btn_icon;
public Label GetLabelTitle() => lbl_title;
public Label GetLabelTitleSub() => lbl_sub;
/* ===== 悬停逻辑 ===== */
private void HoverEnter(object s, EventArgs e)
@@ -103,6 +106,10 @@ namespace Lskj.Main.Control
_isHover = true;
//BackColor = _hoverBack;
btn_icon.BackgroundImage = _imgHover ?? _imgDefault;
if (_imgBorderHover != null)
{
this.BackgroundImage = _imgBorderHover;
}
Cursor = Cursors.Hand;
Invalidate();
}
@@ -110,21 +117,4 @@ namespace Lskj.Main.Control
{
if (ClientRectangle.Contains(PointToClient(System.Windows.Forms.Control.MousePosition))) return;
_isHover = false;
//BackColor = _normalBack;
btn_icon.BackgroundImage = _imgDefault;
Invalidate();
}
private void BindHover(System.Windows.Forms.Control ctl)
{
ctl.MouseEnter += HoverEnter;
ctl.MouseLeave += HoverLeave;
}
/* ===== 绘制高亮边框(无圆角) ===== */
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (!_isHover) return;
var rc = new Rectangle(0, 0, Width - 1, Height - 1);
//BackCol