diff --git a/Dotnet/MainForm.cs b/Dotnet/MainForm.cs index 6db54a50..bfde0a1e 100644 --- a/Dotnet/MainForm.cs +++ b/Dotnet/MainForm.cs @@ -25,11 +25,25 @@ public partial class MainForm : WinformBase 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; + } + } + } + public MainForm() { Instance = this; InitializeComponent(); - + // adding a 5s delay here to avoid excessive writes to disk _saveTimer = new Timer(); _saveTimer.Interval = 5000; @@ -129,28 +143,32 @@ private void MainForm_Load(object sender, System.EventArgs e) jslogger.Error(ex); } + LastWindowStateToRestore = WindowState; + // 가끔 화면 위치가 안맞음.. 이걸로 해결 될지는 모르겠음 Browser.Invalidate(); } private void MainForm_Resize(object sender, System.EventArgs e) { + LastWindowStateToRestore = WindowState; + if (WindowState != FormWindowState.Normal) { return; } LastSizeWidth = Size.Width; LastSizeHeight = Size.Height; - + _saveTimer?.Start(); } - + private void SaveTimer_Tick(object sender, EventArgs e) { SaveWindowState(); _saveTimer?.Stop(); } - + private void MainForm_Move(object sender, System.EventArgs e) { if (WindowState != FormWindowState.Normal) @@ -159,7 +177,7 @@ private void MainForm_Move(object sender, System.EventArgs e) } LastLocationX = Location.X; LastLocationY = Location.Y; - + _saveTimer?.Start(); } @@ -172,7 +190,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) Hide(); } } - + private void SaveWindowState() { VRCXStorage.Instance.Set("VRCX_LocationX", LastLocationX.ToString()); @@ -203,11 +221,11 @@ private void TrayMenu_Open_Click(object sender, System.EventArgs e) public void Focus_Window() { + Show(); if (WindowState == FormWindowState.Minimized) { - WindowState = FormWindowState.Normal; + WindowState = LastWindowStateToRestore; } - Show(); // Focus(); Activate(); }