Windows 0.3.0 clean next-generation source delta; no private history or other platform changes

This commit is contained in:
2026-10-22 05:43:39 +00:00
parent ac650ed51d
commit 366b3c5c9a
31 changed files with 2036 additions and 323 deletions
+77 -75
View File
@@ -9,7 +9,6 @@ internal sealed partial class MainForm
private readonly Label _sampleLabel = new();
private readonly Label _uploadLegend = new();
private readonly Label _downloadLegend = new();
private readonly Label _dailyUploadLegend = new(), _dailyDownloadLegend = new();
private readonly Label _historyStatus = new();
private readonly ReadOnlyModeLabel _routeReadOnly = new();
private readonly ComboBox _historyRangeCombo = new();
@@ -29,7 +28,11 @@ internal sealed partial class MainForm
private readonly DashboardGlyph _trafficIcon = new(DashboardIcon.Chart), _dailyIcon = new(DashboardIcon.History);
private readonly Label _trafficHeading = new(), _dailyHeading = new();
private bool _layingOutDashboard;
private DashboardWheelRouter? _dashboardWheelRouter;
private sealed record SpeedHistoryPeriod(int Minutes, string Label)
{
public override string ToString() => Label;
internal static readonly SpeedHistoryPeriod[] All = [new(1, "近 1 分钟"), new(5, "近 5 分钟"), new(15, "近 15 分钟"), new(60, "近 1 小时")];
}
private void BuildDashboardView()
{
@@ -71,7 +74,7 @@ internal sealed partial class MainForm
_statusDot.ForeColor = Brand.Muted;
_statusCard.ScenicStatus = true;
_nodeCard.AccentBar = _modeCard.AccentBar = true;
_trafficCard.MetricBand = _dailyCard.MetricBand = true;
_trafficCard.MetricBand = _dailyCard.MetricBand = false;
ConfigurePrimaryButton(_connectButton, "连接", Point.Empty, new(130, 42));
_connectButton.Click += async (_, _) =>
{
@@ -91,20 +94,21 @@ internal sealed partial class MainForm
_routeReadOnly.Visible = false;
_modeCard.Controls.AddRange([_modeIcon, _routeHeading, _routeCombo, _routeReadOnly]);
ConfigureLabel(_trafficHeading, "实时网速", Brand.Font(9.5f, FontStyle.Bold), Brand.Text);
ConfigureLabel(_dailyHeading, "代理流量", Brand.Font(9.5f, FontStyle.Bold), Brand.Text);
ConfigureLabel(_trafficHeading, "代理实时速度", Brand.Font(9.5f, FontStyle.Bold), Brand.Text);
ConfigureLabel(_dailyHeading, "速度与累计", Brand.Font(9.5f, FontStyle.Bold), Brand.Text);
ConfigureLabel(_sampleLabel, "仅代理流量 · 近 5 分钟", Brand.Font(7.5f), Brand.Muted);
_sampleLabel.TextAlign = ContentAlignment.MiddleRight;
ConfigureLabel(_uploadLegend, "● 上传 —", Brand.Font(8), Brand.RoyalBlue);
ConfigureLabel(_downloadLegend, "● 下载 —", Brand.Font(8), Brand.Cyan);
ConfigureLabel(_dailyUploadLegend, "● 上传", Brand.Font(8), Brand.RoyalBlue);
ConfigureLabel(_dailyDownloadLegend, "● 下载", Brand.Font(8), Brand.Cyan);
ConfigureLabel(_historyStatus, "套餐全部设备 · 按天统计", Brand.Font(7), Brand.Muted);
ConfigureLabel(_historyStatus, "仅本次运行采样 · B/s", Brand.Font(7), Brand.Muted);
_historyStatus.AutoEllipsis = true;
_historyStatus.TextAlign = ContentAlignment.MiddleRight;
_dailyChart.HistoryChanged += () => { _historyStatus.Text = _dailyChart.StatusText; _historyStatus.AccessibleDescription = _dailyChart.DetailText; };
_trafficCard.Controls.AddRange([_trafficIcon, _trafficHeading, _sampleLabel, _trafficChart, _uploadLegend, _downloadLegend]);
_dailyCard.Controls.AddRange([_dailyIcon, _dailyHeading, _dailyChart, _dailyUploadLegend, _dailyDownloadLegend]);
_historyStatus.AccessibleDescription = "右侧曲线仅为当前客户端实际采集的代理速度。累计数值来自套餐和本次连接,不随速度时间范围改变。";
_trafficCard.Controls.AddRange([_trafficIcon, _trafficHeading]);
_dailyCard.Controls.AddRange([_dailyIcon, _dailyHeading, _trafficChart, _uploadLegend, _downloadLegend]);
// Keep backend accounting data available to UpdateProfile, but daily
// byte totals are no longer drawn as a misleading speed history.
_dailyChart.Visible = false;
ConfigureCombo(_historyRangeCombo, Point.Empty, new(120, 28));
_historyRangeCombo.BackColor = Color.White;
_historyRangeCombo.Font = Brand.Font(8.5f);
@@ -119,12 +123,12 @@ internal sealed partial class MainForm
e.Bounds, Brand.Text, TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.EndEllipsis);
e.DrawFocusRectangle();
};
_historyRangeCombo.AccessibleName = "代理流量历史时间范围";
_historyRangeCombo.Items.AddRange(UsageHistoryPeriod.All);
_historyRangeCombo.SelectedItem = UsageHistoryPeriod.All[2];
_historyRangeCombo.AccessibleName = "代理实时速度时间范围";
_historyRangeCombo.Items.AddRange(SpeedHistoryPeriod.All);
_historyRangeCombo.SelectedItem = SpeedHistoryPeriod.All[1];
_historyRangeCombo.SelectedIndexChanged += (_, _) =>
{
if (_historyRangeCombo.SelectedItem is UsageHistoryPeriod period) _dailyChart.SetPeriod(period);
if (_historyRangeCombo.SelectedItem is SpeedHistoryPeriod period) _trafficChart.SetPeriodMinutes(period.Minutes);
};
_dailyCard.Controls.AddRange([_historyRangeCombo, _historyStatus]);
ConfigureLabel(_planLabel, "", Brand.Font(8.5f), Brand.Muted);
@@ -155,14 +159,15 @@ internal sealed partial class MainForm
}
_sessionMetric.SetBytes(0, hint: "本次连接累计");
DisplayTraffic(null, null, "仅代理流量 · 近 5 分钟");
_dashboardWheelRouter = new DashboardWheelRouter(_dashboardView, _dashboardScrollBar);
// The dashboard is one fitted page; no hidden vertical or horizontal
// canvas is introduced by Tailnet, and mouse-wheel cannot shift it.
LayoutDashboard();
}
private void DisplayTraffic(double? upload, double? download, string sampling)
{
_uploadMetric.SetBytes(upload, speed: true);
_downloadMetric.SetBytes(download, speed: true);
_uploadMetric.SetBytes(upload, speed: true, hint: "");
_downloadMetric.SetBytes(download, speed: true, hint: "");
_sampleLabel.Text = sampling;
_uploadLegend.Text = upload.HasValue ? $"● 上传 {FormatBytes((long)upload.Value)}/s" : "● 上传 —";
_downloadLegend.Text = download.HasValue ? $"● 下载 {FormatBytes((long)download.Value)}/s" : "● 下载 —";
@@ -179,71 +184,66 @@ internal sealed partial class MainForm
foreach (var container in layoutContainers) container.SuspendLayout();
try
{
var previousScroll = _dashboardScrollBar.Value;
// 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, _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, _tailnetTrafficVisible);
var titleSize = 17f * Math.Max(.7f, layout.VerticalScale);
if (Math.Abs(_statusTitle.Font.Size - titleSize) > .1f)
{
var previousTitleFont = _statusTitle.Font;
_statusTitle.Font = Brand.Font(titleSize, FontStyle.Bold);
previousTitleFont.Dispose();
}
_dashboardScrollBar.Visible = false;
_dashboardScrollBar.Value = 0;
_dashboardScrollBar.Maximum = 0;
int Y(int value) => Math.Max(0, (int)Math.Floor(ScaleLogical(value) * layout.VerticalScale));
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));
Rectangle R(int x, int y, int w, int h) => new(ScaleLogical(x), Y(y), ScaleLogical(w), Y(h));
Place(_welcomeLabel, layout.WelcomeLabel); Place(_accountLabel, layout.AccountLabel);
Place(_identityBadge, layout.IdentityBadge); Place(_logoutButton, layout.LogoutButton);
Place(_statusCard, layout.StatusCard); Place(_nodeCard, layout.NodeCard); Place(_modeCard, layout.ModeCard);
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);
LayoutTailnetTrafficCard(layout.TailnetTrafficCard, layout.VerticalScale);
_statusDot.Bounds = R(24, 15, 42, 46);
_connectButton.Bounds = new(_statusCard.Width - ScaleLogical(148), ScaleLogical(17), ScaleLogical(130), ScaleLogical(42));
_connectButton.Bounds = new(_statusCard.Width - ScaleLogical(148), Y(17), ScaleLogical(130), Y(42));
var textWidth = _connectButton.Left - ScaleLogical(100);
_statusTitle.Bounds = new(ScaleLogical(84), ScaleLogical(10), textWidth, ScaleLogical(33));
_statusDetail.Bounds = new(ScaleLogical(85), ScaleLogical(43), textWidth, ScaleLogical(25));
_statusTitle.Bounds = new(ScaleLogical(84), Y(10), textWidth, Y(33));
_statusDetail.Bounds = new(ScaleLogical(85), Y(43), textWidth, Y(25));
_nodeIcon.Bounds = R(26, 23, 24, 24); _modeIcon.Bounds = R(26, 23, 24, 24);
_nodeHeading.Bounds = new(ScaleLogical(54), ScaleLogical(9), Math.Max(0, _nodeCard.Width - ScaleLogical(205)), ScaleLogical(23));
_connectionModeCombo.Bounds = new(_nodeCard.Width - ScaleLogical(144), ScaleLogical(6), ScaleLogical(130), ScaleLogical(28));
_manualNodeCombo.Bounds = new(ScaleLogical(54), ScaleLogical(34), _nodeCard.Width - ScaleLogical(68), ScaleLogical(28));
_nodeHeading.Bounds = new(ScaleLogical(54), Y(9), Math.Max(0, _nodeCard.Width - ScaleLogical(205)), Y(23));
_nodeHeading.Text = layout.Compact ? "工作节点" : "当前工作节点";
_connectionModeCombo.Bounds = new(_nodeCard.Width - ScaleLogical(144), Y(6), ScaleLogical(130), Y(28));
_manualNodeCombo.Bounds = new(ScaleLogical(54), Y(34), _nodeCard.Width - ScaleLogical(68), Y(28));
var badgeWidth = ScaleLogical(88);
var badgeX = _nodeCard.Width - badgeWidth - ScaleLogical(14);
_currentNodeLabel.Bounds = new(ScaleLogical(54), ScaleLogical(34),
_selectionUiConnected ? _nodeCard.Width - ScaleLogical(68) : badgeX - ScaleLogical(60), ScaleLogical(27));
_scheduleBadge.Bounds = new(badgeX, ScaleLogical(35), badgeWidth, ScaleLogical(23));
_routeHeading.Bounds = new(ScaleLogical(54), ScaleLogical(8), _modeCard.Width - ScaleLogical(70), ScaleLogical(22));
_routeCombo.Bounds = new(ScaleLogical(54), ScaleLogical(33), _modeCard.Width - ScaleLogical(70), ScaleLogical(28));
_routeReadOnly.Bounds = new(_routeCombo.Left, _routeCombo.Top, _routeCombo.Width, ScaleLogical(28));
_currentNodeLabel.Bounds = new(ScaleLogical(54), Y(34),
_selectionUiConnected ? _nodeCard.Width - ScaleLogical(68) : badgeX - ScaleLogical(60), Y(27));
_scheduleBadge.Bounds = new(badgeX, Y(35), badgeWidth, Y(23));
_routeHeading.Bounds = new(ScaleLogical(54), Y(8), _modeCard.Width - ScaleLogical(70), Y(22));
_routeCombo.Bounds = new(ScaleLogical(54), Y(33), _modeCard.Width - ScaleLogical(70), Y(28));
_routeReadOnly.Bounds = new(_routeCombo.Left, _routeCombo.Top, _routeCombo.Width, Y(28));
_trafficIcon.Bounds = R(15, 10, 20, 20); _dailyIcon.Bounds = R(15, 10, 20, 20);
_trafficHeading.Bounds = R(42, 8, 92, 26);
_sampleLabel.Bounds = new(ScaleLogical(132), ScaleLogical(10), _trafficCard.Width - ScaleLogical(146), ScaleLogical(22));
_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), _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));
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));
_dailyHeading.Bounds = new(ScaleLogical(42), Y(8), Math.Max(1, _dailyCard.Width - ScaleLogical(166)), Y(26));
_historyRangeCombo.Bounds = new(_dailyCard.Width - ScaleLogical(120), Y(8), ScaleLogical(106), Y(26));
_trafficChart.Bounds = new(ScaleLogical(10), Y(127), _dailyCard.Width - ScaleLogical(20), Y(105));
var legendWidth = (_dailyCard.Width - ScaleLogical(28)) / 2;
_uploadLegend.Bounds = new(ScaleLogical(14), Y(234), legendWidth, Y(19));
_downloadLegend.Bounds = new(ScaleLogical(14) + legendWidth, Y(234), legendWidth, Y(19));
_historyStatus.Bounds = new(ScaleLogical(14), Y(255), _dailyCard.Width - ScaleLogical(28), Y(17));
_planLabel.Bounds = R(0, 4, 300, 26);
_expiryLabel.Bounds = R(306, 4, 132, 26);
_footerCompanyLogo.Bounds = R(0, 34, 32, 34);
_footerCompanySite.Bounds = R(0, 41, 220, 22);
_footerHint.Visible = true;
_footerHint.Bounds = new(ScaleLogical(232), ScaleLogical(39), Math.Max(1, _footer.Width - ScaleLogical(232)), ScaleLogical(28));
_footerHint.Bounds = new(ScaleLogical(232), Y(39), Math.Max(1, _footer.Width - ScaleLogical(232)), Y(28));
_footerPoem.Visible = !layout.Compact && _footer.Width >= ScaleLogical(780);
_footerPoem.Bounds = new(_footer.Width - ScaleLogical(322), ScaleLogical(5), ScaleLogical(322), ScaleLogical(29));
_dashboardBody.Size = new Size(layout.StatusCard.Right + ScaleLogical(20), layout.ContentHeight);
_dashboardScrollBar.Maximum = Math.Max(0, layout.ContentHeight - 1);
_dashboardScrollBar.LargeChange = Math.Max(1, viewport.Height);
_dashboardScrollBar.SmallChange = ScaleLogical(28);
_dashboardScrollBar.Value = Math.Clamp(previousScroll, 0, Math.Max(0, layout.ContentHeight - viewport.Height));
_dashboardBody.Location = new Point(0, -_dashboardScrollBar.Value);
_dashboardScrollBar.BringToFront();
_footerPoem.Bounds = new(_footer.Width - ScaleLogical(322), Y(5), ScaleLogical(322), Y(29));
_dashboardBody.Size = viewport;
_dashboardBody.Location = Point.Empty;
}
finally
{
@@ -314,26 +314,29 @@ internal sealed partial class MainForm
checks["content_uses_local_buffers_not_composited_subtree"] = !form._content.ComposeChildren;
checks["dashboard_reuses_login_backdrop"] = form._dashboardView.LoginArtwork && form._dashboardBody.ParentArtwork;
checks["header_only_has_minimize_button"] = form._brandHeader.Controls.OfType<CaptionButton>().Count() == 1;
checks["scenic_asset_is_decoration_only"] = form._brandHeader.BackgroundImage is null && form._trafficChart.Parent == form._trafficCard;
checks["scenic_asset_is_decoration_only"] = form._brandHeader.BackgroundImage is null && form._trafficChart.Parent == form._dailyCard;
checks["scenic_artwork_packaged_in_exe"] = ScenicTheme.ArtworkAvailable;
checks["footer_poem_does_not_overlap_plan"] = !form._footerPoem.Visible || form._footerPoem.Left > form._expiryLabel.Right;
checks["internal_use_notice_visible"] = form._footerHint.Text == "仅限内部使用,不作商业使用。" && form._footerHint.Visible;
checks["proxy_metrics_values"] = form._usageMetric.UnitText == "GB" && form._uploadMetric.UnitText == "KB/s" && form._sessionMetric.UnitText == "MB";
checks["related_metrics_share_chart_parent"] = form._usageMetric.Parent == form._sessionMetric.Parent &&
form._uploadMetric.Parent == form._trafficChart.Parent && form._downloadMetric.Parent == form._trafficChart.Parent;
checks["speed_figures_left_curve_and_totals_right"] = form._usageMetric.Parent == form._sessionMetric.Parent
&& form._usageMetric.Parent == form._trafficChart.Parent && form._uploadMetric.Parent == form._trafficCard
&& form._downloadMetric.Parent == form._trafficCard;
form._historyRangeCombo.SelectedIndex = 0;
Capture("history-legacy-unavailable");
checks["legacy_hourly_no_invented_curve"] = form._dailyChart.PointCount == 0;
checks["daily_accounting_curve_no_longer_displayed"] = form._dailyChart.Parent is null && !form._dailyChart.Visible;
form._dailyChart.SetHistory([], fixtureRanges);
foreach (var period in UsageHistoryPeriod.All)
var retainedSampleCount = form._trafficChart.PointCount;
foreach (var period in SpeedHistoryPeriod.All)
{
form._historyRangeCombo.SelectedItem = period;
Capture("history-" + period.Key);
checks["filter_" + period.Key] = form._dailyChart.SelectedRange == period.Key && form._dailyChart.PointCount == period.Count;
Capture("speed-" + period.Minutes + "m");
checks["speed_filter_" + period.Minutes] = form._trafficChart.PeriodMinutes == period.Minutes
&& form._trafficChart.PointCount == retainedSampleCount;
}
form._dailyChart.SetHistory([], fixtureRanges);
checks["profile_refresh_preserves_filter"] = form._dailyChart.SelectedRange == "30d";
form._historyRangeCombo.SelectedIndex = 2;
checks["profile_refresh_preserves_speed_filter"] = form._trafficChart.PeriodMinutes == 60;
form._historyRangeCombo.SelectedIndex = 1;
form.Size = form.MinimumSize;
Capture("compact");
checks["zero3_compact_name_fits"] = TextRenderer.MeasureText(form._currentNodeName, form._currentNodeLabel.Font).Width <= form._currentNodeLabel.Width;
@@ -341,7 +344,8 @@ internal sealed partial class MainForm
form._dashboardScrollBar.Value = Math.Max(0, form._dashboardScrollBar.Maximum - form._dashboardScrollBar.LargeChange + 1);
Application.DoEvents();
form.LayoutDashboard();
checks["compact_footer_scrolls_into_view"] = form._footer.RectangleToScreen(form._footer.ClientRectangle).Bottom <= form._dashboardView.RectangleToScreen(form._dashboardView.ClientRectangle).Bottom;
checks["compact_footer_fits_without_scroll"] = !form._dashboardScrollBar.Visible
&& form._footer.RectangleToScreen(form._footer.ClientRectangle).Bottom <= form._dashboardView.RectangleToScreen(form._dashboardView.ClientRectangle).Bottom;
checks["compact_no_horizontal_scrollbar"] = !form._dashboardView.HorizontalScroll.Visible;
Capture("compact-scrolled");
form._dashboardScrollBar.Value = 0;
@@ -364,16 +368,15 @@ 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.
// Same window dimensions with or without Tailnet: only the left speed
// region is subdivided. Synthetic samples do not claim live acceptance.
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.ClientSize = new Size(form.ScaleLogical(900), form.ScaleLogical(640));
form._trafficChart.Reset();
form.ResetTailnetTraffic();
for (var i = 0; i < 60; i++)
@@ -382,7 +385,6 @@ internal sealed partial class MainForm
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 分钟");