private void MainWindow_VisibleChanged(object sender, EventArgs e) { if (this.Visible == false && GameScreen == null) { GameScreen = new Sc_game(this, null); GameScreen.ShowDialog(this); } }
private void ButtonClik(object o, EventArgs e) { Button bouton = o as Button; bouton.BackgroundImage = Properties.Resources.btn_not_hover; switch (bouton.Text) { case "NOUVELLE PARTIE": CacherControl(2); break; case "CHARGER PARTIE": { GameState sauvegarde; using (OpenFileDialog file = new OpenFileDialog()) { if (file.ShowDialog() == DialogResult.OK) { string path = file.FileName; System.Runtime.Serialization.IFormatter formatter = new BinaryFormatter(); System.IO.FileStream filestream = new System.IO.FileStream(path, System.IO.FileMode.Open); try { sauvegarde = (GameState)formatter.Deserialize(filestream); MessageBox.Show("Test "); } catch (Exception ex) { MessageBox.Show("An error has occured : " + ex.Message); return; } GameScreen = new Sc_game(this, sauvegarde); GameScreen.ShowDialog(this); filestream.Close(); } } } break; case "QUITTER": if (MessageBox.Show("VOULEZ VOUS QUITTER LE JEU ?", "QUITTER", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Application.Exit(); } break; default: break; } }