diff --git a/SunnyUI/Font/UFontImages.cs b/SunnyUI/Font/UFontImages.cs
index 1690ff9e..2b165d7d 100644
--- a/SunnyUI/Font/UFontImages.cs
+++ b/SunnyUI/Font/UFontImages.cs
@@ -185,7 +185,7 @@ namespace Sunny.UI
}
}
- public static class FontAweSomeV6ItemBuilder
+ internal static class FontAweSomeV6ItemBuilder
{
public static void Build()
{
diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs
index 427b822d..5ae71239 100644
--- a/SunnyUI/Forms/UIForm.cs
+++ b/SunnyUI/Forms/UIForm.cs
@@ -107,6 +107,8 @@ namespace Sunny.UI
ZoomScaleRectChanged?.Invoke(this, ZoomScaleRect);
}
+ public event OnZoomScaleRectChanged ZoomScaleRectChanged;
+
[DefaultValue(typeof(Size), "0, 0")]
[Description("设计界面大小"), Category("SunnyUI")]
public Size ZoomScaleSize
@@ -761,8 +763,6 @@ namespace Sunny.UI
SetZoomScaleRect();
}
- public event OnZoomScaleRectChanged ZoomScaleRectChanged;
-
///
/// 是否显示圆角
///
diff --git a/SunnyUI/Forms/UIForm2.cs b/SunnyUI/Forms/UIForm2.cs
index 84282759..166b8a7c 100644
--- a/SunnyUI/Forms/UIForm2.cs
+++ b/SunnyUI/Forms/UIForm2.cs
@@ -23,6 +23,7 @@
* 2024-05-16: V3.6.6 Resizable替代ShowDragStretch,显示边框可拖拽调整窗体大小
* 2024-06-08: V3.6.6 防止图标转换错误
* 2024-07-20: V3.6.8 修改最大化时按钮位置
+ * 2024-07-21: V3.6.8 修改属性与UIForm兼容
******************************************************************************/
using System;
@@ -48,6 +49,74 @@ namespace Sunny.UI
fieldH = typeof(Control).GetField("_clientHeight", BindingFlags.NonPublic | BindingFlags.Instance) ?? typeof(Control).GetField("clientHeight", BindingFlags.NonPublic | BindingFlags.Instance);
}
+ ///
+ /// 禁止控件跟随窗体缩放
+ ///
+ [DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
+ public bool ZoomScaleDisabled { get; set; }
+
+ private void SetZoomScaleRect()
+ {
+ if (ZoomScaleRect.Width == 0 && ZoomScaleRect.Height == 0)
+ {
+ ZoomScaleRect = new Rectangle(ZoomScaleSize.Width, ZoomScaleSize.Height, 0, 0);
+ }
+
+ if (ZoomScaleRect.Width == 0 && ZoomScaleRect.Height == 0)
+ {
+ ZoomScaleRect = new Rectangle(Left, Top, Width, Height);
+ }
+
+ ZoomScaleRectChanged?.Invoke(this, ZoomScaleRect);
+ }
+
+ public event OnZoomScaleRectChanged ZoomScaleRectChanged;
+
+ [DefaultValue(typeof(Size), "0, 0")]
+ [Description("设计界面大小"), Category("SunnyUI")]
+ public Size ZoomScaleSize
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 控件缩放前在其容器里的位置
+ ///
+ [Browsable(false), DefaultValue(typeof(Rectangle), "0, 0, 0, 0")]
+ public Rectangle ZoomScaleRect { get; set; }
+
+ ///
+ /// 设置控件缩放比例
+ ///
+ /// 缩放比例
+ private void SetZoomScale()
+ {
+ if (ZoomScaleDisabled) return;
+ if (!UIStyles.DPIScale || !UIStyles.ZoomScale) return;
+ if (ZoomScaleRect.Width == 0 || ZoomScaleRect.Height == 0) return;
+ if (Width == 0 || Height == 0) return;
+ float scale = Math.Min(Width * 1.0f / ZoomScaleRect.Width, Height * 1.0f / ZoomScaleRect.Height);
+ if (scale.EqualsFloat(0)) return;
+ foreach (Control control in this.GetAllZoomScaleControls())
+ {
+ if (control is IZoomScale ctrl)
+ {
+ UIZoomScale.SetZoomScale(control, scale);
+ }
+ }
+
+ ZoomScaleChanged?.Invoke(this, scale);
+ }
+
+ public event OnZoomScaleChanged ZoomScaleChanged;
+
+ protected override void OnShown(EventArgs e)
+ {
+ base.OnShown(e);
+ SetZoomScaleRect();
+ }
+
[Description("显示边框可拖拽调整窗体大小"), Category("SunnyUI"), DefaultValue(false)]
public bool Resizable
{