* UIStyle: 更改全局字体引用方法

This commit is contained in:
Sunny 2022-01-02 12:19:45 +08:00
parent 9d1b7fe77d
commit 6e25a650af
27 changed files with 46 additions and 60 deletions

Binary file not shown.

Binary file not shown.

View File

@ -108,16 +108,13 @@
this.LineChart.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(54)))), ((int)(((byte)(54)))));
this.LineChart.IsScaled = false;
this.LineChart.LegendFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LineChart.LegendFontSize = 9F;
this.LineChart.Location = new System.Drawing.Point(30, 55);
this.LineChart.MinimumSize = new System.Drawing.Size(1, 1);
this.LineChart.Name = "LineChart";
this.LineChart.Size = new System.Drawing.Size(670, 430);
this.LineChart.SubFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LineChart.SubTextFontSize = 9F;
this.LineChart.TabIndex = 35;
this.LineChart.Text = "uiLineChart1";
this.LineChart.TipsFontSize = 9F;
this.LineChart.PointValue += new Sunny.UI.UILineChart.OnPointValue(this.LineChart_PointValue);
//
// uiSymbolButton2

View File

@ -39,8 +39,8 @@ namespace Sunny.UI
Width = 400;
Height = 300;
SubFont = UIFontColor.CreateSubFont();
LegendFont = UIFontColor.CreateSubFont();
SubFont = UIFontColor.SubFont();
LegendFont = UIFontColor.SubFont();
tip.Parent = this;
tip.Height = 32;
@ -49,7 +49,7 @@ namespace Sunny.UI
tip.Top = 1;
tip.StyleCustomMode = true;
tip.Style = UIStyle.Custom;
tip.Font = UIFontColor.CreateSubFont();
tip.Font = UIFontColor.SubFont();
tip.RadiusSides = UICornerRadiusSides.None;
tip.Visible = false;
@ -64,7 +64,7 @@ namespace Sunny.UI
private void Tip_VisibleChanged(object sender, EventArgs e)
{
tip.IsScaled = true;
float size = SubFont != null ? SubFont.Size : SubTextFontSize;
float size = SubFont != null ? SubFont.Size : UIFontColor.SubFontSize;
tip.Font = this.DPIScaleFont(Font, size);
}
@ -190,25 +190,13 @@ namespace Sunny.UI
DrawOption(e.Graphics);
}
[Category("SunnyUI")]
[DefaultValue(9), Browsable(false)]
public float LegendFontSize { get; set; } = 9;
[Category("SunnyUI")]
[DefaultValue(9), Browsable(false)]
public float SubTextFontSize { get; set; } = 9;
[Category("SunnyUI")]
[DefaultValue(9), Browsable(false)]
public float TipsFontSize { get; set; } = 9;
Font tmpFont;
protected Font TempFont
{
get
{
float size = SubFont != null ? SubFont.Size : SubTextFontSize;
float size = SubFont != null ? SubFont.Size : UIFontColor.SubFontSize;
if (tmpFont == null || !tmpFont.Size.EqualsFloat(size / this.DPIScale()))
{
@ -226,7 +214,7 @@ namespace Sunny.UI
{
get
{
float size = LegendFont != null ? LegendFont.Size : LegendFontSize;
float size = LegendFont != null ? LegendFont.Size : UIFontColor.SubFontSize;
if (tmpLegendFont == null || !tmpLegendFont.Size.EqualsFloat(size / this.DPIScale()))
{

View File

@ -39,7 +39,7 @@ namespace Sunny.UI
public static class UIMessageTip
{
//默认字体。当样式中的Font==null时用该字体替换
static readonly Font DefaultFont = UIFontColor.Font;
static readonly Font DefaultFont = UIFontColor.Font();
//文本格式。用于测量和绘制
static readonly StringFormat DefStringFormat = StringFormat.GenericTypographic;
@ -213,8 +213,9 @@ namespace Sunny.UI
}
}
})
{
IsBackground = true, Name = "T_Showing"
{
IsBackground = true,
Name = "T_Showing"
}.Start();
}
@ -625,7 +626,7 @@ namespace Sunny.UI
Width = 2
};
IconSpacing = 5;
TextFont = UIFontColor.Font;
TextFont = UIFontColor.Font();
var fontName = TextFont.Name;
if (fontName == "宋体") { TextOffset = new Point(1, 1); }
TextColor = Color.Black;

View File

@ -50,7 +50,7 @@ namespace Sunny.UI
SetStyleFlags();
Padding = new Padding(0, 0, 30, 2);
edit.Font = UIFontColor.Font;
edit.Font = UIFontColor.Font();
edit.Left = 3;
edit.Top = 3;
edit.Text = String.Empty;

View File

@ -135,10 +135,10 @@ namespace Sunny.UI
}
}
private Font tipsFont = new Font("Microsoft Sans Serif", 9);
private Font tipsFont = UIFontColor.SubFont();
[Description("角标文字字体"), Category("SunnyUI")]
[DefaultValue(typeof(Font), "Microsoft Sans Serif, 9pt")]
[DefaultValue(typeof(Font), "微软雅黑, 9pt")]
public Font TipsFont
{
get { return tipsFont; }

View File

@ -32,7 +32,7 @@ namespace Sunny.UI
{
Version = UIGlobal.Version;
base.Font = UIFontColor.Font;
base.Font = UIFontColor.Font();
base.ForeColor = UIFontColor.Primary;
base.BackColor = Color.White;
DrawMode = DrawMode.OwnerDrawFixed;

View File

@ -32,7 +32,7 @@ namespace Sunny.UI
public UIContextMenuStrip()
{
Font = UIFontColor.Font;
Font = UIFontColor.Font();
RenderMode = ToolStripRenderMode.Professional;
Renderer = new ToolStripProfessionalRenderer(ColorTable);
Version = UIGlobal.Version;

View File

@ -41,7 +41,7 @@ namespace Sunny.UI
public UIControl()
{
Version = UIGlobal.Version;
base.Font = UIFontColor.Font;
base.Font = UIFontColor.Font();
Size = new Size(100, 35);
base.MinimumSize = new Size(1, 1);
}

View File

@ -46,7 +46,7 @@ namespace Sunny.UI
{
BackgroundColor = UIColor.White;
GridColor = UIColor.Blue;
base.Font = UIFontColor.Font;
base.Font = UIFontColor.Font();
base.DoubleBuffered = true;
VBar.Parent = this;

View File

@ -40,7 +40,7 @@ namespace Sunny.UI
RadiusSides = UICornerRadiusSides.None;
RectSides = ToolStripStatusLabelBorderSides.None;
Font = UIFontColor.Font;
Font = UIFontColor.Font();
foreColor = UIFontColor.Primary;
fillColor = UIColor.LightBlue;
}

View File

@ -42,7 +42,7 @@ namespace Sunny.UI
{
//设置为单选边框
BorderStyle = BorderStyle.FixedSingle;
base.Font = UIFontColor.Font;
base.Font = UIFontColor.Font();
base.ForeColor = UIFontColor.Primary;
Width = 150;
base.MaxLength = 32767;

View File

@ -166,7 +166,7 @@ namespace Sunny.UI
Height = 35;
Version = UIGlobal.Version;
Cursor = Cursors.Hand;
base.Font = UIFontColor.Font;
base.Font = UIFontColor.Font();
}
/// <summary>

View File

@ -36,7 +36,7 @@ namespace Sunny.UI
{
public UILabel()
{
base.Font = UIFontColor.Font;
base.Font = UIFontColor.Font();
Version = UIGlobal.Version;
base.TextAlign = ContentAlignment.MiddleLeft;
ForeColorChanged += UILabel_ForeColorChanged;
@ -156,7 +156,7 @@ namespace Sunny.UI
{
public UILinkLabel()
{
Font = UIFontColor.Font;
Font = UIFontColor.Font();
LinkBehavior = LinkBehavior.AlwaysUnderline;
Version = UIGlobal.Version;

View File

@ -755,7 +755,7 @@ namespace Sunny.UI
//
BorderStyle = BorderStyle.FixedSingle;
DrawMode = DrawMode.OwnerDrawFixed;
Font = UIFontColor.Font;
Font = UIFontColor.Font();
IntegralHeight = false;
ItemHeight = 25;
Size = new Size(150, 200);

View File

@ -51,7 +51,7 @@ namespace Sunny.UI
//SetStyle(ControlStyles.ResizeRedraw, true);
DoubleBuffered = true;
UpdateStyles();
Font = UIFontColor.Font;
Font = UIFontColor.Font();
NavBarMenu.VisibleChanged += NavBarMenu_VisibleChanged;
Dock = DockStyle.Top;
@ -328,7 +328,7 @@ namespace Sunny.UI
set => NavBarMenu.ImageList = value;
}
private Font dropMenuFont = UIFontColor.Font;
private Font dropMenuFont = UIFontColor.Font();
/// <summary>
/// 标题字体

View File

@ -61,7 +61,7 @@ namespace Sunny.UI
//ShowRootLines = false;
DoubleBuffered = true;
Font = UIFontColor.Font;
Font = UIFontColor.Font();
//CheckBoxes = false;
ItemHeight = 50;
BackColor = Color.FromArgb(56, 56, 56);
@ -260,10 +260,10 @@ namespace Sunny.UI
}
}
private Font tipsFont = new Font("Microsoft Sans Serif", 9);
private Font tipsFont = UIFontColor.SubFont();
[Description("角标文字字体"), Category("SunnyUI")]
[DefaultValue(typeof(Font), "Microsoft Sans Serif, 9pt")]
[DefaultValue(typeof(Font), "微软雅黑, 9pt")]
public Font TipsFont
{
get => tipsFont;

View File

@ -49,7 +49,7 @@ namespace Sunny.UI
InitializeComponent();
Version = UIGlobal.Version;
AutoScaleMode = AutoScaleMode.None;
base.Font = UIFontColor.Font;
base.Font = UIFontColor.Font();
base.MinimumSize = new System.Drawing.Size(1, 1);
SetStyleFlags(true, false);
}

View File

@ -52,7 +52,7 @@ namespace Sunny.UI
ItemSize = new Size(150, 40);
DrawMode = TabDrawMode.OwnerDrawFixed;
Font = UIFontColor.Font;
Font = UIFontColor.Font();
AfterSetFillColor(FillColor);
Version = UIGlobal.Version;

View File

@ -40,7 +40,7 @@ namespace Sunny.UI
ItemSize = new Size(40, 200);
DrawMode = TabDrawMode.OwnerDrawFixed;
Font = UIFontColor.Font;
Font = UIFontColor.Font();
AfterSetFillColor(FillColor);
Size = new Size(450, 270);
Version = UIGlobal.Version;

View File

@ -55,7 +55,7 @@ namespace Sunny.UI
CalcEditHeight();
Height = MinHeight;
ShowText = false;
Font = UIFontColor.Font;
Font = UIFontColor.Font();
Padding = new Padding(0);
MinimumSize = new Size(1, 16);

View File

@ -63,7 +63,7 @@ namespace Sunny.UI
float size = 0;
foreach (var info in Option.Infos)
{
SizeF sf = info.Text.MeasureString(UIFontColor.Font);
SizeF sf = info.Text.MeasureString(Font);
size = Math.Max(sf.Width, size);
}

View File

@ -432,7 +432,7 @@ namespace Sunny.UI
/// <summary>
/// 标题字体
/// </summary>
private Font titleFont = UIFontColor.Font;
private Font titleFont = UIFontColor.Font();
/// <summary>
/// 标题字体

View File

@ -170,7 +170,7 @@
this.lblSubText.Name = "lblSubText";
this.lblSubText.Size = new System.Drawing.Size(310, 26);
this.lblSubText.TabIndex = 7;
this.lblSubText.Text = "SunnyUI V2.2.5";
this.lblSubText.Text = "SunnyUI";
this.lblSubText.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// uiLabel1

View File

@ -474,7 +474,7 @@ namespace Sunny.UI
/// <summary>
/// 标题字体
/// </summary>
private Font titleFont = UIFontColor.Font;
private Font titleFont = UIFontColor.Font();
/// <summary>
/// 标题字体

View File

@ -705,23 +705,23 @@ namespace Sunny.UI
/// <summary>
/// 默认字体
/// </summary>
public static readonly Font Font = new Font("微软雅黑", 12, FontStyle.Regular, GraphicsUnit.Point, GdiCharSet);
public static Font CreateFont()
public static Font Font()
{
return new Font("微软雅黑", 12, FontStyle.Regular, GraphicsUnit.Point, GdiCharSet);
return new Font("微软雅黑", FontSize, FontStyle.Regular, GraphicsUnit.Point, GdiCharSet);
}
public static float FontSize = 12;
/// <summary>
/// 默认字体
/// 默认二级字体
/// </summary>
public static readonly Font SubFont = new Font("微软雅黑", 9, FontStyle.Regular, GraphicsUnit.Point, GdiCharSet);
public static Font CreateSubFont()
public static Font SubFont()
{
return new Font("微软雅黑", 9, FontStyle.Regular, GraphicsUnit.Point, GdiCharSet);
return new Font("微软雅黑", SubFontSize, FontStyle.Regular, GraphicsUnit.Point, GdiCharSet);
}
public static float SubFontSize = 9;
/// <summary>
/// 主要颜色
/// </summary>