private void ApplySettingsProcedure(PdfCreatorSettings settings) { _settingsManager.ApplyAndSaveSettings(settings); _settingsManager.LoadPdfCreatorSettings(); //Load settings to ensure default profile _settingsManager.SaveCurrentSettings(); //Save settings again to synch registry with current settings SettingsLoaded?.Invoke(this, new SettingsEventArgs(_settingsProvider.Settings)); }
private void ExecuteProfileSettings(object o) { var interaction = new ProfileSettingsInteraction(_settingsProvider.Settings, _settingsProvider.GpoSettings); _interactionInvoker.Invoke(interaction); if (interaction.ApplySettings) { _settingsManager.ApplyAndSaveSettings(interaction.Settings); } }
public bool LoadIniSettings() { var fileName = QueryLoadFileName(); if (string.IsNullOrWhiteSpace(fileName)) { return(false); } var overwriteSettings = QueryOverwriteSettings(); if (!overwriteSettings) { return(false); } var settings = _iniSettingsLoader.LoadIniSettings(fileName); if (!_settingsProvider.CheckValidSettings(settings)) { DisplayInvalidSettingsWarning(); return(false); } _settingsManager.ApplyAndSaveSettings(settings); return(true); }
public void CreateNewSettings_SetNewSettings_SettingsAreSetAndEventIsCalled() { var settings = new PdfCreatorSettings(new XmlStorage()); settings.ApplicationSettings.PrimaryPrinter = "primaryPrinter"; _simpleSettingsProvider.Settings.Returns(settings); HandleMessageInteraction(interaction => interaction.Response = MessageResponse.Yes); var viewModel = BuildModel(); var wasSettingsLoadedCalled = false; viewModel.SettingsLoaded += (sender, args) => wasSettingsLoadedCalled = true; (viewModel as RestoreSettingsViewModel).RestoreDefaultSettingsCommand.Execute(null); Received.InOrder(() => { _settingsManager.ApplyAndSaveSettings(Arg.Any <PdfCreatorSettings>()); _settingsManager.LoadAllSettings(); _settingsManager.SaveCurrentSettings(); }); Assert.IsTrue(wasSettingsLoadedCalled); }
public void ModifiedSettings_UserAcceptInteraction_RequestTestPage_CreatesPage() { _invoker .When(invoker => invoker.Invoke(Arg.Any <MessageInteraction>())) .Do(x => { var message = x.Arg <MessageInteraction>(); message.Response = MessageResponse.Yes; }); var viewModel = SetupPdfCreatorTestPagePreperations(true); var wasCalled = false; _testPageHelper .When(x => _testPageHelper.CreateTestPage()) .Do(x => wasCalled = true); viewModel.PrintPdfCreatorTestpageCommand.Execute(null); Received .InOrder(() => { _currentSettingsProvider.Settings.ApplicationSettings = _currentSettingsProvider.Settings.ApplicationSettings.Copy(); _settingsManager.ApplyAndSaveSettings(_currentSettingsProvider.Settings); }); Assert.IsTrue(wasCalled); }
public override bool LoadIniSettings() { var fileName = QueryLoadFileName(); if (string.IsNullOrWhiteSpace(fileName)) { return(false); } var overwriteSettings = QueryOverwriteSettings(); if (!overwriteSettings) { return(false); } if (_iniSettingsLoader.LoadIniSettings(fileName) is PdfCreatorSettings settings) { if (!_settingsProvider.CheckValidSettings(settings)) { DisplayInvalidSettingsWarning(); return(false); } var missingPrinters = FindMissingPrinters(settings.ApplicationSettings.PrinterMappings); var unusedPrinters = GetUnusedPrinters(settings.ApplicationSettings.PrinterMappings); if (unusedPrinters.Any()) { QueryAndDeleteUnusedPrinters(unusedPrinters); } if (missingPrinters.Any()) { QueryAndAddMissingPrinters(missingPrinters); } _actionOrderChecker.Check(settings.ConversionProfiles); foreach (var profile in settings.ConversionProfiles) { profile.Properties.IsShared = false; } _settingsManager.ApplyAndSaveSettings(settings); } return(true); }
private void ExecuteShowSettings(object obj) { _settingsProvider.Settings.ApplicationSettings.LastUsedProfileGuid = SelectedProfile.Guid; var interaction = new ProfileSettingsInteraction(_settingsProvider.Settings.Copy(), _settingsProvider.GpoSettings); _interactionInvoker.Invoke(interaction); if (!interaction.ApplySettings) { return; } ApplicationSettings = interaction.Settings.ApplicationSettings; Profiles = interaction.Settings.ConversionProfiles; SelectProfileByGuid(ApplicationSettings.LastUsedProfileGuid); _settingsManager.ApplyAndSaveSettings(interaction.Settings); }
public void LoadSettings_SettingsAreSetNoError() { IStorage storage = Substitute.For <IStorage>(); var settings = new PdfCreatorSettings(storage); settings.ApplicationSettings.PrimaryPrinter = "primaryPrinter"; _simpleSettingsProvider.Settings.Returns(settings); _iniSettingsAssitant.LoadIniSettings().Returns(true); HandleMessageInteraction(interaction => interaction.Response = MessageResponse.Yes); var viewModel = BuildModel(); viewModel.LoadIniSettingsCommand.Execute(null); Received .InOrder(() => { _settingsManager.ApplyAndSaveSettings(Arg.Any <PdfCreatorSettings>()); _settingsManager.LoadPdfCreatorSettings(); _settingsManager.SaveCurrentSettings(); }); }