From 30b5c92b93be1b54419e6ea319d9d3c3049dbcea Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 7 Feb 2023 21:24:12 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIDropControl:=20=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E6=8E=A7=E4=BB=B6=E5=A2=9E=E5=8A=A0Tips=E5=B0=8F?= =?UTF-8?q?=E7=BA=A2=E7=82=B9=20*=20UITextBox:=20=E5=A2=9E=E5=8A=A0Tips?= =?UTF-8?q?=E5=B0=8F=E7=BA=A2=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/DropItem/UIDropControl.cs | 56 ++++++++++++++++++++++ SunnyUI/Controls/UITextBox.cs | 51 ++++++++++++++++++++ 2 files changed, 107 insertions(+) diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs index 18f7494e..eefd3b06 100644 --- a/SunnyUI/Controls/DropItem/UIDropControl.cs +++ b/SunnyUI/Controls/DropItem/UIDropControl.cs @@ -20,6 +20,7 @@ * 2020-04-25: V2.2.4 更新主题配置类 * 2020-07-05: V2.2.6 更新KeyDown、KeyUp、KeyPress事件 * 2022-09-16: V3.2.4 支持自定义右键菜单 + * 2023-02-07: V3.3.1 增加Tips小红点 ******************************************************************************/ using System; @@ -73,6 +74,56 @@ namespace Sunny.UI ControlBoxRect = new Rectangle(Width - 24, 0, 24, Height); } + private UIButton tipsBtn; + public void SetTipsText(ToolTip toolTip, string text) + { + if (tipsBtn == null) + { + tipsBtn = new UIButton(); + tipsBtn.Cursor = System.Windows.Forms.Cursors.Hand; + tipsBtn.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.Location = new System.Drawing.Point(285, 519); + tipsBtn.MinimumSize = new System.Drawing.Size(1, 1); + tipsBtn.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.Size = new System.Drawing.Size(9, 9); + tipsBtn.Style = Sunny.UI.UIStyle.Red; + tipsBtn.StyleCustomMode = true; + tipsBtn.TabIndex = 118; + tipsBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + tipsBtn.Text = ""; + tipsBtn.Click += TipsBtn_Click; + + Controls.Add(tipsBtn); + tipsBtn.Location = new System.Drawing.Point(Width - 11, 2); + tipsBtn.BringToFront(); + } + + toolTip.SetToolTip(tipsBtn, text); + } + + public event EventHandler TipsClick; + private void TipsBtn_Click(object sender, EventArgs e) + { + TipsClick?.Invoke(this, EventArgs.Empty); + } + + public void CloseTips() + { + if (tipsBtn != null) + { + tipsBtn.Click -= TipsBtn_Click; + tipsBtn.Dispose(); + tipsBtn = null; + } + } + protected override void OnContextMenuStripChanged(EventArgs e) { base.OnContextMenuStripChanged(e); @@ -317,6 +368,11 @@ namespace Sunny.UI protected override void OnSizeChanged(EventArgs e) { SizeChange(); + + if (tipsBtn != null) + { + tipsBtn.Location = new System.Drawing.Point(Width - 11, 2); + } } private void SizeChange() diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index dc3307a7..9e4fc37c 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -44,6 +44,7 @@ * 2022-11-12: V3.2.8 修改整数、浮点数大小离开判断为实时输入判断 * 2022-11-12: V3.2.8 删除MaximumEnabled、MinimumEnabled、HasMaximum、HasMinimum属性 * 2022-11-26: V3.2.9 增加MouseClick,MouseDoubleClick事件 + * 2023-02-07: V3.3.1 增加Tips小红点 ******************************************************************************/ using System; @@ -134,6 +135,56 @@ namespace Sunny.UI TextAlignmentChange += UITextBox_TextAlignmentChange; } + private UIButton tipsBtn; + public void SetTipsText(ToolTip toolTip, string text) + { + if (tipsBtn == null) + { + tipsBtn = new UIButton(); + tipsBtn.Cursor = System.Windows.Forms.Cursors.Hand; + tipsBtn.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.Location = new System.Drawing.Point(285, 519); + tipsBtn.MinimumSize = new System.Drawing.Size(1, 1); + tipsBtn.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80))))); + tipsBtn.Size = new System.Drawing.Size(9, 9); + tipsBtn.Style = Sunny.UI.UIStyle.Red; + tipsBtn.StyleCustomMode = true; + tipsBtn.TabIndex = 118; + tipsBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + tipsBtn.Text = ""; + tipsBtn.Click += TipsBtn_Click; + + Controls.Add(tipsBtn); + tipsBtn.Location = new System.Drawing.Point(Width - 11, 2); + tipsBtn.BringToFront(); + } + + toolTip.SetToolTip(tipsBtn, text); + } + + public event EventHandler TipsClick; + private void TipsBtn_Click(object sender, EventArgs e) + { + TipsClick?.Invoke(this, EventArgs.Empty); + } + + public void CloseTips() + { + if (tipsBtn != null) + { + tipsBtn.Click -= TipsBtn_Click; + tipsBtn.Dispose(); + tipsBtn = null; + } + } + public new event EventHandler MouseDoubleClick; public new event EventHandler MouseClick;