字体预览工具 v1.0.0 初始版本
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace FontPreview
|
||||
{
|
||||
/// <summary>
|
||||
/// 集中 UI 主题:颜色常量、字体、控件样式工厂。
|
||||
/// 所有界面颜色/样式统一从这里取,避免散落硬编码和重复写法。
|
||||
/// </summary>
|
||||
internal static class UiTheme
|
||||
{
|
||||
// ---- 颜色 ----
|
||||
public static readonly Color Primary = Color.FromArgb(43, 58, 85); // 主深蓝
|
||||
public static readonly Color Accent = Color.FromArgb(98, 137, 200); // 强调蓝(竖条/hover 边)
|
||||
public static readonly Color AccentText = Color.FromArgb(70, 110, 180); // 字体名标签蓝
|
||||
public static readonly Color CardBg = Color.White;
|
||||
public static readonly Color PreviewBg = Color.FromArgb(245, 246, 248); // 预览图浅灰底
|
||||
public static readonly Color PanelBg = Color.White;
|
||||
public static readonly Color Border = Color.FromArgb(226, 230, 235);
|
||||
public static readonly Color SubText = Color.Gray;
|
||||
|
||||
// ---- 字体 ----
|
||||
public const string UiFontFamily = "Microsoft YaHei UI";
|
||||
public static readonly Font GroupLabel = new Font(UiFontFamily, 9.5f, FontStyle.Bold);
|
||||
public static readonly Font CardTitle = new Font(UiFontFamily, 11.5f, FontStyle.Bold);
|
||||
public static readonly Font StatusText = new Font(UiFontFamily, 8f);
|
||||
public static readonly Font UiBase = new Font(UiFontFamily, 9f);
|
||||
|
||||
// ---- 圆角卡片 ----
|
||||
public const int CardRadius = 10;
|
||||
|
||||
/// <summary>创建一张统一风格的圆角卡片面板。</summary>
|
||||
public static RoundPanel CreateCard(int width, int height)
|
||||
{
|
||||
RoundPanel p = new RoundPanel
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
BackColor = CardBg,
|
||||
Radius = CardRadius,
|
||||
BorderColor = Border,
|
||||
HoverBorder = Accent
|
||||
};
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>卡片左侧的强调色竖条。</summary>
|
||||
public static Panel CreateAccentBar(int x, int y)
|
||||
{
|
||||
return new Panel { BackColor = Accent, Location = new Point(x, y), Size = new Size(4, 18) };
|
||||
}
|
||||
|
||||
/// <summary>卡片标题字体名标签。</summary>
|
||||
public static Label CreateCardTitle(string text, int x, int y, int width)
|
||||
{
|
||||
return new Label
|
||||
{
|
||||
Text = text,
|
||||
Location = new Point(x, y),
|
||||
Size = new Size(width, 26),
|
||||
Font = CardTitle,
|
||||
ForeColor = AccentText,
|
||||
AutoEllipsis = true,
|
||||
Cursor = Cursors.Hand,
|
||||
BackColor = Color.Transparent
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>卡片里的预览图 PictureBox(浅灰底、贴左)。</summary>
|
||||
public static PictureBox CreatePreviewBox(int x, int y, int width, int height)
|
||||
{
|
||||
return new PictureBox
|
||||
{
|
||||
Location = new Point(x, y),
|
||||
Size = new Size(width, height),
|
||||
BackColor = PreviewBg,
|
||||
SizeMode = PictureBoxSizeMode.Normal,
|
||||
Cursor = Cursors.Hand
|
||||
};
|
||||
}
|
||||
|
||||
// ---- 按钮 ----
|
||||
/// <summary>主按钮:深蓝填充白字。</summary>
|
||||
public static Button CreatePrimaryButton(string text, int x, int y, int w, int h, EventHandler onClick)
|
||||
{
|
||||
Button b = new Button
|
||||
{
|
||||
Text = text,
|
||||
Location = new Point(x, y),
|
||||
Size = new Size(w, h),
|
||||
BackColor = Primary,
|
||||
ForeColor = Color.White,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
Cursor = Cursors.Hand
|
||||
};
|
||||
b.FlatAppearance.BorderSize = 0;
|
||||
if (onClick != null) b.Click += onClick;
|
||||
return b;
|
||||
}
|
||||
|
||||
/// <summary>次要按钮:扁平白底。</summary>
|
||||
public static Button CreateSecondaryButton(string text, int x, int y, int w, int h, EventHandler onClick)
|
||||
{
|
||||
Button b = new Button
|
||||
{
|
||||
Text = text,
|
||||
Location = new Point(x, y),
|
||||
Size = new Size(w, h),
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
Cursor = Cursors.Hand
|
||||
};
|
||||
if (onClick != null) b.Click += onClick;
|
||||
return b;
|
||||
}
|
||||
|
||||
/// <summary>左侧分组小标题。</summary>
|
||||
public static Label CreateGroupLabel(string text, int x, int y, int w)
|
||||
{
|
||||
return new Label
|
||||
{
|
||||
Text = text,
|
||||
Location = new Point(x, y),
|
||||
Size = new Size(w, 20),
|
||||
Font = GroupLabel,
|
||||
ForeColor = Primary,
|
||||
BackColor = Color.Transparent
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>主窗体应用主题:白底、统一字体。</summary>
|
||||
public static void ApplyForm(Form f)
|
||||
{
|
||||
f.BackColor = PanelBg;
|
||||
f.Font = UiBase;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user