/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// <summary> /// When the user close the application, save the options. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e) { try { Configuration.Serialize(OPTIONSFILEPATH, options); // Try to save BestScore.Save(SCOREFILEPATH, highScore); } catch (Exception ex) // Error occured { MessageBox.Show("Vos options n'ont pas pu être sauvegardée pour la raison suivante :\n" + ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
static void Main() { try { options = Configuration.Deserialize(OPTIONSFILEPATH); highScore = BestScore.Load(SCOREFILEPATH); } catch (Exception) { options = new Options(); // Error, load defaut values highScore = new Hashtable(); } Application.Run(new frmMain()); // Load the application }