* 重构全局字体设置逻辑,以期可以在程序运行时设置全局字体
This commit is contained in:
parent
1ec80d250c
commit
83caee295e
@ -65,7 +65,6 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void Tip_VisibleChanged(object sender, EventArgs e)
|
private void Tip_VisibleChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
tip.IsScaled = true;
|
|
||||||
tip.Font = this.Font.DPIScaleFont(UIStyles.DefaultSubFontSize);
|
tip.Font = this.Font.DPIScaleFont(UIStyles.DefaultSubFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,26 +13,16 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
|
||||||
{
|
|
||||||
m_opacitySlider.SetDPIScaleFont();
|
|
||||||
m_colorBar.SetDPIScaleFont();
|
|
||||||
|
|
||||||
foreach (var label in this.GetControls<UILabel>())
|
|
||||||
{
|
|
||||||
label.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var label in this.GetControls<UITextBox>())
|
|
||||||
{
|
|
||||||
label.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
btnOK.SetDPIScaleFont();
|
|
||||||
btnCancel.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
|
if (DesignMode) return;
|
||||||
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
|
||||||
|
m_opacitySlider.SetDPIScale();
|
||||||
|
m_colorBar.SetDPIScale();
|
||||||
|
btnOK.SetDPIScale();
|
||||||
|
btnCancel.SetDPIScale();
|
||||||
|
foreach (var label in this.GetControls<UILabel>()) label.SetDPIScale();
|
||||||
|
foreach (var label in this.GetControls<UITextBox>()) label.SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
|
@ -67,16 +67,15 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
|
||||||
{
|
|
||||||
edtFilter.SetDPIScaleFont();
|
|
||||||
btnSearch.SetDPIScaleFont();
|
|
||||||
btnClear.SetDPIScaleFont();
|
|
||||||
btnOK.SetDPIScaleFont();
|
|
||||||
btnCancel.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
|
if (DesignMode) return;
|
||||||
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
|
||||||
|
edtFilter.SetDPIScale();
|
||||||
|
btnSearch.SetDPIScale();
|
||||||
|
btnClear.SetDPIScale();
|
||||||
|
btnOK.SetDPIScale();
|
||||||
|
btnCancel.SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
|
@ -14,13 +14,12 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
|
||||||
{
|
|
||||||
btnOK.SetDPIScaleFont();
|
|
||||||
btnCancel.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
|
if (DesignMode) return;
|
||||||
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
|
||||||
|
btnOK.SetDPIScale();
|
||||||
|
btnCancel.SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowSelectedAllCheckBox
|
public bool ShowSelectedAllCheckBox
|
||||||
|
@ -330,12 +330,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
|
||||||
{
|
|
||||||
TopPanel.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
|
if (DesignMode) return;
|
||||||
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
|
||||||
|
TopPanel.SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime max = DateTime.MaxValue;
|
public DateTime max = DateTime.MaxValue;
|
||||||
|
@ -738,20 +738,14 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
|
||||||
{
|
|
||||||
TopPanel.SetDPIScaleFont();
|
|
||||||
|
|
||||||
foreach (var label in this.GetControls<UILabel>())
|
|
||||||
{
|
|
||||||
label.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
btnOK.SetDPIScaleFont();
|
|
||||||
btnCancel.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
|
if (DesignMode) return;
|
||||||
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
|
||||||
|
TopPanel.SetDPIScale();
|
||||||
|
btnOK.SetDPIScale();
|
||||||
|
btnCancel.SetDPIScale();
|
||||||
|
foreach (var label in this.GetControls<UILabel>()) label.SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
|
@ -77,8 +77,8 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
edit.IsScaled = true;
|
|
||||||
edit.Font = Font;
|
edit.Font = Font;
|
||||||
|
edit.SetDPIScale();
|
||||||
SizeChange();
|
SizeChange();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
@ -440,18 +440,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
|
||||||
{
|
|
||||||
foreach (var label in this.GetControls<UILabel>())
|
|
||||||
{
|
|
||||||
label.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
btnOK.SetDPIScaleFont();
|
|
||||||
btnCancel.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
|
if (DesignMode) return;
|
||||||
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
|
||||||
|
btnOK.SetDPIScale();
|
||||||
|
btnCancel.SetDPIScale();
|
||||||
|
foreach (var label in this.GetControls<UILabel>()) label.SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UITimeItem_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
|
private void UITimeItem_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||||
|
@ -295,32 +295,6 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Font tmpFont;
|
|
||||||
|
|
||||||
private Font TempFont
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(TipsFont.DPIScaleFontSize()))
|
|
||||||
{
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
tmpFont = TipsFont.DPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmpFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 析构函数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">释放参数</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
base.Dispose(disposing);
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重载绘图
|
/// 重载绘图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -339,6 +313,7 @@ namespace Sunny.UI
|
|||||||
if (Enabled && ShowTips && !string.IsNullOrEmpty(TipsText))
|
if (Enabled && ShowTips && !string.IsNullOrEmpty(TipsText))
|
||||||
{
|
{
|
||||||
e.Graphics.SetHighQuality();
|
e.Graphics.SetHighQuality();
|
||||||
|
using var TempFont = TipsFont.DPIScaleFont(TipsFont.Size);
|
||||||
Size sf = TextRenderer.MeasureText(TipsText, TempFont);
|
Size sf = TextRenderer.MeasureText(TipsText, TempFont);
|
||||||
int sfMax = Math.Max(sf.Width, sf.Height);
|
int sfMax = Math.Max(sf.Width, sf.Height);
|
||||||
int x = Width - 1 - 2 - sfMax;
|
int x = Width - 1 - 2 - sfMax;
|
||||||
|
@ -344,12 +344,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public override void SetDPIScale()
|
public override void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
|
||||||
{
|
|
||||||
TopPanel.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.SetDPIScale();
|
base.SetDPIScale();
|
||||||
|
if (DesignMode) return;
|
||||||
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
|
||||||
|
TopPanel.SetDPIScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Translate()
|
public void Translate()
|
||||||
|
@ -63,26 +63,20 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnOpening(CancelEventArgs e)
|
protected override void OnOpening(CancelEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnOpening(e);
|
base.OnOpening(e);
|
||||||
if (!IsScaled && UIStyles.DPIScale)
|
|
||||||
{
|
|
||||||
SetDPIScale();
|
SetDPIScale();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义主题风格
|
/// 自定义主题风格
|
||||||
|
@ -78,9 +78,6 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
protected bool selected;
|
protected bool selected;
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
private float DefaultFontSize = -1;
|
private float DefaultFontSize = -1;
|
||||||
|
|
||||||
public virtual void SetDPIScale()
|
public virtual void SetDPIScale()
|
||||||
|
@ -191,22 +191,35 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
float ColumnHeadersDefaultCellStyleFontSize = -1;
|
||||||
public bool IsScaled { get; private set; }
|
float RowHeadersDefaultCellStyleFontSize = -1;
|
||||||
|
float DefaultCellStyleFontSize = -1;
|
||||||
|
float RowsDefaultCellStyleFontSize = -1;
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
|
||||||
if (!IsScaled)
|
|
||||||
{
|
{
|
||||||
if (ColumnHeadersDefaultCellStyle.Font != null)
|
if (ColumnHeadersDefaultCellStyle.Font != null)
|
||||||
ColumnHeadersDefaultCellStyle.Font = ColumnHeadersDefaultCellStyle.Font.DPIScaleFont();
|
{
|
||||||
|
if (ColumnHeadersDefaultCellStyleFontSize < 0) ColumnHeadersDefaultCellStyleFontSize = ColumnHeadersDefaultCellStyle.Font.Size;
|
||||||
|
ColumnHeadersDefaultCellStyle.Font = ColumnHeadersDefaultCellStyle.Font.DPIScaleFont(ColumnHeadersDefaultCellStyleFontSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (RowHeadersDefaultCellStyle.Font != null)
|
if (RowHeadersDefaultCellStyle.Font != null)
|
||||||
RowHeadersDefaultCellStyle.Font = RowHeadersDefaultCellStyle.Font.DPIScaleFont();
|
{
|
||||||
|
if (RowHeadersDefaultCellStyleFontSize < 0) RowHeadersDefaultCellStyleFontSize = RowHeadersDefaultCellStyle.Font.Size;
|
||||||
|
RowHeadersDefaultCellStyle.Font = RowHeadersDefaultCellStyle.Font.DPIScaleFont(RowHeadersDefaultCellStyleFontSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (DefaultCellStyle.Font != null)
|
if (DefaultCellStyle.Font != null)
|
||||||
DefaultCellStyle.Font = DefaultCellStyle.Font.DPIScaleFont();
|
{
|
||||||
|
if (DefaultCellStyleFontSize < 0) DefaultCellStyleFontSize = DefaultCellStyle.Font.Size;
|
||||||
|
DefaultCellStyle.Font = DefaultCellStyle.Font.DPIScaleFont(DefaultCellStyleFontSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (RowsDefaultCellStyle.Font != null)
|
if (RowsDefaultCellStyle.Font != null)
|
||||||
RowsDefaultCellStyle.Font = RowsDefaultCellStyle.Font.DPIScaleFont();
|
{
|
||||||
IsScaled = true;
|
if (RowsDefaultCellStyleFontSize < 0) RowsDefaultCellStyleFontSize = RowsDefaultCellStyle.Font.Size;
|
||||||
|
RowsDefaultCellStyle.Font = RowsDefaultCellStyle.Font.DPIScaleFont(RowsDefaultCellStyleFontSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,18 +99,8 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
|
pnlValue?.SetDPIScale();
|
||||||
if (pnlValue != null)
|
edit?.SetDPIScale();
|
||||||
{
|
|
||||||
pnlValue.IsScaled = true;
|
|
||||||
pnlValue.Font = Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (edit != null)
|
|
||||||
{
|
|
||||||
edit.IsScaled = true;
|
|
||||||
edit.Font = Font;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public event OnValueChanged ValueChanged;
|
public event OnValueChanged ValueChanged;
|
||||||
|
@ -173,16 +173,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
Font = UIDPIScale.SetDPIScaleFont(Font, DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Description("开启后可响应某些触屏的点击事件"), Category("SunnyUI")]
|
[Description("开启后可响应某些触屏的点击事件"), Category("SunnyUI")]
|
||||||
|
@ -727,6 +727,7 @@ namespace Sunny.UI
|
|||||||
if (Enabled && ShowTips && !string.IsNullOrEmpty(TipsText))
|
if (Enabled && ShowTips && !string.IsNullOrEmpty(TipsText))
|
||||||
{
|
{
|
||||||
e.Graphics.SetHighQuality();
|
e.Graphics.SetHighQuality();
|
||||||
|
using var TempFont = TipsFont.DPIScaleFont(TipsFont.Size);
|
||||||
Size sf = TextRenderer.MeasureText(TipsText, TempFont);
|
Size sf = TextRenderer.MeasureText(TipsText, TempFont);
|
||||||
int sfMax = Math.Max(sf.Width, sf.Height);
|
int sfMax = Math.Max(sf.Width, sf.Height);
|
||||||
int x = Width - 1 - 2 - sfMax;
|
int x = Width - 1 - 2 - sfMax;
|
||||||
@ -736,22 +737,6 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Font tmpFont;
|
|
||||||
|
|
||||||
private Font TempFont
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(TipsFont.DPIScaleFontSize()))
|
|
||||||
{
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
tmpFont = TipsFont.DPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmpFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[DefaultValue(null)]
|
[DefaultValue(null)]
|
||||||
[Description("关联的TabControl"), Category("SunnyUI")]
|
[Description("关联的TabControl"), Category("SunnyUI")]
|
||||||
public UITabControl TabControl { get; set; }
|
public UITabControl TabControl { get; set; }
|
||||||
|
@ -117,15 +117,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private UIStyle _style = UIStyle.Blue;
|
private UIStyle _style = UIStyle.Blue;
|
||||||
public bool IsScaled { get; private set; }
|
private float DefaultFontSize = -1;
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Category("SunnyUI")]
|
[Category("SunnyUI")]
|
||||||
|
@ -223,7 +223,6 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
listbox.IsScaled = true;
|
|
||||||
listbox.Font = Font;
|
listbox.Font = Font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,7 +460,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ToolboxItem(false)]
|
[ToolboxItem(false)]
|
||||||
private sealed class ImageListBox : ListBox
|
private sealed class ImageListBox : ListBox, IStyleInterface
|
||||||
{
|
{
|
||||||
private UIScrollBar bar;
|
private UIScrollBar bar;
|
||||||
|
|
||||||
@ -482,16 +481,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//protected override void WndProc(ref Message m)
|
//protected override void WndProc(ref Message m)
|
||||||
|
@ -117,18 +117,8 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
|
pnlValue?.SetDPIScale();
|
||||||
if (pnlValue != null)
|
edit?.SetDPIScale();
|
||||||
{
|
|
||||||
pnlValue.IsScaled = true;
|
|
||||||
pnlValue.Font = Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (edit != null)
|
|
||||||
{
|
|
||||||
edit.IsScaled = true;
|
|
||||||
edit.Font = Font;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int step = 1;
|
private int step = 1;
|
||||||
|
@ -1323,17 +1323,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public virtual void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (DesignMode) return;
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
if (!IsScaled)
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
{
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
this.SetDPIScaleFont();
|
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Version
|
public string Version
|
||||||
|
@ -76,16 +76,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -213,16 +210,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; private set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -413,7 +413,6 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
listbox.IsScaled = true;
|
|
||||||
listbox.Font = Font;
|
listbox.Font = Font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace Sunny.UI
|
|||||||
/// ListBox
|
/// ListBox
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ToolboxItem(false)]
|
[ToolboxItem(false)]
|
||||||
internal sealed class ListBoxEx : ListBox
|
internal sealed class ListBoxEx : ListBox, IStyleInterface
|
||||||
{
|
{
|
||||||
private UIScrollBar bar;
|
private UIScrollBar bar;
|
||||||
|
|
||||||
@ -42,16 +42,13 @@ namespace Sunny.UI
|
|||||||
[Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")]
|
[Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")]
|
||||||
public string TagString { get; set; }
|
public string TagString { get; set; }
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UIScrollBar Bar
|
public UIScrollBar Bar
|
||||||
|
@ -145,29 +145,10 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
foreach (var item in this.GetControls<UISymbolButton>(true))
|
foreach (var item in this.GetControls<UISymbolButton>(true)) item.Font = Font;
|
||||||
{
|
foreach (var item in this.GetControls<UITextBox>(true)) item.Font = Font;
|
||||||
item.IsScaled = true;
|
foreach (var item in this.GetControls<UIComboBox>(true)) item.Font = Font;
|
||||||
item.Font = Font;
|
foreach (var item in this.GetControls<UILabel>(true)) item.Font = Font;
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in this.GetControls<UITextBox>(true))
|
|
||||||
{
|
|
||||||
item.IsScaled = true;
|
|
||||||
item.Font = Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in this.GetControls<UIComboBox>(true))
|
|
||||||
{
|
|
||||||
item.IsScaled = true;
|
|
||||||
item.Font = Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in this.GetControls<UILabel>(true))
|
|
||||||
{
|
|
||||||
item.IsScaled = true;
|
|
||||||
item.Font = Font;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int buttonInterval = 8;
|
private int buttonInterval = 8;
|
||||||
|
@ -91,16 +91,13 @@ namespace Sunny.UI
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; private set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int radius;
|
private int radius;
|
||||||
@ -645,8 +642,7 @@ namespace Sunny.UI
|
|||||||
NavBarMenu.Style = UIStyles.Style;
|
NavBarMenu.Style = UIStyles.Style;
|
||||||
NavBarMenu.Items.Clear();
|
NavBarMenu.Items.Clear();
|
||||||
NavBarMenu.ImageList = ImageList;
|
NavBarMenu.ImageList = ImageList;
|
||||||
NavBarMenu.IsScaled = false;
|
NavBarMenu.Font = DropMenuFont.SetDPIScaleFont(DropMenuFont.Size);
|
||||||
NavBarMenu.Font = DropMenuFont;
|
|
||||||
foreach (TreeNode node in Nodes[SelectedIndex].Nodes)
|
foreach (TreeNode node in Nodes[SelectedIndex].Nodes)
|
||||||
{
|
{
|
||||||
ToolStripMenuItem item = new ToolStripMenuItem(node.Text) { Tag = node };
|
ToolStripMenuItem item = new ToolStripMenuItem(node.Text) { Tag = node };
|
||||||
|
@ -197,22 +197,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
private float DefaultFontSize = -1;
|
||||||
{
|
|
||||||
base.Dispose(disposing);
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Browsable(false)]
|
|
||||||
public bool IsScaled { get; private set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
@ -757,6 +748,7 @@ namespace Sunny.UI
|
|||||||
//显示Tips圆圈
|
//显示Tips圆圈
|
||||||
if (ShowTips && MenuHelper.GetTipsText(e.Node).IsValid())
|
if (ShowTips && MenuHelper.GetTipsText(e.Node).IsValid())
|
||||||
{
|
{
|
||||||
|
using var TempFont = TipsFont.DPIScaleFont(TipsFont.Size);
|
||||||
Size tipsSize = TextRenderer.MeasureText(MenuHelper.GetTipsText(e.Node), TempFont);
|
Size tipsSize = TextRenderer.MeasureText(MenuHelper.GetTipsText(e.Node), TempFont);
|
||||||
int sfMax = Math.Max(tipsSize.Width, tipsSize.Height);
|
int sfMax = Math.Max(tipsSize.Width, tipsSize.Height);
|
||||||
int tipsLeft = Width - sfMax - 16;
|
int tipsLeft = Width - sfMax - 16;
|
||||||
@ -784,22 +776,6 @@ namespace Sunny.UI
|
|||||||
base.OnDrawNode(e);
|
base.OnDrawNode(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Font tmpFont;
|
|
||||||
|
|
||||||
private Font TempFont
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(TipsFont.DPIScaleFontSize()))
|
|
||||||
{
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
tmpFont = TipsFont.DPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmpFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Color tipsColor = Color.Red;
|
private Color tipsColor = Color.Red;
|
||||||
|
|
||||||
[DefaultValue(typeof(Color), "Red"), Category("SunnyUI"), Description("节点提示圆点背景颜色")]
|
[DefaultValue(typeof(Color), "Red"), Category("SunnyUI"), Description("节点提示圆点背景颜色")]
|
||||||
|
@ -140,30 +140,10 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
foreach (var item in this.GetControls<UISymbolButton>(true))
|
foreach (var item in this.GetControls<UISymbolButton>(true)) item.SetDPIScale();
|
||||||
{
|
foreach (var item in this.GetControls<UITextBox>(true)) item.SetDPIScale();
|
||||||
item.IsScaled = true;
|
foreach (var item in this.GetControls<UIComboBox>(true)) item.SetDPIScale();
|
||||||
item.Font = Font;
|
foreach (var item in this.GetControls<UILabel>(true)) item.SetDPIScale();
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in this.GetControls<UITextBox>(true))
|
|
||||||
{
|
|
||||||
item.IsScaled = true;
|
|
||||||
item.Font = Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in this.GetControls<UIComboBox>(true))
|
|
||||||
{
|
|
||||||
item.IsScaled = true;
|
|
||||||
item.Font = Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in this.GetControls<UILabel>(true))
|
|
||||||
{
|
|
||||||
item.IsScaled = true;
|
|
||||||
item.Font = Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
Translate();
|
Translate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,6 @@ namespace Sunny.UI
|
|||||||
Parent = this,
|
Parent = this,
|
||||||
TagString = i.ToString(),
|
TagString = i.ToString(),
|
||||||
Style = Style,
|
Style = Style,
|
||||||
IsScaled = IsScaled,
|
|
||||||
Text = Items[i]?.ToString(),
|
Text = Items[i]?.ToString(),
|
||||||
StyleCustomMode = StyleCustomMode,
|
StyleCustomMode = StyleCustomMode,
|
||||||
ForeColor = ForeColor
|
ForeColor = ForeColor
|
||||||
|
@ -87,16 +87,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color foreColor;
|
private Color foreColor;
|
||||||
|
@ -288,9 +288,6 @@ namespace Sunny.UI
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false), DefaultValue(false)]
|
|
||||||
public bool IsScaled { get; set; }
|
|
||||||
|
|
||||||
public void Collapse()
|
public void Collapse()
|
||||||
{
|
{
|
||||||
if (_collapsePanel != UICollapsePanel.None && SplitPanelState == UISplitPanelState.Expanded)
|
if (_collapsePanel != UICollapsePanel.None && SplitPanelState == UISplitPanelState.Expanded)
|
||||||
|
@ -166,16 +166,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
private float DefaultFontSize = -1;
|
||||||
public bool IsScaled { get; private set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
{
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont();
|
this.SetDPIScaleFont(DefaultFontSize);
|
||||||
IsScaled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
@ -696,6 +693,7 @@ namespace Sunny.UI
|
|||||||
string TipsText = GetTipsText(TabPages[index]);
|
string TipsText = GetTipsText(TabPages[index]);
|
||||||
if (Enabled && TipsText.IsValid())
|
if (Enabled && TipsText.IsValid())
|
||||||
{
|
{
|
||||||
|
using var TempFont = TipsFont.DPIScaleFont(TipsFont.Size);
|
||||||
sf = TextRenderer.MeasureText(TipsText, TempFont);
|
sf = TextRenderer.MeasureText(TipsText, TempFont);
|
||||||
int sfMax = Math.Max(sf.Width, sf.Height);
|
int sfMax = Math.Max(sf.Width, sf.Height);
|
||||||
int x = TabRect.Width - 1 - 2 - sfMax;
|
int x = TabRect.Width - 1 - 2 - sfMax;
|
||||||
@ -734,22 +732,6 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Font tmpFont;
|
|
||||||
|
|
||||||
private Font TempFont
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(TipsFont.DPIScaleFontSize()))
|
|
||||||
{
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
tmpFont = TipsFont.DPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmpFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重载鼠标按下事件
|
/// 重载鼠标按下事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -650,7 +650,6 @@ namespace Sunny.UI
|
|||||||
protected override void OnFontChanged(EventArgs e)
|
protected override void OnFontChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
edit.IsScaled = true;
|
|
||||||
edit.Font = Font;
|
edit.Font = Font;
|
||||||
SizeChange();
|
SizeChange();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
@ -44,19 +44,11 @@ namespace Sunny.UI
|
|||||||
InitOwnerDraw();
|
InitOwnerDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UIToolTip(IContainer cont)
|
public UIToolTip(IContainer cont) : base(cont)
|
||||||
: base(cont)
|
|
||||||
{
|
{
|
||||||
InitOwnerDraw();
|
InitOwnerDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
base.Dispose(disposing);
|
|
||||||
tmpTitleFont?.Dispose();
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
[DefaultValue(typeof(Font), "微软雅黑, 9pt"), Description("字体"), Category("SunnyUI")]
|
[DefaultValue(typeof(Font), "微软雅黑, 9pt"), Description("字体"), Category("SunnyUI")]
|
||||||
public Font Font { get; set; } = new Font("宋体", 9);
|
public Font Font { get; set; } = new Font("宋体", 9);
|
||||||
|
|
||||||
@ -172,6 +164,9 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void UIToolTip_Popup(object sender, PopupEventArgs e)
|
private void UIToolTip_Popup(object sender, PopupEventArgs e)
|
||||||
{
|
{
|
||||||
|
using var TempFont = Font.DPIScaleFont(Font.Size);
|
||||||
|
using var TempTitleFont = TitleFont.DPIScaleFont(TitleFont.Size);
|
||||||
|
|
||||||
if (ToolTipControls.ContainsKey(e.AssociatedControl))
|
if (ToolTipControls.ContainsKey(e.AssociatedControl))
|
||||||
{
|
{
|
||||||
var tooltip = ToolTipControls[e.AssociatedControl];
|
var tooltip = ToolTipControls[e.AssociatedControl];
|
||||||
@ -206,43 +201,13 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Font tmpFont;
|
|
||||||
|
|
||||||
private Font TempFont
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(Font.DPIScaleFontSize()))
|
|
||||||
{
|
|
||||||
tmpFont?.Dispose();
|
|
||||||
tmpFont = Font.DPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmpFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Font tmpTitleFont;
|
|
||||||
|
|
||||||
private Font TempTitleFont
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (tmpTitleFont == null || !tmpTitleFont.Size.EqualsFloat(TitleFont.DPIScaleFontSize()))
|
|
||||||
{
|
|
||||||
tmpTitleFont?.Dispose();
|
|
||||||
tmpTitleFont = TitleFont.DPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmpTitleFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ToolTipExDraw(object sender, DrawToolTipEventArgs e)
|
private void ToolTipExDraw(object sender, DrawToolTipEventArgs e)
|
||||||
{
|
{
|
||||||
var bounds = new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1);
|
var bounds = new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1);
|
||||||
e.Graphics.FillRectangle(BackColor, bounds);
|
e.Graphics.FillRectangle(BackColor, bounds);
|
||||||
e.Graphics.DrawRectangle(RectColor, bounds);
|
e.Graphics.DrawRectangle(RectColor, bounds);
|
||||||
|
using var TempFont = Font.DPIScaleFont(Font.Size);
|
||||||
|
using var TempTitleFont = TitleFont.DPIScaleFont(TitleFont.Size);
|
||||||
|
|
||||||
if (ToolTipControls.ContainsKey(e.AssociatedControl))
|
if (ToolTipControls.ContainsKey(e.AssociatedControl))
|
||||||
{
|
{
|
||||||
|
@ -746,7 +746,6 @@ namespace Sunny.UI
|
|||||||
base.OnFontChanged(e);
|
base.OnFontChanged(e);
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
view.IsScaled = true;
|
|
||||||
view.Font = Font;
|
view.Font = Font;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -925,7 +924,7 @@ namespace Sunny.UI
|
|||||||
if (DesignMode) return;
|
if (DesignMode) return;
|
||||||
if (!UIDPIScale.NeedSetDPIFont()) return;
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||||||
this.SetDPIScaleFont(DefaultFontSize);
|
this.Font = UIDPIScale.SetDPIScaleFont(this.Font, DefaultFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DefaultValue(typeof(Color), "155, 200, 255")]
|
[DefaultValue(typeof(Color), "155, 200, 255")]
|
||||||
|
@ -84,7 +84,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private float DefaultFontSize = -1;
|
private float DefaultFontSize = -1;
|
||||||
|
|
||||||
public void SetDPIScale()
|
public virtual void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (DesignMode) return;
|
if (DesignMode) return;
|
||||||
if (!UIDPIScale.NeedSetDPIFont()) return;
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
|
@ -41,26 +41,17 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
public sealed partial class UINotifier : Form
|
public sealed partial class UINotifier : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
[Browsable(false)]
|
|
||||||
public bool IsScaled { get; private set; }
|
|
||||||
|
|
||||||
public void SetDPIScale()
|
public void SetDPIScale()
|
||||||
{
|
{
|
||||||
if (!IsScaled && UIStyles.DPIScale)
|
Font = UIDPIScale.SetDPIScaleFont(Font, Font.Size);
|
||||||
|
|
||||||
|
noteTitle.Font = noteTitle.Font.DPIScaleFont(noteTitle.Font.Size);
|
||||||
|
noteContent.Font = noteContent.Font.DPIScaleFont(noteContent.Font.Size);
|
||||||
|
noteDate.Font = noteDate.Font.DPIScaleFont(noteDate.Font.Size);
|
||||||
|
|
||||||
|
foreach (var control in this.GetAllDPIScaleControls())
|
||||||
{
|
{
|
||||||
this.SetDPIScaleFont();
|
control.SetDPIScale();
|
||||||
|
|
||||||
noteTitle.Font = noteTitle.Font.DPIScaleFont();
|
|
||||||
noteContent.Font = noteContent.Font.DPIScaleFont();
|
|
||||||
noteDate.Font = noteDate.Font.DPIScaleFont();
|
|
||||||
|
|
||||||
foreach (Control control in this.GetAllDPIScaleControls())
|
|
||||||
{
|
|
||||||
control.SetDPIScaleFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
IsScaled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +376,7 @@ namespace Sunny.UI
|
|||||||
//-------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------
|
||||||
private void onMenuClick(object sender, EventArgs e)
|
private void onMenuClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
closeAllToolStripMenuItem.Font = menu.Font.DPIScaleFont();
|
closeAllToolStripMenuItem.Font = menu.Font.DPIScaleFont(menu.Font.Size);
|
||||||
menu.Show(buttonMenu, new Point(0, buttonMenu.Height));
|
menu.Show(buttonMenu, new Point(0, buttonMenu.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,14 +67,11 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void SetDPIScaleFont(this Control control, float fontSize)
|
internal static void SetDPIScaleFont<T>(this T control, float fontSize) where T : Control, IStyleInterface
|
||||||
{
|
{
|
||||||
if (!UIDPIScale.NeedSetDPIFont()) return;
|
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||||||
if (control is IStyleInterface ctrl)
|
|
||||||
{
|
|
||||||
control.Font = SetDPIScaleFont(control.Font, fontSize);
|
control.Font = SetDPIScaleFont(control.Font, fontSize);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal static Font SetDPIScaleFont(this Font font, float fontSize) => UIDPIScale.NeedSetDPIFont() ? font.DPIScaleFont(fontSize) : font;
|
internal static Font SetDPIScaleFont(this Font font, float fontSize) => UIDPIScale.NeedSetDPIFont() ? font.DPIScaleFont(fontSize) : font;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user