* 重构全局字体设置逻辑,以期可以在程序运行时设置全局字体

* UIPagination: 左右跳转按钮的文字换成字体图标
* UIMiniPagination: 左右跳转按钮的文字换成字体图标
This commit is contained in:
Sunny 2023-08-30 16:17:12 +08:00
parent d759f41ad8
commit 073b782bcf
6 changed files with 32 additions and 49 deletions

View File

@ -76,6 +76,7 @@ namespace Sunny.UI
btnClear.SetDPIScale();
btnOK.SetDPIScale();
btnCancel.SetDPIScale();
dataGridView.SetDPIScale();
}
public void Translate()

View File

@ -18,6 +18,7 @@ namespace Sunny.UI
if (DesignMode) return;
if (!UIDPIScale.NeedSetDPIFont()) return;
treeView.SetDPIScale();
btnOK.SetDPIScale();
btnCancel.SetDPIScale();
uiCheckBox1.SetDPIScale();

View File

@ -140,16 +140,6 @@ namespace Sunny.UI
return edit;
}
/// <summary>
/// 重载字体变更
/// </summary>
/// <param name="e">参数</param>
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (item != null) item.DataGridView.Font = Font;
}
[DefaultValue(false)]
public bool ShowFilter { get; set; }

View File

@ -118,16 +118,6 @@ namespace Sunny.UI
TreeView.Nodes.Clear();
}
/// <summary>
/// 重载字体变更
/// </summary>
/// <param name="e">参数</param>
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (item != null) item.TreeView.Font = Font;
}
[Browsable(false)]
public UITreeView TreeView => item.TreeView;

View File

@ -19,6 +19,7 @@
* 2023-02-19: V3.3.2
* 2023-06-14: V3.3.9
* 2023-06-27: V3.3.9 Tag改为TagString
* 2023-08-30: V3.4.2
******************************************************************************/
using System;
@ -138,17 +139,16 @@ namespace Sunny.UI
}
}
/// <summary>
/// 重载字体变更
/// </summary>
/// <param name="e">参数</param>
protected override void OnFontChanged(EventArgs e)
public override void SetDPIScale()
{
base.OnFontChanged(e);
foreach (var item in this.GetControls<UISymbolButton>(true)) item.Font = Font;
foreach (var item in this.GetControls<UITextBox>(true)) item.Font = Font;
foreach (var item in this.GetControls<UIComboBox>(true)) item.Font = Font;
foreach (var item in this.GetControls<UILabel>(true)) item.Font = Font;
base.SetDPIScale();
if (DesignMode) return;
if (!UIDPIScale.NeedSetDPIFont()) return;
foreach (var item in this.GetControls<UISymbolButton>(true)) item.SetDPIScale();
foreach (var item in this.GetControls<UITextBox>(true)) item.SetDPIScale();
foreach (var item in this.GetControls<UIComboBox>(true)) item.SetDPIScale();
foreach (var item in this.GetControls<UILabel>(true)) item.SetDPIScale();
}
private int buttonInterval = 8;
@ -292,8 +292,8 @@ namespace Sunny.UI
var btn = (UISymbolButton)sender;
if (btn.TagString == "<<" || btn.TagString == ">>")
{
btn.Symbol = 0;
btn.Text = @"···";
btn.Symbol = 361761;
btn.Text = "";
}
}
@ -302,13 +302,13 @@ namespace Sunny.UI
var btn = (UISymbolButton)sender;
if (btn.TagString == "<<")
{
btn.Symbol = 61696;
btn.Symbol = 361696;
btn.Text = "";
}
if (btn.TagString == ">>")
{
btn.Symbol = 61697;
btn.Symbol = 361697;
btn.Text = "";
}
}
@ -624,8 +624,9 @@ namespace Sunny.UI
private void SetShowButton(int buttonIdx, int addCount, string tagString)
{
buttons[buttonIdx].Symbol = 0;
buttons[buttonIdx].Text = @"···";
buttons[buttonIdx].Symbol = 361761;
buttons[buttonIdx].Text = "";
buttons[buttonIdx].SymbolOffset = new Point(-1, 1);
buttonTags[buttons[buttonIdx]] = addCount;
buttons[buttonIdx].Visible = true;
buttons[buttonIdx].TagString = tagString;

View File

@ -20,6 +20,7 @@
* 2021-03-27: V3.0.2
* 2021-07-10: V3.0.4
* 2023-06-27: V3.3.9 Tag改为TagString
* 2023-08-30: V3.4.2
******************************************************************************/
using System;
@ -133,18 +134,16 @@ namespace Sunny.UI
p1.FillColor = p1.RectColor = color;
}
/// <summary>
/// 重载字体变更
/// </summary>
/// <param name="e">参数</param>
protected override void OnFontChanged(EventArgs e)
public override void SetDPIScale()
{
base.OnFontChanged(e);
base.SetDPIScale();
if (DesignMode) return;
if (!UIDPIScale.NeedSetDPIFont()) return;
foreach (var item in this.GetControls<UISymbolButton>(true)) item.SetDPIScale();
foreach (var item in this.GetControls<UITextBox>(true)) item.SetDPIScale();
foreach (var item in this.GetControls<UIComboBox>(true)) item.SetDPIScale();
foreach (var item in this.GetControls<UILabel>(true)) item.SetDPIScale();
Translate();
}
public void Translate()
@ -330,8 +329,8 @@ namespace Sunny.UI
var btn = (UISymbolButton)sender;
if (btn.TagString == "<<" || btn.TagString == ">>")
{
btn.Symbol = 0;
btn.Text = @"···";
btn.Symbol = 361761;
btn.Text = "";
}
}
@ -340,13 +339,13 @@ namespace Sunny.UI
var btn = (UISymbolButton)sender;
if (btn.TagString == "<<")
{
btn.Symbol = 61696;
btn.Symbol = 361696;
btn.Text = "";
}
if (btn.TagString == ">>")
{
btn.Symbol = 61697;
btn.Symbol = 361697;
btn.Text = "";
}
}
@ -770,8 +769,9 @@ namespace Sunny.UI
private void SetShowButton(int buttonIdx, int addCount, string tagString)
{
buttons[buttonIdx].Symbol = 0;
buttons[buttonIdx].Text = @"···";
buttons[buttonIdx].Symbol = 361761;
buttons[buttonIdx].Text = "";
buttons[buttonIdx].SymbolOffset = new Point(-1, 1);
buttonTags[buttons[buttonIdx]] = addCount;
buttons[buttonIdx].Visible = true;
buttons[buttonIdx].TagString = tagString;