private void ChangeGameFolderButton_Click(object sender, EventArgs e) { try { // Configure browser dialog where current path is valid if (Directory.Exists(Settings.Default.UserGameFolderPath)) { GameFolderBrowserDialog.SelectedPath = Settings.Default.UserGameFolderPath; } else { GameFolderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop; } // Get game folder from user var dialogResult = GameFolderBrowserDialog.ShowDialog(); // If user selects a folder if (dialogResult == DialogResult.OK) { // Save selected folder Settings.Default.UserGameFolderPath = GameFolderBrowserDialog.SelectedPath; Settings.Default.Save(); // Update controls PathTextBox.Text = Settings.Default.UserGameFolderPath; } } catch (Exception ex) { MessageBox.Show( $"{Settings.Default.ApplicationName} has encountered an error while attempting to update the game folder path.{Environment.NewLine}{Environment.NewLine}Error: {ex.Message}", Settings.Default.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BrowseBtn_Click(object sender, EventArgs e) { var result = GameFolderBrowserDialog.ShowDialog(); if (result == DialogResult.OK) { SelectedGamePath(); } }
private void ConfigureGameFolder() { try { // Prompt the user to select the game folder MessageBox.Show( string.Format("{0} requires you to select the {1} installation folder.{2}{2}Click OK to browse for the {1} installation folder.", Settings.Default.ApplicationName, Settings.Default.GameName, Environment.NewLine), Settings.Default.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // Get game folder from user var folderDialogResult = GameFolderBrowserDialog.ShowDialog(); // If user does not select an installation folder if (folderDialogResult != DialogResult.OK) { // Set installation folder to default and show message to advise Settings.Default.UserGameFolderPath = Settings.Default.DefaultGameFolderPath; MessageBox.Show( string.Format("As you did not select an installation folder for {1}, {0} will assume that the game is installed at the following location.{2}{2}{3}", Settings.Default.ApplicationName, Settings.Default.GameName, Environment.NewLine, Settings.Default.DefaultGameFolderPath), Settings.Default.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Settings.Default.UserGameFolderPath = GameFolderBrowserDialog.SelectedPath; } // Save selected game installation folder Settings.Default.Save(); } catch (Exception ex) { MessageBox.Show( string.Format( "{0} has encountered an error while attempting to configure the game folder.{1}{1}" + "Error: {2}{1}{1}To resolve this error, try running {0} as an administrator.", Settings.Default.ApplicationName, Environment.NewLine, ex.Message), Settings.Default.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Opens the dialog to save the game to an xml file private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (gameNameText.Text != "" && isStarted) { GameFolderBrowserDialog.Disposed += SaveGameFolderBrowserDialog_Disposed; GameFolderBrowserDialog.ShowDialog(); } else { if (gameNameText.Text == "") { Notification temp = new Notification("Please provide a name for your game!"); temp.Show(); } else { Notification temp = new Notification("Please create a new game before saving!"); temp.Show(); } } }
// Opens the dialog to load the game from an xml file private void loadToolStripMenuItem_Click(object sender, EventArgs e) { GameFolderBrowserDialog.Disposed += LoadGameFolderBrowserDialog_Disposed; GameFolderBrowserDialog.ShowDialog(); }