From 3ccaea3d52f6b45eed33b7d2170d767aa73bff3d Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 13 Oct 2026 04:32:04 +0000 Subject: [PATCH] Windows 0.2.22 clean UI-maintenance source delta; no private history or other platform changes --- PUBLICATION-AUDIT.json | 9 +- README.md | 2 +- SOURCE-PROVENANCE.json | 63 ++++++++--- windows/DailyTrafficChart.cs | 12 +- windows/DashboardControls.cs | 7 +- windows/DashboardInteractionSelfTest.cs | 139 ++++++++++++++++++++++++ windows/DashboardWheelRouter.cs | 60 ++++++++++ windows/MainForm.Chrome.cs | 36 +++++- windows/MainForm.Dashboard.cs | 25 +++-- windows/MainForm.cs | 24 ++-- windows/Program.cs | 5 + windows/README.md | 6 +- windows/ScenicTheme.cs | 9 ++ windows/StartupSelfTest.cs | 12 +- windows/TrafficChart.cs | 19 +++- windows/VPNPlus.csproj | 8 +- windows/WindowChrome.cs | 12 +- windows/WindowChromeSelfTest.cs | 9 +- windows/release/RELEASE-NOTES-0.2.22.md | 10 ++ 19 files changed, 393 insertions(+), 74 deletions(-) create mode 100644 windows/DashboardInteractionSelfTest.cs create mode 100644 windows/DashboardWheelRouter.cs create mode 100644 windows/release/RELEASE-NOTES-0.2.22.md diff --git a/PUBLICATION-AUDIT.json b/PUBLICATION-AUDIT.json index 9ac8ad6..9ff80f0 100644 --- a/PUBLICATION-AUDIT.json +++ b/PUBLICATION-AUDIT.json @@ -99,5 +99,12 @@ ], "OriginalPrivateSourcesModified": false, "ProductionAccepted": false, - "SourceOnly": true + "SourceOnly": true, + "Windows022MaintenanceDelta": { + "ExampleEndpointChanges": [], + "OptionalUnlicensedSceneRemainsOmitted": true, + "OtherComponentsModified": false, + "ProductionAccepted": false, + "SourceOnly": true + } } diff --git a/README.md b/README.md index d6f2463..2eb3227 100644 --- a/README.md +++ b/README.md @@ -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.22、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。 | 目录 | 内容与状态 | | --- | --- | diff --git a/SOURCE-PROVENANCE.json b/SOURCE-PROVENANCE.json index ceb971a..7fb40fd 100644 --- a/SOURCE-PROVENANCE.json +++ b/SOURCE-PROVENANCE.json @@ -4,7 +4,7 @@ "ExportDiffersFromOriginalCandidates": true, "FilesBeforeProvenanceAndAudit": { "LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e", - "README.md": "5bd226c3cf2855eabf3fae2758944b94fa14ceb16f8ad3a2449e4f97a7a794ae", + "README.md": "607d74c04a6642f9cb596000f9b7f2b790610aa89dd32aeef007f254a406e89d", "SECURITY.md": "34e56cd9b8f6aa5fee45921c6eb831a542e05e76e41850fc31c44e09de088b3c", "THIRD_PARTY_NOTICES.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371", "android/README.md": "bb4387da9a055e97f33bb29a883c543e0938fa858df3fd744abc80553a5ec65c", @@ -191,9 +191,11 @@ "windows/ConnectionSelection.cs": "def94b338b9e1fd940c19b8991e4268a4e59bec741ea624f5a6e4fb7a7d3bbcc", "windows/ConnectionSelectionSelfTest.cs": "12bd82071989c5e539031f6e7921660edb4eb10a4136ac332cc84eca2e2d96de", "windows/ConnectionSelfTest.cs": "6511feda4c81da766e745a499c682d2d0b3be0386c4ba424e7ddc04029ebca12", - "windows/DailyTrafficChart.cs": "5006497ef28cd8a7a00f8553d729220f559cc5205ea0471bdc16be5a7e97fc7d", - "windows/DashboardControls.cs": "f58f30cbd766c0b912afc9b3bda6bc3b88073cb40dc04986c0286790ff2bb758", + "windows/DailyTrafficChart.cs": "4af8d8a91559e6a3fc1dd56db11f3534606aeb486ff918b2b301db0b82e4c716", + "windows/DashboardControls.cs": "b7b1ec34e78d96d23861b0236b945239f4e389d6b8494f53e95e5efe3f4c2182", + "windows/DashboardInteractionSelfTest.cs": "0c91f8ccb702891395d85e4901220381468f576f3ed5b88972a7d7bd12f215e7", "windows/DashboardLayout.cs": "a761de5842c1aa03e68089dc90f73e0a2372532e5367b8e64198ba7b5bd6f8a8", + "windows/DashboardWheelRouter.cs": "d903097a5febbff296febb65855dc10b4e056ea5bb54d2df71b5d1f0297dcc1f", "windows/GitReleasePolicySelfTest.cs": "c43d0e63e9c00a7c6b376ed204bc6c400572085075397685c92862e8318fe369", "windows/GitReleaseUpdater.cs": "dcd00a0feca6801aad4e346c7565d8bcd80b3fd24a4accbe5cd4643d04264b9b", "windows/InstallationIntegration.cs": "af4e5d0cd78d66546079f452e110be627494550594e847d13b77178494fb3bda", @@ -213,11 +215,11 @@ "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": "f11943211bd43259e90ae357512870132fc4e6bdb6cf1b2cdca40382b47170d6", "windows/MainForm.Handover.cs": "a7c6e81186be1d7a154c6997b7d44621543c163ba703901d7974632dd462d25f", "windows/MainForm.Selection.cs": "297186f274b45cd9bf14fbc15492cbe026aea8902ffda386029cbcb75901e469", - "windows/MainForm.cs": "becb27dfb9f94c17506f94f2d7479e5db51033a31b0f3dc1d755634c1310f46a", + "windows/MainForm.cs": "729a5364fcb7d20b53198ba9619a28971029ab4162cced1b2fd4ba49812beccc", "windows/NOTICE.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371", "windows/NetworkHandover.cs": "b43548be0051cf92dfd332e537951e4b5083f2a123be8021994513bbc3748d46", "windows/NetworkHandoverSelfTest.cs": "681d0154dc0aa5f49d7ce1f3088b465eea3ed82571b464951df8d4c89cecdf73", @@ -238,16 +240,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": "e57715545f39c8e4ad0cbd0198ecfcb82be1601b5d1d8bad89abed6eb6ad1513", "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 +257,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 +265,10 @@ "windows/UpdateSelfTest.cs": "453165bb611efb8db0d8a8c9ea13f3553e0047aa22b838c43096e3d83fe18771", "windows/UpdateStreamSelfTest.cs": "ad059016c0197f33582b1969ab3280c5b9589a28d659613b3e97ce4a357d38c1", "windows/UsageHistorySeries.cs": "9e7515ceede1899e06116352de79edd6252c921048bcae9958bf9358d93b3069", - "windows/VPNPlus.csproj": "b85db9d1bbadc126d5e9112d4f78eb33fe8478fd5fb0c9818483a538af68d91b", + "windows/VPNPlus.csproj": "8623063d4b69ff256adb3f5565193a758318fd0173152543745cda9b9fb275d2", "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 +303,8 @@ "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" }, "IosSourceCommit": "b07d085413b1b6370245866fd82271b76590b6d6", "Kind": "clean-history-free-open-source-export", @@ -324,5 +327,35 @@ "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" + }, "WindowsSourceCommit": "0d463e6af91a3802c564b06dabb6bf86ebff5a38" } diff --git a/windows/DailyTrafficChart.cs b/windows/DailyTrafficChart.cs index e3f59da..36f2be9 100644 --- a/windows/DailyTrafficChart.cs +++ b/windows/DailyTrafficChart.cs @@ -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 history, Dictionary? 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) { diff --git a/windows/DashboardControls.cs b/windows/DashboardControls.cs index 413e2b9..43d4f87 100644 --- a/windows/DashboardControls.cs +++ b/windows/DashboardControls.cs @@ -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); } } diff --git a/windows/DashboardInteractionSelfTest.cs b/windows/DashboardInteractionSelfTest.cs new file mode 100644 index 0000000..097209f --- /dev/null +++ b/windows/DashboardInteractionSelfTest.cs @@ -0,0 +1,139 @@ +using System.Text.Json; + +namespace UCVL.VPNPlus; + +internal static class DashboardInteractionSelfTest +{ + internal static int Run() + { + var checks = new Dictionary(); + 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 >= 15 && 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 CheckDashboardInteraction() + { + var checks = new Dictionary(); + 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(); + 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; + } +} diff --git a/windows/DashboardWheelRouter.cs b/windows/DashboardWheelRouter.cs new file mode 100644 index 0000000..7645661 --- /dev/null +++ b/windows/DashboardWheelRouter.cs @@ -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; + } +} diff --git a/windows/MainForm.Chrome.cs b/windows/MainForm.Chrome.cs index 6659c33..c32fb47 100644 --- a/windows/MainForm.Chrome.cs +++ b/windows/MainForm.Chrome.cs @@ -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); } diff --git a/windows/MainForm.Dashboard.cs b/windows/MainForm.Dashboard.cs index 58f7223..0490077 100644 --- a/windows/MainForm.Dashboard.cs +++ b/windows/MainForm.Dashboard.cs @@ -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); @@ -147,6 +154,7 @@ internal sealed partial class MainForm } _sessionMetric.SetBytes(0, hint: "本次连接累计"); DisplayTraffic(null, null, "仅代理流量 · 近 5 分钟"); + _dashboardWheelRouter = new DashboardWheelRouter(_dashboardView, _dashboardScrollBar); LayoutDashboard(); } @@ -159,14 +167,6 @@ internal sealed partial class MainForm _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; - } - private void LayoutDashboard() { if (_layingOutDashboard || _dashboardView.ClientSize.Width <= 0) return; @@ -305,7 +305,8 @@ internal sealed partial class MainForm checks["product_header_named_zonghengjia"] = form.Text == "纵横家" && form._brandHeader.Controls.OfType