Windows 0.3.3 dashboard layout and speed presentation source delta; no private history or other platform changes

This commit is contained in:
2026-11-03 15:15:23 +00:00
parent bfe8d6c62a
commit aff1a50d35
32 changed files with 1673 additions and 652 deletions
+66 -35
View File
@@ -4,8 +4,8 @@ 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 readonly Font _compactStatusFont=Brand.Font(10,FontStyle.Bold);
private readonly Font _compactChartFont=Brand.Font(6.5f);
private readonly Font _compactStatusFont=Brand.Font(9.5f,FontStyle.Bold);
private readonly Font _compactChartFont=Brand.Font(7.5f);
private readonly Dictionary<Control, (Font Original, Font? Compact)> _presentationFonts = new();
private bool _presentationFontsDisposed;
protected override void Dispose(bool disposing)
@@ -20,16 +20,14 @@ internal sealed partial class MainForm
}
private void SetStatusTitleFont(float size)
{
if(CompactPresentation && ReferenceEquals(_statusTitle.Font,_compactStatusFont))return;
if(!CompactPresentation && !ReferenceEquals(_statusTitle.Font,_compactStatusFont)
&& Math.Abs(_statusTitle.Font.SizeInPoints-size)<.1f)return;
if(ReferenceEquals(_statusTitle.Font,_compactStatusFont))return;
var previous=_statusTitle.Font;
_statusTitle.Font=CompactPresentation?_compactStatusFont:Brand.Font(size,FontStyle.Bold);
_statusTitle.Font=_compactStatusFont;
if(!ReferenceEquals(previous,_compactStatusFont))previous.Dispose();
}
private void ApplyCompactTypography()
{
void Visit(Control parent)
void Visit(Control parent, bool dashboardTypography=false)
{
foreach (Control control in parent.Controls)
{
@@ -37,11 +35,13 @@ internal sealed partial class MainForm
if (!_presentationFonts.TryGetValue(control, out var fonts))
{
var original = control.Font;
fonts = (original, new Font(original.FontFamily, Math.Max(6.5f, original.SizeInPoints * .78f), original.Style));
fonts = (original, new Font(original.FontFamily, Math.Max(7.5f, original.SizeInPoints * .78f), original.Style));
_presentationFonts.Add(control, fonts);
}
control.Font = CompactPresentation ? fonts.Compact! : fonts.Original;
Visit(control);
var dashboard = dashboardTypography || ReferenceEquals(control,_dashboardBody)
|| ReferenceEquals(control,_welcomeLabel) || ReferenceEquals(control,_logoutButton);
control.Font = CompactPresentation || dashboard ? fonts.Compact! : fonts.Original;
Visit(control,dashboard);
}
}
Visit(this);
@@ -60,6 +60,11 @@ internal sealed partial class MainForm
}
_headerPoem.Visible=false;
LayoutWindowChrome();
if (_welcomeLabel.Parent == _brandHeader)
{
_welcomeLabel.Visible=_dashboardView.Visible;
_logoutButton.Visible=_dashboardView.Visible;
}
}
private void LayoutCompactLogin()
@@ -94,41 +99,67 @@ internal sealed partial class MainForm
{
int S(int n)=>ScaleLogical(n);
Rectangle R(int x,int y,int w,int h)=>new(S(x),S(y),S(w),S(h));
_statusDot.Bounds=R(10,8,24,24);
_connectButton.Bounds=new(_statusCard.Width-S(68),S(7),S(60),S(26));
_statusTitle.Bounds=new(S(42),S(1),_statusCard.Width-S(116),S(21));
_statusDetail.Bounds=new(S(42),S(22),_statusCard.Width-S(116),S(15));
if (CompactPresentation)
{
_welcomeLabel.Parent=_brandHeader;
_logoutButton.Parent=_brandHeader;
_welcomeLabel.Bounds=new(_brandHeader.Width-S(226),S(5),S(172),S(20));
_logoutButton.Bounds=new(_brandHeader.Width-S(128),S(28),S(72),S(19));
_welcomeLabel.Visible=_logoutButton.Visible=_dashboardView.Visible;
_accountLabel.Visible=_identityBadge.Visible=false;
}
else
{
_welcomeLabel.Parent=_dashboardBody;
_logoutButton.Parent=_dashboardBody;
_welcomeLabel.Bounds=layout.WelcomeLabel;
_logoutButton.Bounds=layout.LogoutButton;
_welcomeLabel.Visible=_logoutButton.Visible=_accountLabel.Visible=_identityBadge.Visible=true;
}
_statusDot.Bounds=R(10,4,22,22);
_connectButton.Bounds=new(_statusCard.Width-S(80),S(4),S(70),S(24));
_statusTitle.Bounds=new(S(40),S(1),_statusCard.Width-S(130),S(17));
_statusDetail.Bounds=new(S(40),S(17),_statusCard.Width-S(130),S(14));
_nodeIcon.Visible=_modeIcon.Visible=false;
_nodeHeading.Bounds=R(8,0,122,15);
_nodeHeading.Text="工作节点";
_connectionModeCombo.Bounds=new(_nodeCard.Width-S(102),S(1),S(96),S(18));
_manualNodeCombo.Bounds=new(S(8),S(22),_nodeCard.Width-S(16),S(19));
_currentNodeLabel.Bounds=new(S(8),S(23),_nodeCard.Width-S(16),S(17));
_scheduleBadge.Visible=false;
_routeHeading.Bounds=new(S(8),0,_modeCard.Width-S(16),S(14));
_routeCombo.Bounds=new(S(8),S(14),_modeCard.Width-S(16),S(20));
_routeReadOnly.Bounds=_routeCombo.Bounds;
var leftWidth=_modeCard.Left-S(8);
_selectionHeading.Bounds=R(10,3,27,20);
_routeHeading.Bounds=R(10,25,27,20);
_routeHeading.Text="模式";
var fieldLeft=S(38); var fieldWidth=leftWidth-fieldLeft;
var splitWidth=Math.Max(S(84),(fieldWidth-S(4))/2);
_connectionModeCombo.Bounds=new(fieldLeft,S(3),_manualNodeCombo.Visible?splitWidth:fieldWidth,S(20));
_manualNodeCombo.Bounds=new(_connectionModeCombo.Right+S(4),S(3),Math.Max(S(60),fieldWidth-splitWidth-S(4)),S(20));
_routeCombo.Bounds=new(fieldLeft,S(25),fieldWidth,S(20));
_nodeHeading.Text="节点";
_nodeHeading.Bounds=R(8,0,27,20);
_currentNodeLabel.Bounds=new(S(39),0,_modeCard.Width-S(41),S(20));
_actualModeHeading.Bounds=R(8,22,27,20);
_routeReadOnly.Bounds=new(S(39),S(22),_modeCard.Width-S(41),S(20));
_trafficIcon.Visible=_dailyIcon.Visible=_tailnetTrafficIcon.Visible=false;
_trafficHeading.Bounds=new(S(6),0,_trafficCard.Width-S(12),S(13));
_dailyHeading.Bounds=new(S(7),S(2),_dailyCard.Width-S(14),S(17));
_tailnetTrafficHeading.Bounds=new(S(6),0,_tailnetTrafficCard.Width-S(12),S(13));
_trafficHeading.Bounds=new(S(10),0,S(96),_trafficCard.Height-S(2));
_dailyHeading.Bounds=new(S(10),0,S(56),_dailyCard.Height-S(2));
_tailnetTrafficHeading.Text="Tailscale 速度";
_tailnetTrafficHeading.Bounds=new(S(10),0,S(96),_tailnetTrafficCard.Height-S(2));
if(_tailnetTrafficVisible)
{
var width=(_tailnetTrafficCard.Width-S(8))/2;
_tailnetUploadMetric.Bounds=new(S(4),S(11),width-S(1),S(18));
_tailnetDownloadMetric.Bounds=new(S(4)+width,S(11),width-S(1),S(18));
_tailnetUploadMetric.Bounds=_uploadMetric.Bounds;
_tailnetDownloadMetric.Bounds=_downloadMetric.Bounds;
}
_trendHeading.Bounds=new(S(6),0,_speedTrendCard.Width-S(88),S(15));
_historyRangeCombo.Bounds=new(_speedTrendCard.Width-S(82),0,S(77),S(19));
var rail=CompactPresentation && _speedTrendCard.Height<S(100);
_trendHeading.Bounds=rail?R(10,6,90,20):new(S(10),S(1),_speedTrendCard.Width-S(210),S(20));
_historyRangeCombo.Bounds=rail?R(8,30,88,20):new(_speedTrendCard.Width-S(98),S(2),S(88),S(20));
_trafficChart.Font=_compactChartFont;
_trafficChart.Bounds=new(S(1),S(18),_speedTrendCard.Width-S(3),Math.Max(S(30),_speedTrendCard.Height-S(19)));
_trafficChart.Bounds=rail?new(S(104),S(1),_speedTrendCard.Width-S(108),_speedTrendCard.Height-S(3))
:new(S(2),S(21),_speedTrendCard.Width-S(4),Math.Max(S(22),_speedTrendCard.Height-S(23)));
_uploadLegend.Visible=_downloadLegend.Visible=_historyStatus.Visible=false;
_sampleLabel.Visible=false;
_planLabel.Bounds=new(0,0,_footer.Width-S(75),S(11));
_expiryLabel.Bounds=new(_footer.Width-S(72),0,S(72),S(11));
_footerCompanySite.Bounds=new(0,S(11),S(210),S(11));
_footerHint.Bounds=new(_footer.Width-S(205),S(11),S(205),S(11));
_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));
_footerPoem.Visible=false;
_footerHint.Visible=true;
_dashboardBody.Size=_dashboardView.ClientSize;
_dashboardBody.Location=Point.Empty;
}