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

This commit is contained in:
Sunny 2023-09-17 23:02:05 +08:00
parent 7b2bbd897f
commit e322338506
16 changed files with 341 additions and 294 deletions

View File

@ -86,8 +86,7 @@ namespace Sunny.UI
protected override void OnFontChanged(EventArgs e) protected override void OnFontChanged(EventArgs e)
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size; if (DefaultFontSize < 0 && edit != null) edit.Font = this.Font;
edit.Font = this.Font.Clone(DefaultFontSize);
SizeChange(); SizeChange();
Invalidate(); Invalidate();
} }
@ -373,7 +372,6 @@ namespace Sunny.UI
protected override void OnSizeChanged(EventArgs e) protected override void OnSizeChanged(EventArgs e)
{ {
SizeChange(); SizeChange();
if (tipsBtn != null) if (tipsBtn != null)
{ {
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2); tipsBtn.Location = new System.Drawing.Point(Width - 8, 2);

View File

@ -47,293 +47,279 @@ namespace Sunny.UI
#region InitializeComponent #region InitializeComponent
private UITabControl TabControl; private UITabControl TabControl;
private System.Windows.Forms.TabPage tabPage1; private TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2; private TabPage tabPage2;
private UIPanel p1; private UIPanel p1;
private UISymbolButton b4; private UISymbolButton b4;
private UISymbolButton b3; private UISymbolButton b3;
private UISymbolButton b2; private UISymbolButton b2;
private UISymbolButton b1; private UISymbolButton b1;
private UIPanel p2; private UIPanel p2;
private System.Windows.Forms.TabPage tabPage3; private TabPage tabPage3;
private UIPanel p3; private UIPanel p3;
private UIPanel TopPanel; private UIPanel TopPanel;
private void InitializeComponent() private void InitializeComponent()
{ {
this.TopPanel = new Sunny.UI.UIPanel(); TopPanel = new UIPanel();
this.b4 = new Sunny.UI.UISymbolButton(); b4 = new UISymbolButton();
this.b3 = new Sunny.UI.UISymbolButton(); b3 = new UISymbolButton();
this.b2 = new Sunny.UI.UISymbolButton(); b2 = new UISymbolButton();
this.b1 = new Sunny.UI.UISymbolButton(); b1 = new UISymbolButton();
this.TabControl = new Sunny.UI.UITabControl(); TabControl = new UITabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); tabPage1 = new TabPage();
this.p1 = new Sunny.UI.UIPanel(); p1 = new UIPanel();
this.tabPage2 = new System.Windows.Forms.TabPage(); tabPage2 = new TabPage();
this.p2 = new Sunny.UI.UIPanel(); p2 = new UIPanel();
this.tabPage3 = new System.Windows.Forms.TabPage(); tabPage3 = new TabPage();
this.p3 = new Sunny.UI.UIPanel(); p3 = new UIPanel();
this.TopPanel.SuspendLayout(); TopPanel.SuspendLayout();
this.TabControl.SuspendLayout(); TabControl.SuspendLayout();
this.tabPage1.SuspendLayout(); tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout(); tabPage2.SuspendLayout();
this.tabPage3.SuspendLayout(); tabPage3.SuspendLayout();
this.SuspendLayout(); SuspendLayout();
// //
// TopPanel // TopPanel
// //
this.TopPanel.Controls.Add(this.b4); TopPanel.Controls.Add(b4);
this.TopPanel.Controls.Add(this.b3); TopPanel.Controls.Add(b3);
this.TopPanel.Controls.Add(this.b2); TopPanel.Controls.Add(b2);
this.TopPanel.Controls.Add(this.b1); TopPanel.Controls.Add(b1);
this.TopPanel.Dock = System.Windows.Forms.DockStyle.Top; TopPanel.Dock = DockStyle.Top;
this.TopPanel.Font = new System.Drawing.Font("宋体", 12F); TopPanel.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.TopPanel.Location = new System.Drawing.Point(0, 0); TopPanel.Location = new Point(0, 0);
this.TopPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); TopPanel.Margin = new Padding(4, 5, 4, 5);
this.TopPanel.MinimumSize = new System.Drawing.Size(1, 1); TopPanel.MinimumSize = new Size(1, 1);
this.TopPanel.Name = "TopPanel"; TopPanel.Name = "TopPanel";
this.TopPanel.RadiusSides = Sunny.UI.UICornerRadiusSides.None; TopPanel.RadiusSides = UICornerRadiusSides.None;
this.TopPanel.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)(((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) TopPanel.RectSides = ToolStripStatusLabelBorderSides.Left | ToolStripStatusLabelBorderSides.Top | ToolStripStatusLabelBorderSides.Right;
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Right))); TopPanel.Size = new Size(461, 31);
this.TopPanel.Size = new System.Drawing.Size(461, 31); TopPanel.StyleCustomMode = true;
this.TopPanel.StyleCustomMode = true; TopPanel.TabIndex = 0;
this.TopPanel.TabIndex = 0; TopPanel.Text = "2020-05-05";
this.TopPanel.Text = "2020-05-05"; TopPanel.TextAlignment = ContentAlignment.MiddleCenter;
this.TopPanel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; TopPanel.Click += TopPanel_Click;
this.TopPanel.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.TopPanel.Click += new System.EventHandler(this.TopPanel_Click);
// //
// b4 // b4
// //
this.b4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); b4.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.b4.BackColor = System.Drawing.Color.Transparent; b4.BackColor = Color.Transparent;
this.b4.Cursor = System.Windows.Forms.Cursors.Hand; b4.Cursor = Cursors.Hand;
this.b4.FillColor = System.Drawing.Color.White; b4.FillColor = Color.White;
this.b4.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b4.FillHoverColor = Color.FromArgb(80, 160, 255);
this.b4.Font = new System.Drawing.Font("宋体", 12F); b4.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.b4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b4.ForeColor = Color.FromArgb(80, 160, 255);
this.b4.ImageInterval = 0; b4.Location = new Point(427, 4);
this.b4.Location = new System.Drawing.Point(427, 4); b4.MinimumSize = new Size(1, 1);
this.b4.MinimumSize = new System.Drawing.Size(1, 1); b4.Name = "b4";
this.b4.Name = "b4"; b4.Padding = new Padding(24, 0, 0, 0);
this.b4.Padding = new System.Windows.Forms.Padding(24, 0, 0, 0); b4.RadiusSides = UICornerRadiusSides.None;
this.b4.RadiusSides = Sunny.UI.UICornerRadiusSides.None; b4.RectHoverColor = Color.FromArgb(80, 160, 255);
this.b4.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b4.RectSides = ToolStripStatusLabelBorderSides.None;
this.b4.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None; b4.Size = new Size(30, 24);
this.b4.Size = new System.Drawing.Size(30, 24); b4.Style = UIStyle.Custom;
this.b4.Style = Sunny.UI.UIStyle.Custom; b4.StyleCustomMode = true;
this.b4.StyleCustomMode = true; b4.Symbol = 61697;
this.b4.Symbol = 61697; b4.TabIndex = 3;
this.b4.TabIndex = 3; b4.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point);
this.b4.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); b4.Click += b4_Click;
this.b4.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.b4.Click += new System.EventHandler(this.b4_Click);
// //
// b3 // b3
// //
this.b3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); b3.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.b3.BackColor = System.Drawing.Color.Transparent; b3.BackColor = Color.Transparent;
this.b3.Cursor = System.Windows.Forms.Cursors.Hand; b3.Cursor = Cursors.Hand;
this.b3.FillColor = System.Drawing.Color.White; b3.FillColor = Color.White;
this.b3.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b3.FillHoverColor = Color.FromArgb(80, 160, 255);
this.b3.Font = new System.Drawing.Font("宋体", 12F); b3.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.b3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b3.ForeColor = Color.FromArgb(80, 160, 255);
this.b3.ImageInterval = 0; b3.Location = new Point(391, 4);
this.b3.Location = new System.Drawing.Point(391, 4); b3.MinimumSize = new Size(1, 1);
this.b3.MinimumSize = new System.Drawing.Size(1, 1); b3.Name = "b3";
this.b3.Name = "b3"; b3.Padding = new Padding(24, 0, 0, 0);
this.b3.Padding = new System.Windows.Forms.Padding(24, 0, 0, 0); b3.RadiusSides = UICornerRadiusSides.None;
this.b3.RadiusSides = Sunny.UI.UICornerRadiusSides.None; b3.RectHoverColor = Color.FromArgb(80, 160, 255);
this.b3.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b3.RectSides = ToolStripStatusLabelBorderSides.None;
this.b3.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None; b3.Size = new Size(30, 24);
this.b3.Size = new System.Drawing.Size(30, 24); b3.Style = UIStyle.Custom;
this.b3.Style = Sunny.UI.UIStyle.Custom; b3.StyleCustomMode = true;
this.b3.StyleCustomMode = true; b3.Symbol = 61701;
this.b3.Symbol = 61701; b3.TabIndex = 2;
this.b3.TabIndex = 2; b3.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point);
this.b3.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); b3.Click += b3_Click;
this.b3.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.b3.Click += new System.EventHandler(this.b3_Click);
// //
// b2 // b2
// //
this.b2.BackColor = System.Drawing.Color.Transparent; b2.BackColor = Color.Transparent;
this.b2.Cursor = System.Windows.Forms.Cursors.Hand; b2.Cursor = Cursors.Hand;
this.b2.FillColor = System.Drawing.Color.White; b2.FillColor = Color.White;
this.b2.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b2.FillHoverColor = Color.FromArgb(80, 160, 255);
this.b2.Font = new System.Drawing.Font("宋体", 12F); b2.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.b2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b2.ForeColor = Color.FromArgb(80, 160, 255);
this.b2.ImageInterval = 0; b2.Location = new Point(40, 4);
this.b2.Location = new System.Drawing.Point(40, 4); b2.MinimumSize = new Size(1, 1);
this.b2.MinimumSize = new System.Drawing.Size(1, 1); b2.Name = "b2";
this.b2.Name = "b2"; b2.Padding = new Padding(24, 0, 0, 0);
this.b2.Padding = new System.Windows.Forms.Padding(24, 0, 0, 0); b2.RadiusSides = UICornerRadiusSides.None;
this.b2.RadiusSides = Sunny.UI.UICornerRadiusSides.None; b2.RectHoverColor = Color.FromArgb(80, 160, 255);
this.b2.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b2.RectSides = ToolStripStatusLabelBorderSides.None;
this.b2.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None; b2.Size = new Size(30, 24);
this.b2.Size = new System.Drawing.Size(30, 24); b2.Style = UIStyle.Custom;
this.b2.Style = Sunny.UI.UIStyle.Custom; b2.StyleCustomMode = true;
this.b2.StyleCustomMode = true; b2.Symbol = 61700;
this.b2.Symbol = 61700; b2.TabIndex = 1;
this.b2.TabIndex = 1; b2.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point);
this.b2.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); b2.Click += b2_Click;
this.b2.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.b2.Click += new System.EventHandler(this.b2_Click);
// //
// b1 // b1
// //
this.b1.BackColor = System.Drawing.Color.Transparent; b1.BackColor = Color.Transparent;
this.b1.Cursor = System.Windows.Forms.Cursors.Hand; b1.Cursor = Cursors.Hand;
this.b1.FillColor = System.Drawing.Color.White; b1.FillColor = Color.White;
this.b1.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b1.FillHoverColor = Color.FromArgb(80, 160, 255);
this.b1.Font = new System.Drawing.Font("宋体", 12F); b1.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.b1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b1.ForeColor = Color.FromArgb(80, 160, 255);
this.b1.ImageInterval = 0; b1.Location = new Point(4, 4);
this.b1.Location = new System.Drawing.Point(4, 4); b1.MinimumSize = new Size(1, 1);
this.b1.MinimumSize = new System.Drawing.Size(1, 1); b1.Name = "b1";
this.b1.Name = "b1"; b1.Padding = new Padding(24, 0, 0, 0);
this.b1.Padding = new System.Windows.Forms.Padding(24, 0, 0, 0); b1.RadiusSides = UICornerRadiusSides.None;
this.b1.RadiusSides = Sunny.UI.UICornerRadiusSides.None; b1.RectHoverColor = Color.FromArgb(80, 160, 255);
this.b1.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); b1.RectSides = ToolStripStatusLabelBorderSides.None;
this.b1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None; b1.Size = new Size(30, 24);
this.b1.Size = new System.Drawing.Size(30, 24); b1.Style = UIStyle.Custom;
this.b1.Style = Sunny.UI.UIStyle.Custom; b1.StyleCustomMode = true;
this.b1.StyleCustomMode = true; b1.Symbol = 61696;
this.b1.Symbol = 61696; b1.TabIndex = 0;
this.b1.TabIndex = 0; b1.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point);
this.b1.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); b1.Click += b1_Click;
this.b1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
this.b1.Click += new System.EventHandler(this.b1_Click);
// //
// TabControl // TabControl
// //
this.TabControl.Controls.Add(this.tabPage1); TabControl.Controls.Add(tabPage1);
this.TabControl.Controls.Add(this.tabPage2); TabControl.Controls.Add(tabPage2);
this.TabControl.Controls.Add(this.tabPage3); TabControl.Controls.Add(tabPage3);
this.TabControl.Dock = System.Windows.Forms.DockStyle.Fill; TabControl.Dock = DockStyle.Fill;
this.TabControl.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed; TabControl.DrawMode = TabDrawMode.OwnerDrawFixed;
this.TabControl.Font = new System.Drawing.Font("宋体", 12F); TabControl.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.TabControl.ItemSize = new System.Drawing.Size(150, 40); TabControl.ItemSize = new Size(150, 40);
this.TabControl.Location = new System.Drawing.Point(0, 31); TabControl.Location = new Point(0, 31);
this.TabControl.MainPage = ""; TabControl.MainPage = "";
this.TabControl.Name = "TabControl"; TabControl.Name = "TabControl";
this.TabControl.SelectedIndex = 0; TabControl.SelectedIndex = 0;
this.TabControl.Size = new System.Drawing.Size(461, 317); TabControl.Size = new Size(461, 317);
this.TabControl.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; TabControl.SizeMode = TabSizeMode.Fixed;
this.TabControl.Style = Sunny.UI.UIStyle.Custom; TabControl.Style = UIStyle.Custom;
this.TabControl.TabIndex = 1; TabControl.TabIndex = 1;
this.TabControl.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); TabControl.TabUnSelectedForeColor = Color.FromArgb(240, 240, 240);
this.TabControl.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); TabControl.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point);
this.TabControl.SelectedIndexChanged += new System.EventHandler(this.TabControl_SelectedIndexChanged); TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;
// //
// tabPage1 // tabPage1
// //
this.tabPage1.Controls.Add(this.p1); tabPage1.Controls.Add(p1);
this.tabPage1.Location = new System.Drawing.Point(0, 40); tabPage1.Location = new Point(0, 40);
this.tabPage1.Name = "tabPage1"; tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(461, 277); tabPage1.Size = new Size(461, 277);
this.tabPage1.TabIndex = 0; tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1"; tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true; tabPage1.UseVisualStyleBackColor = true;
// //
// p1 // p1
// //
this.p1.Dock = System.Windows.Forms.DockStyle.Fill; p1.Dock = DockStyle.Fill;
this.p1.FillColor = System.Drawing.Color.White; p1.FillColor = Color.White;
this.p1.Font = new System.Drawing.Font("宋体", 12F); p1.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.p1.Location = new System.Drawing.Point(0, 0); p1.Location = new Point(0, 0);
this.p1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); p1.Margin = new Padding(4, 5, 4, 5);
this.p1.MinimumSize = new System.Drawing.Size(1, 1); p1.MinimumSize = new Size(1, 1);
this.p1.Name = "p1"; p1.Name = "p1";
this.p1.RadiusSides = Sunny.UI.UICornerRadiusSides.None; p1.RadiusSides = UICornerRadiusSides.None;
this.p1.Size = new System.Drawing.Size(461, 277); p1.Size = new Size(461, 277);
this.p1.Style = Sunny.UI.UIStyle.Custom; p1.Style = UIStyle.Custom;
this.p1.TabIndex = 0; p1.TabIndex = 0;
this.p1.Text = null; p1.Text = null;
this.p1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; p1.TextAlignment = ContentAlignment.MiddleCenter;
this.p1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); p1.Paint += p1_Paint;
this.p1.Paint += new System.Windows.Forms.PaintEventHandler(this.p1_Paint); p1.MouseClick += p1_MouseClick;
this.p1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.p1_MouseClick); p1.MouseLeave += p1_MouseLeave;
this.p1.MouseLeave += new System.EventHandler(this.p1_MouseLeave); p1.MouseMove += p1_MouseMove;
this.p1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.p1_MouseMove);
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.p2); tabPage2.Controls.Add(p2);
this.tabPage2.Location = new System.Drawing.Point(0, 40); tabPage2.Location = new Point(0, 40);
this.tabPage2.Name = "tabPage2"; tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(200, 60); tabPage2.Size = new Size(461, 277);
this.tabPage2.TabIndex = 1; tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2"; tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true; tabPage2.UseVisualStyleBackColor = true;
// //
// p2 // p2
// //
this.p2.Dock = System.Windows.Forms.DockStyle.Fill; p2.Dock = DockStyle.Fill;
this.p2.FillColor = System.Drawing.Color.White; p2.FillColor = Color.White;
this.p2.Font = new System.Drawing.Font("宋体", 12F); p2.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.p2.Location = new System.Drawing.Point(0, 0); p2.Location = new Point(0, 0);
this.p2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); p2.Margin = new Padding(4, 5, 4, 5);
this.p2.MinimumSize = new System.Drawing.Size(1, 1); p2.MinimumSize = new Size(1, 1);
this.p2.Name = "p2"; p2.Name = "p2";
this.p2.RadiusSides = Sunny.UI.UICornerRadiusSides.None; p2.RadiusSides = UICornerRadiusSides.None;
this.p2.Size = new System.Drawing.Size(200, 60); p2.Size = new Size(461, 277);
this.p2.Style = Sunny.UI.UIStyle.Custom; p2.Style = UIStyle.Custom;
this.p2.TabIndex = 1; p2.TabIndex = 1;
this.p2.Text = null; p2.Text = null;
this.p2.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; p2.TextAlignment = ContentAlignment.MiddleCenter;
this.p2.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); p2.Paint += p2_Paint;
this.p2.Paint += new System.Windows.Forms.PaintEventHandler(this.p2_Paint); p2.MouseClick += p2_MouseClick;
this.p2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.p2_MouseClick); p2.MouseLeave += p2_MouseLeave;
this.p2.MouseLeave += new System.EventHandler(this.p2_MouseLeave); p2.MouseMove += p2_MouseMove;
this.p2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.p2_MouseMove);
// //
// tabPage3 // tabPage3
// //
this.tabPage3.Controls.Add(this.p3); tabPage3.Controls.Add(p3);
this.tabPage3.Location = new System.Drawing.Point(0, 40); tabPage3.Location = new Point(0, 40);
this.tabPage3.Name = "tabPage3"; tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(200, 60); tabPage3.Size = new Size(461, 277);
this.tabPage3.TabIndex = 2; tabPage3.TabIndex = 2;
this.tabPage3.Text = "tabPage3"; tabPage3.Text = "tabPage3";
this.tabPage3.UseVisualStyleBackColor = true; tabPage3.UseVisualStyleBackColor = true;
// //
// p3 // p3
// //
this.p3.Dock = System.Windows.Forms.DockStyle.Fill; p3.Dock = DockStyle.Fill;
this.p3.FillColor = System.Drawing.Color.White; p3.FillColor = Color.White;
this.p3.Font = new System.Drawing.Font("宋体", 12F); p3.Font = new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point);
this.p3.Location = new System.Drawing.Point(0, 0); p3.Location = new Point(0, 0);
this.p3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); p3.Margin = new Padding(4, 5, 4, 5);
this.p3.MinimumSize = new System.Drawing.Size(1, 1); p3.MinimumSize = new Size(1, 1);
this.p3.Name = "p3"; p3.Name = "p3";
this.p3.RadiusSides = Sunny.UI.UICornerRadiusSides.None; p3.RadiusSides = UICornerRadiusSides.None;
this.p3.Size = new System.Drawing.Size(200, 60); p3.Size = new Size(461, 277);
this.p3.Style = Sunny.UI.UIStyle.Custom; p3.Style = UIStyle.Custom;
this.p3.TabIndex = 2; p3.TabIndex = 2;
this.p3.Text = null; p3.Text = null;
this.p3.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; p3.TextAlignment = ContentAlignment.MiddleCenter;
this.p3.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); p3.Paint += p3_Paint;
this.p3.Paint += new System.Windows.Forms.PaintEventHandler(this.p3_Paint); p3.MouseClick += p3_MouseClick;
this.p3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.p3_MouseClick); p3.MouseLeave += p3_MouseLeave;
this.p3.MouseLeave += new System.EventHandler(this.p3_MouseLeave); p3.MouseMove += p3_MouseMove;
this.p3.MouseMove += new System.Windows.Forms.MouseEventHandler(this.p3_MouseMove);
// //
// UIDate // UICalendar
// //
this.Controls.Add(this.TabControl); Controls.Add(TabControl);
this.Controls.Add(this.TopPanel); Controls.Add(TopPanel);
this.FillColor = System.Drawing.Color.White; FillColor = Color.White;
this.Name = "UIDate"; Name = "UICalendar";
this.Size = new System.Drawing.Size(461, 348); Size = new Size(461, 348);
this.Style = Sunny.UI.UIStyle.Custom; Style = UIStyle.Custom;
this.TopPanel.ResumeLayout(false); TopPanel.ResumeLayout(false);
this.TabControl.ResumeLayout(false); TabControl.ResumeLayout(false);
this.tabPage1.ResumeLayout(false); tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false); tabPage2.ResumeLayout(false);
this.tabPage3.ResumeLayout(false); tabPage3.ResumeLayout(false);
this.ResumeLayout(false); ResumeLayout(false);
} }
#endregion InitializeComponent #endregion InitializeComponent
@ -592,7 +578,7 @@ namespace Sunny.UI
TopPanel.SetStyleColor(uiColor); TopPanel.SetStyleColor(uiColor);
} }
private void p2_Paint(object sender, System.Windows.Forms.PaintEventArgs e) private void p2_Paint(object sender, PaintEventArgs e)
{ {
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
@ -611,7 +597,7 @@ namespace Sunny.UI
} }
} }
private void p2_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) private void p2_MouseClick(object sender, MouseEventArgs e)
{ {
int width = p2.Width / 4; int width = p2.Width / 4;
int height = p2.Height / 3; int height = p2.Height / 3;
@ -635,7 +621,7 @@ namespace Sunny.UI
private int activeMonth = -1; private int activeMonth = -1;
private void p2_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) private void p2_MouseMove(object sender, MouseEventArgs e)
{ {
int width = p2.Width / 4; int width = p2.Width / 4;
int height = p2.Height / 3; int height = p2.Height / 3;
@ -653,7 +639,7 @@ namespace Sunny.UI
//public bool ShowToday { get; set; } //public bool ShowToday { get; set; }
private void p1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) private void p1_Paint(object sender, PaintEventArgs e)
{ {
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
@ -670,7 +656,7 @@ namespace Sunny.UI
} }
} }
private void p1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) private void p1_MouseMove(object sender, MouseEventArgs e)
{ {
int width = p1.Width / 4; int width = p1.Width / 4;
int height = p1.Height / 3; int height = p1.Height / 3;
@ -684,7 +670,7 @@ namespace Sunny.UI
} }
} }
private void p1_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) private void p1_MouseClick(object sender, MouseEventArgs e)
{ {
int width = p1.Width / 4; int width = p1.Width / 4;
int height = p1.Height / 3; int height = p1.Height / 3;
@ -707,7 +693,7 @@ namespace Sunny.UI
} }
} }
private void p3_Paint(object sender, System.Windows.Forms.PaintEventArgs e) private void p3_Paint(object sender, PaintEventArgs e)
{ {
int width = p3.Width / 7; int width = p3.Width / 7;
int height = (p3.Height - 30) / 6; int height = (p3.Height - 30) / 6;
@ -749,7 +735,7 @@ namespace Sunny.UI
private int activeDay = -1; private int activeDay = -1;
private void p3_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) private void p3_MouseMove(object sender, MouseEventArgs e)
{ {
if (e.Location.Y <= 30) if (e.Location.Y <= 30)
{ {
@ -771,7 +757,7 @@ namespace Sunny.UI
} }
} }
private void p3_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) private void p3_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Location.Y <= 30) return; if (e.Location.Y <= 30) return;
int width = p3.Width / 7; int width = p3.Width / 7;

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->

