Windows 0.2.22 clean UI-maintenance source delta; no private history or other platform changes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user