From aa6f7d0e76a7cf4b5479f58dec3bd2247b8a70d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Tue, 24 Nov 2020 05:18:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=B9=8B=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E7=89=88=E6=9C=AC=EF=BC=8C=E8=BF=98=E5=8E=9F=E5=89=8DMouseLeav?= =?UTF-8?q?e=E4=BA=8B=E4=BB=B6=E4=B8=8D=E8=83=BD=E5=AE=8C=E7=BE=8E?= =?UTF-8?q?=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BulePointLilac.Controls/MyToolBar.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/ContextMenuManager/BulePointLilac.Controls/MyToolBar.cs b/ContextMenuManager/BulePointLilac.Controls/MyToolBar.cs index a6f00a8..8f5398e 100644 --- a/ContextMenuManager/BulePointLilac.Controls/MyToolBar.cs +++ b/ContextMenuManager/BulePointLilac.Controls/MyToolBar.cs @@ -74,15 +74,15 @@ namespace BulePointLilac.Controls this.Image = image; this.Text = text; MyToolTip.SetToolTip(this, text); - ThroughControl(picImage); - ThroughControl(lblText); + lblText.SetEnabled(false); } readonly PictureBox picImage = new PictureBox { SizeMode = PictureBoxSizeMode.StretchImage, Size = new Size(40, 40).DpiZoom(), - BackColor = Color.Transparent + BackColor = Color.Transparent, + Enabled = false }; readonly Label lblText = new Label @@ -93,6 +93,8 @@ namespace BulePointLilac.Controls ForeColor = Color.White }; + private static Label LblText = new Label(); + public Image Image { get => picImage.Image; @@ -108,17 +110,5 @@ namespace BulePointLilac.Controls get => BackColor.A / 255; set => BackColor = Color.FromArgb((int)(value * 255), Color.White); } - - private void ThroughControl(Control ctr) - { - MouseEventArgs getAbsArgs(MouseEventArgs e) - { - return new MouseEventArgs(e.Button, e.Clicks, ctr.Left + e.X, ctr.Top + e.Y, e.Delta); - } - ctr.MouseDown += (sender, e) => this.OnMouseDown(getAbsArgs(e)); - ctr.MouseMove += (sender, e) => this.OnMouseMove(getAbsArgs(e)); - ctr.MouseEnter += (sender, e) => this.OnMouseEnter(e); - MyToolTip.SetToolTip(ctr, this.Text); - } } } \ No newline at end of file