diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe
index 3291a711..8aae1561 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 389d635b..3011619a 100644
Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ
diff --git a/Bin/net45/SunnyUI.dll b/Bin/net45/SunnyUI.dll
index 2bfe8a94..03b66385 100644
Binary files a/Bin/net45/SunnyUI.dll and b/Bin/net45/SunnyUI.dll differ
diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll
index e0e79923..03898c37 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 2200b3c9..b94137f7 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 7418a792..ca021f94 100644
Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ
diff --git a/SunnyUI/Controls/DropItem/UIDropDown.cs b/SunnyUI/Controls/DropItem/UIDropDown.cs
index 48518097..8a30f644 100644
--- a/SunnyUI/Controls/DropItem/UIDropDown.cs
+++ b/SunnyUI/Controls/DropItem/UIDropDown.cs
@@ -136,7 +136,23 @@ namespace Sunny.UI
throw new ArgumentNullException(nameof(control));
}
- Show(control, control.ClientRectangle);
+ Show(control, control.ClientRectangle, new Point(0, 0));
+ }
+
+ ///
+ /// 显示
+ ///
+ /// Control
+ /// 大小
+ public void Show(Control control, Size size, Point offset)
+ {
+ if (control == null)
+ {
+ throw new ArgumentNullException(nameof(control));
+ }
+
+ Size = size;
+ Show(control, control.ClientRectangle, offset);
}
///
@@ -176,7 +192,7 @@ namespace Sunny.UI
///
/// Control
/// 区域
- public void Show(Control control, Rectangle area)
+ public void Show(Control control, Rectangle area, Point offset)
{
if (control == null)
{
@@ -187,6 +203,10 @@ namespace Sunny.UI
Point location = control.PointToScreen(new Point(area.Left, area.Top + area.Height));
Rectangle screen = Screen.FromControl(control).WorkingArea;
+
+ location.X += offset.X;
+ location.Y += offset.Y;
+
if (location.X + Size.Width > (screen.Left + screen.Width))
{
location.X = (screen.Left + screen.Width) - Size.Width;
diff --git a/SunnyUI/Controls/DropItem/UIDropDown.resx b/SunnyUI/Controls/DropItem/UIDropDown.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/SunnyUI/Controls/DropItem/UIDropDown.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SunnyUI/Controls/DropItem/UIDropDownItem.cs b/SunnyUI/Controls/DropItem/UIDropDownItem.cs
index 160885ee..ba611eb8 100644
--- a/SunnyUI/Controls/DropItem/UIDropDownItem.cs
+++ b/SunnyUI/Controls/DropItem/UIDropDownItem.cs
@@ -94,6 +94,11 @@ namespace Sunny.UI
parent?.Close();
}
+ public void Close()
+ {
+ CloseParent();
+ }
+
public virtual void SetStyle(UIBaseStyle style)
{
}
diff --git a/SunnyUI/Controls/DropItem/UIToolStripDropDown.cs b/SunnyUI/Controls/DropItem/UIToolStripDropDown.cs
new file mode 100644
index 00000000..054f6893
--- /dev/null
+++ b/SunnyUI/Controls/DropItem/UIToolStripDropDown.cs
@@ -0,0 +1,133 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace Sunny.UI
+{
+ public class UIToolStripDropDown
+ {
+ private UIDropDown itemForm;
+
+ public UIToolStripDropDown(UIDropDownItem item)
+ {
+ itemForm = new UIDropDown(item);
+ itemForm.ValueChanged += ItemForm_ValueChanged;
+ itemForm.VisibleChanged += ItemForm_VisibleChanged;
+ itemForm.Closed += ItemForm_Closed;
+ itemForm.Opened += ItemForm_Opened;
+ itemForm.Opening += ItemForm_Opening;
+ }
+
+ private void ItemForm_Opening(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ Opening?.Invoke(this, e);
+ }
+
+ private void ItemForm_Opened(object sender, EventArgs e)
+ {
+ Opened?.Invoke(this, e);
+ }
+
+ public event ToolStripDropDownClosedEventHandler Closed;
+ public event UIDropDown.OnValueChanged ValueChanged;
+ public event EventHandler VisibleChanged;
+ public event EventHandler Opened;
+ public event CancelEventHandler Opening;
+
+ private void ItemForm_Closed(object sender, ToolStripDropDownClosedEventArgs e)
+ {
+ Closed?.Invoke(this, e);
+ }
+
+ private void ItemForm_VisibleChanged(object sender, EventArgs e)
+ {
+ VisibleChanged?.Invoke(this, e);
+ }
+
+ private void ItemForm_ValueChanged(object sender, object value)
+ {
+ ValueChanged?.Invoke(this, value);
+ }
+
+ ///
+ /// 显示
+ ///
+ /// Control
+ /// 区域
+ public void Show(Control control, Rectangle area, Point offset)
+ {
+ itemForm.Show(control, area, offset);
+ }
+
+ ///
+ /// 显示
+ ///
+ /// Control
+ /// 大小
+ public void Show(Control control, Size size)
+ {
+ itemForm.Show(control, size);
+ }
+
+ ///
+ /// 显示
+ ///
+ /// Control
+ /// 大小
+ public void Show(Control control, Size size, Point offset)
+ {
+ itemForm.Show(control, size, offset);
+ }
+
+ ///
+ /// 显示
+ ///
+ /// Control
+ public void Show(Control control)
+ {
+ itemForm.Show(control);
+ }
+
+ ///
+ /// 显示
+ ///
+ /// 区域
+ public void Show(Rectangle area)
+ {
+ itemForm.Show(area);
+ }
+
+ ///
+ /// 设置边框颜色
+ ///
+ /// 颜色
+ public void SetRectColor(Color color)
+ {
+ itemForm.SetRectColor(color);
+ }
+
+ ///
+ /// 设置填充颜色
+ ///
+ /// 颜色
+ public void SetFillColor(Color color)
+ {
+ itemForm.SetFillColor(color);
+ }
+
+ ///
+ /// 设置字体颜色
+ ///
+ /// 颜色
+ public void SetForeColor(Color color)
+ {
+ itemForm.SetForeColor(color);
+ }
+
+ public void SetStyle(UIBaseStyle style)
+ {
+ itemForm.SetStyle(style);
+ }
+ }
+}