mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
Fix restoring window state when window starts minimized
Only start minimized when starting at Windows start-up
This commit is contained in:
@@ -26,20 +26,7 @@ namespace VRCX
|
||||
private int LastLocationY;
|
||||
private int LastSizeWidth;
|
||||
private int LastSizeHeight;
|
||||
|
||||
private FormWindowState _LastWindowStateToRestore = FormWindowState.Normal;
|
||||
private FormWindowState LastWindowStateToRestore
|
||||
{
|
||||
get => _LastWindowStateToRestore;
|
||||
set
|
||||
{
|
||||
// Used to restore window state after minimized
|
||||
if (FormWindowState.Minimized != value)
|
||||
{
|
||||
_LastWindowStateToRestore = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
private FormWindowState LastWindowStateToRestore = FormWindowState.Normal;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
@@ -119,25 +106,28 @@ namespace VRCX
|
||||
try
|
||||
{
|
||||
var state = WindowState;
|
||||
if (int.TryParse(VRCXStorage.Instance.Get("VRCX_WindowState"), out int v))
|
||||
var startAsMinimized = VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState") == "true";
|
||||
var closeToTray = VRCXStorage.Instance.Get("VRCX_CloseToTray") == "true";
|
||||
if (int.TryParse(VRCXStorage.Instance.Get("VRCX_WindowState"), out var value))
|
||||
{
|
||||
state = (FormWindowState)v;
|
||||
state = (FormWindowState)value;
|
||||
}
|
||||
if (state == FormWindowState.Minimized)
|
||||
{
|
||||
state = FormWindowState.Normal;
|
||||
}
|
||||
if ("true".Equals(VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState")))
|
||||
// Apply WindowState twice to maximize before minimize
|
||||
WindowState = state;
|
||||
LastWindowStateToRestore = state;
|
||||
|
||||
if (StartupArgs.LaunchArguments.IsStartup && startAsMinimized)
|
||||
{
|
||||
if (closeToTray)
|
||||
{
|
||||
BeginInvoke(Hide);
|
||||
return;
|
||||
}
|
||||
state = FormWindowState.Minimized;
|
||||
}
|
||||
if ("true".Equals(VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState")) &&
|
||||
"true".Equals(VRCXStorage.Instance.Get("VRCX_CloseToTray")))
|
||||
{
|
||||
BeginInvoke(Hide);
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = state;
|
||||
}
|
||||
}
|
||||
@@ -146,20 +136,17 @@ namespace VRCX
|
||||
logger.Error(ex);
|
||||
}
|
||||
|
||||
LastWindowStateToRestore = WindowState;
|
||||
|
||||
// 가끔 화면 위치가 안맞음.. 이걸로 해결 될지는 모르겠음
|
||||
Browser.Invalidate();
|
||||
}
|
||||
|
||||
private void MainForm_Resize(object sender, System.EventArgs e)
|
||||
{
|
||||
LastWindowStateToRestore = WindowState;
|
||||
if (WindowState != FormWindowState.Minimized)
|
||||
LastWindowStateToRestore = WindowState;
|
||||
|
||||
if (WindowState != FormWindowState.Normal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LastSizeWidth = Size.Width;
|
||||
LastSizeHeight = Size.Height;
|
||||
|
||||
@@ -200,7 +187,7 @@ namespace VRCX
|
||||
VRCXStorage.Instance.Set("VRCX_LocationY", LastLocationY.ToString());
|
||||
VRCXStorage.Instance.Set("VRCX_SizeWidth", LastSizeWidth.ToString());
|
||||
VRCXStorage.Instance.Set("VRCX_SizeHeight", LastSizeHeight.ToString());
|
||||
VRCXStorage.Instance.Set("VRCX_WindowState", ((int)WindowState).ToString());
|
||||
VRCXStorage.Instance.Set("VRCX_WindowState", ((int)LastWindowStateToRestore).ToString());
|
||||
VRCXStorage.Instance.Flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace VRCX
|
||||
var arguments = new VrcxLaunchArguments();
|
||||
foreach (var arg in args)
|
||||
{
|
||||
if (arg == VrcxLaunchArguments.IsStartupPrefix)
|
||||
arguments.IsStartup = true;
|
||||
|
||||
if (arg == VrcxLaunchArguments.IsUpgradePrefix)
|
||||
arguments.IsUpgrade = true;
|
||||
|
||||
@@ -95,6 +98,9 @@ namespace VRCX
|
||||
|
||||
internal class VrcxLaunchArguments
|
||||
{
|
||||
public const string IsStartupPrefix = "--startup";
|
||||
public bool IsStartup { get; set; } = false;
|
||||
|
||||
public const string IsUpgradePrefix = "/Upgrade";
|
||||
public bool IsUpgrade { get; set; } = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user