Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            GameForm form = new GameForm();

            form.Show();
            this.Visibility = System.Windows.Visibility.Hidden;
            this.Close();
        }
Exemplo n.º 2
0
 //On click of the button ok event to deal with getting the selected option and loading the game from the file
 private void buttonOK_Click(object sender, EventArgs e)
 {
     //load the game by file name in game form
     GameForm loadGame = new GameForm(comboFiles.SelectedItem.ToString());
     //show the loaded game form
     loadGame.Show();
     //dispose this load menu form
     this.Dispose();
 }
Exemplo n.º 3
0
 //on click button ok event
 private void buttonOK_Click(object sender, EventArgs e)
 {
     //default caluse of size and rate
     int size = 20;
     int rate = 240;
     //Check if new information in the text boxes different to empty string get that info as size and rate
     if(sizeText.Text.ToString()!= "") size = (int)Convert.ToDouble(sizeText.Text.ToString()) + 1;
     //rate entered by the user in seconds but used in the game as milliseconds thus multiplication of the number by 60
     if(genRateText.Text.ToString() != "") rate = ((int)(Convert.ToDouble(genRateText.Text.ToString()) + 1))* 60 ;
     //creates a new game form with the new size and rate
     GameForm theGame = new GameForm(size, rate);
     //show the new game form to start playing
     theGame.Show();
     this.Dispose();
 }
Exemplo n.º 4
0
 // ************ LOADING ************ //
 /// <summary>
 /// Presents a FolderBrowserDialog that allows for the user to select a past state to load.
 /// </summary>
 /// <remarks>
 /// Author: Rudy Ariaz
 /// </remarks>
 private void btnLoadState_Click(object sender, EventArgs e)
 {
     // Create the browser
     using (FolderBrowserDialog browser = new FolderBrowserDialog())
     {
         // Set the initial path to the directory with all the past states
         browser.SelectedPath = Datastore.GeneralStatesDirectoryPath;
         // Hide the "New Folder" button in the dialog
         browser.ShowNewFolderButton = false;
         // Get the result of the selection
         DialogResult result = browser.ShowDialog();
         // Check if there was an error with the selection, if:
         //     A folder was selected
         //     The selected path was empty, or it was out of the past states directory, or
         //     if no subdirectory was selected
         if (result == DialogResult.OK && (string.IsNullOrWhiteSpace(browser.SelectedPath) ||
                                           !browser.SelectedPath.Contains(Datastore.GeneralStatesDirectoryPath) ||
                                           browser.SelectedPath.Length <= Datastore.GeneralStatesDirectoryPath.Length))
         {
             // Show an error message
             MessageBox.Show("Please select a valid directory within the PastStates directory.");
         }
         // Otherwise, if a valid folder was selected:
         else if (result == DialogResult.OK)
         {
             // Load the selected state
             manager.LoadState(browser.SelectedPath);
             // Create the game form
             GameForm gameForm = new GameForm(manager, manager.Username);
             // Display the new game form
             gameForm.ShowDialog();
             // Close this form
             this.Close();
         }
     }
 }