View File

@ -73,6 +73,19 @@ namespace Sunny.UI
} }
} }
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (DefaultFontSize < 0)
{
foreach (var item in boxes)
{
item.Font = Font;
}
}
}
private void Items_CountChange(object sender, EventArgs e) private void Items_CountChange(object sender, EventArgs e)
{ {
Invalidate(); Invalidate();

View File

@ -99,8 +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 (DefaultFontSize < 0 && pnlValue != null) pnlValue.Font = this.Font;
edit?.SetDPIScale(); if (DefaultFontSize < 0 && edit != null) edit.Font = this.Font;
} }
public event OnValueChanged ValueChanged; public event OnValueChanged ValueChanged;

View File

@ -457,8 +457,12 @@ namespace Sunny.UI
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
if (!InitializeComponentEnd) return; if (!InitializeComponentEnd) return;
if (txt1 == null || txt2 == null || txt3 == null || txt4 == null) return;
txt1.Font = txt2.Font = txt3.Font = txt4.Font = Font; if (DefaultFontSize < 0 && txt1 != null) txt1.Font = this.Font;
if (DefaultFontSize < 0 && txt2 != null) txt2.Font = this.Font;
if (DefaultFontSize < 0 && txt3 != null) txt3.Font = this.Font;
if (DefaultFontSize < 0 && txt4 != null) txt4.Font = this.Font;
UIIPTextBox_SizeChanged(null, null); UIIPTextBox_SizeChanged(null, null);
Invalidate(); Invalidate();
} }

