Green ball to un-maximize window

I have code in window Maximize to store window setting of “MAX” so that next time app runs the main window is maximized.

But I added code to Minimize to undo that and set to “MIN”. But I realize now Minimize is not what I want but if they click green ball when maximized… then set to default windows size not full screen.

How do I detect when they clicked green ball when window is full screen so that I can detect the reverse?

Window.Restore will fire when moving from Maximized to its “regular” floating size, it will also fire when coming out of Minimized.