Windows 0.2.23 clean UI-maintenance source delta; no private history or other platform changes
This commit is contained in:
@@ -3,13 +3,13 @@ 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 DailyCard, Rectangle Footer,
|
||||
Rectangle[] Metrics, Rectangle TrafficCard, Rectangle TailnetTrafficCard, Rectangle DailyCard, Rectangle Footer,
|
||||
int ContentHeight, bool Compact);
|
||||
|
||||
// Logical pixels converted once, independent of WinForms autoscaling.
|
||||
internal static class DashboardLayout
|
||||
{
|
||||
internal static DashboardGeometry Calculate(Size viewport, int dpi)
|
||||
internal static DashboardGeometry Calculate(Size viewport, int dpi, bool showTailnet = false)
|
||||
{
|
||||
var scale = Math.Max(1f, dpi / 96f);
|
||||
int S(int n) => (int)Math.Round(n * scale);
|
||||
@@ -28,25 +28,30 @@ internal static class DashboardLayout
|
||||
? new Rectangle(margin, node.Bottom + gap, width, node.Height)
|
||||
: new Rectangle(node.Right + gap, node.Top, width - half - gap, node.Height);
|
||||
var traffic = new Rectangle(margin, mode.Bottom + gap, compact ? width : half, S(276));
|
||||
var tailnet = showTailnet ? new Rectangle(traffic.Left, traffic.Bottom + gap, traffic.Width, traffic.Height) : Rectangle.Empty;
|
||||
var daily = compact
|
||||
? new Rectangle(margin, traffic.Bottom + gap, width, traffic.Height)
|
||||
: new Rectangle(traffic.Right + gap, traffic.Top, width - half - gap, traffic.Height);
|
||||
? new Rectangle(margin, (showTailnet ? tailnet.Bottom : traffic.Bottom) + gap, width, traffic.Height)
|
||||
: new Rectangle(traffic.Right + gap, traffic.Top, width - half - gap,
|
||||
showTailnet ? tailnet.Bottom - traffic.Top : traffic.Height);
|
||||
Rectangle Metric(Rectangle parent, int column) => new(S(14) + column * ((parent.Width - S(28)) / 2), S(43), (parent.Width - S(28)) / 2 - S(2), S(82));
|
||||
// Relative to their matching chart card: totals together; speeds together.
|
||||
Rectangle[] metrics = [Metric(daily, 0), Metric(traffic, 0), Metric(traffic, 1), Metric(daily, 1)];
|
||||
var footer = new Rectangle(margin, daily.Bottom + gap, width, S(76));
|
||||
return new(welcome, account, identity, logout, status, node, mode, metrics, traffic,
|
||||
daily, footer, footer.Bottom + S(12), compact);
|
||||
tailnet, daily, footer, footer.Bottom + S(12), compact);
|
||||
}
|
||||
|
||||
internal static bool SelfTest()
|
||||
{
|
||||
foreach (var dpi in new[] { 96, 120, 144, 168, 192, 240, 288 })
|
||||
foreach (var width in new[] { 600, 620, 739, 760, 780, 900, 1100, 1600 })
|
||||
foreach (var showTailnet in new[] { false, true })
|
||||
{
|
||||
var viewport = new Size(width * dpi / 96, 560 * dpi / 96);
|
||||
var p = Calculate(viewport, dpi);
|
||||
Rectangle[] cards = [p.StatusCard, p.NodeCard, p.ModeCard, p.TrafficCard, p.DailyCard, p.Footer];
|
||||
var p = Calculate(viewport, dpi, showTailnet);
|
||||
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 (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++)
|
||||
@@ -55,6 +60,10 @@ internal static class DashboardLayout
|
||||
if (p.Metrics[0].IntersectsWith(p.Metrics[3]) || p.Metrics[1].IntersectsWith(p.Metrics[2])) return false;
|
||||
for (var i = 0; i < p.Metrics.Length; i++)
|
||||
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 (showTailnet && (p.TailnetTrafficCard.Top <= p.TrafficCard.Bottom
|
||||
|| p.Compact && p.DailyCard.Top <= p.TailnetTrafficCard.Bottom
|
||||
|| !p.Compact && (p.DailyCard.Top != p.TrafficCard.Top || p.DailyCard.Bottom != p.TailnetTrafficCard.Bottom))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user