View File

@ -223,7 +223,7 @@ namespace Sunny.UI
protected override void OnFontChanged(EventArgs e) protected override void OnFontChanged(EventArgs e)
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
listbox.Font = Font; if (DefaultFontSize < 0 && listbox != null) listbox.Font = this.Font;
} }
/// <summary> /// <summary>

View File

@ -117,8 +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 (DefaultFontSize < 0 && pnlValue != null) pnlValue.Font = this.Font;
edit?.SetDPIScale(); if (DefaultFontSize < 0 && edit != null) edit.Font = this.Font;
} }
private int step = 1; private int step = 1;

View File

@ -413,7 +413,7 @@ namespace Sunny.UI
protected override void OnFontChanged(EventArgs e) protected override void OnFontChanged(EventArgs e)
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
listbox.Font = Font; if (DefaultFontSize < 0 && listbox != null) listbox.Font = this.Font;
} }
/// <summary> /// <summary>

View File

@ -118,10 +118,23 @@ namespace Sunny.UI
buttonTags.TryAdd(buttons[i], 0); buttonTags.TryAdd(buttons[i], 0);
} }
TotalCount = 1000; TotalCount = 1000;
} }
/// <summary>
/// 重载字体变更
/// </summary>
/// <param name="e">参数</param>
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (DefaultFontSize < 0)
{
foreach (var item in this.GetControls<UISymbolButton>(true))
item.Font = Font;
}
}
/// <summary> /// <summary>
/// 设置主题样式 /// 设置主题样式
/// </summary> /// </summary>

