Windows 0.2.23 clean UI-maintenance source delta; no private history or other platform changes
This commit is contained in:
@@ -14,7 +14,7 @@ internal static class DashboardInteractionSelfTest
|
||||
foreach (var check in form.CheckDashboardInteraction()) checks.Add(check.Key, check.Value);
|
||||
}
|
||||
catch (Exception exception) { error = exception.ToString(); }
|
||||
var passed = error is null && checks.Count >= 15 && checks.Values.All(value => value);
|
||||
var passed = error is null && checks.Count >= 43 && checks.Values.All(value => value);
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "dashboard-interaction-self-test.json"),
|
||||
JsonSerializer.Serialize(new { passed, checks, error, scope = "owned synthetic WinForms fixture; no physical user-input or production acceptance claim",
|
||||
network_modified = false, installed_client_modified = false, credentials_loaded = false }, new JsonSerializerOptions { WriteIndented = true }));
|
||||
@@ -96,6 +96,7 @@ internal sealed partial class MainForm
|
||||
checks["card_surface_is_half_transparent"] = CardPanel.SurfaceAlpha == 128;
|
||||
checks["whole_content_composition_disabled"] = !_content.ComposeChildren;
|
||||
checks["metric_dirty_refresh_clears_previous_digits"] = CheckMetricRefreshPaint();
|
||||
foreach (var check in CheckTailnetTrafficUi()) checks.Add(check.Key, check.Value);
|
||||
ShowLogin();
|
||||
checks["hidden_dashboard_does_not_consume_login_wheel"] = !Wheel(_loginText, -120);
|
||||
RequestExit();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
namespace UCVL.VPNPlus;
|
||||
|
||||
internal sealed partial class MainForm
|
||||
{
|
||||
// UI fixture only: independent supplied values, no adapter/core/route reads.
|
||||
internal Dictionary<string, bool> CheckTailnetTrafficUi()
|
||||
{
|
||||
var checks = new Dictionary<string, bool>();
|
||||
int TailnetPoints()
|
||||
{
|
||||
var queue = typeof(TrafficChart).GetField("_points", System.Reflection.BindingFlags.Instance
|
||||
| System.Reflection.BindingFlags.NonPublic)!.GetValue(_tailnetTrafficChart)!;
|
||||
return (int)queue.GetType().GetProperty("Count")!.GetValue(queue)!;
|
||||
}
|
||||
var originalSize = ClientSize;
|
||||
SetTailnetTrafficVisibility(false);
|
||||
ClientSize = new Size(ScaleLogical(960), ScaleLogical(720));
|
||||
LayoutDashboard();
|
||||
var baseTraffic = _trafficCard.Bounds;
|
||||
var baseDaily = _dailyCard.Bounds;
|
||||
var baseFooter = _footer.Bounds;
|
||||
var baseHeight = _dashboardBody.Height;
|
||||
checks["tailnet_absent_has_original_two_card_layout"] = !_tailnetTrafficCard.Visible
|
||||
&& baseTraffic.Top == baseDaily.Top && baseTraffic.Bottom == baseDaily.Bottom;
|
||||
_dashboardScrollBar.Value = Math.Min(35, Math.Max(0, _dashboardScrollBar.Maximum - _dashboardScrollBar.LargeChange + 1));
|
||||
var previous = _dashboardScrollBar.Value;
|
||||
SetTailnetTrafficVisibility(true);
|
||||
checks["tailnet_wide_left_cards_stack"] = _tailnetTrafficCard.Left == _trafficCard.Left
|
||||
&& _tailnetTrafficCard.Width == _trafficCard.Width && _tailnetTrafficCard.Top > _trafficCard.Bottom;
|
||||
checks["tailnet_wide_right_history_spans_two_rows"] = _dailyCard.Top == _trafficCard.Top
|
||||
&& _dailyCard.Bottom == _tailnetTrafficCard.Bottom && _dailyCard.Left > _trafficCard.Right;
|
||||
checks["tailnet_show_preserves_scroll"] = _dashboardScrollBar.Value == previous;
|
||||
checks["tailnet_expanded_history_chart_fills_card"] = _dailyChart.Height > _trafficChart.Height
|
||||
&& _dailyChart.Bottom < _dailyUploadLegend.Top && _historyStatus.Bottom <= _dailyCard.Height;
|
||||
var originalProxyValue = _uploadMetric.ValueText;
|
||||
var originalProxyLegend = _uploadLegend.Text;
|
||||
var originalSessionUp = _sessionUp;
|
||||
var originalSessionDown = _sessionDown;
|
||||
DisplayTailnetTraffic(12345, 67890, "独立 UI 样本");
|
||||
checks["tailnet_view_never_adds_sample_to_session_totals_again"] = _sessionUp == originalSessionUp
|
||||
&& _sessionDown == originalSessionDown;
|
||||
checks["tailnet_values_are_independent_controls"] = _tailnetUploadMetric.ValueText == "12.06"
|
||||
&& _tailnetDownloadMetric.ValueText == "66.3" && _tailnetUploadMetric.Parent == _tailnetTrafficCard
|
||||
&& _tailnetDownloadMetric.Parent == _tailnetTrafficCard && _tailnetTrafficChart.Parent == _tailnetTrafficCard
|
||||
&& _uploadMetric.ValueText == originalProxyValue && _uploadLegend.Text == originalProxyLegend;
|
||||
checks["tailnet_valid_sample_appends_one_curve_point"] = TailnetPoints() == 1;
|
||||
checks["tailnet_scope_and_already_accounted_are_explicit"] = _tailnetSampleLabel.Text.StartsWith("仅纵横家链路 · ")
|
||||
&& _tailnetUploadMetric.Hint == "已计入代理总流量" && _tailnetDownloadMetric.Hint == "已计入代理总流量";
|
||||
DisplayTailnetTraffic(null, double.NaN, "独立采样不可用");
|
||||
checks["tailnet_missing_samples_not_total_or_fake_zero"] = _tailnetUploadMetric.ValueText == "—"
|
||||
&& _tailnetDownloadMetric.ValueText == "—" && _tailnetUploadLegend.Text == "● 上传 —" && TailnetPoints() == 0;
|
||||
ResetTailnetTraffic();
|
||||
checks["tailnet_reset_clears_metric_and_sampling"] = _tailnetUploadMetric.ValueText == "—"
|
||||
&& _tailnetDownloadMetric.ValueText == "—" && _tailnetSampleLabel.Text == "仅纵横家链路 · 等待 Tailscale 流量采样" && TailnetPoints() == 0;
|
||||
SetTailnetTrafficVisibility(false);
|
||||
checks["tailnet_hide_restores_exact_original_geometry_without_gap"] = _trafficCard.Bounds == baseTraffic
|
||||
&& _dailyCard.Bounds == baseDaily && _footer.Bounds == baseFooter && _dashboardBody.Height == baseHeight;
|
||||
SetTailnetTrafficVisibility(true);
|
||||
checks["tailnet_resurface_has_no_previous_connection_numbers"] = _tailnetUploadMetric.ValueText == "—"
|
||||
&& _tailnetDownloadMetric.ValueText == "—" && TailnetPoints() == 0;
|
||||
Size = MinimumSize;
|
||||
PerformLayout();
|
||||
LayoutDashboard();
|
||||
Application.DoEvents();
|
||||
checks["tailnet_compact_orders_realtime_tailnet_history"] = _trafficCard.Left == _tailnetTrafficCard.Left
|
||||
&& _tailnetTrafficCard.Left == _dailyCard.Left && _tailnetTrafficCard.Top > _trafficCard.Bottom
|
||||
&& _dailyCard.Top > _tailnetTrafficCard.Bottom;
|
||||
checks["tailnet_all_controls_fit_transparent_cards"] = DashboardControlsFit() && CardPanel.SurfaceAlpha == 128;
|
||||
var limit = Math.Max(0, _dashboardScrollBar.Maximum - _dashboardScrollBar.LargeChange + 1);
|
||||
_dashboardScrollBar.Value = limit;
|
||||
LayoutDashboard();
|
||||
checks["tailnet_compact_footer_remains_reachable"] = !_dashboardView.HorizontalScroll.Visible
|
||||
&& _footer.RectangleToScreen(_footer.ClientRectangle).Bottom <= _dashboardView.RectangleToScreen(_dashboardView.ClientRectangle).Bottom;
|
||||
DisplayTailnetTraffic(1, 2, "独立 UI 样本");
|
||||
SetTailnetTrafficVisibility(false);
|
||||
checks["tailnet_hide_clamps_scroll_and_clears_data"] = _dashboardScrollBar.Value <= Math.Max(0,
|
||||
_dashboardScrollBar.Maximum - _dashboardScrollBar.LargeChange + 1)
|
||||
&& _tailnetUploadMetric.ValueText == "—" && _tailnetDownloadMetric.ValueText == "—";
|
||||
UpdateConnectedTransportPresentation(true);
|
||||
checks["actual_transport_presentation_enables_tailnet_card"] = _currentNodeUsesTailnet && _tailnetTrafficVisible;
|
||||
UpdateConnectedTransportPresentation(false);
|
||||
checks["public_transport_presentation_hides_tailnet_card"] = !_currentNodeUsesTailnet && !_tailnetTrafficVisible;
|
||||
ClientSize = originalSize;
|
||||
LayoutDashboard();
|
||||
checks["tailnet_geometry_112_viewport_dpi_cases"] = DashboardLayout.SelfTest();
|
||||
return checks;
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ internal sealed partial class MainForm
|
||||
_currentNodeUsesTailnet = usesTailnet;
|
||||
_currentNodeName = _currentNodeBaseName is null ? null
|
||||
: NodePresentation.WithTransport(_currentNodeBaseName, _currentNodeUsesTailnet);
|
||||
SetTailnetTrafficVisibility(usesTailnet);
|
||||
}
|
||||
|
||||
private void BuildConnectionSelection()
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
namespace UCVL.VPNPlus;
|
||||
|
||||
internal sealed partial class MainForm
|
||||
{
|
||||
// Presentation only. These controls never read adapter/counter state and
|
||||
// never change proxy, account, session totals or route decisions.
|
||||
private readonly CardPanel _tailnetTrafficCard = new() { MetricBand = true };
|
||||
private readonly MetricCard _tailnetUploadMetric = new("上传速度", DashboardIcon.Upload) { Embedded = true };
|
||||
private readonly MetricCard _tailnetDownloadMetric = new("下载速度", DashboardIcon.Download) { Embedded = true };
|
||||
private readonly TrafficChart _tailnetTrafficChart = new();
|
||||
private readonly DashboardGlyph _tailnetTrafficIcon = new(DashboardIcon.Chart);
|
||||
private readonly Label _tailnetTrafficHeading = new(), _tailnetSampleLabel = new();
|
||||
private readonly Label _tailnetUploadLegend = new(), _tailnetDownloadLegend = new();
|
||||
private bool _tailnetTrafficVisible;
|
||||
|
||||
private void BuildTailnetTrafficCard()
|
||||
{
|
||||
ConfigureLabel(_tailnetTrafficHeading, "Tailscale 实时网速", Brand.Font(9.5f, FontStyle.Bold), Brand.Text);
|
||||
ConfigureLabel(_tailnetSampleLabel, "等待流量采样", Brand.Font(7.5f), Brand.Muted);
|
||||
_tailnetSampleLabel.TextAlign = ContentAlignment.MiddleRight;
|
||||
_tailnetSampleLabel.AutoEllipsis = true;
|
||||
ConfigureLabel(_tailnetUploadLegend, "● 上传 —", Brand.Font(8), Brand.RoyalBlue);
|
||||
ConfigureLabel(_tailnetDownloadLegend, "● 下载 —", Brand.Font(8), Brand.Cyan);
|
||||
_tailnetTrafficCard.AccessibleName = "Tailscale 实时网速";
|
||||
_tailnetTrafficCard.AccessibleDescription = "仅纵横家当前 Tailscale 代理链路;已计入代理总流量,不代表所有 Tailscale 网卡或整机流量。";
|
||||
_tailnetTrafficCard.Controls.AddRange([_tailnetTrafficIcon, _tailnetTrafficHeading, _tailnetSampleLabel,
|
||||
_tailnetUploadMetric, _tailnetDownloadMetric, _tailnetTrafficChart, _tailnetUploadLegend, _tailnetDownloadLegend]);
|
||||
_tailnetTrafficCard.Visible = false;
|
||||
_dashboardBody.Controls.Add(_tailnetTrafficCard);
|
||||
ResetTailnetTraffic();
|
||||
}
|
||||
|
||||
internal void SetTailnetTrafficVisibility(bool show)
|
||||
{
|
||||
if (_tailnetTrafficVisible == show) return;
|
||||
_tailnetTrafficVisible = show;
|
||||
_tailnetTrafficCard.Visible = show;
|
||||
if (!show) ResetTailnetTraffic();
|
||||
LayoutDashboard();
|
||||
}
|
||||
|
||||
internal void DisplayTailnetTraffic(double? up, double? down, string sampling)
|
||||
{
|
||||
// Root supplies the already-accounted proxy sample only for the active
|
||||
// Tailnet transport. This presentation never reads an adapter or adds
|
||||
// bytes to session/backend totals. Missing samples are not fake zeroes.
|
||||
static double? Clean(double? value) => value.HasValue && double.IsFinite(value.Value)
|
||||
? Math.Max(0, value.Value) : null;
|
||||
up = Clean(up); down = Clean(down);
|
||||
_tailnetUploadMetric.SetBytes(up, speed: true, hint: "已计入代理总流量");
|
||||
_tailnetDownloadMetric.SetBytes(down, speed: true, hint: "已计入代理总流量");
|
||||
_tailnetSampleLabel.Text = "仅纵横家链路 · " + sampling;
|
||||
_tailnetUploadLegend.Text = up.HasValue ? $"● 上传 {FormatBytes((long)up.Value)}/s" : "● 上传 —";
|
||||
_tailnetDownloadLegend.Text = down.HasValue ? $"● 下载 {FormatBytes((long)down.Value)}/s" : "● 下载 —";
|
||||
if (up.HasValue && down.HasValue) _tailnetTrafficChart.Add(up.Value, down.Value);
|
||||
else _tailnetTrafficChart.Reset();
|
||||
}
|
||||
|
||||
internal void ResetTailnetTraffic()
|
||||
{
|
||||
_tailnetTrafficChart.Reset();
|
||||
DisplayTailnetTraffic(null, null, "等待 Tailscale 流量采样");
|
||||
}
|
||||
|
||||
private void LayoutTailnetTrafficCard(Rectangle bounds)
|
||||
{
|
||||
_tailnetTrafficCard.Visible = _tailnetTrafficVisible;
|
||||
if (!_tailnetTrafficVisible) { _tailnetTrafficCard.Bounds = Rectangle.Empty; return; }
|
||||
_tailnetTrafficCard.Bounds = bounds;
|
||||
int S(int value) => ScaleLogical(value);
|
||||
_tailnetTrafficIcon.Bounds = new Rectangle(S(15), S(10), S(20), S(20));
|
||||
_tailnetTrafficHeading.Bounds = new Rectangle(S(42), S(8), S(132), S(26));
|
||||
_tailnetSampleLabel.Bounds = new Rectangle(S(178), S(10), Math.Max(1, bounds.Width - S(192)), S(22));
|
||||
var metricWidth = (bounds.Width - S(28)) / 2;
|
||||
_tailnetUploadMetric.Bounds = new Rectangle(S(14), S(43), metricWidth - S(2), S(82));
|
||||
_tailnetDownloadMetric.Bounds = new Rectangle(S(14) + metricWidth, S(43), metricWidth - S(2), S(82));
|
||||
_tailnetTrafficChart.Bounds = new Rectangle(S(13), S(132), bounds.Width - S(26), S(106));
|
||||
var legendWidth = (bounds.Width - S(40)) / 2;
|
||||
_tailnetUploadLegend.Bounds = new Rectangle(S(20), S(248), legendWidth, S(19));
|
||||
_tailnetDownloadLegend.Bounds = new Rectangle(S(20) + legendWidth, S(248), legendWidth, S(19));
|
||||
}
|
||||
}
|
||||
+12
-2
@@ -501,7 +501,7 @@ internal sealed partial class MainForm : Form
|
||||
_connectionHealth.Invalidate();
|
||||
_nextReconnect = DateTimeOffset.MinValue;
|
||||
_wantConnected = true;
|
||||
if (!reconnect) { _transportRetryNodeSlug = null; _failedNodes.Clear(); _sessionUp = _sessionDown = 0; _trafficChart.Reset(); _sessionMetric.SetBytes(0, hint: "本次连接累计"); }
|
||||
if (!reconnect) { _transportRetryNodeSlug = null; _failedNodes.Clear(); _sessionUp = _sessionDown = 0; _trafficChart.Reset(); ResetTailnetTraffic(); _sessionMetric.SetBytes(0, hint: "本次连接累计"); }
|
||||
foreach (var slug in _failedNodes.Where(p => p.Value <= DateTimeOffset.UtcNow).Select(p => p.Key).ToList()) _failedNodes.Remove(slug);
|
||||
SetConnectionState(false, "正在连接", selection.Manual ? "正在连接手动指定节点…" : "vpn-ai 正在分配工作节点…");
|
||||
var replacementStarted = false;
|
||||
@@ -656,6 +656,7 @@ internal sealed partial class MainForm : Form
|
||||
_currentNodeIsPrivateAuxiliary = false;
|
||||
_currentPrivateEndpoint = null;
|
||||
_currentNodeUsesTailnet = false;
|
||||
SetTailnetTrafficVisibility(false);
|
||||
_transportRetryNodeSlug = null;
|
||||
_privateLeaseDeadlineTicks = 0;
|
||||
_currentNodeName = null;
|
||||
@@ -674,7 +675,11 @@ internal sealed partial class MainForm : Form
|
||||
{
|
||||
var core = _xray.CoreId;
|
||||
var counters = await _xray.ReadTrafficAsync(_lifetime.Token);
|
||||
if (counters is null || core != _xray.CoreId) { DisplayTraffic(null, null, "采样暂不可用"); return; }
|
||||
if (counters is null || core != _xray.CoreId)
|
||||
{
|
||||
DisplayTraffic(null, null, "采样暂不可用");
|
||||
return;
|
||||
}
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
if (core != _lastCoreId) { _lastCoreId = core ?? 0; _lastUp = _lastDown = 0; _lastSample = now.AddSeconds(-5); }
|
||||
var seconds = Math.Max(0.1, (now-_lastSample).TotalSeconds);
|
||||
@@ -685,6 +690,11 @@ internal sealed partial class MainForm : Form
|
||||
DisplayTraffic(up / seconds, down / seconds, $"{now.LocalDateTime:HH:mm:ss} · 近 5 分钟");
|
||||
_sessionMetric.SetBytes(_sessionUp + _sessionDown, hint: "本次连接累计");
|
||||
_trafficChart.Add(up/seconds, down/seconds);
|
||||
// This is a view of the SAME proxy sample, not a second counter.
|
||||
// A single connected proxy uses either its Tailnet or public ingress.
|
||||
// Do not read the whole Tailscale adapter or add this subset to usage.
|
||||
if (_currentNodeUsesTailnet)
|
||||
DisplayTailnetTraffic(up / seconds, down / seconds, $"{now.LocalDateTime:HH:mm:ss} · 近 5 分钟");
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
catch (Exception exception) { AppPaths.WriteError(exception); }
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
# 纵横家 Windows 0.2.22 开源源码
|
||||
# 纵横家 Windows 0.2.23 开源源码
|
||||
|
||||
基于已冻结的 0.2.22 r2 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
|
||||
基于已冻结的 0.2.23 r2 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
|
||||
|
||||
## 构建
|
||||
|
||||
@@ -18,3 +18,5 @@ dotnet publish VPNPlus.csproj -c Release -r win-x64 --self-contained true
|
||||
公司自有代码适用 LICENSE;公司 Logo/商标保留来源识别用途、不授予品牌权利;第三方许可文本在 licenses/ 中,原 THIRD_PARTY_NOTICES.md 保持原文。
|
||||
|
||||
本次只同步Windows界面维护代码:滚动/刷新、托盘与透明卡片。清洁导出继续省略可选登录人物插图,使用已有原创山水fallback;未重新导出或修改其它平台。安装包发布证据不能转移为此脱敏源码的构建/真实网络验收。
|
||||
|
||||
新增条件 Tailscale 实时卡,内网左二右一,公网隐藏;仅已有代理总量分项,不重复累计。源码仍省略许可不明可选人物插图。
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
<ApplicationIcon>assets\zonghengjia-app-v1.ico</ApplicationIcon>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
|
||||
<Version>0.2.22</Version>
|
||||
<AssemblyVersion>0.2.22.0</AssemblyVersion>
|
||||
<FileVersion>0.2.22.0</FileVersion>
|
||||
<InformationalVersion>0.2.22</InformationalVersion>
|
||||
<Version>0.2.23</Version>
|
||||
<AssemblyVersion>0.2.23.0</AssemblyVersion>
|
||||
<FileVersion>0.2.23.0</FileVersion>
|
||||
<InformationalVersion>0.2.23</InformationalVersion>
|
||||
<Product>纵横家</Product>
|
||||
<Company>优创未来(UCVL)</Company>
|
||||
<Description>纵横家 Windows 智能网络客户端</Description>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# 纵横家 Windows 0.2.23
|
||||
|
||||
- 实际使用 Tailscale 时,左侧原实时网速下方增加 Tailscale 实时上传、下载和曲线;右侧代理流量跨两行。
|
||||
- 公网连接隐藏 Tailscale 卡片并恢复原布局,不留空白;窄窗口保持纵向滚动。
|
||||
- Tailscale 卡展示本软件已计入代理总量的链路分项,不重复累计,不代表整机或其它应用的 Tailscale 网卡流量。
|
||||
- 断开、切换公网或无有效采样时清除旧值。保留现有 Tailscale 优先、同节点公网回退及安装升级逻辑。
|
||||
|
||||
Windows x64 非强制维护更新,需管理员授权,安装包未签名。本包离线界面与隔离安装检查不等于生产实窗、新版真实长连接或所有用户均已升级。其它平台不随本次 Windows 版本发布。
|
||||
Reference in New Issue
Block a user