* 控件缩放部分代码修改
This commit is contained in:
parent
b6554b162c
commit
1580848281
Binary file not shown.
@ -36,7 +36,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
|
@ -11,7 +11,7 @@ namespace Sunny.UI
|
||||
private ContentAlignment m_rotatePointAlignment = ContentAlignment.MiddleCenter;
|
||||
private ContentAlignment m_textAlignment = ContentAlignment.MiddleLeft;
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
|
@ -45,7 +45,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
[Browsable(false), DefaultValue(false)]
|
||||
|
@ -49,7 +49,7 @@ namespace Sunny.UI
|
||||
base.MinimumSize = new Size(1, 1);
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -103,7 +103,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -44,7 +44,7 @@ namespace Sunny.UI
|
||||
private ContentAlignment textAlign = ContentAlignment.MiddleCenter;
|
||||
private Color foreColor = UIFontColor.Primary;
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
|
@ -345,7 +345,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -46,7 +46,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
@ -191,7 +191,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -609,7 +609,7 @@ namespace Sunny.UI
|
||||
{
|
||||
private UIScrollBar bar;
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
|
@ -67,7 +67,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -90,7 +90,7 @@ namespace Sunny.UI
|
||||
selectedHighColor = UIStyles.Blue.NavMenuMenuSelectedColor;
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -63,7 +63,7 @@ namespace Sunny.UI
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -82,7 +82,7 @@ namespace Sunny.UI
|
||||
Version = UIGlobal.Version;
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -75,7 +75,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -50,7 +50,7 @@ namespace Sunny.UI
|
||||
_fillColor = UIStyles.Blue.TabControlBackColor;
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
|
@ -33,7 +33,7 @@ namespace Sunny.UI
|
||||
Version = UIGlobal.Version;
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
|
@ -345,7 +345,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -115,8 +115,30 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDesignedSize()
|
||||
{
|
||||
if (DesignedRect.Width == 0 && DesignedRect.Height == 0)
|
||||
{
|
||||
DesignedRect = new ControlScaleInfo(DesignedSize.Width, DesignedSize.Height, 0, 0);
|
||||
}
|
||||
|
||||
if (DesignedRect.Width == 0 && DesignedRect.Height == 0)
|
||||
{
|
||||
DesignedRect = new ControlScaleInfo(this);
|
||||
}
|
||||
|
||||
DesignSizeChanged?.Invoke(this, DesignedRect);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Size), "0, 0")]
|
||||
[Description("设计界面大小"), Category("SunnyUI")]
|
||||
public Size DesignedSize
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
private void SetControlScale()
|
||||
@ -134,8 +156,12 @@ namespace Sunny.UI
|
||||
UIDPIScale.SetControlScale(control, scale);
|
||||
}
|
||||
}
|
||||
|
||||
ControlScaleChanged?.Invoke(this, scale);
|
||||
}
|
||||
|
||||
public event OnControlScaleChanged ControlScaleChanged;
|
||||
|
||||
public void ResetDPIScale()
|
||||
{
|
||||
IsScaled = false;
|
||||
@ -1329,13 +1355,7 @@ namespace Sunny.UI
|
||||
SetDesignedSize();
|
||||
}
|
||||
|
||||
protected virtual void SetDesignedSize()
|
||||
{
|
||||
if (DesignedRect.Width == 0 && DesignedRect.Height == 0)
|
||||
{
|
||||
DesignedRect = new ControlScaleInfo(this); ;
|
||||
}
|
||||
}
|
||||
public event OnDesignSizeChanged DesignSizeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示圆角
|
||||
|
@ -30,6 +30,10 @@ using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
public delegate void OnControlScaleChanged(object sender, float scale);
|
||||
|
||||
public delegate void OnDesignSizeChanged(object sender, ControlScaleInfo info);
|
||||
|
||||
public static class UIMessageDialog
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -79,7 +79,7 @@ namespace Sunny.UI
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
|
||||
public bool ForbidControlScale { get; set; }
|
||||
|
||||
[Browsable(false), DefaultValue(typeof(Size), "0, 0")]
|
||||
[Browsable(false)]
|
||||
public ControlScaleInfo DesignedRect { get; private set; }
|
||||
|
||||
protected override void OnVisibleChanged(EventArgs e)
|
||||
|
@ -77,6 +77,14 @@ namespace Sunny.UI
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
|
||||
public ControlScaleInfo(int width, int height, int xInterval, int yInterval)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
XInterval = xInterval;
|
||||
YInterval = yInterval;
|
||||
}
|
||||
|
||||
public ControlScaleInfo(Control control)
|
||||
{
|
||||
Width = control.Width;
|
||||
|
@ -85,12 +85,6 @@ namespace Sunny.UI
|
||||
set => UIStyles.FontSize = value;
|
||||
}
|
||||
|
||||
public bool ControlScale
|
||||
{
|
||||
get => UIStyles.ControlScale;
|
||||
set => UIStyles.ControlScale = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 版本
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user