Publish Zonghengjia Windows 0.3.18 client source

This commit is contained in:
2026-11-15 22:17:39 +08:00
parent ebec81ceb1
commit eb90ef4042
15 changed files with 1575 additions and 1680 deletions
+67 -66
View File
@@ -1,66 +1,67 @@
namespace UCVL.VPNPlus;
internal readonly record struct DashboardWideLayout(Rectangle Banner, Rectangle Sidebar, Rectangle Monitor,
Rectangle State, Rectangle Trend, Rectangle Servers, Rectangle Totals, Rectangle Footer)
{
// State, Trend, Servers and Totals are relative to the monitor card.
internal static DashboardWideLayout Calculate(Size size, int dpi, bool showServers)
{
int S(double logical) => (int)Math.Round(logical * dpi / 96d);
var dense = size.Height < S(465);
var margin = S(dense ? 16 : 20);
var gap = S(dense ? 8 : 12);
var width = size.Width - 2 * margin;
var banner = new Rectangle(margin, S(4), width, Math.Clamp(size.Height / 7, S(dense ? 56 : 68), S(dense ? 68 : 92)));
var footer = new Rectangle(margin, size.Height - S(dense ? 40 : 52), width, S(dense ? 32 : 40));
var middleTop = banner.Bottom + gap;
var middleHeight = footer.Top - gap - middleTop;
var leftWidth = Math.Clamp((int)(width * .252), S(212), S(320));
var sidebar = new Rectangle(margin, middleTop, leftWidth, middleHeight);
var monitor = new Rectangle(sidebar.Right + gap, middleTop, width - leftWidth - gap, middleHeight);
var inset = S(dense ? 6 : 8);
var innerWidth = monitor.Width - 2 * inset;
var state = new Rectangle(inset, inset, innerWidth, S(dense ? 36 : 44));
var totalHeight = S(dense ? 45 : 62);
var totals = new Rectangle(inset, monitor.Height - inset - totalHeight, innerWidth, totalHeight);
var serverHeight = showServers ? Math.Clamp(monitor.Height / 4, S(dense ? 66 : 90), S(dense ? 100 : 144)) : 0;
var servers = showServers
? new Rectangle(inset, totals.Top - inset - serverHeight, innerWidth, serverHeight)
: Rectangle.Empty;
var trendBottom = (showServers ? servers.Top : totals.Top) - inset;
var trend = new Rectangle(inset, state.Bottom + S(4), innerWidth, trendBottom - state.Bottom - S(4));
return new(banner, sidebar, monitor, state, trend, servers, totals, footer);
}
internal static bool SelfTest()
{
foreach (var dpi in new[] { 96, 120, 144, 192, 240, 288 })
foreach (var width in new[] { 840, 960, 1160, 1440 })
foreach (var height in new[] { 390, 420, 465, 515, 650, 850 })
foreach (var servers in new[] { false, true })
{
var size = new Size(width * dpi / 96, height * dpi / 96);
var layout = Calculate(size, dpi, servers);
Rectangle[] outer = [layout.Banner, layout.Sidebar, layout.Monitor, layout.Footer];
Rectangle[] inner = servers
? [layout.State, layout.Trend, layout.Servers, layout.Totals]
: [layout.State, layout.Trend, layout.Totals];
if (!Fits(outer, size) || !Fits(inner, layout.Monitor.Size)) return false;
var controlRows = height < 465 ? 41 : 51;
if (layout.Trend.Height <= controlRows * dpi / 96 || layout.Sidebar.Height != layout.Monitor.Height) return false;
}
return true;
static bool Fits(Rectangle[] cards, Size size)
{
var bounds = new Rectangle(Point.Empty, size);
for (var i = 0; i < cards.Length; i++)
{
if (cards[i].IsEmpty || !bounds.Contains(cards[i])) return false;
for (var j = i + 1; j < cards.Length; j++)
if (cards[i].IntersectsWith(cards[j])) return false;
}
return true;
}
}
}
namespace UCVL.VPNPlus;
internal readonly record struct DashboardWideLayout(Rectangle Banner, Rectangle Configuration, Rectangle Monitor,
Rectangle State, Rectangle Trend, Rectangle Servers, Rectangle Totals, Rectangle Footer)
{
// State belongs to the configuration card. The remaining panels belong to the monitor.
internal static DashboardWideLayout Calculate(Size size, int dpi, bool showServers, bool showManualNode = false)
{
int S(double logical) => (int)Math.Round(logical * dpi / 96d);
var dense = size.Height < S(465);
var margin = S(dense ? 13 : 20);
var gap = S(dense ? 6 : 10);
var width = size.Width - 2 * margin;
var banner = new Rectangle(margin, S(3), width, S(dense ? 53 : 62));
var footer = new Rectangle(margin, size.Height - S(dense ? 31 : 40), width, S(dense ? 25 : 31));
var middleTop = banner.Bottom + gap;
var rowHeight = S(dense ? 26 : 31);
var configuration = new Rectangle(margin, middleTop, width, rowHeight * (showManualNode ? 3 : 2) + S(10));
var stateLeft = (int)(width * .48);
var state = new Rectangle(stateLeft, S(5), width - stateLeft - S(12), rowHeight * 2);
var monitorTop = configuration.Bottom + gap;
var monitor = new Rectangle(margin, monitorTop, width, footer.Top - gap - monitorTop);
var totalHeight = S(dense ? 30 : 38);
var totals = new Rectangle(0, monitor.Height - totalHeight, width, totalHeight);
var serverHeight = showServers ? Math.Clamp(monitor.Height / 3, S(dense ? 58 : 80), S(dense ? 105 : 150)) : 0;
var servers = showServers
? new Rectangle(0, totals.Top - gap - serverHeight, width, serverHeight)
: Rectangle.Empty;
var trendBottom = (showServers ? servers.Top : totals.Top) - gap;
var trend = new Rectangle(0, 0, width, trendBottom);
return new(banner, configuration, monitor, state, trend, servers, totals, footer);
}
internal static bool SelfTest()
{
foreach (var dpi in new[] { 96, 120, 144, 192, 240, 288 })
foreach (var width in new[] { 840, 960, 1160, 1440 })
foreach (var height in new[] { 390, 420, 465, 515, 650, 850 })
foreach (var servers in new[] { false, true })
foreach (var manualNode in new[] { false, true })
{
var size = new Size(width * dpi / 96, height * dpi / 96);
var layout = Calculate(size, dpi, servers, manualNode);
Rectangle[] outer = [layout.Banner, layout.Configuration, layout.Monitor, layout.Footer];
Rectangle[] inner = servers
? [layout.Trend, layout.Servers, layout.Totals]
: [layout.Trend, layout.Totals];
if (!Fits(outer, size) || !Fits(inner, layout.Monitor.Size)
|| !new Rectangle(Point.Empty, layout.Configuration.Size).Contains(layout.State)) return false;
if (layout.Trend.Height < 80 * dpi / 96 || layout.Trend.Width != layout.Banner.Width
|| layout.Totals.Height > Math.Ceiling(38 * dpi / 96d)) return false;
}
return true;
static bool Fits(Rectangle[] cards, Size size)
{
var bounds = new Rectangle(Point.Empty, size);
for (var i = 0; i < cards.Length; i++)
{
if (cards[i].IsEmpty || !bounds.Contains(cards[i])) return false;
for (var j = i + 1; j < cards.Length; j++)
if (cards[i].IntersectsWith(cards[j])) return false;
}
return true;
}
}
}