MainWindow.cs: fix window-size clamping function, and only save window-size&position when window is in normal mode (not maximized, not minimized)