Windows 0.2.22 clean UI-maintenance source delta; no private history or other platform changes
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
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 >= 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<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();
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<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;
|
||||
|
||||
+14
-10
@@ -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();
|
||||
@@ -1185,6 +1186,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 +1393,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 +1417,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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
# 纵横家 Windows 0.2.21 开源源码
|
||||
# 纵横家 Windows 0.2.22 开源源码
|
||||
|
||||
基于已冻结的 0.2.21 r22 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
|
||||
基于已冻结的 0.2.22 r2 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
|
||||
|
||||
## 构建
|
||||
|
||||
@@ -16,3 +16,5 @@ dotnet publish VPNPlus.csproj -c Release -r win-x64 --self-contained true
|
||||
公司公开 API/下载域名保留兼容用途,内部节点值已替换为示例;不能直接连接公司生产服务。请使用自有环境配置。登录令牌由运行时产生,不应提交进源码。
|
||||
|
||||
公司自有代码适用 LICENSE;公司 Logo/商标保留来源识别用途、不授予品牌权利;第三方许可文本在 licenses/ 中,原 THIRD_PARTY_NOTICES.md 保持原文。
|
||||
|
||||
本次只同步Windows界面维护代码:滚动/刷新、托盘与透明卡片。清洁导出继续省略可选登录人物插图,使用已有原创山水fallback;未重新导出或修改其它平台。安装包发布证据不能转移为此脱敏源码的构建/真实网络验收。
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.22</Version>
|
||||
<AssemblyVersion>0.2.22.0</AssemblyVersion>
|
||||
<FileVersion>0.2.22.0</FileVersion>
|
||||
<InformationalVersion>0.2.22</InformationalVersion>
|
||||
<Product>纵横家</Product>
|
||||
<Company>优创未来(UCVL)</Company>
|
||||
<Description>纵横家 Windows 智能网络客户端</Description>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# 纵横家 Windows 0.2.22
|
||||
|
||||
本次为界面维护更新,保留现有 VPN、账号、代理、流量统计和 Tailscale 优先连接逻辑。
|
||||
|
||||
- 修复嵌套卡片、图表和关闭状态下拉框区域的上下滚动。
|
||||
- 登录后最小化收进系统托盘,不保留任务栏窗口;双击托盘恢复,右键菜单断开并退出。登录前右上角 X 仍退出软件。
|
||||
- 移除全子树合成绘制,修复恢复/缩放时背景漏画及动态数字重影。
|
||||
- 主界面沿用登录页全景背景;卡片约 50% 白色透明度,文字、按钮和图表仍独立绘制。
|
||||
|
||||
只描述本版实际取得的验收证据;旧版网络验收不冒充新版安装验收。其他平台不随本次 Windows 更新宣称正式发布。
|
||||
Reference in New Issue
Block a user