private void button2_Click(object sender, EventArgs e) { if (File.Exists("Save.bin")) { Stream stream = new FileStream("Save.bin", FileMode.Open, FileAccess.Read, FileShare.Read); FormState formState = (FormState)formatter.Deserialize(stream); stream.Close(); switch (formState.level) { case "Level1": Level1 level1 = new Level1(); level1.InitState(formState); level1.Show(); break; case "Level2": Level2 level2 = new Level2(); level2.InitState(formState); level2.Show(); break; case "Level3": Level3 level3 = new Level3(); level3.InitState(formState); level3.Show(); break; case "Level4": Level4 level4 = new Level4(); level4.InitState(formState); level4.Show(); break; case "Level5": Level5 level5 = new Level5(); level5.InitState(formState); level5.Show(); break; } this.Hide(); } }
private void button1_Click(object sender, EventArgs e) { Level1 level1 = new Level1(); this.Hide(); if (File.Exists("Save.bin")) { File.Delete("Save.bin"); } level1.Show(); }