Example #1
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Check if user entered values (should always have a value but just in case)
            if (string.IsNullOrWhiteSpace(DocumentTextBox.Text) || string.IsNullOrWhiteSpace(SaveGamesTextBox.Text))
            {
                switch (MessageBox.Show($"You haven't entered all paths, without these the program cannot function. Do you want to close the program or try again?", "Missing settings", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning))
                {
                case System.Windows.Forms.DialogResult.Cancel:
                    System.Windows.Application.Current.Shutdown();
                    break;

                default:
                    return;
                }
            }
            // Update settings with new values and save
            SettingsLoader.Instance.Settings.DocumentsFolder  = DocumentTextBox.Text;
            SettingsLoader.Instance.Settings.SavedGamesFolder = SaveGamesTextBox.Text;
            SettingsLoader.SaveSettings();
        }
Example #2
0
        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            #region CheckFolder
            // Check if user entered values (should always have a value but just in case)
            if (string.IsNullOrWhiteSpace(DocumentTextBox.Text) || string.IsNullOrWhiteSpace(SaveGamesTextBox.Text))
            {
                switch (MessageBox.Show($"You haven't entered the paths, without these the program cannot function. Do you want to cancel or try again?", "Missing paths", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning))
                {
                case System.Windows.Forms.DialogResult.Cancel:
                    Close();
                    break;

                default:
                    return;
                }
            }
            // Check if user has selected a special folder, and if so warn them and give directions on how to move special folders through Windows's settings
            bool          ShouldShowWarning = false;
            DirectoryInfo directoryInfo     = new(DocumentTextBox.Text);
            foreach (Environment.SpecialFolder suit in Enum.GetValues(typeof(Environment.SpecialFolder)))
            {
                if (directoryInfo.FullName == Environment.GetFolderPath(suit))
                {
                    ShouldShowWarning = true;
                    break;
                }
            }
            if (ShouldShowWarning)
            {
                switch (MessageBox.Show($"You're about to redirect a \"special\" folder, these are important Windows folders and it's recommended to change them through the system settings, only continue if you know what you're doing.", "Special folder detected", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
                {
                case System.Windows.Forms.DialogResult.Cancel:
                    return;

                default:
                    break;
                }
            }
            // Check if folder is inside of the Windows directory
            if (DocumentTextBox.Text.StartsWith(Environment.GetFolderPath(Environment.SpecialFolder.Windows), StringComparison.OrdinalIgnoreCase))
            {
                switch (MessageBox.Show($"You're about to redirect a system folder, these are important Windows folders and it's recommended to not move them, only continue if you know what you're doing. This program is not to blame if your system breaks!", "Windows folder detected", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
                {
                case System.Windows.Forms.DialogResult.Cancel:
                    return;

                default:
                    break;
                }
            }
            #endregion
            Redirection redirection = new()
            {
                SourcePath      = DocumentTextBox.Text,
                DestinationPath = SaveGamesTextBox.Text,
                Name            = GameNameTextBox.Text,
                IconPath        = RedirectionImageTextBox.Text
            };
            Redirector.Redirect(redirection, StatusReport);
            SettingsLoader.SaveSettings();
            MessageBox.Show("Success!", "Redirection Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
        }
    }
Example #3
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     SettingsLoader.SaveSettings();
 }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     redirection.IconPath = RedirectionImageTextBox.Text;
     redirection.Name     = GameNameTextBox.Text;
     SettingsLoader.SaveSettings();
 }