fix: 修复软件图标显示问题
This commit is contained in:
@@ -93,23 +93,57 @@ namespace TimerApp
|
||||
int clockSize = size - margin * 2;
|
||||
Rectangle rect = new Rectangle(margin, margin, clockSize, clockSize);
|
||||
|
||||
// 定义轮廓颜色和宽度
|
||||
Color outlineColor = Color.FromArgb(64, 64, 64);
|
||||
float mainWidth = Math.Max(2, size / 16f);
|
||||
float outlineWidth = mainWidth + Math.Max(1, size / 32f);
|
||||
float handWidth = Math.Max(2, size / 22f);
|
||||
float handOutlineWidth = handWidth + Math.Max(1, size / 32f);
|
||||
|
||||
// 1. 绘制耳朵 (先画轮廓)
|
||||
using (Pen outlinePen = new Pen(outlineColor, Math.Max(1, size / 32f)))
|
||||
using (Brush earBrush = new SolidBrush(Color.White))
|
||||
{
|
||||
// 左耳
|
||||
g.DrawPie(outlinePen, 0, 0, size / 2, size / 2, 200, 50);
|
||||
g.FillPie(earBrush, 0, 0, size / 2, size / 2, 200, 50);
|
||||
|
||||
// 右耳
|
||||
g.DrawPie(outlinePen, size / 2, 0, size / 2, size / 2, 290, 50);
|
||||
g.FillPie(earBrush, size / 2, 0, size / 2, size / 2, 290, 50);
|
||||
}
|
||||
|
||||
using (Pen pen = new Pen(Color.White, Math.Max(2, size / 16)))
|
||||
// 2. 绘制表盘外圈 (先画轮廓)
|
||||
using (Pen outlinePen = new Pen(outlineColor, outlineWidth))
|
||||
using (Pen pen = new Pen(Color.White, mainWidth))
|
||||
using (Brush bgBrush = new SolidBrush(Color.Black))
|
||||
{
|
||||
// 填充表盘背景,确保浅色模式下也能看清
|
||||
g.FillEllipse(bgBrush, rect);
|
||||
g.DrawEllipse(outlinePen, rect);
|
||||
g.DrawEllipse(pen, rect);
|
||||
}
|
||||
|
||||
// 3. 绘制指针 (先画轮廓)
|
||||
Point center = new Point(size / 2, size / 2);
|
||||
using (Pen handPen = new Pen(Color.LightGreen, Math.Max(2, size / 22)))
|
||||
Point handEnd1 = new Point(center.X + Math.Max(2, size * 10 / 64), center.Y - Math.Max(2, size * 10 / 64));
|
||||
Point handEnd2 = new Point(center.X, center.Y - Math.Max(3, size * 18 / 64));
|
||||
|
||||
using (Pen outlinePen = new Pen(outlineColor, handOutlineWidth))
|
||||
using (Pen handPen = new Pen(Color.LightGreen, handWidth))
|
||||
{
|
||||
outlinePen.EndCap = LineCap.Round;
|
||||
outlinePen.StartCap = LineCap.Round;
|
||||
handPen.EndCap = LineCap.Round;
|
||||
g.DrawLine(handPen, center, new Point(center.X + Math.Max(2, size * 10 / 64), center.Y - Math.Max(2, size * 10 / 64)));
|
||||
g.DrawLine(handPen, center, new Point(center.X, center.Y - Math.Max(3, size * 18 / 64)));
|
||||
handPen.StartCap = LineCap.Round;
|
||||
|
||||
// 指针1
|
||||
g.DrawLine(outlinePen, center, handEnd1);
|
||||
g.DrawLine(handPen, center, handEnd1);
|
||||
|
||||
// 指针2
|
||||
g.DrawLine(outlinePen, center, handEnd2);
|
||||
g.DrawLine(handPen, center, handEnd2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Properties/app.ico
Normal file
BIN
Properties/app.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -6,6 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<ApplicationIcon>Properties\app.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user