private PdfCreatorSettings CreateSettings()
        {
            var profileBuilder = new DefaultProfileBuilder();
            var settings       = profileBuilder.CreateDefaultSettings("MySpecialPrinter", new IniStorage(), "Elbisch");

            return(settings);
        }
Exemple #2
0
        public void SettingsUpdateV3To4_VersionBecomes4_TiffColorBlackWihteGetsBlackWhiteG4Fax()
        {
            const int oldSettingsVersion = 3;
            const int newSettingsVersion = 4;

            var ini         = new IniStorage(Encoding.UTF8);
            var builder     = new DefaultProfileBuilder();
            var oldSettings = builder.CreateDefaultSettings("PDFCreator", ini, "English");

            oldSettings.ConversionProfiles[0].TiffSettings.Color = TiffColor.BlackWhiteG4Fax;
            var currentSettingsVersion = oldSettings.ApplicationProperties.SettingsVersion;

            oldSettings.ApplicationProperties.SettingsVersion = oldSettingsVersion;
            var iniFile = Path.Combine(_th.TmpTestFolder, "TestSettings.ini");

            oldSettings.SaveData(ini, iniFile);

            var settingsFromIni = File.ReadAllText(iniFile);

            settingsFromIni = settingsFromIni.Replace("BlackWhiteG4Fax", "BlackWhite");
            File.WriteAllText(iniFile, settingsFromIni);

            var upgrader = new SettingsUpgradeHelper(newSettingsVersion);
            var settings = new DefaultProfileBuilder().CreateEmptySettings(null);

            settings.LoadData(ini, iniFile, upgrader.UpgradeSettings);

            Assert.AreEqual(newSettingsVersion, settings.ApplicationProperties.SettingsVersion, "Did not update SettingsVersion.");
            Assert.AreEqual(TiffColor.BlackWhiteG4Fax, settings.ConversionProfiles[0].TiffSettings.Color, "Did not update TiffColor BlackWhite to BlackWhiteG4Fax");
        }
Exemple #3
0
        public PdfCreatorSettings LoadPdfCreatorSettings()
        {
            MoveSettingsIfRequired();
            var regStorage = BuildStorage();

            var profileBuilder = new DefaultProfileBuilder();
            var settings       = profileBuilder.CreateEmptySettings(regStorage);

            var settingsUpgrader = new SettingsUpgradeHelper(SettingsVersion);

            if (UserSettingsExist())
            {
                settings.LoadData(regStorage, "", settingsUpgrader.UpgradeSettings);
            }

            if (!CheckValidSettings(settings))
            {
                var defaultLanguage = _languageDetector.FindDefaultLanguage();
                if (!_languageProvider.HasTranslation(defaultLanguage))
                {
                    defaultLanguage = "English";
                }

                var defaultSettings = profileBuilder.CreateDefaultSettings(FindPrimaryPrinter(), regStorage, defaultLanguage);

                if (DefaultUserSettingsExist())
                {
                    settings = LoadDefaultUserSettings(defaultSettings, profileBuilder, regStorage);
                }
                else
                {
                    settings = defaultSettings;
                }
            }

            CheckAndAddMissingDefaultProfile(settings, profileBuilder);
            CheckPrinterMappings(settings);
            CheckTitleReplacement(settings);

            if (settings.ApplicationSettings.Language == "")
            {
                var language = _languageProvider.FindBestLanguage(CultureInfo.CurrentCulture);

                if (language != null)
                {
                    settings.ApplicationSettings.Language = Path.GetFileNameWithoutExtension(language.FileName);
                }
            }

            TranslateProfilenames(settings);

            LogProfiles(settings);

            return(settings);
        }
        private void ExecuteRestoreDefaultSettings(object obj)
        {
            var title              = Translator.GetTranslation("ApplicationSettingsWindow", "RestoreDefaultSettingsTitle");
            var message            = Translator.GetTranslation("ApplicationSettingsWindow", "RestoreDefaultSettingsMessage");
            var messageInteraction = new MessageInteraction(message, title, MessageOptions.YesNo, MessageIcon.Question);

            _invoker.Invoke(messageInteraction);
            if (messageInteraction.Response == MessageResponse.Yes)
            {
                var profileBuilder  = new DefaultProfileBuilder();
                var defaultSettings = profileBuilder.CreateDefaultSettings(_settingsProvider.Settings);
                ApplySettingsProcedure(defaultSettings);
            }
        }