예제 #1
0
        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);
            }
        }
예제 #2
0
        private void BrowseBtn_Click(object sender, EventArgs e)
        {
            var result = GameFolderBrowserDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                SelectedGamePath();
            }
        }
예제 #3
0
파일: MainForm.cs 프로젝트: Vjww/F1mpEditor
        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);
            }
        }
예제 #4
0
 // 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();
         }
     }
 }
예제 #5
0
 // 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();
 }