Publish Zonghengjia Windows 0.3.13 client source
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace UCVL.VPNPlus;
|
||||
|
||||
@@ -15,7 +15,7 @@ internal static class ConnectionSelectionSelfTest
|
||||
string[] authorized = ["office-test", "remote-test"];
|
||||
var auto = ConnectionSelection.Create(false, "office-test", authorized);
|
||||
checks["default_auto_ignores_previous_manual_choice"] = auto.NodeSlug == "auto" && !auto.Manual;
|
||||
checks["auto_attempts_are_bounded"] = auto.Attempts(12) == 8 && auto.Attempts(2) == 2;
|
||||
checks["auto_attempts_are_bounded"] = auto.Attempts(12) == 3 && auto.Attempts(2) == 2;
|
||||
var manual = ConnectionSelection.Create(true, "office-test", authorized);
|
||||
checks["manual_uses_exact_authorized_node"] = manual.Manual && manual.NodeSlug == "office-test";
|
||||
checks["manual_has_no_fallback_attempt"] = manual.Attempts(12) == 1;
|
||||
@@ -52,7 +52,11 @@ internal sealed partial class MainForm
|
||||
internal Dictionary<string, bool> CheckSelectionUi()
|
||||
{
|
||||
var result = new Dictionary<string, bool>();
|
||||
var profile = new Profile { Nodes = [new() { Slug = "office-test", Name = "优创未来·济南办" }, new() { Slug = "remote-test", Name = "远程测试" }] };
|
||||
var profile = new Profile
|
||||
{
|
||||
Nodes = [new() { Slug = "office-test", Name = "优创未来·济南办" }, new() { Slug = "remote-test", Name = "远程测试" }],
|
||||
RouteModes = [new() { Id = "smart", Name = "AI 智能代理" }],
|
||||
};
|
||||
_availableNodeCount = 2;
|
||||
UpdateSelectionNodes(profile, false);
|
||||
result["ui_defaults_to_auto"] = !ManualSelection;
|
||||
@@ -106,31 +110,47 @@ internal sealed partial class MainForm
|
||||
_currentNodeLabel.Text = _currentNodeName;
|
||||
SetConnectionState(true, "已安全连接", _currentNodeName);
|
||||
LayoutDashboard();
|
||||
var fullConnectedRow = true;
|
||||
foreach (var (size, label) in new[] { (new Size(480, 360), "compact"), (new Size(960, 720), "wide") })
|
||||
var allConnectedLayoutsFit = true;
|
||||
foreach (var (size, label) in new[] { (new Size(480, 360), "compact"), (new Size(840, 480), "minimum_wide"), (new Size(960, 720), "wide") })
|
||||
{
|
||||
ClientSize = new Size(ScaleLogical(size.Width), ScaleLogical(size.Height));
|
||||
PerformLayout(); LayoutDashboard(); Application.DoEvents();
|
||||
var rightInset = _modeCard.ClientSize.Width - _currentNodeLabel.Right;
|
||||
// The node keeps the available row, with only a small edge inset.
|
||||
// Exact decorative padding can differ between compact and wide UI.
|
||||
var usesRow = _currentNodeLabel.Visible && _currentNodeLabel.Left >= 0
|
||||
&& rightInset >= 0 && rightInset <= ScaleLogical(16)
|
||||
&& _currentNodeLabel.Width >= _modeCard.ClientSize.Width * .75;
|
||||
result["connected_node_full_row_" + label] = usesRow;
|
||||
result["connected_node_name_fits_" + label] = TextRenderer.MeasureText(_currentNodeName,
|
||||
_currentNodeLabel.Font).Width <= _currentNodeLabel.Width;
|
||||
fullConnectedRow &= usesRow;
|
||||
var isWide = WideDashboardPresentation;
|
||||
var rowFits = _currentNodeLabel.Visible && _modeCard.ClientRectangle.Contains(_currentNodeLabel.Bounds)
|
||||
&& _nodeHeading.Right <= _currentNodeLabel.Left
|
||||
&& (isWide
|
||||
? _currentNodeLabel.Right <= _modeIcon.Left && _routeReadOnly.Right <= _historyRangeCombo.Left
|
||||
: _currentNodeLabel.Bottom <= _routeReadOnly.Top);
|
||||
result["connected_node_does_not_overlap_mode_or_range_" + label] = rowFits;
|
||||
result["connected_node_name_fits_" + label] = _currentNodeLabel.Text == NodePresentation.JinanName && FitsNodeText();
|
||||
allConnectedLayoutsFit &= rowFits && FitsNodeText();
|
||||
if (isWide)
|
||||
{
|
||||
_currentNodeBaseName = NodePresentation.JinanName;
|
||||
UpdateConnectedTransportPresentation(true);
|
||||
LayoutDashboard();
|
||||
result["long_tailnet_name_keeps_node_and_transport_visible_" + label] = FitsNodeText()
|
||||
&& (_currentNodeLabel.Text == _currentNodeName || _currentNodeLabel.Text == _currentNodeBaseName)
|
||||
&& _wideSummaryState.Text.Contains("Tailscale", StringComparison.Ordinal);
|
||||
UpdateConnectedTransportPresentation(false);
|
||||
LayoutDashboard();
|
||||
}
|
||||
}
|
||||
result["connected_node_has_dedicated_actual_state_row"] = fullConnectedRow;
|
||||
result["connected_node_has_dedicated_actual_state_space"] = allConnectedLayoutsFit;
|
||||
result["connected_mode_badge_does_not_cover_name"] = !_scheduleBadge.Visible;
|
||||
result["zero3_name_fits_connected_row"] = TextRenderer.MeasureText(_currentNodeName, _currentNodeLabel.Font).Width <= _currentNodeLabel.Width;
|
||||
Size = MinimumSize;
|
||||
PerformLayout();
|
||||
LayoutDashboard();
|
||||
Application.DoEvents();
|
||||
result["zero3_name_fits_compact_connected_row"] = TextRenderer.MeasureText(_currentNodeName, _currentNodeLabel.Font).Width <= _currentNodeLabel.Width;
|
||||
result["zero3_name_fits_compact_connected_row"] = FitsNodeText();
|
||||
RequestExit();
|
||||
return result;
|
||||
|
||||
bool FitsNodeText()
|
||||
{
|
||||
using var graphics = _currentNodeLabel.CreateGraphics();
|
||||
return TextRenderer.MeasureText(graphics, _currentNodeLabel.Text, _currentNodeLabel.Font,
|
||||
Size.Empty, TextFormatFlags.SingleLine).Width <= _currentNodeLabel.ClientSize.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user