* UIStyle: 增加系统DPI缩放自适应
* UIStyleManager: 增加系统DPI缩放自适应
This commit is contained in:
parent
030db76dd8
commit
4c8d722ce6
Binary file not shown.
@ -303,6 +303,57 @@ namespace Sunny.UI
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Control> GetAllControls(this Control control)
|
||||||
|
{
|
||||||
|
var list = new List<Control>();
|
||||||
|
foreach (Control con in control.Controls)
|
||||||
|
{
|
||||||
|
list.Add(con);
|
||||||
|
if (con.Controls.Count > 0)
|
||||||
|
{
|
||||||
|
list.AddRange(GetAllControls(con));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float DPIScale(this Control control)
|
||||||
|
{
|
||||||
|
return control.CreateGraphics().DpiX / 96.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Font DPIScaleFont(this Control control)
|
||||||
|
{
|
||||||
|
return new Font(control.Font.FontFamily, control.Font.Size / control.DPIScale(),
|
||||||
|
control.Font.Style, control.Font.Unit, control.Font.GdiCharSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetDPIScaleFont(this Control control)
|
||||||
|
{
|
||||||
|
if (!control.DPIScale().Equals(1))
|
||||||
|
{
|
||||||
|
control.Font = control.DPIScaleFont();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Control> GetAllDPIScaleControls(this Control control)
|
||||||
|
{
|
||||||
|
var list = new List<Control>();
|
||||||
|
foreach (Control con in control.Controls)
|
||||||
|
{
|
||||||
|
list.Add(con);
|
||||||
|
if (con is IToolTip) continue;
|
||||||
|
|
||||||
|
if (con.Controls.Count > 0)
|
||||||
|
{
|
||||||
|
list.AddRange(GetAllControls(con));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找包含接口名称的控件列表
|
/// 查找包含接口名称的控件列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -401,10 +452,10 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
object obj = f1.GetValue(button);
|
object obj = f1.GetValue(button);
|
||||||
PropertyInfo pi = button.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance);
|
PropertyInfo pi = button.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
if (pi != null)
|
if (pi != null && obj != null)
|
||||||
{
|
{
|
||||||
EventHandlerList list = (EventHandlerList)pi.GetValue(button, null);
|
EventHandlerList list = (EventHandlerList)pi.GetValue(button, null);
|
||||||
list.RemoveHandler(obj, list[obj]);
|
list?.RemoveHandler(obj, list[obj]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,17 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetLightness(double lightness)
|
public void SetLightness(double lightness)
|
||||||
{
|
{
|
||||||
m_selectedColor.Lightness = lightness;
|
m_selectedColor.Lightness = lightness;
|
||||||
|
@ -11,6 +11,17 @@ namespace Sunny.UI
|
|||||||
private ContentAlignment m_rotatePointAlignment = ContentAlignment.MiddleCenter;
|
private ContentAlignment m_rotatePointAlignment = ContentAlignment.MiddleCenter;
|
||||||
private ContentAlignment m_textAlignment = ContentAlignment.MiddleLeft;
|
private ContentAlignment m_textAlignment = ContentAlignment.MiddleLeft;
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public new string Text
|
public new string Text
|
||||||
{
|
{
|
||||||
get { return base.Text; }
|
get { return base.Text; }
|
||||||
|
@ -49,6 +49,17 @@ namespace Sunny.UI
|
|||||||
Width = 150;
|
Width = 150;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private UIStyle _style = UIStyle.Blue;
|
private UIStyle _style = UIStyle.Blue;
|
||||||
|
|
||||||
protected override void OnBackColorChanged(EventArgs e)
|
protected override void OnBackColorChanged(EventArgs e)
|
||||||
|
@ -38,6 +38,17 @@ namespace Sunny.UI
|
|||||||
Version = UIGlobal.Version;
|
Version = UIGlobal.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义主题风格
|
/// 自定义主题风格
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -45,6 +45,17 @@ namespace Sunny.UI
|
|||||||
base.MinimumSize = new Size(1, 1);
|
base.MinimumSize = new Size(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void SetStyleFlags(bool supportTransparent = true, bool selectable = true, bool resizeRedraw = false)
|
protected void SetStyleFlags(bool supportTransparent = true, bool selectable = true, bool resizeRedraw = false)
|
||||||
{
|
{
|
||||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||||
|
@ -98,6 +98,17 @@ namespace Sunny.UI
|
|||||||
HorizontalScrollBar.VisibleChanged += HorizontalScrollBar_VisibleChanged;
|
HorizontalScrollBar.VisibleChanged += HorizontalScrollBar_VisibleChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly Dictionary<string, CellStyle> CellStyles = new Dictionary<string, CellStyle>();
|
private readonly Dictionary<string, CellStyle> CellStyles = new Dictionary<string, CellStyle>();
|
||||||
|
|
||||||
public class CellStyle
|
public class CellStyle
|
||||||
|
@ -33,7 +33,7 @@ using System.Windows.Forms;
|
|||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
[DefaultEvent("ItemClick")]
|
[DefaultEvent("ItemClick")]
|
||||||
public sealed partial class UIImageListBox : UIPanel,IToolTip
|
public sealed partial class UIImageListBox : UIPanel, IToolTip
|
||||||
{
|
{
|
||||||
private readonly ImageListBox listbox = new ImageListBox();
|
private readonly ImageListBox listbox = new ImageListBox();
|
||||||
private readonly UIScrollBar bar = new UIScrollBar();
|
private readonly UIScrollBar bar = new UIScrollBar();
|
||||||
@ -136,7 +136,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
listbox.SetScrollInfo();
|
listbox.SetScrollInfo();
|
||||||
LastCount = Items.Count;
|
LastCount = Items.Count;
|
||||||
ItemsCountChange?.Invoke(this, null);
|
ItemsCountChange?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +368,17 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//protected override void WndProc(ref Message m)
|
//protected override void WndProc(ref Message m)
|
||||||
//{
|
//{
|
||||||
// if (IsDisposed || Disposing) return;
|
// if (IsDisposed || Disposing) return;
|
||||||
|
@ -42,6 +42,17 @@ namespace Sunny.UI
|
|||||||
ForeColorChanged += UILabel_ForeColorChanged;
|
ForeColorChanged += UILabel_ForeColorChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UILabel_ForeColorChanged(object sender, EventArgs e)
|
private void UILabel_ForeColorChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_style = UIStyle.Custom;
|
_style = UIStyle.Custom;
|
||||||
@ -128,6 +139,17 @@ namespace Sunny.UI
|
|||||||
LinkColor = UIColor.Blue;
|
LinkColor = UIColor.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tag字符串
|
/// Tag字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -605,6 +605,17 @@ namespace Sunny.UI
|
|||||||
[Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")]
|
[Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")]
|
||||||
public string TagString { get; set; }
|
public string TagString { get; set; }
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UIScrollBar Bar
|
public UIScrollBar Bar
|
||||||
{
|
{
|
||||||
get => bar;
|
get => bar;
|
||||||
|
@ -60,6 +60,17 @@ namespace Sunny.UI
|
|||||||
Version = UIGlobal.Version;
|
Version = UIGlobal.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int radius;
|
private int radius;
|
||||||
|
|
||||||
[DefaultValue(0)]
|
[DefaultValue(0)]
|
||||||
|
@ -80,6 +80,17 @@ namespace Sunny.UI
|
|||||||
SetScrollInfo();
|
SetScrollInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
[Description("只显示一个打开的节点"), Category("SunnyUI")]
|
[Description("只显示一个打开的节点"), Category("SunnyUI")]
|
||||||
public bool ShowOneNode { get; set; }
|
public bool ShowOneNode { get; set; }
|
||||||
|
@ -52,6 +52,17 @@ namespace Sunny.UI
|
|||||||
SetStyleFlags(true, false);
|
SetStyleFlags(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void SetStyleFlags(bool supportTransparent = true, bool selectable = true, bool resizeRedraw = false)
|
protected void SetStyleFlags(bool supportTransparent = true, bool selectable = true, bool resizeRedraw = false)
|
||||||
{
|
{
|
||||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||||
|
@ -62,6 +62,17 @@ namespace Sunny.UI
|
|||||||
timer.Tick += Timer_Tick;
|
timer.Tick += Timer_Tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
@ -457,7 +468,7 @@ namespace Sunny.UI
|
|||||||
Rectangle TabRect = new Rectangle(GetTabRect(index).Location.X - 2, GetTabRect(index).Location.Y - 2, ItemSize.Width, ItemSize.Height);
|
Rectangle TabRect = new Rectangle(GetTabRect(index).Location.X - 2, GetTabRect(index).Location.Y - 2, ItemSize.Width, ItemSize.Height);
|
||||||
if (Alignment == TabAlignment.Bottom)
|
if (Alignment == TabAlignment.Bottom)
|
||||||
{
|
{
|
||||||
TabRect = new Rectangle(GetTabRect(index).Location.X- 2, GetTabRect(index).Location.Y + 2, ItemSize.Width, ItemSize.Height);
|
TabRect = new Rectangle(GetTabRect(index).Location.X - 2, GetTabRect(index).Location.Y + 2, ItemSize.Width, ItemSize.Height);
|
||||||
}
|
}
|
||||||
Bitmap bmp = new Bitmap(TabRect.Width, TabRect.Height);
|
Bitmap bmp = new Bitmap(TabRect.Width, TabRect.Height);
|
||||||
Graphics g = Graphics.FromImage(bmp);
|
Graphics g = Graphics.FromImage(bmp);
|
||||||
@ -479,10 +490,10 @@ namespace Sunny.UI
|
|||||||
if (TabSelectedHighColorSize > 0)
|
if (TabSelectedHighColorSize > 0)
|
||||||
g.FillRectangle(TabSelectedHighColor, 0, bmp.Height - TabSelectedHighColorSize, bmp.Width, TabSelectedHighColorSize);
|
g.FillRectangle(TabSelectedHighColor, 0, bmp.Height - TabSelectedHighColorSize, bmp.Width, TabSelectedHighColorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Alignment == TabAlignment.Bottom)
|
if (Alignment == TabAlignment.Bottom)
|
||||||
{
|
{
|
||||||
g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, (TabRect.Height - sf.Height - TabSelectedHighColorSize) / 2.0f);
|
g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, (TabRect.Height - sf.Height - TabSelectedHighColorSize) / 2.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,17 @@ namespace Sunny.UI
|
|||||||
Version = UIGlobal.Version;
|
Version = UIGlobal.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义主题风格
|
/// 自定义主题风格
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -32,6 +32,17 @@ namespace Sunny.UI
|
|||||||
Version = UIGlobal.Version;
|
Version = UIGlobal.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnControlAdded(ControlEventArgs e)
|
protected override void OnControlAdded(ControlEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnControlAdded(e);
|
base.OnControlAdded(e);
|
||||||
|
@ -70,6 +70,22 @@ namespace Sunny.UI
|
|||||||
showTitleIcon = false;
|
showTitleIcon = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled && UIStyles.DPIScale)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
foreach (Control control in this.GetAllDPIScaleControls())
|
||||||
|
{
|
||||||
|
control.SetDPIScaleFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[DefaultValue(true)]
|
[DefaultValue(true)]
|
||||||
[Description("是否点击标题栏可以移动窗体"), Category("SunnyUI")]
|
[Description("是否点击标题栏可以移动窗体"), Category("SunnyUI")]
|
||||||
public bool Movable { get; set; } = true;
|
public bool Movable { get; set; } = true;
|
||||||
@ -1183,6 +1199,7 @@ namespace Sunny.UI
|
|||||||
CalcSystemBoxPos();
|
CalcSystemBoxPos();
|
||||||
SetRadius();
|
SetRadius();
|
||||||
isShow = true;
|
isShow = true;
|
||||||
|
SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -65,6 +65,23 @@ namespace Sunny.UI
|
|||||||
if (!IsDesignMode) base.Dock = DockStyle.Fill;
|
if (!IsDesignMode) base.Dock = DockStyle.Fill;
|
||||||
|
|
||||||
Version = UIGlobal.Version;
|
Version = UIGlobal.Version;
|
||||||
|
SetDPIScale();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsScaled { get; private set; }
|
||||||
|
|
||||||
|
public void SetDPIScale()
|
||||||
|
{
|
||||||
|
if (!IsScaled)
|
||||||
|
{
|
||||||
|
this.SetDPIScaleFont();
|
||||||
|
foreach (Control control in this.GetAllDPIScaleControls())
|
||||||
|
{
|
||||||
|
control.SetDPIScaleFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
IsScaled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Render()
|
public void Render()
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
* 2021-07-12: V3.0.5 增加紫色主题
|
* 2021-07-12: V3.0.5 增加紫色主题
|
||||||
* 2021-07-18: V3.0.5 增加多彩主题,以颜色深色,文字白色为主
|
* 2021-07-18: V3.0.5 增加多彩主题,以颜色深色,文字白色为主
|
||||||
* 2021-09-24: V3.0.7 修改默认字体的GdiCharSet
|
* 2021-09-24: V3.0.7 修改默认字体的GdiCharSet
|
||||||
|
* 2021-10-16: V3.0.8 增加系统DPI缩放自适应
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -56,6 +57,10 @@ namespace Sunny.UI
|
|||||||
void SetStyleColor(UIBaseStyle uiColor);
|
void SetStyleColor(UIBaseStyle uiColor);
|
||||||
|
|
||||||
void SetStyle(UIStyle style);
|
void SetStyle(UIStyle style);
|
||||||
|
|
||||||
|
bool IsScaled { get; }
|
||||||
|
|
||||||
|
void SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -189,6 +194,8 @@ namespace Sunny.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class UIStyles
|
public static class UIStyles
|
||||||
{
|
{
|
||||||
|
public static bool DPIScale { get; set; }
|
||||||
|
|
||||||
public static List<UIStyle> PopularStyles()
|
public static List<UIStyle> PopularStyles()
|
||||||
{
|
{
|
||||||
List<UIStyle> styles = new List<UIStyle>();
|
List<UIStyle> styles = new List<UIStyle>();
|
||||||
@ -503,6 +510,21 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetDPIScale()
|
||||||
|
{
|
||||||
|
foreach (var form in Forms.Values)
|
||||||
|
{
|
||||||
|
if (!form.DPIScale().EqualsFloat(1))
|
||||||
|
form.SetDPIScale();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var page in Pages.Values)
|
||||||
|
{
|
||||||
|
if (!page.DPIScale().EqualsFloat(1))
|
||||||
|
page.SetDPIScale();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Translate()
|
public static void Translate()
|
||||||
{
|
{
|
||||||
foreach (var form in Forms.Values)
|
foreach (var form in Forms.Values)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
* 创建日期: 2020-01-01
|
* 创建日期: 2020-01-01
|
||||||
*
|
*
|
||||||
* 2020-01-01: V2.2.0 增加文件说明
|
* 2020-01-01: V2.2.0 增加文件说明
|
||||||
|
* 2021-10-16: V3.0.8 增加系统DPI缩放自适应
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -67,5 +68,12 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
container.Add(this);
|
container.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DefaultValue(false), Description("DPI缩放"), Category("SunnyUI")]
|
||||||
|
public bool DPIScale
|
||||||
|
{
|
||||||
|
get => UIStyles.DPIScale;
|
||||||
|
set => UIStyles.DPIScale = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user