コード例 #1
0
 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));
 }
コード例 #2
0
        private void ExecuteProfileSettings(object o)
        {
            var interaction = new ProfileSettingsInteraction(_settingsProvider.Settings, _settingsProvider.GpoSettings);

            _interactionInvoker.Invoke(interaction);

            if (interaction.ApplySettings)
            {
                _settingsManager.ApplyAndSaveSettings(interaction.Settings);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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();
            });
        }