Publish Zonghengjia Windows 0.3.13 client source

This commit is contained in:
2026-11-13 10:35:04 +08:00
parent 1590443809
commit 839434a313
55 changed files with 2324 additions and 963 deletions
+63 -14
View File
@@ -1,19 +1,19 @@
using System.Drawing.Drawing2D;
using System.Drawing.Drawing2D;
namespace UCVL.VPNPlus;
internal enum DashboardIcon { Server, Settings, Database, Upload, Download, Document, Chart, History, Shield }
internal enum DashboardIcon { Server, Settings, Database, Upload, Download, Document, Chart, History, Shield, Layers, ShieldPending, ShieldAlert }
// Code-drawn icons keep the existing brand assets and remain crisp at high DPI.
internal static class DashboardDrawing
{
internal static void Icon(Graphics g, DashboardIcon icon, Rectangle bounds, Color color)
internal static void Icon(Graphics g, DashboardIcon icon, Rectangle bounds, Color color, bool featured = false)
{
var state = g.Save();
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TranslateTransform(bounds.Left, bounds.Top);
g.ScaleTransform(bounds.Width / 24f, bounds.Height / 24f);
using var pen = new Pen(color, 1.8f) { StartCap = LineCap.Round, EndCap = LineCap.Round, LineJoin = LineJoin.Round };
using var pen = new Pen(color, 1.65f) { StartCap = LineCap.Round, EndCap = LineCap.Round, LineJoin = LineJoin.Round };
switch (icon)
{
case DashboardIcon.Server:
@@ -40,18 +40,41 @@ internal static class DashboardDrawing
for (var i = 0; i < 4; i++) g.DrawLine(pen, 4 + i * 5, 21, 4 + i * 5, 16 - i * 4); break;
case DashboardIcon.History:
g.DrawArc(pen, 2, 2, 20, 20, -85, 350); g.DrawLine(pen, 12, 2, 12, 12); g.DrawLine(pen, 12, 12, 22, 12); break;
case DashboardIcon.Layers:
g.DrawPolygon(pen, [new PointF(2, 7), new(12, 2), new(22, 7), new(12, 12)]);
g.DrawLines(pen, [new PointF(2, 12), new(12, 17), new(22, 12)]);
g.DrawLines(pen, [new PointF(2, 17), new(12, 22), new(22, 17)]); break;
case DashboardIcon.Shield:
case DashboardIcon.ShieldPending:
case DashboardIcon.ShieldAlert:
using (var shield = new GraphicsPath())
{
shield.AddLines([new PointF(12, 1), new(22, 5), new(22, 12)]);
shield.AddBezier(22, 12, 22, 18, 15, 22, 12, 24);
shield.AddBezier(12, 24, 9, 22, 2, 18, 2, 12);
shield.AddLine(2, 12, 2, 5); shield.CloseFigure();
using var fill = new LinearGradientBrush(new Point(2, 2), new Point(22, 24), Color.FromArgb(100, color), color);
shield.AddLines([new PointF(12, 1.2f), new(22, 5.3f), new(22, 11.8f)]);
shield.AddBezier(22, 11.8f, 22, 17.8f, 15, 21.8f, 12, 23);
shield.AddBezier(12, 23, 9, 21.8f, 2, 17.8f, 2, 11.8f);
shield.AddLine(2, 11.8f, 2, 5.3f);
shield.CloseFigure();
using var fill = new LinearGradientBrush(new Point(2, 2), new Point(22, 24),
featured ? Color.FromArgb(125, 107, 215, 255) : Color.FromArgb(176, color), color);
g.FillPath(fill, shield);
if (featured)
{
using var halo = new Pen(Color.FromArgb(100, 114, 217, 255), 1.9f) { LineJoin = LineJoin.Round };
using var edge = new Pen(Color.FromArgb(244, 213, 245, 255), .85f) { LineJoin = LineJoin.Round };
g.DrawPath(halo, shield);
g.DrawPath(edge, shield);
}
}
using (var mark = new Pen(Color.White, featured ? 1.9f : 2.25f) { StartCap = LineCap.Round, EndCap = LineCap.Round, LineJoin = LineJoin.Round })
{
if (icon == DashboardIcon.Shield) g.DrawLines(mark, [new PointF(7, 12), new(10.5f, 15.5f), new(17, 9)]);
else if (icon == DashboardIcon.ShieldAlert)
{
g.DrawLine(mark, 12, 7, 12, 12);
g.FillEllipse(Brushes.White, 10.8f, 14.5f, 2.4f, 2.4f);
}
else for (var x = 7; x <= 17; x += 5) g.FillEllipse(Brushes.White, x - 1.2f, 10.8f, 2.4f, 2.4f);
}
using (var check = new Pen(Color.White, 2.4f) { StartCap = LineCap.Round, EndCap = LineCap.Round, LineJoin = LineJoin.Round })
g.DrawLines(check, [new PointF(7, 12), new(10.5f, 15.5f), new(17, 9)]);
break;
}
g.Restore(state);
@@ -60,13 +83,16 @@ internal static class DashboardDrawing
internal sealed class DashboardGlyph : Control
{
internal DashboardIcon Glyph { get; set; }
private DashboardIcon _glyph;
private bool _featured;
internal DashboardIcon Glyph { get => _glyph; set { if (_glyph != value) { _glyph = value; Invalidate(); } } }
internal bool Featured { get => _featured; set { if (_featured != value) { _featured = value; Invalidate(); } } }
internal DashboardGlyph(DashboardIcon glyph) { Glyph = glyph; DoubleBuffered = true; SetStyle(ControlStyles.SupportsTransparentBackColor, true); BackColor = Color.Transparent; ForeColor = Brand.RoyalBlue; }
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var side = Math.Min(Width, Height) - 4;
if (side > 0) DashboardDrawing.Icon(e.Graphics, Glyph, new((Width - side) / 2, (Height - side) / 2, side, side), ForeColor);
if (side > 0) DashboardDrawing.Icon(e.Graphics, Glyph, new((Width - side) / 2, (Height - side) / 2, side, side), ForeColor, Featured);
}
}
@@ -86,6 +112,7 @@ internal sealed class MetricCard : CardPanel
internal string ValueText { get; private set; } = "—";
internal string UnitText { get; private set; } = "";
internal string Hint { get; private set; } = "仅代理流量";
internal bool InlineTotal { get; set; }
internal MetricCard(string heading, DashboardIcon glyph) { Heading = heading; Glyph = glyph; AccessibleName = heading; }
internal void SetBytes(double? bytes, bool speed = false, string? hint = null)
{
@@ -113,6 +140,21 @@ internal sealed class MetricCard : CardPanel
var s = DeviceDpi / 96f;
int S(int n) => (int)Math.Round(n * s);
var g = e.Graphics;
if (InlineTotal)
{
using var divider = new Pen(Color.FromArgb(145, 148, 188, 218), Math.Max(1, s * .7f));
g.DrawLine(divider, 0, S(12), 0, Height - S(12));
using var heading = Brand.Font(10);
using var value = Brand.Font(Width < S(190) ? 13 : 17, FontStyle.Bold);
var inlineFlags = ChartAxis.PaintFlags | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter
| TextFormatFlags.NoPadding | TextFormatFlags.EndEllipsis;
var headingWidth = S(39);
TextRenderer.DrawText(g, Heading.Replace("代理流量", ""), heading,
new Rectangle(S(12), 0, headingWidth, Height), Brand.Muted, inlineFlags);
TextRenderer.DrawText(g, (ValueText + " " + UnitText).TrimEnd(), value,
new Rectangle(S(12) + headingWidth, 0, Math.Max(1, Width - S(18) - headingWidth), Height), Brand.Navy, inlineFlags);
return;
}
if(Height<S(40))
{
var speed=Glyph is DashboardIcon.Upload or DashboardIcon.Download;
@@ -197,6 +239,7 @@ internal sealed class ReadOnlyModeLabel : Control
internal sealed class DashboardCombo : Control
{
internal List<object> Items { get; } = [];
internal DashboardIcon? LeadingIcon { get; set; }
private int _selectedIndex = -1;
private bool _hovered;
private ContextMenuStrip? _popup;
@@ -276,11 +319,17 @@ internal sealed class DashboardCombo : Control
if (Width < 10 || Height < 10) return;
var s = DeviceDpi / 96f;
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
using var path = UiGeometry.RoundedRectangle(new(1, 1, Width - 3, Height - 3), Math.Max(4, (int)(5*s)));
using var path = UiGeometry.RoundedRectangle(new(1, 1, Width - 3, Height - 3), Math.Max(4, (int)((Height >= 28*s ? 9 : 5)*s)));
using var fill = new SolidBrush(Color.FromArgb(Enabled ? 208 : 115, 245, 250, 255));
using var border = new Pen(Color.FromArgb(_hovered && Enabled ? 125 : 155, 151, 185, 213), Math.Max(1, s * .65f));
e.Graphics.FillPath(fill, path); e.Graphics.DrawPath(border, path);
var pad = (int)(7*s); var arrowX = Width - (int)(10*s); var arrowY = Height / 2;
if (LeadingIcon is { } icon && Height >= 26*s)
{
var side = (int)(19*s);
DashboardDrawing.Icon(e.Graphics, icon, new Rectangle(pad + 2, (Height - side)/2, side, side), Enabled ? Brand.RoyalBlue : Brand.Muted);
pad += side + (int)(8*s);
}
TextRenderer.DrawText(e.Graphics, SelectedItem?.ToString() ?? "选择节点", Font,
new Rectangle(pad, 0, Math.Max(1, Width-pad-(int)(20*s)), Height), Enabled ? ForeColor : Brand.Muted,
ChartAxis.PaintFlags | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter | TextFormatFlags.NoPadding | TextFormatFlags.EndEllipsis);