/// <summary> /// Called when the <see cref="ResetToDefaultsCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnResetToDefaultsCommandExecuted(object parameter) { var activeSettingsName = ActiveSettingsName; var result = MessageBox.Show(@"Are you sure you want all " + activeSettingsName + " to be reset to their defaults?" + Environment.NewLine + Environment.NewLine + @"This action cannot be undone.", @"CodeMaid: Confirmation for Reset " + activeSettingsName, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { try { File.Delete(ActiveSettingsPath); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format("CodeMaid has successfully reset " + activeSettingsName + "."), "CodeMaid: Reset " + activeSettingsName + " Successful", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine("Unable to reset " + ActiveSettingsName, ex); MessageBox.Show("CodeMaid was unable to reset " + activeSettingsName + ". See output window for more details.", "CodeMaid: Reset " + activeSettingsName + " Unsuccessful", MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// Called when the <see cref="ResetToDefaultsCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnResetToDefaultsCommandExecuted(object parameter) { var activeSettingsName = ActiveSettingsName; var result = MessageBox.Show(Resources.AreYouSureYouWantAll + activeSettingsName + Resources.OptionsViewModel_OnResetToDefaultsCommandExecuted_ToBeResetToTheirDefaults + Environment.NewLine + Environment.NewLine + Resources.ThisActionCannotBeUndone, Resources.CodeMaidConfirmationForReset + activeSettingsName, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { try { File.Delete(ActiveSettingsPath); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format(Resources.CodeMaidHasSuccessfullyReset + activeSettingsName + "."), Resources.CodeMaidReset + activeSettingsName + Resources.Successful, MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(Resources.UnableToReset + ActiveSettingsName, ex); MessageBox.Show(Resources.CodeMaidWasUnableToReset + activeSettingsName + Resources.SeeOutputWindowForMoreDetails, Resources.CodeMaidReset + activeSettingsName + Resources.Unsuccessful, MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// Called when the <see cref="ImportCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnImportCommandExecuted(object parameter) { if (CheckToSavePendingChangesShouldCancelOperation()) { return; } var activeSettingsName = ActiveSettingsName; var dialog = new Microsoft.Win32.OpenFileDialog { Title = Resources.CodeMaidImport + activeSettingsName, DefaultExt = ".config", Filter = Resources.ConfigFilesConfigConfigAllFiles, CheckFileExists = true }; if (dialog.ShowDialog() == true) { try { File.Copy(dialog.FileName, ActiveSettingsPath, true); File.SetAttributes(ActiveSettingsPath, File.GetAttributes(ActiveSettingsPath) & ~FileAttributes.ReadOnly); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format(Resources.CodeMaidHasSuccessfullyImported1From0, dialog.FileName, activeSettingsName), Resources.CodeMaidImport + activeSettingsName + Resources.Successful, MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(Resources._UnableToImport + activeSettingsName, ex); MessageBox.Show(Resources.CodeMaidWasUnableToImport + activeSettingsName + Resources.SeeOutputWindowForMoreDetails, Resources.CodeMaidImport + activeSettingsName + Resources.Unsuccessful, MessageBoxButton.OK, MessageBoxImage.Error); } } }
/// <summary> /// Called when the <see cref="ImportCommand" /> is executed. /// </summary> /// <param name="parameter">The command parameter.</param> private void OnImportCommandExecuted(object parameter) { if (CheckToSavePendingChangesShouldCancelOperation()) { return; } var activeSettingsName = ActiveSettingsName; var dialog = new Microsoft.Win32.OpenFileDialog { Title = "CodeMaid: Import " + activeSettingsName, DefaultExt = ".config", Filter = "Config files (*.config)|*.config|All Files (*.*)|*.*", CheckFileExists = true }; if (dialog.ShowDialog() == true) { try { File.Copy(dialog.FileName, ActiveSettingsPath, true); RefreshPackageSettings(); ActiveSettings.Reload(); ReloadPagesFromSettings(); MessageBox.Show(string.Format("CodeMaid has successfully imported " + activeSettingsName + " from '{0}'.", dialog.FileName), "CodeMaid: Import " + activeSettingsName + " Successful", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine("Unable to import " + activeSettingsName, ex); MessageBox.Show("CodeMaid was unable to import " + activeSettingsName + ". See output window for more details.", "CodeMaid: Import " + activeSettingsName + " Unsuccessful", MessageBoxButton.OK, MessageBoxImage.Error); } } }