Windows 0.3.1 clean monitor source delta; no private history or other platform changes

This commit is contained in:
2026-10-27 02:00:33 +00:00
parent 366b3c5c9a
commit 1cf54a46e4
40 changed files with 983 additions and 206 deletions
+12 -8
View File
@@ -3,19 +3,19 @@ namespace UCVL.VPNPlus;
internal readonly record struct DashboardGeometry(
Rectangle WelcomeLabel, Rectangle AccountLabel, Rectangle IdentityBadge,
Rectangle LogoutButton, Rectangle StatusCard, Rectangle NodeCard, Rectangle ModeCard,
Rectangle[] Metrics, Rectangle TrafficCard, Rectangle TailnetTrafficCard, Rectangle DailyCard, Rectangle Footer,
Rectangle[] Metrics, Rectangle TrafficCard, Rectangle TailnetTrafficCard, Rectangle DailyCard, Rectangle ServerTrafficCard, Rectangle Footer,
int ContentHeight, bool Compact, float VerticalScale);
// Logical pixels converted once, independent of WinForms autoscaling.
internal static class DashboardLayout
{
internal static DashboardGeometry Calculate(Size viewport, int dpi, bool showTailnet = false)
internal static DashboardGeometry Calculate(Size viewport, int dpi, bool showTailnet = false, bool showServerTraffic = false)
{
var scale = Math.Max(1f, dpi / 96f);
int S(int n) => (int)Math.Round(n * scale);
// Tailnet is a subdivision of the existing speed area, not another
// dashboard row. Fit the complete canvas even on a small/high-DPI screen.
var verticalScale = Math.Min(1f, Math.Max(1, viewport.Height) / (614f * scale));
var verticalScale = Math.Min(1f, Math.Max(1, viewport.Height) / ((showServerTraffic ? 718f : 614f) * scale));
int Y(int n) => Math.Max(1, (int)Math.Floor(n * scale * verticalScale));
var margin = S(20);
var gap = Y(10);
@@ -43,23 +43,26 @@ internal static class DashboardLayout
speed ? Math.Min(Y(82), parent.Height - Y(44)) : Y(82));
// Relative to their matching chart card: totals together; speeds together.
Rectangle[] metrics = [Metric(daily, 0, false), Metric(traffic, 0, true), Metric(traffic, 1, true), Metric(daily, 1, false)];
var footer = new Rectangle(margin, daily.Bottom + gap, width, Y(76));
var serverTraffic = showServerTraffic ? new Rectangle(margin, daily.Bottom + gap, width, Y(94)) : Rectangle.Empty;
var footer = new Rectangle(margin, (showServerTraffic ? serverTraffic.Bottom : daily.Bottom) + gap, width, Y(76));
return new(welcome, account, identity, logout, status, node, mode, metrics, traffic,
tailnet, daily, footer, Math.Min(viewport.Height, footer.Bottom + Y(12)), compact, verticalScale);
tailnet, daily, serverTraffic, footer, Math.Min(viewport.Height, footer.Bottom + Y(12)), compact, verticalScale);
}
internal static bool SelfTest()
{
foreach (var dpi in new[] { 96, 120, 144, 168, 192, 240, 288 })
foreach (var dpi in new[] { 96, 120, 144, 168, 192, 240, 288, 336, 384 })
foreach (var width in new[] { 600, 620, 739, 760, 780, 900, 1100, 1600 })
foreach (var height in new[] { 350, 418, 560, 720 })
foreach (var showTailnet in new[] { false, true })
foreach (var showServers in new[] { false, true })
{
var viewport = new Size(width * dpi / 96, height * dpi / 96);
var p = Calculate(viewport, dpi, showTailnet);
var p = Calculate(viewport, dpi, showTailnet, showServers);
Rectangle[] cards = showTailnet
? [p.StatusCard, p.NodeCard, p.ModeCard, p.TrafficCard, p.TailnetTrafficCard, p.DailyCard, p.Footer]
: [p.StatusCard, p.NodeCard, p.ModeCard, p.TrafficCard, p.DailyCard, p.Footer];
if (showServers) cards = [..cards, p.ServerTrafficCard];
if (cards.Any(c => c.Left < 0 || c.Right > viewport.Width || c.Bottom > p.ContentHeight || c.Width <= 0)) return false;
for (var i = 0; i < cards.Length; i++)
for (var j = i + 1; j < cards.Length; j++)
@@ -70,10 +73,11 @@ internal static class DashboardLayout
if (p.Metrics[i].Right > (i == 0 || i == 3 ? p.DailyCard.Width : p.TrafficCard.Width)) return false;
if (!showTailnet && p.TailnetTrafficCard != Rectangle.Empty) return false;
if (p.ContentHeight > viewport.Height || p.Footer.Bottom > viewport.Height) return false;
var baseline = Calculate(viewport, dpi, false);
var baseline = Calculate(viewport, dpi, false, showServers);
if (p.DailyCard != baseline.DailyCard || p.Footer != baseline.Footer || p.ContentHeight != baseline.ContentHeight) return false;
if (showTailnet && (p.TailnetTrafficCard.Top <= p.TrafficCard.Bottom
|| p.DailyCard.Top != p.TrafficCard.Top || p.DailyCard.Bottom != p.TailnetTrafficCard.Bottom)) return false;
if (showServers && (p.ServerTrafficCard.Top <= p.DailyCard.Bottom || p.ServerTrafficCard.Bottom >= p.Footer.Top)) return false;
}
return true;
}