View File

@ -128,6 +128,31 @@ namespace Sunny.UI
Translate(); Translate();
} }
/// <summary>
/// 重载字体变更
/// </summary>
/// <param name="e">参数</param>
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (DefaultFontSize < 0)
{
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;
}
Translate();
}
protected override void AfterSetFillColor(Color color) protected override void AfterSetFillColor(Color color)
{ {
base.AfterSetFillColor(color); base.AfterSetFillColor(color);

View File

@ -48,6 +48,19 @@ namespace Sunny.UI
StyleCustomModeChanged += UICheckBoxGroup_StyleCustomModeChanged; StyleCustomModeChanged += UICheckBoxGroup_StyleCustomModeChanged;
} }
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (DefaultFontSize < 0)
{
foreach (var item in buttons)
{
item.Font = Font;
}
}
}
private void UICheckBoxGroup_StyleCustomModeChanged(object sender, EventArgs e) private void UICheckBoxGroup_StyleCustomModeChanged(object sender, EventArgs e)
{ {
foreach (var item in buttons) foreach (var item in buttons)

View File

@ -228,7 +228,7 @@ namespace Sunny.UI
protected override void OnFontChanged(EventArgs e) protected override void OnFontChanged(EventArgs e)
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
if (edit != null) edit.Font = Font; if (DefaultFontSize < 0 && edit != null) edit.Font = this.Font;
} }
private bool showScrollBar = true; private bool showScrollBar = true;

View File

@ -660,8 +660,7 @@ namespace Sunny.UI
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size; if (DefaultFontSize < 0 && edit != null) edit.Font = this.Font;
edit.Font = this.Font.Clone(DefaultFontSize);
SizeChange(); SizeChange();
Invalidate(); Invalidate();

View File

@ -289,9 +289,8 @@ namespace Sunny.UI
protected override void OnFontChanged(EventArgs e) protected override void OnFontChanged(EventArgs e)
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
if (l1 == null || l2 == null) return; if (DefaultFontSize < 0 && l1 != null) l1.Font = this.Font;
l1.Font = Font; if (DefaultFontSize < 0 && l2 != null) l2.Font = this.Font;
l2.Font = Font;
} }
private int itemHeight = 25; private int itemHeight = 25;

View File

@ -744,10 +744,7 @@ namespace Sunny.UI
protected override void OnFontChanged(EventArgs e) protected override void OnFontChanged(EventArgs e)
{ {
base.OnFontChanged(e); base.OnFontChanged(e);
if (view != null) if (DefaultFontSize < 0 && view != null) view.Font = this.Font;
{
view.Font = Font;
}
} }
protected override void OnMouseWheel(MouseEventArgs e) protected override void OnMouseWheel(MouseEventArgs e)