diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 0724b527..4c01e61a 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index a2048986..4040d1d9 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net462/SunnyUI.dll b/Bin/net462/SunnyUI.dll index 02c8314c..ce56c4d0 100644 Binary files a/Bin/net462/SunnyUI.dll and b/Bin/net462/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index 6047ca6b..f7c74c13 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index cd57bfd8..131d29d9 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index ceb6f804..62c6acd6 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FTextBox.Designer.cs b/SunnyUI.Demo/Controls/FTextBox.Designer.cs index 12406339..e552d988 100644 --- a/SunnyUI.Demo/Controls/FTextBox.Designer.cs +++ b/SunnyUI.Demo/Controls/FTextBox.Designer.cs @@ -29,6 +29,7 @@ namespace Sunny.UI.Demo /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.uiTextBox6 = new Sunny.UI.UITextBox(); this.uiTextBox5 = new Sunny.UI.UITextBox(); this.uiTextBox4 = new Sunny.UI.UITextBox(); @@ -46,6 +47,7 @@ namespace Sunny.UI.Demo this.uiLabel1 = new Sunny.UI.UILabel(); this.uiTextBox1 = new Sunny.UI.UITextBox(); this.uiIntegerUpDown1 = new Sunny.UI.UIIntegerUpDown(); + this.uiToolTip1 = new Sunny.UI.UIToolTip(this.components); this.SuspendLayout(); // // uiTextBox6 @@ -280,6 +282,7 @@ namespace Sunny.UI.Demo this.uiTextBox1.Size = new System.Drawing.Size(221, 29); this.uiTextBox1.TabIndex = 0; this.uiTextBox1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + this.uiToolTip1.SetToolTip(this.uiTextBox1, "Hello world!"); this.uiTextBox1.Watermark = "水印文字"; // // uiIntegerUpDown1 @@ -296,6 +299,12 @@ namespace Sunny.UI.Demo this.uiIntegerUpDown1.Text = "_uiIntegerUpDown1"; this.uiIntegerUpDown1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; // + // uiToolTip1 + // + this.uiToolTip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(54)))), ((int)(((byte)(54))))); + this.uiToolTip1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(239)))), ((int)(((byte)(239))))); + this.uiToolTip1.OwnerDraw = true; + // // FTextBox // this.AllowShowTitle = true; @@ -348,5 +357,6 @@ namespace Sunny.UI.Demo private UILabel uiLabel1; private UITextBox uiTextBox1; private UIIntegerUpDown uiIntegerUpDown1; + private UIToolTip uiToolTip1; } } \ No newline at end of file diff --git a/SunnyUI.Demo/Controls/FTextBox.resx b/SunnyUI.Demo/Controls/FTextBox.resx index 1af7de15..8018e1c6 100644 --- a/SunnyUI.Demo/Controls/FTextBox.resx +++ b/SunnyUI.Demo/Controls/FTextBox.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/SunnyUI/Controls/UIComboBox.cs b/SunnyUI/Controls/UIComboBox.cs index 397a0791..d2065188 100644 --- a/SunnyUI/Controls/UIComboBox.cs +++ b/SunnyUI/Controls/UIComboBox.cs @@ -32,7 +32,7 @@ namespace Sunny.UI [DefaultEvent("SelectedIndexChanged")] [ToolboxItem(true)] [LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")] - public sealed partial class UIComboBox : UIDropControl + public sealed partial class UIComboBox : UIDropControl,IToolTip { public UIComboBox() { @@ -49,6 +49,11 @@ namespace Sunny.UI fullControlSelect = true; } + public Control ExToolTipControl() + { + return edit; + } + [DefaultValue(false)] public bool Sorted { diff --git a/SunnyUI/Controls/UIComboTreeView.cs b/SunnyUI/Controls/UIComboTreeView.cs index 724bdf93..24f4d0e2 100644 --- a/SunnyUI/Controls/UIComboTreeView.cs +++ b/SunnyUI/Controls/UIComboTreeView.cs @@ -9,7 +9,7 @@ namespace Sunny.UI [DefaultEvent("NodeSelected")] [DefaultProperty("Nodes")] [ToolboxItem(true)] - public class UIComboTreeView : UIDropControl + public class UIComboTreeView : UIDropControl,IToolTip { public UIComboTreeView() { @@ -32,6 +32,11 @@ namespace Sunny.UI } + public Control ExToolTipControl() + { + return edit; + } + protected override void OnFontChanged(EventArgs e) { base.OnFontChanged(e); diff --git a/SunnyUI/Controls/UIDatePicker.cs b/SunnyUI/Controls/UIDatePicker.cs index 67634771..3bf82602 100644 --- a/SunnyUI/Controls/UIDatePicker.cs +++ b/SunnyUI/Controls/UIDatePicker.cs @@ -22,13 +22,14 @@ using System; using System.ComponentModel; +using System.Windows.Forms; namespace Sunny.UI { [ToolboxItem(true)] [DefaultProperty("Value")] [DefaultEvent("ValueChanged")] - public sealed partial class UIDatePicker : UIDropControl + public sealed partial class UIDatePicker : UIDropControl,IToolTip { public delegate void OnDateTimeChanged(object sender, DateTime value); @@ -74,6 +75,11 @@ namespace Sunny.UI } } + public Control ExToolTipControl() + { + return edit; + } + public int Year => Value.Year; public int Month => Value.Month; public int Day => Value.Day; diff --git a/SunnyUI/Controls/UIDateTimePicker.cs b/SunnyUI/Controls/UIDateTimePicker.cs index 545cd0d1..26934032 100644 --- a/SunnyUI/Controls/UIDateTimePicker.cs +++ b/SunnyUI/Controls/UIDateTimePicker.cs @@ -24,13 +24,14 @@ using System; using System.ComponentModel; +using System.Windows.Forms; namespace Sunny.UI { [ToolboxItem(true)] [DefaultProperty("Value")] [DefaultEvent("ValueChanged")] - public sealed partial class UIDatetimePicker : UIDropControl + public sealed partial class UIDatetimePicker : UIDropControl,IToolTip { private void InitializeComponent() { @@ -48,6 +49,11 @@ namespace Sunny.UI } + public Control ExToolTipControl() + { + return edit; + } + [DefaultValue(false)] [Description("日期输入时,是否可空显示"), Category("SunnyUI")] public bool CanEmpty { get; set; } diff --git a/SunnyUI/Controls/UIDoubleUpDown.cs b/SunnyUI/Controls/UIDoubleUpDown.cs index 12327271..e1e00933 100644 --- a/SunnyUI/Controls/UIDoubleUpDown.cs +++ b/SunnyUI/Controls/UIDoubleUpDown.cs @@ -30,7 +30,7 @@ namespace Sunny.UI { [DefaultEvent("ValueChanged")] [DefaultProperty("Value")] - public sealed partial class UIDoubleUpDown : UIPanel + public sealed partial class UIDoubleUpDown : UIPanel,IToolTip { public delegate void OnValueChanged(object sender, double value); @@ -50,6 +50,11 @@ namespace Sunny.UI pnlValue.Paint += PnlValue_Paint; } + public Control ExToolTipControl() + { + return pnlValue; + } + private void PnlValue_Paint(object sender, PaintEventArgs e) { if (Enabled) diff --git a/SunnyUI/Controls/UIFlowLayoutPanel.cs b/SunnyUI/Controls/UIFlowLayoutPanel.cs index 5263645b..72db5e26 100644 --- a/SunnyUI/Controls/UIFlowLayoutPanel.cs +++ b/SunnyUI/Controls/UIFlowLayoutPanel.cs @@ -27,7 +27,7 @@ using System.Windows.Forms; namespace Sunny.UI { - public class UIFlowLayoutPanel : UIPanel + public class UIFlowLayoutPanel : UIPanel,IToolTip { private UIVerScrollBarEx VBar; private UIHorScrollBarEx HBar; @@ -58,6 +58,11 @@ namespace Sunny.UI timer.Start(); } + public Control ExToolTipControl() + { + return Panel; + } + public new void Focus() { base.Focus(); diff --git a/SunnyUI/Controls/UIImageListBox.cs b/SunnyUI/Controls/UIImageListBox.cs index 94260eaf..c54449ae 100644 --- a/SunnyUI/Controls/UIImageListBox.cs +++ b/SunnyUI/Controls/UIImageListBox.cs @@ -32,7 +32,7 @@ using System.Windows.Forms; namespace Sunny.UI { [DefaultEvent("ItemClick")] - public sealed partial class UIImageListBox : UIPanel + public sealed partial class UIImageListBox : UIPanel,IToolTip { private readonly ImageListBox listbox = new ImageListBox(); private readonly UIScrollBar bar = new UIScrollBar(); @@ -67,6 +67,11 @@ namespace Sunny.UI listbox.MouseMove += Listbox_MouseMove; } + + public Control ExToolTipControl() + { + return listbox; + } public int IndexFromPoint(Point p) { return listbox.IndexFromPoint(p); diff --git a/SunnyUI/Controls/UIIntegerUpDown.cs b/SunnyUI/Controls/UIIntegerUpDown.cs index fdcc9337..824350f1 100644 --- a/SunnyUI/Controls/UIIntegerUpDown.cs +++ b/SunnyUI/Controls/UIIntegerUpDown.cs @@ -30,7 +30,7 @@ namespace Sunny.UI { [DefaultEvent("ValueChanged")] [DefaultProperty("Value")] - public sealed partial class UIIntegerUpDown : UIPanel + public sealed partial class UIIntegerUpDown : UIPanel,IToolTip { public delegate void OnValueChanged(object sender, int value); @@ -48,6 +48,11 @@ namespace Sunny.UI pnlValue.Paint += PnlValue_Paint; } + public Control ExToolTipControl() + { + return pnlValue; + } + private void PnlValue_Paint(object sender, PaintEventArgs e) { if (Enabled) diff --git a/SunnyUI/Controls/UIListBox.cs b/SunnyUI/Controls/UIListBox.cs index eb67aa86..10614989 100644 --- a/SunnyUI/Controls/UIListBox.cs +++ b/SunnyUI/Controls/UIListBox.cs @@ -33,7 +33,7 @@ namespace Sunny.UI { [DefaultEvent("ItemClick")] [DefaultProperty("Items")] - public sealed partial class UIListBox : UIPanel + public sealed partial class UIListBox : UIPanel,IToolTip { private readonly ListBoxEx listbox = new ListBoxEx(); private readonly UIScrollBar bar = new UIScrollBar(); @@ -79,6 +79,11 @@ namespace Sunny.UI timer.Start(); } + public Control ExToolTipControl() + { + return listbox; + } + private void Listbox_MouseClick(object sender, MouseEventArgs e) { MouseClick?.Invoke(this, e); diff --git a/SunnyUI/Controls/UIRichTextBox.cs b/SunnyUI/Controls/UIRichTextBox.cs index ee707c4b..20b50964 100644 --- a/SunnyUI/Controls/UIRichTextBox.cs +++ b/SunnyUI/Controls/UIRichTextBox.cs @@ -30,7 +30,7 @@ namespace Sunny.UI { [DefaultEvent("TextChanged")] [DefaultProperty("Text")] - public sealed class UIRichTextBox : UIPanel + public sealed class UIRichTextBox : UIPanel,IToolTip { private UIScrollBar bar; private RichTextBox edit; @@ -67,6 +67,11 @@ namespace Sunny.UI edit.ScrollBars = RichTextBoxScrollBars.Vertical; } + public Control ExToolTipControl() + { + return edit; + } + public RichTextBox RichTextBox => edit; public override Color BackColor { get => edit.BackColor; set { edit.BackColor = base.BackColor = value; } } diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index 3ad11fe4..a57a1ecd 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -33,7 +33,7 @@ namespace Sunny.UI { [DefaultEvent("TextChanged")] [DefaultProperty("Text")] - public sealed partial class UITextBox : UIPanel, ISymbol + public sealed partial class UITextBox : UIPanel, ISymbol, IToolTip { private readonly UIEdit edit = new UIEdit(); private readonly UIScrollBar bar = new UIScrollBar(); @@ -86,6 +86,11 @@ namespace Sunny.UI TextAlignmentChange += UITextBox_TextAlignmentChange; } + public Control ExToolTipControl() + { + return edit; + } + private void Edit_LostFocus(object sender, EventArgs e) { LostFocus?.Invoke(this, e); diff --git a/SunnyUI/Controls/UITimePicker.cs b/SunnyUI/Controls/UITimePicker.cs index 4318c1db..d03e1b09 100644 --- a/SunnyUI/Controls/UITimePicker.cs +++ b/SunnyUI/Controls/UITimePicker.cs @@ -23,13 +23,14 @@ using System; using System.ComponentModel; +using System.Windows.Forms; namespace Sunny.UI { [ToolboxItem(true)] [DefaultProperty("Value")] [DefaultEvent("ValueChanged")] - public sealed partial class UITimePicker : UIDropControl + public sealed partial class UITimePicker : UIDropControl,IToolTip { private void InitializeComponent() { @@ -46,6 +47,11 @@ namespace Sunny.UI this.PerformLayout(); } + public Control ExToolTipControl() + { + return edit; + } + public UITimePicker() { InitializeComponent(); diff --git a/SunnyUI/Controls/UIToolTip.cs b/SunnyUI/Controls/UIToolTip.cs index 57bae6d6..0c62414b 100644 --- a/SunnyUI/Controls/UIToolTip.cs +++ b/SunnyUI/Controls/UIToolTip.cs @@ -93,6 +93,11 @@ namespace Sunny.UI ToolTipControls.TryAdd(control, ctrl); } + if (control is IToolTip toolTip) + { + SetToolTip(toolTip.ExToolTipControl(), description, title, symbol, symbolSize, symbolColor); + } + base.SetToolTip(control, description); } @@ -117,6 +122,11 @@ namespace Sunny.UI ToolTipControls.TryAdd(control, ctrl); } + if (control is IToolTip toolTip) + { + SetToolTip(toolTip.ExToolTipControl(), description, title); + } + base.SetToolTip(control, description); } @@ -139,13 +149,25 @@ namespace Sunny.UI ToolTipControls.TryAdd(control, ctrl); } + if (control is IToolTip toolTip) + { + SetToolTip(toolTip.ExToolTipControl(), description); + } + base.SetToolTip(control, description); } public void RemoveToolTip(Control control) { if (ToolTipControls.ContainsKey(control)) + { ToolTipControls.TryRemove(control, out _); + } + + if (control is IToolTip toolTip) + { + RemoveToolTip(toolTip.ExToolTipControl()); + } } public new string GetToolTip(Control control) diff --git a/SunnyUI/Controls/UITreeView.cs b/SunnyUI/Controls/UITreeView.cs index 8dcedea6..9414b8a3 100644 --- a/SunnyUI/Controls/UITreeView.cs +++ b/SunnyUI/Controls/UITreeView.cs @@ -31,7 +31,7 @@ using System.Windows.Forms; namespace Sunny.UI { - public sealed class UITreeView : UIPanel + public sealed class UITreeView : UIPanel,IToolTip { private UIScrollBar Bar; @@ -65,6 +65,11 @@ namespace Sunny.UI view.MouseLeave += View_MouseLeave; } + public Control ExToolTipControl() + { + return view; + } + public new EventHandler MouseLeave; public new EventHandler MouseEnter; public new MouseEventHandler MouseMove; diff --git a/SunnyUI/Units/UDefine.cs b/SunnyUI/Units/UDefine.cs index 70084a1c..d37b39c0 100644 --- a/SunnyUI/Units/UDefine.cs +++ b/SunnyUI/Units/UDefine.cs @@ -1,4 +1,6 @@ -namespace Sunny.UI +using System.Windows.Forms; + +namespace Sunny.UI { public enum UIDateType { @@ -6,4 +8,9 @@ YearMonth, Year } + + public interface IToolTip + { + Control ExToolTipControl(); + } }