Windows 0.2.23 clean UI-maintenance source delta; no private history or other platform changes
This commit is contained in:
@@ -146,6 +146,7 @@ internal sealed partial class MainForm
|
||||
foreach (var metric in new[] { _usageMetric, _sessionMetric, _uploadMetric, _downloadMetric }) metric.Embedded = true;
|
||||
_trafficCard.Controls.AddRange([_uploadMetric, _downloadMetric]);
|
||||
_dailyCard.Controls.AddRange([_usageMetric, _sessionMetric]);
|
||||
BuildTailnetTrafficCard();
|
||||
_dashboardBody.Controls.Add(_footer);
|
||||
foreach (var label in new[] { _welcomeLabel, _accountLabel, _statusTitle, _statusDetail, _currentNodeLabel, _planLabel, _expiryLabel })
|
||||
{
|
||||
@@ -165,13 +166,16 @@ internal sealed partial class MainForm
|
||||
_sampleLabel.Text = sampling;
|
||||
_uploadLegend.Text = upload.HasValue ? $"● 上传 {FormatBytes((long)upload.Value)}/s" : "● 上传 —";
|
||||
_downloadLegend.Text = download.HasValue ? $"● 下载 {FormatBytes((long)download.Value)}/s" : "● 下载 —";
|
||||
// Waiting/handover/error paths also invalidate the separate transport
|
||||
// view. Valid samples are supplied once by the existing traffic reader.
|
||||
if (!upload.HasValue || !download.HasValue) DisplayTailnetTraffic(null, null, sampling);
|
||||
}
|
||||
|
||||
private void LayoutDashboard()
|
||||
{
|
||||
if (_layingOutDashboard || _dashboardView.ClientSize.Width <= 0) return;
|
||||
_layingOutDashboard = true;
|
||||
Control[] layoutContainers = [_dashboardView, _dashboardBody, _statusCard, _nodeCard, _modeCard, _trafficCard, _dailyCard, _footer];
|
||||
Control[] layoutContainers = [_dashboardView, _dashboardBody, _statusCard, _nodeCard, _modeCard, _trafficCard, _tailnetTrafficCard, _dailyCard, _footer];
|
||||
foreach (var container in layoutContainers) container.SuspendLayout();
|
||||
try
|
||||
{
|
||||
@@ -179,11 +183,11 @@ internal sealed partial class MainForm
|
||||
// Explicit vertical canvas: card reflow must never retain a previous
|
||||
// horizontal extent or reset the user's scroll offset on repaint.
|
||||
var viewport = _dashboardView.ClientSize;
|
||||
var layout = DashboardLayout.Calculate(viewport, DeviceDpi);
|
||||
var layout = DashboardLayout.Calculate(viewport, DeviceDpi, _tailnetTrafficVisible);
|
||||
_dashboardScrollBar.Visible = layout.ContentHeight > viewport.Height;
|
||||
_dashboardScrollBar.Bounds = new Rectangle(viewport.Width - ScaleLogical(17), 0, ScaleLogical(17), viewport.Height);
|
||||
if (_dashboardScrollBar.Visible)
|
||||
layout = DashboardLayout.Calculate(new Size(viewport.Width - ScaleLogical(17), viewport.Height), DeviceDpi);
|
||||
layout = DashboardLayout.Calculate(new Size(viewport.Width - ScaleLogical(17), viewport.Height), DeviceDpi, _tailnetTrafficVisible);
|
||||
void Place(Control c, Rectangle r) { c.Bounds = r; }
|
||||
Rectangle R(int x, int y, int w, int h) => new(ScaleLogical(x), ScaleLogical(y), ScaleLogical(w), ScaleLogical(h));
|
||||
Place(_welcomeLabel, layout.WelcomeLabel); Place(_accountLabel, layout.AccountLabel);
|
||||
@@ -192,6 +196,7 @@ internal sealed partial class MainForm
|
||||
var metrics = new[] { _usageMetric, _uploadMetric, _downloadMetric, _sessionMetric };
|
||||
for (var i = 0; i < 4; i++) Place(metrics[i], layout.Metrics[i]);
|
||||
Place(_trafficCard, layout.TrafficCard); Place(_dailyCard, layout.DailyCard); Place(_footer, layout.Footer);
|
||||
LayoutTailnetTrafficCard(layout.TailnetTrafficCard);
|
||||
|
||||
_statusDot.Bounds = R(24, 15, 42, 46);
|
||||
_connectButton.Bounds = new(_statusCard.Width - ScaleLogical(148), ScaleLogical(17), ScaleLogical(130), ScaleLogical(42));
|
||||
@@ -216,13 +221,14 @@ internal sealed partial class MainForm
|
||||
_dailyHeading.Bounds = new(ScaleLogical(42), ScaleLogical(8), _dailyCard.Width - ScaleLogical(180), ScaleLogical(26));
|
||||
_historyRangeCombo.Bounds = new(_dailyCard.Width - ScaleLogical(140), ScaleLogical(10), ScaleLogical(124), ScaleLogical(26));
|
||||
_trafficChart.Bounds = new(ScaleLogical(13), ScaleLogical(132), _trafficCard.Width - ScaleLogical(26), ScaleLogical(106));
|
||||
_dailyChart.Bounds = new(ScaleLogical(13), ScaleLogical(132), _dailyCard.Width - ScaleLogical(26), ScaleLogical(106));
|
||||
_dailyChart.Bounds = new(ScaleLogical(13), ScaleLogical(132), _dailyCard.Width - ScaleLogical(26), _dailyCard.Height - ScaleLogical(170));
|
||||
var legendWidth = (_trafficCard.Width - ScaleLogical(40)) / 2;
|
||||
_uploadLegend.Bounds = new(ScaleLogical(20), ScaleLogical(248), legendWidth, ScaleLogical(19));
|
||||
_downloadLegend.Bounds = new(ScaleLogical(20) + legendWidth, ScaleLogical(248), legendWidth, ScaleLogical(19));
|
||||
_dailyUploadLegend.Bounds = new(ScaleLogical(20), ScaleLogical(248), ScaleLogical(52), ScaleLogical(19));
|
||||
_dailyDownloadLegend.Bounds = new(ScaleLogical(76), ScaleLogical(248), ScaleLogical(52), ScaleLogical(19));
|
||||
_historyStatus.Bounds = new(ScaleLogical(134), ScaleLogical(248), _dailyCard.Width - ScaleLogical(148), ScaleLogical(19));
|
||||
var dailyLegendTop = _dailyCard.Height - ScaleLogical(28);
|
||||
_dailyUploadLegend.Bounds = new(ScaleLogical(20), dailyLegendTop, ScaleLogical(52), ScaleLogical(19));
|
||||
_dailyDownloadLegend.Bounds = new(ScaleLogical(76), dailyLegendTop, ScaleLogical(52), ScaleLogical(19));
|
||||
_historyStatus.Bounds = new(ScaleLogical(134), dailyLegendTop, _dailyCard.Width - ScaleLogical(148), ScaleLogical(19));
|
||||
_planLabel.Bounds = R(0, 4, 300, 26);
|
||||
_expiryLabel.Bounds = R(306, 4, 132, 26);
|
||||
_footerCompanyLogo.Bounds = R(0, 34, 32, 34);
|
||||
@@ -278,7 +284,7 @@ internal sealed partial class MainForm
|
||||
for (var i = 0; i < 60; i++) form._trafficChart.Add((i % 13 == 0 ? 72 : 8 + Math.Sin(i * 1.8) * 4) * 1024,
|
||||
(i % 9 == 2 ? 130 : 10 + Math.Sin(i * 2.4) * 8) * 1024, DateTimeOffset.Now.AddSeconds((i - 59) * 5));
|
||||
form.LayoutBrandHeader(); form.LayoutDashboard();
|
||||
var checks = new Dictionary<string, bool> { ["geometry_56_viewport_dpi_cases"] = DashboardLayout.SelfTest() };
|
||||
var checks = new Dictionary<string, bool> { ["geometry_112_viewport_dpi_cases"] = DashboardLayout.SelfTest() };
|
||||
foreach (var check in UsageHistorySeries.SelfTest()) checks[check.Key] = check.Value;
|
||||
void Capture(string suffix)
|
||||
{
|
||||
@@ -358,6 +364,39 @@ internal sealed partial class MainForm
|
||||
form.SetConnectionState(true, "已安全连接", "手动指定节点 · AI 智能代理");
|
||||
Capture("manual-connected");
|
||||
checks["manual_connected_selection_locked"] = !form._connectionModeCombo.Enabled && !form._manualNodeCombo.Visible;
|
||||
// Synthetic preview of the same already-accounted proxy sample on a
|
||||
// Tailnet connection. Use a taller fixture to show both left cards;
|
||||
// this does not change the production window size or claim live data.
|
||||
form._connectionModeCombo.SelectedIndex = 0;
|
||||
form._currentNodeBaseName = "VPN003";
|
||||
form.UpdateConnectedTransportPresentation(true);
|
||||
form.SetConnectionState(true, "已安全连接", form._currentNodeName + " · AI 智能代理");
|
||||
form._currentNodeLabel.Text = form._currentNodeName;
|
||||
form._dailyChart.SetHistory([], fixtureRanges);
|
||||
form.ClientSize = new Size(form.ScaleLogical(900), form.ScaleLogical(1020));
|
||||
form._trafficChart.Reset();
|
||||
form.ResetTailnetTraffic();
|
||||
for (var i = 0; i < 60; i++)
|
||||
{
|
||||
var up = (i % 13 == 0 ? 72 : 8 + Math.Sin(i * 1.8) * 4) * 1024;
|
||||
var down = (i % 9 == 2 ? 130 : 10 + Math.Sin(i * 2.4) * 8) * 1024;
|
||||
var sampledAt = DateTimeOffset.Now.AddSeconds((i - 59) * 5);
|
||||
form._trafficChart.Add(up, down, sampledAt);
|
||||
form._tailnetTrafficChart.Add(up, down, sampledAt);
|
||||
}
|
||||
form.DisplayTraffic(23842, 89312, "演示样本 · 近 5 分钟");
|
||||
form.DisplayTailnetTraffic(23842, 89312, "演示样本 · 近 5 分钟");
|
||||
Capture("tailnet-dashboard");
|
||||
checks["tailnet_wide_preview_has_left_two_right_one"] = form._dailyCard.Top == form._trafficCard.Top
|
||||
&& form._dailyCard.Bottom == form._tailnetTrafficCard.Bottom;
|
||||
form.Size = form.MinimumSize;
|
||||
Capture("tailnet-compact");
|
||||
form._dashboardScrollBar.Value = Math.Max(0, form._dashboardScrollBar.Maximum - form._dashboardScrollBar.LargeChange + 1);
|
||||
Capture("tailnet-compact-scrolled");
|
||||
checks["tailnet_compact_preview_footer_reachable"] = form._footer.RectangleToScreen(form._footer.ClientRectangle).Bottom
|
||||
<= form._dashboardView.RectangleToScreen(form._dashboardView.ClientRectangle).Bottom;
|
||||
form.SetTailnetTrafficVisibility(false);
|
||||
form.ClientSize = new Size(form.ScaleLogical(900), form.ScaleLogical(640));
|
||||
form.ShowLogin(); Capture("login");
|
||||
checks["login_fields_visible"] = form.LoginFieldsVisibleForTest;
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "dashboard-ui-self-test.json"), JsonSerializer.Serialize(new
|
||||
@@ -369,6 +408,7 @@ internal sealed partial class MainForm
|
||||
if (checks.Values.Any(v => !v)) throw new InvalidOperationException("Dashboard UI self-test failed; inspect dashboard-ui-self-test.json");
|
||||
}
|
||||
|
||||
private bool DashboardControlsFit() => new Control[] { _statusCard, _nodeCard, _modeCard, _trafficCard, _dailyCard, _footer }
|
||||
private bool DashboardControlsFit() => new Control[] { _statusCard, _nodeCard, _modeCard, _trafficCard, _tailnetTrafficCard, _dailyCard, _footer }
|
||||
.Where(parent => parent.Visible)
|
||||
.All(parent => parent.Controls.Cast<Control>().Where(c => c.Visible).All(c => c.Left >= 0 && c.Top >= 0 && c.Right <= parent.ClientSize.Width && c.Bottom <= parent.ClientSize.Height));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user