Example #1
0
        private void resetButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to restart? You will lose all progress. This cannot be undone.", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);

            if (dialogResult == DialogResult.Yes)
            {
                XMLParser.CreateNewGameSave();
                System.Diagnostics.Process.Start(Application.ExecutablePath); // to start new instance of application
                Application.Exit();                                           //to turn off current app
            }
        }
Example #2
0
        private void saveButton_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                XMLParser.SaveGameData();
            }
            else if (e.Button == MouseButtons.Right)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Title      = "Select a location to save game settings file";
                saveFileDialog.DefaultExt = "XML File|*.xml";
                saveFileDialog.FileName   = "GameSettingsCustom.xml";
                saveFileDialog.Filter     = "XML Files| *.xml";

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string strpathname = saveFileDialog.FileName;
                    XMLParser.CreateNewGameSave(strpathname);
                }
            }
        }
Example #3
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     try
     {
         Application.Run(new MainForm());
     }
     catch (XMLNotFoundException)
     {
         DialogResult dialogResult = MessageBox.Show("It appears you don't have a game save. Create one?", "Hmmm...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dialogResult == DialogResult.Yes)
         {
             XMLParser.CreateNewGameSave();
             Application.Run(new MainForm());
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }