diff --git a/SunnyUI/Common/UControl.cs b/SunnyUI/Common/UControl.cs
index e625ebe1..789b1a00 100644
--- a/SunnyUI/Common/UControl.cs
+++ b/SunnyUI/Common/UControl.cs
@@ -74,12 +74,12 @@ namespace Sunny.UI
return ctrl as Form;
}
- public static Control SettingToCenter(this Control ctrl)
+ public static Control SetToTheCenterOfParent(this Control ctrl)
{
- return ctrl.SettingToXCenter().SettingToYCenter();
+ return ctrl.SetToTheHorizontalCenterOfParent().SetToTheVerticalCenterOfParent();
}
- public static Control SettingToXCenter(this Control ctrl)
+ public static Control SetToTheHorizontalCenterOfParent(this Control ctrl)
{
if (ctrl != null && ctrl.Parent != null)
ctrl.Left = (ctrl.Parent.Width - ctrl.Width) / 2;
@@ -87,7 +87,7 @@ namespace Sunny.UI
return ctrl;
}
- public static Control SettingToYCenter(this Control ctrl)
+ public static Control SetToTheVerticalCenterOfParent(this Control ctrl)
{
if (ctrl != null && ctrl.Parent != null)
ctrl.Top = (ctrl.Parent.Height - ctrl.Height) / 2;
diff --git a/SunnyUI/Controls/UIControl.cs b/SunnyUI/Controls/UIControl.cs
index 871f19bc..d4aa81f2 100644
--- a/SunnyUI/Controls/UIControl.cs
+++ b/SunnyUI/Controls/UIControl.cs
@@ -57,7 +57,7 @@ namespace Sunny.UI
public virtual void SetZoomScale(float scale)
{
-
+ radius = UIZoomScale.Calc(baseRadius, scale);
}
protected bool selected;
@@ -167,6 +167,7 @@ namespace Sunny.UI
}
private int radius = 5;
+ private int baseRadius = 5;
///
/// 圆角角度
@@ -180,7 +181,7 @@ namespace Sunny.UI
{
if (radius != value)
{
- radius = Math.Max(0, value);
+ baseRadius = radius = Math.Max(0, value);
Invalidate();
}
}
diff --git a/SunnyUI/Controls/UIHeaderButton.cs b/SunnyUI/Controls/UIHeaderButton.cs
index 4b35d27f..f0f41ca9 100644
--- a/SunnyUI/Controls/UIHeaderButton.cs
+++ b/SunnyUI/Controls/UIHeaderButton.cs
@@ -67,6 +67,12 @@ namespace Sunny.UI
rectDisableColor = UIStyles.Blue.RectDisableColor;
}
+ public override void SetZoomScale(float scale)
+ {
+ base.SetZoomScale(scale);
+ circleSize = UIZoomScale.Calc(baseCircleSize, scale);
+ }
+
private bool showTips = false;
[Description("是否显示角标"), Category("SunnyUI")]
@@ -435,6 +441,7 @@ namespace Sunny.UI
}
private int circleSize = 50;
+ private int baseCircleSize = 50;
[DefaultValue(50)]
[Description("字体图标背景大小"), Category("SunnyUI")]
@@ -443,7 +450,7 @@ namespace Sunny.UI
get => circleSize;
set
{
- circleSize = value;
+ baseCircleSize = circleSize = value;
Invalidate();
}
}
diff --git a/SunnyUI/Controls/UILedBulb.cs b/SunnyUI/Controls/UILedBulb.cs
index b95f07cf..377681c3 100644
--- a/SunnyUI/Controls/UILedBulb.cs
+++ b/SunnyUI/Controls/UILedBulb.cs
@@ -34,7 +34,7 @@ namespace Sunny.UI
/// provide a sleek looking representation of an LED light that is sizable,
/// has a transparent background and can be set to different colors.
///
- public class UILedBulb : Control
+ public class UILedBulb : Control, IZoomScale
{
#region Public and Private Members
@@ -44,6 +44,17 @@ namespace Sunny.UI
private readonly Color[] _surroundColor = new Color[] { Color.FromArgb(0, 255, 255, 255) };
private readonly Timer timer;
+ [DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
+ public bool ZoomScaleDisabled { get; set; }
+
+ [Browsable(false)]
+ public Rectangle ZoomScaleRect { get; set; }
+
+ public void SetZoomScale(float scale)
+ {
+
+ }
+
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
diff --git a/SunnyUI/Controls/UINavMenu.cs b/SunnyUI/Controls/UINavMenu.cs
index 92cd8297..be8df451 100644
--- a/SunnyUI/Controls/UINavMenu.cs
+++ b/SunnyUI/Controls/UINavMenu.cs
@@ -78,6 +78,7 @@ namespace Sunny.UI
Bar.ForeColor = Color.Silver;
Bar.HoverColor = Color.Silver;
Bar.PressColor = Color.Silver;
+ Bar.ZoomScaleDisabled = true;
Controls.Add(Bar);
Version = UIGlobal.Version;
diff --git a/SunnyUI/Controls/UIPipe.cs b/SunnyUI/Controls/UIPipe.cs
index 362ce5bc..61fefdbf 100644
--- a/SunnyUI/Controls/UIPipe.cs
+++ b/SunnyUI/Controls/UIPipe.cs
@@ -41,6 +41,7 @@ namespace Sunny.UI
Style = UIStyle.Custom;
Width = 200;
Height = 16;
+ ZoomScaleDisabled = true;
}
private ConcurrentDictionary linked = new ConcurrentDictionary();
diff --git a/SunnyUI/Controls/UITransfer.cs b/SunnyUI/Controls/UITransfer.cs
index e946f9c9..b482b000 100644
--- a/SunnyUI/Controls/UITransfer.cs
+++ b/SunnyUI/Controls/UITransfer.cs
@@ -46,6 +46,8 @@ namespace Sunny.UI
l1.ItemsCountChange += L1_ItemsCountChange;
l2.ItemsCountChange += L2_ItemsCountChange;
+ l1.ZoomScaleDisabled = l2.ZoomScaleDisabled = true;
+ b1.ZoomScaleDisabled = b2.ZoomScaleDisabled = b3.ZoomScaleDisabled = b4.ZoomScaleDisabled = true;
}
[DefaultValue(true)]
diff --git a/SunnyUI/Controls/UIValve.cs b/SunnyUI/Controls/UIValve.cs
index 36a09b89..5fedb4ee 100644
--- a/SunnyUI/Controls/UIValve.cs
+++ b/SunnyUI/Controls/UIValve.cs
@@ -31,7 +31,7 @@ namespace Sunny.UI
[ToolboxItem(true)]
[DefaultProperty("Active")]
[DefaultEvent("ActiveChanged")]
- public class UIValve : Control
+ public sealed class UIValve : Control, IZoomScale
{
public UIValve()
{
@@ -41,6 +41,18 @@ namespace Sunny.UI
fillColor = Color.White;
valveColor = UIColor.Blue;
Version = UIGlobal.Version;
+ ZoomScaleDisabled = true;
+ }
+
+ [DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
+ public bool ZoomScaleDisabled { get; set; }
+
+ [Browsable(false)]
+ public Rectangle ZoomScaleRect { get; set; }
+
+ public void SetZoomScale(float scale)
+ {
+
}
protected override void OnClick(EventArgs e)
diff --git a/SunnyUI/Style/UIZoomScale.cs b/SunnyUI/Style/UIZoomScale.cs
index f9000292..bd6f97e0 100644
--- a/SunnyUI/Style/UIZoomScale.cs
+++ b/SunnyUI/Style/UIZoomScale.cs
@@ -12,7 +12,7 @@ namespace Sunny.UI
bool ZoomScaleDisabled { get; set; }
}
- internal static class UIZoomScale
+ public static class UIZoomScale
{
public static Rectangle Create(Control control)
{
@@ -60,12 +60,12 @@ namespace Sunny.UI
}
}
- internal static int Calc(int size, float scale)
+ public static int Calc(int size, float scale)
{
return (int)(size * scale + 0.5);
}
- internal static Size Calc(Size size, float scale)
+ public static Size Calc(Size size, float scale)
{
return new Size(Calc(size.Width, scale), Calc(size.Height, scale));
}