字体预览工具 v1.0.0 初始版本

This commit is contained in:
2026-09-19 23:50:45 +08:00
commit 1883e9ba77
50 changed files with 5959 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace FontPreview;
internal class RoundPanel : Panel
{
private bool mouseOver;
public int Radius { get; set; }
public Color BorderColor { get; set; }
public Color HoverBorder { get; set; }
public RoundPanel()
{
DoubleBuffered = true;
Radius = 10;
BorderColor = Color.FromArgb(226, 230, 235);
HoverBorder = Color.FromArgb(98, 137, 200);
BackColor = Color.White;
SetStyle((ControlStyles)139266, true);
}
protected override void OnResize(EventArgs eventargs)
{
base.OnResize(eventargs);
if (Width > 0 && Height > 0)
{
GraphicsPath path = GetPath();
try
{
Region = new Region(path);
}
finally
{
path?.Dispose();
}
}
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath path = GetPath();
try
{
Pen val = new Pen(mouseOver ? HoverBorder : BorderColor, 1.5f);
try
{
e.Graphics.DrawPath(val, path);
}
finally
{
val?.Dispose();
}
}
finally
{
path?.Dispose();
}
}
protected override void OnMouseEnter(EventArgs e)
{
mouseOver = true;
Invalidate();
base.OnMouseEnter(e);
}
protected override void OnMouseLeave(EventArgs e)
{
mouseOver = false;
Invalidate();
base.OnMouseLeave(e);
}
private GraphicsPath GetPath()
{
int radius = Radius;
int num = Width - 1;
int num2 = Height - 1;
GraphicsPath val = new GraphicsPath();
val.AddArc(0, 0, radius * 2, radius * 2, 180f, 90f);
val.AddArc(num - radius * 2, 0, radius * 2, radius * 2, 270f, 90f);
val.AddArc(num - radius * 2, num2 - radius * 2, radius * 2, radius * 2, 0f, 90f);
val.AddArc(0, num2 - radius * 2, radius * 2, radius * 2, 90f, 90f);
val.CloseFigure();
return val;
}
}