Publish Zonghengjia Windows 0.3.13 client source

This commit is contained in:
2026-11-13 10:35:04 +08:00
parent 1590443809
commit 839434a313
55 changed files with 2324 additions and 963 deletions
+46 -27
View File
@@ -1,12 +1,20 @@
namespace UCVL.VPNPlus;
namespace UCVL.VPNPlus;
internal sealed partial class MainForm
{
// A compact logical canvas; native DPI scaling still happens exactly once.
private bool CompactPresentation => ClientSize.Width < ScaleLogical(720) || ClientSize.Height < ScaleLogical(550);
private bool WideDashboardPresentation => ClientSize.Width >= ScaleLogical(840) && ClientSize.Height >= ScaleLogical(480);
private bool CompactPresentation => !WideDashboardPresentation;
private readonly Font _compactStatusFont=Brand.Font(9.5f,FontStyle.Bold);
private readonly Font _wideStatusFont=Brand.Font(20f,FontStyle.Bold);
private readonly Font _denseStatusFont=Brand.Font(16f,FontStyle.Bold);
private readonly Font _wideChartFont=Brand.Font(9f);
private readonly Font _compactChartFont=Brand.Font(7.5f);
private readonly Font _compactFieldFont=Brand.Font(7.5f, FontStyle.Bold);
private readonly Font _compactStatusDetailFont=Brand.Font(7.5f);
private readonly Font _compactRowFont=Brand.Font(8f,FontStyle.Bold);
private readonly Font _narrowNodeFont=Brand.Font(9.5f, FontStyle.Bold);
private readonly Font _minimumNodeFont=Brand.Font(8.5f, FontStyle.Bold);
private readonly Dictionary<Control, (Font Original, Font? Compact)> _presentationFonts = new();
private bool _presentationFontsDisposed;
protected override void Dispose(bool disposing)
@@ -17,19 +25,29 @@ internal sealed partial class MainForm
foreach(var fonts in _presentationFonts.Values)fonts.Compact?.Dispose();
_presentationFonts.Clear();
_compactStatusFont.Dispose();
_wideStatusFont.Dispose();
_denseStatusFont.Dispose();
_wideChartFont.Dispose();
_compactChartFont.Dispose();
_compactFieldFont.Dispose();
_compactStatusDetailFont.Dispose();
_compactRowFont.Dispose();
_narrowNodeFont.Dispose();
_minimumNodeFont.Dispose();
}
private void SetStatusTitleFont(float size)
private void SetStatusTitleFont(bool wide, bool dense)
{
if(ReferenceEquals(_statusTitle.Font,_compactStatusFont))return;
var selected = wide ? dense ? _denseStatusFont : _wideStatusFont : _compactStatusFont;
if (ReferenceEquals(_statusTitle.Font, selected)) return;
var previous=_statusTitle.Font;
_statusTitle.Font=_compactStatusFont;
if(!ReferenceEquals(previous,_compactStatusFont))previous.Dispose();
_statusTitle.Font = selected;
if (!ReferenceEquals(previous, _compactStatusFont) && !ReferenceEquals(previous, _wideStatusFont)
&& !ReferenceEquals(previous, _denseStatusFont))
previous.Dispose();
}
private void ApplyCompactTypography()
{
void Visit(Control parent, bool dashboardTypography=false)
void Visit(Control parent)
{
foreach (Control control in parent.Controls)
{
@@ -40,10 +58,8 @@ internal sealed partial class MainForm
fonts = (original, new Font(original.FontFamily, Math.Max(7.5f, original.SizeInPoints * .78f), original.Style));
_presentationFonts.Add(control, fonts);
}
var dashboard = dashboardTypography || ReferenceEquals(control,_dashboardBody)
|| ReferenceEquals(control,_welcomeLabel) || ReferenceEquals(control,_logoutButton);
control.Font = CompactPresentation || dashboard ? fonts.Compact! : fonts.Original;
Visit(control,dashboard);
control.Font = CompactPresentation ? fonts.Compact! : fonts.Original;
Visit(control);
}
}
Visit(this);
@@ -105,10 +121,8 @@ internal sealed partial class MainForm
{
_welcomeLabel.Parent=_brandHeader;
_logoutButton.Parent=_brandHeader;
var caption = _windowChrome!.MinimizeButton.Bounds;
_logoutButton.Bounds=new(caption.Left-S(72),caption.Top,S(64),caption.Height);
_welcomeLabel.Bounds=new(_logoutButton.Left-S(126),caption.Top,S(118),caption.Height);
_welcomeLabel.Visible=_logoutButton.Visible=_dashboardView.Visible;
LayoutCompactDashboardActions();
_accountLabel.Visible=_identityBadge.Visible=false;
}
else
@@ -123,24 +137,26 @@ internal sealed partial class MainForm
_connectButton.Bounds=new(_statusCard.Width-S(80),S(3),S(70),S(24));
_statusTitle.Bounds=new(S(40),0,_statusCard.Width-S(130),S(16));
_statusDetail.Bounds=new(S(40),S(16),_statusCard.Width-S(130),S(13));
_statusDetail.Font = _compactStatusDetailFont;
_nodeIcon.Visible=_modeIcon.Visible=false;
_scheduleBadge.Visible=false;
var leftWidth=_modeCard.Left-S(8);
_selectionHeading.Bounds=R(10,1,27,20);
_routeHeading.Bounds=R(10,23,27,20);
_selectionHeading.Bounds=R(10,1,34,20);
_routeHeading.Bounds=R(10,23,34,20);
_routeHeading.Text="模式";
var fieldLeft=S(38); var fieldWidth=leftWidth-fieldLeft;
var fieldLeft=S(46); var fieldWidth=leftWidth-fieldLeft;
var splitWidth=Math.Max(S(84),(fieldWidth-S(4))/2);
_connectionModeCombo.Bounds=new(fieldLeft,S(1),_manualNodeCombo.Visible?splitWidth:fieldWidth,S(20));
_manualNodeCombo.Bounds=new(_connectionModeCombo.Right+S(4),S(1),Math.Max(S(60),fieldWidth-splitWidth-S(4)),S(20));
_routeCombo.Bounds=new(fieldLeft,S(23),fieldWidth,S(20));
_nodeHeading.Text="节点";
_nodeHeading.Bounds=R(8,1,27,20);
_currentNodeLabel.Bounds=new(S(39),S(1),_modeCard.Width-S(41),S(20));
_actualModeHeading.Bounds=R(8,23,27,20);
_routeReadOnly.Bounds=new(S(39),S(23),_modeCard.Width-S(41),S(20));
_nodeHeading.Bounds=R(8,1,34,20);
_currentNodeLabel.Bounds=new(S(44),S(1),_modeCard.Width-S(46),S(20));
_actualModeHeading.Bounds=R(8,23,34,20);
_routeReadOnly.Bounds=new(S(44),S(23),_modeCard.Width-S(46),S(20));
foreach(var label in new[]{_selectionHeading,_routeHeading,_nodeHeading,_actualModeHeading,_currentNodeLabel})
{ label.TextAlign=ContentAlignment.MiddleLeft; label.Padding=Padding.Empty; }
_selectionHeading.Font = _routeHeading.Font = _nodeHeading.Font = _actualModeHeading.Font = _compactFieldFont;
_trafficCard.Visible=_tailnetTrafficCard.Visible=false;
_trafficIcon.Visible=_dailyIcon.Visible=_tailnetTrafficIcon.Visible=false;
_trafficHeading.Bounds=new(S(10),0,S(106),_trafficCard.Height-S(2));
@@ -154,12 +170,13 @@ internal sealed partial class MainForm
_tailnetUploadMetric.Bounds=_uploadMetric.Bounds;
_tailnetDownloadMetric.Bounds=_downloadMetric.Bounds;
}
_trendHeading.Text="本机代理趋势 · "+(_selectionUiConnected?(_currentNodeUsesTailnet?"Tailscale":"域名入口"):"未连接");
_trendHeading.Text="本机代理趋势 · "+(_selectionUiConnected?(_currentNodeUsesTailnet?"Tailscale":"公网入口"):"未连接");
_trendHeading.Bounds=new(S(10),S(2),_speedTrendCard.Width-S(120),S(18));
_trendHeading.TextAlign=ContentAlignment.MiddleLeft;
_historyRangeCombo.Bounds=new(_speedTrendCard.Width-S(98),S(2),S(88),S(18));
_uploadLegend.Bounds=new(S(10),S(20),(_speedTrendCard.Width-S(20))/2,S(16));
_downloadLegend.Bounds=new(_uploadLegend.Right,S(20),(_speedTrendCard.Width-S(20))/2,S(16));
var legendWidth = Math.Max(S(90), (_speedTrendCard.Width - S(118)) / 2);
_uploadLegend.Bounds=new(S(10),S(20),legendWidth,S(16));
_downloadLegend.Bounds=new(_uploadLegend.Right,S(20),legendWidth,S(16));
_uploadLegend.TextAlign=_downloadLegend.TextAlign=ContentAlignment.MiddleLeft;
_uploadLegend.Visible=_downloadLegend.Visible=true;
_trafficChart.Font=_compactChartFont;
@@ -167,12 +184,14 @@ internal sealed partial class MainForm
_historyStatus.Visible=false;
_sampleLabel.Visible=false;
_planLabel.Visible=false;
_expiryLabel.Bounds=new(0,0,S(96),S(17));
_footerCompanySite.Bounds=new(S(100),0,S(145),S(17));
_footerHint.Bounds=new(_footer.Width-S(212),0,S(212),S(17));
var footerHeight = Math.Max(S(15), _footer.Height - S(1));
_expiryLabel.Bounds=new(S(10),0,S(96),footerHeight);
_footerCompanySite.Bounds=new(S(107),0,S(145),footerHeight);
_footerHint.Bounds=new(_footer.Width-S(197),0,S(187),footerHeight);
_footerPoem.Visible=false;
_footerHint.Visible=true;
_dashboardBody.Size=_dashboardView.ClientSize;
_dashboardBody.Location=Point.Empty;
LayoutCompactDashboardActions();
}
}