Compare commits

..

2 Commits

24 changed files with 704 additions and 94 deletions
+32 -1
View File
@@ -99,5 +99,36 @@
],
"OriginalPrivateSourcesModified": false,
"ProductionAccepted": false,
"SourceOnly": true
"SourceOnly": true,
"Windows022MaintenanceDelta": {
"ExampleEndpointChanges": [],
"OptionalUnlicensedSceneRemainsOmitted": true,
"OtherComponentsModified": false,
"ProductionAccepted": false,
"SourceOnly": true
},
"Windows023TailnetDisplayDelta": {
"ChangedWindowsFiles": [
"windows/DashboardInteractionSelfTest.cs",
"windows/DashboardLayout.cs",
"windows/DashboardTailnetLayoutSelfTest.cs",
"windows/MainForm.Dashboard.cs",
"windows/MainForm.Selection.cs",
"windows/MainForm.TailnetTraffic.cs",
"windows/MainForm.cs",
"windows/VPNPlus.csproj",
"windows/release/RELEASE-NOTES-0.2.23.md"
],
"ExampleEndpointChanges": [],
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "b77d3912a8f910f84be94a7adc81d0bd1926310db8c57b83d61a4d72763da2ad",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"PrivateSourceCommit": "e28648198536bdc560a06f05a4e821231e2ea644",
"ProductionAccepted": false,
"PublicBaseCommit": "3ccaea3d52f6b45eed33b7d2170d767aa73bff3d",
"SourceOnly": true,
"Version": "0.2.23"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
# 纵横家开源源码
此仓库是无私有 Git 历史的清洁源码快照:Windows 0.2.21、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。
此仓库是无私有 Git 历史的清洁源码快照:Windows 0.2.23、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。
| 目录 | 内容与状态 |
| --- | --- |
+76 -17
View File
@@ -4,7 +4,7 @@
"ExportDiffersFromOriginalCandidates": true,
"FilesBeforeProvenanceAndAudit": {
"LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e",
"README.md": "5bd226c3cf2855eabf3fae2758944b94fa14ceb16f8ad3a2449e4f97a7a794ae",
"README.md": "3c1651ca130628096d7a19f063742648eaa791fcf6574b721dc69b3a02016a6f",
"SECURITY.md": "34e56cd9b8f6aa5fee45921c6eb831a542e05e76e41850fc31c44e09de088b3c",
"THIRD_PARTY_NOTICES.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371",
"android/README.md": "bb4387da9a055e97f33bb29a883c543e0938fa858df3fd744abc80553a5ec65c",
@@ -191,9 +191,12 @@
"windows/ConnectionSelection.cs": "def94b338b9e1fd940c19b8991e4268a4e59bec741ea624f5a6e4fb7a7d3bbcc",
"windows/ConnectionSelectionSelfTest.cs": "12bd82071989c5e539031f6e7921660edb4eb10a4136ac332cc84eca2e2d96de",
"windows/ConnectionSelfTest.cs": "6511feda4c81da766e745a499c682d2d0b3be0386c4ba424e7ddc04029ebca12",
"windows/DailyTrafficChart.cs": "5006497ef28cd8a7a00f8553d729220f559cc5205ea0471bdc16be5a7e97fc7d",
"windows/DashboardControls.cs": "f58f30cbd766c0b912afc9b3bda6bc3b88073cb40dc04986c0286790ff2bb758",
"windows/DashboardLayout.cs": "a761de5842c1aa03e68089dc90f73e0a2372532e5367b8e64198ba7b5bd6f8a8",
"windows/DailyTrafficChart.cs": "4af8d8a91559e6a3fc1dd56db11f3534606aeb486ff918b2b301db0b82e4c716",
"windows/DashboardControls.cs": "b7b1ec34e78d96d23861b0236b945239f4e389d6b8494f53e95e5efe3f4c2182",
"windows/DashboardInteractionSelfTest.cs": "913357068c2962e2431da1917861d442567fa71fb0e7ddaea176f079d3b97251",
"windows/DashboardLayout.cs": "233ca0dee2ae27bc81d520b60d9a20b004cf70bf334de2ba33e5956777154edd",
"windows/DashboardTailnetLayoutSelfTest.cs": "7bd2cba07f56c0c55da912e47efbec856c58e798b7c7218093adfbb2bfd69f29",
"windows/DashboardWheelRouter.cs": "d903097a5febbff296febb65855dc10b4e056ea5bb54d2df71b5d1f0297dcc1f",
"windows/GitReleasePolicySelfTest.cs": "c43d0e63e9c00a7c6b376ed204bc6c400572085075397685c92862e8318fe369",
"windows/GitReleaseUpdater.cs": "dcd00a0feca6801aad4e346c7565d8bcd80b3fd24a4accbe5cd4643d04264b9b",
"windows/InstallationIntegration.cs": "af4e5d0cd78d66546079f452e110be627494550594e847d13b77178494fb3bda",
@@ -213,11 +216,12 @@
"windows/LearningSelfTest.cs": "786587e8a145bbcd86acfc77f8f204958a6576aa008a19637e521ebb93926b10",
"windows/LearningStore.cs": "cc1c6cf1b0c5b948e16be24a46dc2429a020cafa176a36ad9c450d887410169e",
"windows/LearningTransportSelfTest.cs": "05dcfd3fcfc6f25e20612c020583eb6c36934c1b251e50e70fcd29501ad0efe7",
"windows/MainForm.Chrome.cs": "b537ae6528d5fb592d99915af27bdf2dd819604543a9b5a91d8bf3190b52ca4f",
"windows/MainForm.Dashboard.cs": "9d4774789f74c97f9b47c676d37b1739718cefbd3b51e8dc74b5ab5d565e3dc7",
"windows/MainForm.Chrome.cs": "30dc6520a44a5120c78c472c9fb053e2e4dea8e254b5531d04a5342964969c7a",
"windows/MainForm.Dashboard.cs": "584d888bf9d2f9c90ab481fa2716d69b15a037b2c51440a71865c2b69f548f3d",
"windows/MainForm.Handover.cs": "a7c6e81186be1d7a154c6997b7d44621543c163ba703901d7974632dd462d25f",
"windows/MainForm.Selection.cs": "297186f274b45cd9bf14fbc15492cbe026aea8902ffda386029cbcb75901e469",
"windows/MainForm.cs": "becb27dfb9f94c17506f94f2d7479e5db51033a31b0f3dc1d755634c1310f46a",
"windows/MainForm.Selection.cs": "d872004a98fc634e40c5edebf85eac7f3dfbb62fad8cafaae66a5c8470cfdaf3",
"windows/MainForm.TailnetTraffic.cs": "72b4dbad6595b866f103a10add769b815964d5100579518035385bc19a94f108",
"windows/MainForm.cs": "fdc0b3bb7b49f5bbf29140c631c54c60990757d06c9ca075c95e6b3d18261fec",
"windows/NOTICE.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371",
"windows/NetworkHandover.cs": "b43548be0051cf92dfd332e537951e4b5083f2a123be8021994513bbc3748d46",
"windows/NetworkHandoverSelfTest.cs": "681d0154dc0aa5f49d7ce1f3088b465eea3ed82571b464951df8d4c89cecdf73",
@@ -238,16 +242,16 @@
"windows/PrivateAuxiliaryRoutingSelfTest.cs": "1a955b2d8e7e9ffe8ff0c6a7bc717877ccd0f7681ff8a65219bb2fe93c230382",
"windows/PrivateAuxiliaryRuntime.cs": "dcfb406508e3d7e9a9163163cfe5e2724a6955a18ae4604e2d9f890da61308cf",
"windows/PrivateTransportProbe.cs": "e29e9bd0180a37bdcecf7104fde5069be799aca92b747881d0485a62d382d9b3",
"windows/Program.cs": "cd3f3d5dbb194ac8bb89de151bec0c3494ecae2bb52dffdfee29296449c09c4c",
"windows/Program.cs": "3545afc128a41b77d8c7365e36075bf01ebe379d8119e40343466968e7c25dea",
"windows/ProxyDnsPolicy.cs": "997e2e922ad43956932c1bd0a6da3457bc308ee723f4f77ff8e52aa23fa954c0",
"windows/ProxyProbe.cs": "5d27b5a6c6b192a0c0f3ec4637c5a876a71130497af57f7cb4a04ab4735ca1ec",
"windows/README.md": "bbefa88371cca54662456dac7f1aa48ef030a372695a25b5d1adadc3287f371c",
"windows/README.md": "5ec353b23490df795d096cd1a7d7f87be05b83aa2ae8bbdeaa4a4b7e93e45b76",
"windows/ReplacementContinuitySelfTest.cs": "107878ab2b367f1812377c0b209f6d620da390091c3882e4be53a48e517d86a1",
"windows/RouteLeaseSelfTest.cs": "6189c66b9f66c58bed26de4441c58a9ec02b67257bfa04ed66d702acfcd054d9",
"windows/RoutingRuleBatches.cs": "9997bfa766fffe7bed7352f307c1f6f118a9be9aa86653eaefae3b2bdaa26c1e",
"windows/RoutingUpdateSelfTest.cs": "48c99fc7a01037aa0368c53ccdb7eec0fea1edfac3bb2532c0de89631343206d",
"windows/ScenicTheme.cs": "faa259b527d9753bb7915f76f8b5f40f1e066b11d0a5c891e55fd6aaae48b071",
"windows/StartupSelfTest.cs": "54be29a94bcb4ac20da8fd232e93b363f29c21fcb15608bc8171772da524b68b",
"windows/ScenicTheme.cs": "d0c22d7c38071c37f56a5d0e2e7eadb3d30a3435d0bdd9e921259375c2f0f117",
"windows/StartupSelfTest.cs": "cb035bf5d22624ed5034b719f0c52a4c1527ace4c371e966f15f7c25c8126013",
"windows/SystemPowerShell.cs": "1f9247d2e4f8c9bad1d71105886d2ab33d8958006dcff7fadc63f27502eda6fe",
"windows/SystemProxy.cs": "beaf443f1e285e227e0c390d8e9114d5cf8464e0078a8bb842efa9eeb2b5e916",
"windows/THIRD_PARTY_NOTICES.md": "c7141fe279b2c364c868888db37bd995feba1552025e2259dc4662a01e5122bb",
@@ -255,7 +259,7 @@
"windows/TailnetTransportProbe.cs": "d0811b7d9cddcbf622d88e502c7eb05c6afbddbbc0caf3077fa9ec769e52cf50",
"windows/TailnetTransportSelfTest.cs": "573b3271f377a04455339fb67837ed85f8a288b5f9efebd7e73d97fac08def53",
"windows/TokenStore.cs": "e07cf7d1a4cf7a1bba871c19e50b9d6355cb8c1546657346b0256c8215fed8bb",
"windows/TrafficChart.cs": "8ac141da28a350327874485004520c3a159246d2107f3b1152253f4254e76961",
"windows/TrafficChart.cs": "d34dc4b5575604cef3d617e3e95562e6b0088ebf9d29ee7c6e6bda2675442137",
"windows/TunConfigBuilder.cs": "f651c0525ee0e083d4e723f9409c0992b8cc274105bb8ad1e4c7d1c75f3b4354",
"windows/TunConnectivitySelfTest.cs": "a7d7aff1d03e45dff921807cbfb8f83b5013c9df5c7e06b6662d84a8686b2f86",
"windows/TunRouting.cs": "c6b3e1070a0ba0a3c42dbd12becba55404e540d06aba03cb1cc1053fa426a4c1",
@@ -263,10 +267,10 @@
"windows/UpdateSelfTest.cs": "453165bb611efb8db0d8a8c9ea13f3553e0047aa22b838c43096e3d83fe18771",
"windows/UpdateStreamSelfTest.cs": "ad059016c0197f33582b1969ab3280c5b9589a28d659613b3e97ce4a357d38c1",
"windows/UsageHistorySeries.cs": "9e7515ceede1899e06116352de79edd6252c921048bcae9958bf9358d93b3069",
"windows/VPNPlus.csproj": "b85db9d1bbadc126d5e9112d4f78eb33fe8478fd5fb0c9818483a538af68d91b",
"windows/VPNPlus.csproj": "0669e7192f096654a766390564bf23caaa2abf93b0dc8b2f589b8f5679ad4334",
"windows/VpnApiClient.cs": "6e227467981bbc68aac7fb93fe32cfb96f06b0d06f04405209512f1a11c971af",
"windows/WindowChrome.cs": "f7f74759d9ca149c00abd3a7e2ac1556d6630df29eb1e6afc66884dff01f66b9",
"windows/WindowChromeSelfTest.cs": "9643c547733b3274c866122504cd733f1ea6b4c8ce7f0146b5298e7800c25c5b",
"windows/WindowChrome.cs": "0eceea0879e792b8ae83a74eaf5658d4a7be6a798fbdb026ff8d19fa9aa6af2c",
"windows/WindowChromeSelfTest.cs": "4bc45ed8c7357f360e1d17fe189698102b249cf6d7226c887faf5be4104f55af",
"windows/XrayManager.cs": "90b69de09884d037d21f05c411aef83087ce58ceeeffaca295e583ec6be91b50",
"windows/XrayRoutingUpdater.cs": "91fd2b5db25477dbe4de7118faef79f9c51f9a8a3dd86e8b26c676092de3bca5",
"windows/app.manifest": "4c9a2e8e2056c3bb0ae45a5f7b2e223298ee683a82b70ba4910e17f5728cf5b6",
@@ -301,7 +305,9 @@
"windows/licenses/NSIS-COPYING.txt": "388357c1215ff403c5ebde3a5ecd273e68f8b79a579996775245d1ee65442aba",
"windows/licenses/Wintun-License.txt": "183adac21e7d96c508c8fd34d394b7b6708bc81564ad1bad61ab66143a008cd2",
"windows/licenses/Xray-MPL-2.0.txt": "1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5",
"windows/release/RELEASE-NOTES-0.2.21.md": "839f36685e39c04bf692ffd2896bab4538577c0b3bbddd0a3cc335fe13b65d4c"
"windows/release/RELEASE-NOTES-0.2.21.md": "839f36685e39c04bf692ffd2896bab4538577c0b3bbddd0a3cc335fe13b65d4c",
"windows/release/RELEASE-NOTES-0.2.22.md": "bf6c8b448481f59a05e8653fbaa1356d986d2d481c3cbaf02fe6402dcf55d499",
"windows/release/RELEASE-NOTES-0.2.23.md": "2f8aea1ec4d4f1bcc9860d8945dc6266be6ea924ff9958c589a6e4eb0550dc76"
},
"IosSourceCommit": "b07d085413b1b6370245866fd82271b76590b6d6",
"Kind": "clean-history-free-open-source-export",
@@ -324,5 +330,58 @@
"Wintun-License.txt": "183adac21e7d96c508c8fd34d394b7b6708bc81564ad1bad61ab66143a008cd2",
"Xray-MPL-2.0.txt": "1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5"
},
"Windows022MaintenanceDelta": {
"ChangedWindowsFiles": [
"windows/DailyTrafficChart.cs",
"windows/DashboardControls.cs",
"windows/DashboardInteractionSelfTest.cs",
"windows/DashboardWheelRouter.cs",
"windows/MainForm.Chrome.cs",
"windows/MainForm.Dashboard.cs",
"windows/MainForm.cs",
"windows/Program.cs",
"windows/ScenicTheme.cs",
"windows/StartupSelfTest.cs",
"windows/TrafficChart.cs",
"windows/VPNPlus.csproj",
"windows/WindowChrome.cs",
"windows/WindowChromeSelfTest.cs",
"windows/release/RELEASE-NOTES-0.2.22.md"
],
"MacosExcludedTransferredToSeparateMaintainer": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "b249400a314a1430f80e5609cd67c1360d3a3df8cde2f72be7e513fbdc0a025d",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"PrivateSourceCommit": "279b4e8813391d994f89fd9128b960fd3c37d396",
"ProductionAccepted": false,
"PublicBaseCommit": "901f27baf5436a5318ef4e1e87f48782a0da73d1",
"SourceOnly": true,
"UnlicensedLoginSceneOmitted": true,
"Version": "0.2.22"
},
"Windows023TailnetDisplayDelta": {
"ChangedWindowsFiles": [
"windows/DashboardInteractionSelfTest.cs",
"windows/DashboardLayout.cs",
"windows/DashboardTailnetLayoutSelfTest.cs",
"windows/MainForm.Dashboard.cs",
"windows/MainForm.Selection.cs",
"windows/MainForm.TailnetTraffic.cs",
"windows/MainForm.cs",
"windows/VPNPlus.csproj",
"windows/release/RELEASE-NOTES-0.2.23.md"
],
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "b77d3912a8f910f84be94a7adc81d0bd1926310db8c57b83d61a4d72763da2ad",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"PrivateSourceCommit": "e28648198536bdc560a06f05a4e821231e2ea644",
"ProductionAccepted": false,
"PublicBaseCommit": "3ccaea3d52f6b45eed33b7d2170d767aa73bff3d",
"SourceOnly": true,
"Version": "0.2.23"
},
"WindowsSourceCommit": "0d463e6af91a3802c564b06dabb6bf86ebff5a38"
}
+10 -2
View File
@@ -16,7 +16,14 @@ internal sealed class DailyTrafficChart : Control
$"套餐全部设备 · {_series.Timezone}\n{_series.Note}\n本期总量不随筛选改变;本次流量仅指本机当前连接。";
internal string SelectedRange => _period.Key;
internal int PointCount => _series?.Points.Count ?? 0;
internal DailyTrafficChart() { DoubleBuffered = true; BackColor = Color.White; Font = Brand.Font(7.3f); }
internal DailyTrafficChart()
{
DoubleBuffered = true;
SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.Opaque, false);
BackColor = Color.Transparent;
Font = Brand.Font(7.3f);
}
internal void SetHistory(List<DailyUsage> history, Dictionary<string, UsageHistorySeries>? ranges = null)
{ _legacy = history; _ranges = ranges; RefreshSeries(); }
internal void SetPeriod(UsageHistoryPeriod period) { _period = period; RefreshSeries(); }
@@ -46,7 +53,8 @@ internal sealed class DailyTrafficChart : Control
if (points.Count == 0 || points.All(p => p.UploadBytes is null && p.DownloadBytes is null))
{
var message = _series is null ? "此范围需后台提供明细" : "暂无此范围代理流量明细";
TextRenderer.DrawText(e.Graphics, message, Font, Rectangle.Round(_plot), Brand.Muted, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
TextRenderer.DrawText(e.Graphics, message, Font, Rectangle.Round(_plot), Brand.Muted,
ChartAxis.PaintFlags | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
}
void Line(bool up)
{
+4 -3
View File
@@ -110,8 +110,9 @@ internal sealed class MetricCard : CardPanel
using var headingFont = Brand.Font(9);
using var unitFont = Brand.Font(9);
using var hintFont = Brand.Font(7.8f);
TextRenderer.DrawText(g, Heading, headingFont, new Rectangle(x, S(10), available, S(23)), Brand.Text, TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
var flags = TextFormatFlags.NoPadding | TextFormatFlags.SingleLine;
var paintFlags = TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping;
TextRenderer.DrawText(g, Heading, headingFont, new Rectangle(x, S(10), available, S(23)), Brand.Text, paintFlags | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
var flags = TextFormatFlags.NoPadding | TextFormatFlags.SingleLine | paintFlags;
var unitWidth = TextRenderer.MeasureText(g, UnitText, unitFont, Size.Empty, flags).Width;
var size = 22f;
Font valueFont;
@@ -127,7 +128,7 @@ internal sealed class MetricCard : CardPanel
TextRenderer.DrawText(g, ValueText, valueFont, new Rectangle(x, S(31), available - unitWidth - S(4), S(32)), Brand.Navy, flags | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
TextRenderer.DrawText(g, UnitText, unitFont, new Rectangle(x + valueWidth + S(4), S(40), unitWidth, S(23)), Brand.Muted, flags | TextFormatFlags.VerticalCenter);
}
TextRenderer.DrawText(g, Hint, hintFont, new Rectangle(x, S(64), available, S(17)), Brand.Muted, TextFormatFlags.EndEllipsis);
TextRenderer.DrawText(g, Hint, hintFont, new Rectangle(x, S(64), available, S(17)), Brand.Muted, paintFlags | TextFormatFlags.EndEllipsis);
}
}
+140
View File
@@ -0,0 +1,140 @@
using System.Text.Json;
namespace UCVL.VPNPlus;
internal static class DashboardInteractionSelfTest
{
internal static int Run()
{
var checks = new Dictionary<string, bool>();
string? error = null;
try
{
using var form = new MainForm(preview: true, uiOnly: true) { Opacity = 0, ShowInTaskbar = false };
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 >= 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 }));
return passed ? 0 : 28;
}
}
internal sealed partial class MainForm
{
internal Dictionary<string, bool> CheckDashboardInteraction()
{
var checks = new Dictionary<string, bool>();
var profile = new Profile
{
DisplayName = "滚动测试", Email = "fixture@example.invalid",
Nodes = [new NodeInfo { Slug = "fixture", Name = "测试节点" }],
RouteModes = [new RouteModeInfo { Id = "smart", Name = "AI 智能代理" }]
};
Show();
ShowDashboard(profile);
_refreshTimer.Stop();
Size = MinimumSize;
PerformLayout();
LayoutDashboard();
Application.DoEvents();
int Limit() => Math.Max(0, _dashboardScrollBar.Maximum - _dashboardScrollBar.LargeChange + 1);
bool Wheel(Control target, int delta, Point? screenPoint = null)
{
var screen = screenPoint ?? _dashboardView.PointToScreen(new Point(20, 20));
var packedPoint = unchecked((int)((ushort)screen.X | (uint)(ushort)screen.Y << 16));
var packedDelta = unchecked((int)((uint)(ushort)(short)delta << 16));
var message = Message.Create(target.Handle, 0x20a, (IntPtr)packedDelta, (IntPtr)packedPoint);
return Application.FilterMessage(ref message);
}
checks["compact_view_has_real_scroll_range"] = _dashboardScrollBar.Visible && Limit() > 0;
foreach (var (name, control) in new (string, Control)[]
{
("card", _trafficCard), ("nested_metric", _uploadMetric), ("chart", _trafficChart),
("nested_label", _uploadLegend), ("closed_history_combo", _historyRangeCombo),
("closed_node_combo", _connectionModeCombo), ("closed_mode_combo", _routeCombo),
("button", _connectButton)
})
{
_dashboardScrollBar.Value = 0;
var oldSelection = control is ComboBox combo ? combo.SelectedIndex : -1;
checks["wheel_scrolls_over_" + name] = Wheel(control, -120) && _dashboardScrollBar.Value > 0
&& (control is not ComboBox selector || selector.SelectedIndex == oldSelection);
}
_dashboardScrollBar.Value = 0;
var halfHandled = Wheel(_trafficChart, -60);
var firstHalf = _dashboardScrollBar.Value;
checks["high_resolution_wheel_accumulates_half_notches"] = halfHandled && firstHalf == 0
&& Wheel(_trafficChart, -60) && _dashboardScrollBar.Value > 0;
_dashboardScrollBar.Value = Limit();
checks["wheel_bottom_clamped"] = Wheel(_dailyChart, -240) && _dashboardScrollBar.Value == Limit();
checks["wheel_up_returns_from_bottom"] = Wheel(_dailyChart, 120) && _dashboardScrollBar.Value < Limit();
_dashboardScrollBar.Value = Math.Min(137, Limit());
var previous = _dashboardScrollBar.Value;
UpdateProfile(profile, preserveSelections: true);
DisplayTraffic(1234, 5678, "隔离刷新");
LayoutDashboard();
checks["profile_and_metric_refresh_preserve_scroll"] = _dashboardScrollBar.Value == previous && _dashboardBody.Top == -previous;
ClientSize = new Size(ClientSize.Width, ClientSize.Height + ScaleLogical(20));
LayoutDashboard();
checks["resize_preserves_valid_scroll"] = _dashboardScrollBar.Value == Math.Min(previous, Limit());
_dashboardScrollBar.Value = Limit();
checks["footer_reachable_without_horizontal_scroll"] = !_dashboardView.HorizontalScroll.Visible
&& _footer.RectangleToScreen(_footer.ClientRectangle).Bottom <= _dashboardView.RectangleToScreen(_dashboardView.ClientRectangle).Bottom;
previous = _dashboardScrollBar.Value;
checks["header_pointer_does_not_scroll_dashboard"] = !Wheel(_trafficChart, -120, _brandHeader.PointToScreen(new Point(20, 20)))
&& _dashboardScrollBar.Value == previous;
using (var other = new Form())
checks["other_window_messages_not_captured"] = !Wheel(other, -120) && _dashboardScrollBar.Value == previous;
_dashboardScrollBar.Value = 0;
_historyRangeCombo.DroppedDown = true;
checks["open_combo_keeps_native_wheel_navigation"] = !Wheel(_historyRangeCombo, -120) && _dashboardScrollBar.Value == 0;
_historyRangeCombo.DroppedDown = false;
checks["dashboard_reuses_full_login_artwork"] = _dashboardView.LoginArtwork && _dashboardBody.ParentArtwork;
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();
return checks;
}
private static bool CheckMetricRefreshPaint()
{
// Repaint only an owned control into a deliberately dirty backing
// surface. This checks the real WM_PRINTCLIENT path, not OnPaint alone.
using var parent = new ScenicPanel { LoginArtwork = true, Size = new Size(700, 500) };
using var card = new CardPanel { Bounds = new Rectangle(30, 150, 500, 170), MetricBand = true };
using var metric = new MetricCard("本次代理流量", DashboardIcon.Document)
{ Embedded = true, Bounds = new Rectangle(30, 40, 250, 85) };
parent.Controls.Add(card);
card.Controls.Add(metric);
_ = parent.Handle; _ = card.Handle; _ = metric.Handle;
using var actual = new Bitmap(metric.Width, metric.Height);
void Print()
{
using var graphics = Graphics.FromImage(actual);
var hdc = graphics.GetHdc();
try { ChromeNative.SendMessage(metric.Handle, 0x318, hdc, (IntPtr)(0x4 | 0x8)); }
finally { graphics.ReleaseHdc(hdc); }
}
metric.SetBytes(1_073_741_824, hint: "本次连接累计");
Print();
using var expected = new Bitmap(actual);
for (var iteration = 0; iteration < 5; iteration++)
{
metric.SetBytes(999_999_999_999, hint: "旧数据应清除");
Print();
metric.SetBytes(1_073_741_824, hint: "本次连接累计");
Print();
for (var y = 0; y < actual.Height; y++)
for (var x = 0; x < actual.Width; x++)
if (actual.GetPixel(x, y) != expected.GetPixel(x, y)) return false;
}
return true;
}
}
+16 -7
View File
@@ -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;
}
+88
View File
@@ -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;
}
}
+60
View File
@@ -0,0 +1,60 @@
namespace UCVL.VPNPlus;
// WinForms does not bubble wheel input reliably through nested controls. Route
// only this dashboard's queued wheel messages before charts/native closed combos
// consume them. No global hook, focus stealing or installed-window lookup.
internal sealed class DashboardWheelRouter : IMessageFilter, IDisposable
{
private readonly Control _viewport;
private readonly VScrollBar _scrollBar;
private int _remainder;
private bool _disposed;
internal DashboardWheelRouter(Control viewport, VScrollBar scrollBar)
{
_viewport = viewport;
_scrollBar = scrollBar;
viewport.Disposed += ViewportDisposed;
viewport.VisibleChanged += ViewportVisibilityChanged;
Application.AddMessageFilter(this);
}
public bool PreFilterMessage(ref Message message)
{
if (_disposed || message.Msg != 0x20a /* WM_MOUSEWHEEL */ || !_viewport.Visible
|| !_viewport.Enabled || !_scrollBar.Visible || !_viewport.IsHandleCreated) return false;
var target = Control.FromChildHandle(message.HWnd);
if (target is null || target.FindForm() != _viewport.FindForm()) return false;
var packed = message.LParam.ToInt64();
var point = new Point(unchecked((short)(packed & 0xffff)), unchecked((short)((packed >> 16) & 0xffff)));
if (!_viewport.RectangleToScreen(_viewport.ClientRectangle).Contains(point)) return false;
// Open combo lists own their wheel navigation; closed selectors must
// not silently change node/mode/history when scrolling the page.
for (Control? control = target; control is not null; control = control.Parent)
if (control is ComboBox { DroppedDown: true }) return false;
var delta = unchecked((short)((message.WParam.ToInt64() >> 16) & 0xffff));
if (delta == 0) return false;
_remainder += delta;
var notches = _remainder / 120;
_remainder %= 120;
if (notches != 0)
{
var lines = SystemInformation.MouseWheelScrollLines;
var step = lines < 0 ? _scrollBar.LargeChange : (int)Math.Round(18 * _viewport.DeviceDpi / 96d) * lines;
var limit = Math.Max(0, _scrollBar.Maximum - _scrollBar.LargeChange + 1);
_scrollBar.Value = (int)Math.Clamp((long)_scrollBar.Value - (long)notches * step, 0, limit);
}
return true;
}
private void ViewportDisposed(object? sender, EventArgs e) => Dispose();
private void ViewportVisibilityChanged(object? sender, EventArgs e) => _remainder = 0;
public void Dispose()
{
if (_disposed) return;
_disposed = true;
Application.RemoveMessageFilter(this);
_viewport.Disposed -= ViewportDisposed;
_viewport.VisibleChanged -= ViewportVisibilityChanged;
}
}
+30 -6
View File
@@ -3,6 +3,7 @@ namespace UCVL.VPNPlus;
internal sealed partial class MainForm
{
private WindowChrome? _windowChrome;
private bool _minimizedToTray;
internal WindowChrome? WindowChromeForTest => _windowChrome;
// Remove the native caption before HWND creation, not only after its first
@@ -29,23 +30,46 @@ internal sealed partial class MainForm
private void InitializeWindowChrome(Panel header)
{
if (_windowChrome is not null) return;
_windowChrome = new WindowChrome(this, header, RequestExit);
_windowChrome = new WindowChrome(this, header, RequestExit, MinimizeToTray);
_windowChrome.SetLoginMode(true);
}
private void LayoutWindowChrome() => _windowChrome?.LayoutButtons();
// Minimize is a normal taskbar state, never Hide() or a disconnect. Avoid
// presenting a second, tray-only entry while the taskbar owns restoration.
// Keep the core and timers alive. Only the window presentation changes;
// restore/exit remain the existing tray menu actions.
private void MinimizeToTray()
{
if (_exiting || IsDisposed || Disposing || _windowChrome is not { LoginMode: false }) return;
_minimizedToTray = true;
Hide();
ShowInTaskbar = false;
UpdateTaskbarPresentation();
}
private void RestoreFromTrayPresentation()
{
_minimizedToTray = false;
ShowInTaskbar = true;
WindowState = FormWindowState.Normal;
UpdateTaskbarPresentation();
}
private void UpdateTaskbarPresentation()
{
if (_exitResourcesDisposed) return;
if (!_minimizedToTray && Visible && WindowState == FormWindowState.Minimized
&& _windowChrome is { LoginMode: false })
{
MinimizeToTray();
return;
}
_notifyIcon.Visible = ShouldShowTrayIcon(WindowState, _preview || _uiOnly || _exiting);
}
internal static bool ShouldShowTrayIcon(FormWindowState state, bool suppressed) =>
!suppressed && state != FormWindowState.Minimized;
!suppressed;
internal bool MinimizedToTaskbarForTest => WindowState == FormWindowState.Minimized
&& ShowInTaskbar && Visible && !_notifyIcon.Visible && !_exiting;
internal bool MinimizedToTrayForTest => _minimizedToTray && !Visible && !ShowInTaskbar && !_exiting
&& (_preview || _uiOnly || _notifyIcon.Visible);
}
+62 -21
View File
@@ -29,22 +29,29 @@ 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 void BuildDashboardView()
{
_dashboardView.Dock = DockStyle.Fill;
_dashboardView.BackColor = Brand.Surface;
_dashboardView.LoginArtwork = true;
_dashboardView.AutoScroll = false;
_dashboardView.Visible = false;
_dashboardView.Resize += (_, _) => LayoutDashboard();
_content.Controls.Add(_dashboardView);
_dashboardBody.BackColor = Brand.Surface;
_dashboardBody.ParentArtwork = true;
_dashboardView.Controls.Add(_dashboardBody);
_dashboardView.Controls.Add(_dashboardScrollBar);
_dashboardScrollBar.AccessibleName = "主界面垂直滚动";
_dashboardScrollBar.ValueChanged += (_, _) => _dashboardBody.Top = -_dashboardScrollBar.Value;
_dashboardView.MouseWheel += DashboardMouseWheel;
_dashboardBody.MouseWheel += DashboardMouseWheel;
_dashboardScrollBar.ValueChanged += (_, _) =>
{
_dashboardBody.Top = -_dashboardScrollBar.Value;
// Child surfaces use the viewport's fixed backdrop coordinates.
// Moving a canvas must repaint them, not bit-blit old transparent pixels.
_dashboardBody.Invalidate(true);
};
ConfigureLabel(_welcomeLabel, "", Brand.Font(15, FontStyle.Bold), Brand.Navy);
ConfigureLabel(_accountLabel, "", Brand.Font(9.5f), Brand.Muted);
ConfigureLabel(_identityBadge, "", Brand.Font(8.5f), Brand.RoyalBlue);
@@ -139,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 })
{
@@ -147,6 +155,7 @@ internal sealed partial class MainForm
}
_sessionMetric.SetBytes(0, hint: "本次连接累计");
DisplayTraffic(null, null, "仅代理流量 · 近 5 分钟");
_dashboardWheelRouter = new DashboardWheelRouter(_dashboardView, _dashboardScrollBar);
LayoutDashboard();
}
@@ -157,21 +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" : "● 下载 —";
}
private void DashboardMouseWheel(object? sender, MouseEventArgs e)
{
if (!_dashboardScrollBar.Visible || e is HandledMouseEventArgs { Handled: true }) return;
var limit = Math.Max(0, _dashboardScrollBar.Maximum - _dashboardScrollBar.LargeChange + 1);
_dashboardScrollBar.Value = Math.Clamp(_dashboardScrollBar.Value - Math.Sign(e.Delta) * ScaleLogical(54), 0, limit);
if (e is HandledMouseEventArgs handled) handled.Handled = true;
// 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)
{
@@ -305,7 +311,8 @@ internal sealed partial class MainForm
checks["product_header_named_zonghengjia"] = form.Text == "纵横家" && form._brandHeader.Controls.OfType<Label>().Any(label => label.Text == "纵横家");
checks["powered_by_removed_from_login_and_footer"] = !form._footer.Controls.OfType<Label>().Concat(form._loginView.Controls.OfType<Label>())
.Any(label => label.Text.Contains("Powered by", StringComparison.OrdinalIgnoreCase) || label.Text == "优创未来");
checks["content_composes_child_painting"] = form._content.ComposeChildren;
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_artwork_packaged_in_exe"] = ScenicTheme.ArtworkAvailable;
@@ -357,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
@@ -368,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));
}
+1
View File
@@ -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()
+82
View File
@@ -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));
}
}
+26 -12
View File
@@ -37,7 +37,7 @@ internal sealed partial class MainForm : Form
private readonly bool _preview;
private readonly Func<CancellationToken, Task>? _startupRecovery;
private readonly ScenicPanel _content = new() { ComposeChildren = true, LoginArtwork = true };
private readonly ScenicPanel _content = new() { ComposeChildren = false, LoginArtwork = true };
private readonly BrandHeaderPanel _brandHeader = new();
private readonly Label _headerPoem = new();
private readonly RoundedCardPanel _loginView = new();
@@ -98,6 +98,7 @@ internal sealed partial class MainForm : Form
AutoScaleMode = AutoScaleMode.Dpi;
Font = Brand.Font(9.5f);
DoubleBuffered = true;
ResizeRedraw = true;
Icon = LoadIcon();
SuspendLayout();
@@ -500,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;
@@ -655,6 +656,7 @@ internal sealed partial class MainForm : Form
_currentNodeIsPrivateAuxiliary = false;
_currentPrivateEndpoint = null;
_currentNodeUsesTailnet = false;
SetTailnetTrafficVisibility(false);
_transportRetryNodeSlug = null;
_privateLeaseDeadlineTicks = 0;
_currentNodeName = null;
@@ -673,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);
@@ -684,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); }
@@ -1185,6 +1196,7 @@ internal sealed partial class MainForm : Form
// Windows can deliver a queued tray event while the form is already
// shutting down. Ignore it instead of touching disposed WinForms state.
if (_exiting || IsDisposed || Disposing || !IsHandleCreated) return;
RestoreFromTrayPresentation();
Show();
WindowState = FormWindowState.Normal;
if (!Screen.AllScreens.Any(screen => screen.WorkingArea.IntersectsWith(Bounds))) CenterToScreen();
@@ -1391,19 +1403,21 @@ internal sealed partial class MainForm : Form
internal class CardPanel : Panel
{
internal const int SurfaceAlpha = 128;
internal bool Embedded { get; set; }
internal bool ScenicStatus { get; set; }
internal bool AccentBar { get; set; }
internal bool MetricBand { get; set; }
internal CardPanel()
{
SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw
| ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, false);
BackColor = Color.Transparent;
}
protected override void OnPaintBackground(PaintEventArgs eventArgs)
{
if (Embedded) { eventArgs.Graphics.Clear(Color.White); return; }
if (Width < 16 || Height < 16) return;
var g = eventArgs.Graphics;
if (Parent is not null)
{
@@ -1413,22 +1427,22 @@ internal class CardPanel : Panel
g.Restore(state);
}
else g.Clear(Brand.Surface);
// Metrics inherit the freshly painted card; never retain the previous
// number, or add another white tint on every child repaint.
if (Embedded || Width < 16 || Height < 16) return;
g.SmoothingMode = SmoothingMode.AntiAlias;
var s = DeviceDpi / 96f;
var radius = Math.Max(6, (int)(11 * s));
using var shadow = UiGeometry.RoundedRectangle(new Rectangle(1, 3, Width - 3, Height - 4), radius);
using var shadowBrush = new SolidBrush(Color.FromArgb(215, 237, 249));
g.FillPath(shadowBrush, shadow);
using var shadowPen = new Pen(Color.FromArgb(32, 110, 169, 199), Math.Max(1, 2 * s));
g.DrawPath(shadowPen, shadow);
using var path = UiGeometry.RoundedRectangle(new Rectangle(1, 1, Width - 3, Height - 5), radius);
using var fill = new SolidBrush(Color.White);
using var fill = new SolidBrush(Color.FromArgb(SurfaceAlpha, Color.White));
using var border = new Pen(ScenicStatus ? Color.White : Color.FromArgb(201, 227, 249), Math.Max(1, s * (ScenicStatus ? 1.7f : .75f)));
g.FillPath(fill, path);
if (ScenicStatus)
{
var state = g.Save(); g.SetClip(path);
ScenicTheme.Art(g, ClientRectangle, .19f);
using var mist = new LinearGradientBrush(ClientRectangle, Color.FromArgb(200, 243, 255, 252), Color.FromArgb(100, 228, 250, 253), 0f);
g.FillRectangle(mist, ClientRectangle);
ScenicTheme.Clouds(g, new Rectangle(Width - (int)(260*s), (int)(14*s), (int)(120*s), (int)(50*s)), .6f);
g.Restore(state);
}
+5
View File
@@ -27,6 +27,11 @@ internal static class Program
ApplicationConfiguration.Initialize();
return WindowChromeSelfTest.Run();
}
if (args.Length == 1 && args[0] == "--dashboard-interaction-self-test")
{
ApplicationConfiguration.Initialize();
return DashboardInteractionSelfTest.Run();
}
if (args.Length == 2 && args[0] == "--learning-expiry-soak" && int.TryParse(args[1], out var soakMinutes) && soakMinutes is >= 1 and <= 35)
return LearningExpirySoakSelfTest.RunAsync(soakMinutes).GetAwaiter().GetResult();
if (args.Length == 1 && args[0] == "--learning-self-test") return LearningSelfTest.Run();
+6 -2
View File
@@ -1,6 +1,6 @@
# 纵横家 Windows 0.2.21 开源源码
# 纵横家 Windows 0.2.23 开源源码
基于已冻结的 0.2.21 r22 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
基于已冻结的 0.2.23 r2 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
## 构建
@@ -16,3 +16,7 @@ dotnet publish VPNPlus.csproj -c Release -r win-x64 --self-contained true
公司公开 API/下载域名保留兼容用途,内部节点值已替换为示例;不能直接连接公司生产服务。请使用自有环境配置。登录令牌由运行时产生,不应提交进源码。
公司自有代码适用 LICENSE;公司 Logo/商标保留来源识别用途、不授予品牌权利;第三方许可文本在 licenses/ 中,原 THIRD_PARTY_NOTICES.md 保持原文。
本次只同步Windows界面维护代码:滚动/刷新、托盘与透明卡片。清洁导出继续省略可选登录人物插图,使用已有原创山水fallback;未重新导出或修改其它平台。安装包发布证据不能转移为此脱敏源码的构建/真实网络验收。
新增条件 Tailscale 实时卡,内网左二右一,公网隐藏;仅已有代理总量分项,不重复累计。源码仍省略许可不明可选人物插图。
+9
View File
@@ -155,6 +155,7 @@ internal sealed class ScenicPanel : Panel
internal bool ComposeChildren { get; set; }
internal bool FooterArtwork { get; set; }
internal bool LoginArtwork { get; set; }
internal bool ParentArtwork { get; set; }
protected override CreateParams CreateParams
{
get
@@ -167,6 +168,14 @@ internal sealed class ScenicPanel : Panel
internal ScenicPanel() { DoubleBuffered = true; ResizeRedraw = true; BackColor = Brand.Surface; }
protected override void OnPaintBackground(PaintEventArgs e)
{
if (ParentArtwork && Parent is { } parent)
{
var state = e.Graphics.Save();
e.Graphics.TranslateTransform(-Left, -Top);
InvokePaintBackground(parent, new PaintEventArgs(e.Graphics, parent.ClientRectangle));
e.Graphics.Restore(state);
return;
}
if (!LoginArtwork)
{
ScenicTheme.Backdrop(e.Graphics, ClientSize, DeviceDpi, footer: FooterArtwork);
+6 -6
View File
@@ -99,21 +99,21 @@ internal static class StartupSelfTest
form.ShowFromTray();
report["hidden_window_restored"] = form.LoginReadyForTest;
form.WindowState = FormWindowState.Minimized;
report["minimized_only_in_taskbar_without_exit"] = form.MinimizedToTaskbarForTest;
report["production_minimized_tray_hidden"] = !MainForm.ShouldShowTrayIcon(FormWindowState.Minimized, false);
report["minimized_only_in_tray_without_exit"] = form.MinimizedToTrayForTest;
report["production_minimized_tray_available"] = MainForm.ShouldShowTrayIcon(FormWindowState.Minimized, false);
report["production_restored_tray_available"] = MainForm.ShouldShowTrayIcon(FormWindowState.Normal, false);
report["offline_preview_never_publishes_tray"] = Enum.GetValues<FormWindowState>()
.All(state => !MainForm.ShouldShowTrayIcon(state, true));
form.ShowFromTray();
report["minimized_window_restored"] = form.WindowState == FormWindowState.Normal && form.LoginReadyForTest;
var minimizeButton = form.Controls.OfType<BrandHeaderPanel>().Single().Controls.OfType<CaptionButton>().Single();
var programmaticMinimize = await WindowChromeSelfTest.ProbeMinimizeInputAsync(form, minimizeButton, mouse: false);
var programmaticMinimize = await WindowChromeSelfTest.ProbeMinimizeInputAsync(form, minimizeButton, mouse: false, tray: true);
report["mainform_performclick_detail"] = programmaticMinimize;
report["mainform_performclick_minimizes"] = programmaticMinimize.Passed && form.MinimizedToTaskbarForTest;
report["mainform_performclick_minimizes_to_tray"] = programmaticMinimize.Passed && form.MinimizedToTrayForTest;
form.ShowFromTray();
var mouseMinimize = await WindowChromeSelfTest.ProbeMinimizeInputAsync(form, minimizeButton, mouse: true);
var mouseMinimize = await WindowChromeSelfTest.ProbeMinimizeInputAsync(form, minimizeButton, mouse: true, tray: true);
report["mainform_mouse_minimize_detail"] = mouseMinimize;
report["mainform_mouse_down_up_click_minimizes"] = mouseMinimize.Passed && form.MinimizedToTaskbarForTest;
report["mainform_mouse_down_up_click_minimizes_to_tray"] = mouseMinimize.Passed && form.MinimizedToTrayForTest;
form.ShowFromTray();
report["mainform_mouse_minimize_restores"] = form.WindowState == FormWindowState.Normal && form.LoginReadyForTest;
chrome.SetLoginMode(true);
+14 -5
View File
@@ -6,7 +6,14 @@ namespace UCVL.VPNPlus;
internal sealed class TrafficChart : Control
{
private readonly Queue<(DateTimeOffset Time, double Up, double Down)> _points = new();
internal TrafficChart() { DoubleBuffered = true; BackColor = Color.White; Font = Brand.Font(7.3f); }
internal TrafficChart()
{
DoubleBuffered = true;
SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.Opaque, false);
BackColor = Color.Transparent;
Font = Brand.Font(7.3f);
}
internal void Add(double up, double down, DateTimeOffset? time = null)
{
var at = time ?? DateTimeOffset.Now;
@@ -27,7 +34,8 @@ internal sealed class TrafficChart : Control
ChartAxis.TimeLabels(e.Graphics, chart.Plot, Font, [end.AddMinutes(-5).ToString("HH:mm"), end.AddMinutes(-2.5).ToString("HH:mm"), end.ToString("HH:mm")]);
if (points.Length == 0)
{
TextRenderer.DrawText(e.Graphics, "等待代理流量采样", Font, Rectangle.Round(chart.Plot), Brand.Muted, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
TextRenderer.DrawText(e.Graphics, "等待代理流量采样", Font, Rectangle.Round(chart.Plot), Brand.Muted,
ChartAxis.PaintFlags | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
return;
}
PointF[] Line(bool up) => points.Select(p => new PointF(
@@ -40,6 +48,7 @@ internal sealed class TrafficChart : Control
internal static class ChartAxis
{
internal const TextFormatFlags PaintFlags = TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping;
internal static (RectangleF Plot, double Maximum) Draw(Graphics g, Rectangle bounds, Font font, int dpi, double peak, bool speed)
{
var scale = dpi / 96f;
@@ -53,13 +62,13 @@ internal static class ChartAxis
var left = Math.Max(31 * scale, TextRenderer.MeasureText(g, maximum.ToString("0.#"), font).Width + 5 * scale);
var plot = new RectangleF(left, fontHeight + 1, Math.Max(1, bounds.Width - left - 9 * scale), Math.Max(1, bounds.Height - fontHeight * 2 - 7 * scale));
g.SmoothingMode = SmoothingMode.AntiAlias;
TextRenderer.DrawText(g, unitName + (speed ? "/s" : ""), font, new Rectangle(0, 0, bounds.Width, fontHeight), Brand.Muted, TextFormatFlags.NoPadding);
TextRenderer.DrawText(g, unitName + (speed ? "/s" : ""), font, new Rectangle(0, 0, bounds.Width, fontHeight), Brand.Muted, PaintFlags | TextFormatFlags.NoPadding);
using var grid = new Pen(Color.FromArgb(218, 230, 245), Math.Max(1, scale * .6f)) { DashStyle = DashStyle.Dash };
for (var i = 0; i <= 2; i++)
{
var y = plot.Bottom - plot.Height * i / 2;
g.DrawLine(grid, plot.Left, y, plot.Right, y);
TextRenderer.DrawText(g, (maximum * i / 2).ToString("0.#"), font, new Rectangle(0, (int)y - fontHeight / 2, (int)left - 4, fontHeight), Brand.Muted, TextFormatFlags.Right | TextFormatFlags.NoPadding);
TextRenderer.DrawText(g, (maximum * i / 2).ToString("0.#"), font, new Rectangle(0, (int)y - fontHeight / 2, (int)left - 4, fontHeight), Brand.Muted, PaintFlags | TextFormatFlags.Right | TextFormatFlags.NoPadding);
}
for (var i = 0; i <= 6; i++)
{
@@ -77,7 +86,7 @@ internal static class ChartAxis
var x = plot.Left + i * plot.Width / Math.Max(1, labels.Length - 1);
// Align edge labels inside the chart rather than cutting their final digits.
var left = i == 0 ? x : i == labels.Length - 1 ? x - width : x - width / 2;
TextRenderer.DrawText(g, labels[i], font, new Point((int)left, (int)plot.Bottom + 3), Brand.Muted, TextFormatFlags.NoPadding);
TextRenderer.DrawText(g, labels[i], font, new Point((int)left, (int)plot.Bottom + 3), Brand.Muted, PaintFlags | TextFormatFlags.NoPadding);
}
}
+4 -4
View File
@@ -10,10 +10,10 @@
<ApplicationIcon>assets\zonghengjia-app-v1.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<Version>0.2.21</Version>
<AssemblyVersion>0.2.21.0</AssemblyVersion>
<FileVersion>0.2.21.0</FileVersion>
<InformationalVersion>0.2.21</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>
+9 -3
View File
@@ -15,6 +15,7 @@ internal sealed class WindowChrome : IDisposable
private readonly Form _form;
private readonly Panel _header;
private readonly Action _requestExit;
private readonly Action _minimize;
private readonly ToolTip _toolTip = new();
private readonly ChromeFormWindow _window;
private readonly Dictionary<Control, ChromeChildWindow> _children = new();
@@ -27,11 +28,12 @@ internal sealed class WindowChrome : IDisposable
internal CaptionButton MinimizeButton { get; } = new(CaptionAction.Minimize);
internal WindowChrome(Form form, Panel header, Action requestExit)
internal WindowChrome(Form form, Panel header, Action requestExit, Action? minimize = null)
{
_form = form;
_header = header;
_requestExit = requestExit;
_minimize = minimize ?? (() => _form.WindowState = FormWindowState.Minimized);
_window = new ChromeFormWindow(this);
// Managed geometry must see a client-only form. Leaving Sizable here
// makes WinForms add the removed caption dimensions again on restore.
@@ -88,7 +90,7 @@ internal sealed class WindowChrome : IDisposable
if (generation != _handleGeneration || modeGeneration != _modeGeneration) return;
_minimizePending = false;
if (LoginMode || _disposed || _form.IsDisposed || _form.Disposing || !_form.IsHandleCreated) return;
_form.WindowState = FormWindowState.Minimized;
_minimize();
});
}
catch (InvalidOperationException)
@@ -317,7 +319,11 @@ internal sealed class WindowChrome : IDisposable
if (ChromeNative.GetMonitorInfo(monitor, ref info))
Marshal.StructureToPtr(info.Work, m.LParam, false);
}
m.Result = IntPtr.Zero;
// The client-owned header spans the resized window. Retaining
// the old client bits leaves the newly exposed header strip
// unpainted on some DWM/scaling paths. Repaint the complete
// client after a valid NCCALCSIZE sizing transaction.
m.Result = m.WParam != IntPtr.Zero ? (IntPtr)0x300 /* WVR_REDRAW */ : IntPtr.Zero;
return;
}
if (m.Msg == ChromeNative.WmNcHitTest)
+5 -4
View File
@@ -346,15 +346,15 @@ internal static class WindowChromeSelfTest
private static int Distance(Color a, Color b) => Math.Abs(a.R - b.R) + Math.Abs(a.G - b.G) + Math.Abs(a.B - b.B);
internal sealed record MinimizeInputProbe(bool Mouse, bool PointTargetsButton, bool CapturedAfterDown,
int Clicks, bool CapturedDuringClick, bool ManagedMinimized, bool NativeMinimized, bool Visible,
long ReadyElapsedMilliseconds, bool ReadyTimedOut)
long ReadyElapsedMilliseconds, bool ReadyTimedOut, bool ExpectedTray = false, bool HiddenFromTaskbar = false)
{
public bool Passed => (!Mouse || PointTargetsButton && CapturedAfterDown) && Clicks == 1
&& ManagedMinimized && NativeMinimized && Visible;
&& (ExpectedTray ? HiddenFromTaskbar : ManagedMinimized && NativeMinimized && Visible);
}
// Call only for a fixture created by the caller. No global input injection,
// external HWND search, live client, token, process or network interaction.
internal static Task<MinimizeInputProbe> ProbeMinimizeInputAsync(Form form, CaptionButton button, bool mouse)
internal static Task<MinimizeInputProbe> ProbeMinimizeInputAsync(Form form, CaptionButton button, bool mouse, bool tray = false)
{
form.BringToFront();
form.Activate();
@@ -435,7 +435,8 @@ internal static class WindowChromeSelfTest
var style = ChromeNative.GetWindowLongPtr(form.Handle, ChromeNative.GwlStyle).ToInt64();
completion.SetResult(new(mouse, pointTargetsButton, capturedAfterDown, clicks, capturedDuringClick,
form.WindowState == FormWindowState.Minimized, (style & 0x20000000L /* WS_MINIMIZE */) != 0, form.Visible,
ReadyElapsedMilliseconds: readyElapsedMilliseconds, ReadyTimedOut: readyTimedOut));
ReadyElapsedMilliseconds: readyElapsedMilliseconds, ReadyTimedOut: readyTimedOut,
ExpectedTray: tray, HiddenFromTaskbar: !form.Visible && !form.ShowInTaskbar));
}
catch (Exception error) { completion.SetException(error); }
finally { Cleanup(); }
+10
View File
@@ -0,0 +1,10 @@
# 纵横家 Windows 0.2.22
本次为界面维护更新,保留现有 VPN、账号、代理、流量统计和 Tailscale 优先连接逻辑。
- 修复嵌套卡片、图表和关闭状态下拉框区域的上下滚动。
- 登录后最小化收进系统托盘,不保留任务栏窗口;双击托盘恢复,右键菜单断开并退出。登录前右上角 X 仍退出软件。
- 移除全子树合成绘制,修复恢复/缩放时背景漏画及动态数字重影。
- 主界面沿用登录页全景背景;卡片约 50% 白色透明度,文字、按钮和图表仍独立绘制。
只描述本版实际取得的验收证据;旧版网络验收不冒充新版安装验收。其他平台不随本次 Windows 更新宣称正式发布。
+8
View File
@@ -0,0 +1,8 @@
# 纵横家 Windows 0.2.23
- 实际使用 Tailscale 时,左侧原实时网速下方增加 Tailscale 实时上传、下载和曲线;右侧代理流量跨两行。
- 公网连接隐藏 Tailscale 卡片并恢复原布局,不留空白;窄窗口保持纵向滚动。
- Tailscale 卡展示本软件已计入代理总量的链路分项,不重复累计,不代表整机或其它应用的 Tailscale 网卡流量。
- 断开、切换公网或无有效采样时清除旧值。保留现有 Tailscale 优先、同节点公网回退及安装升级逻辑。
Windows x64 非强制维护更新,需管理员授权,安装包未签名。本包离线界面与隔离安装检查不等于生产实窗、新版真实长连接或所有用户均已升级。其它平台不随本次 Windows 版本发布。