52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
|
|
namespace UCVL.VPNPlus;
|
||
|
|
|
||
|
|
internal sealed partial class MainForm
|
||
|
|
{
|
||
|
|
private WindowChrome? _windowChrome;
|
||
|
|
internal WindowChrome? WindowChromeForTest => _windowChrome;
|
||
|
|
|
||
|
|
// Remove the native caption before HWND creation, not only after its first
|
||
|
|
// style/paint messages. This avoids a transient second caption at startup.
|
||
|
|
protected override CreateParams CreateParams
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
var parameters = base.CreateParams;
|
||
|
|
parameters.Style = unchecked((int)ChromeNative.ClientChromeStyle(parameters.Style));
|
||
|
|
return parameters;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnLoad(EventArgs e)
|
||
|
|
{
|
||
|
|
base.OnLoad(e);
|
||
|
|
LayoutBrandHeader();
|
||
|
|
CenterCards();
|
||
|
|
LayoutDashboard();
|
||
|
|
}
|
||
|
|
|
||
|
|
// Explicit title/tray Exit and installer IPC share the graceful exit path.
|
||
|
|
private void InitializeWindowChrome(Panel header)
|
||
|
|
{
|
||
|
|
if (_windowChrome is not null) return;
|
||
|
|
_windowChrome = new WindowChrome(this, header, RequestExit);
|
||
|
|
_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.
|
||
|
|
private void UpdateTaskbarPresentation()
|
||
|
|
{
|
||
|
|
if (_exitResourcesDisposed) return;
|
||
|
|
_notifyIcon.Visible = ShouldShowTrayIcon(WindowState, _preview || _uiOnly || _exiting);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal static bool ShouldShowTrayIcon(FormWindowState state, bool suppressed) =>
|
||
|
|
!suppressed && state != FormWindowState.Minimized;
|
||
|
|
|
||
|
|
internal bool MinimizedToTaskbarForTest => WindowState == FormWindowState.Minimized
|
||
|
|
&& ShowInTaskbar && Visible && !_notifyIcon.Visible && !_exiting;
|
||
|
|
}
|