why use all that code when you could use one simple line of code

Form1.WindowState = 1