Exemple #1
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);
        }
Exemple #2
0
        private PdfCreatorSettings LoadDefaultUserSettings(PdfCreatorSettings defaultSettings, DefaultProfileBuilder profileBuilder,
                                                           IStorage regStorage)
        {
            var defaultUserStorage = new RegistryStorage(RegistryHive.Users,
                                                         @".DEFAULT\" + _installationPathProvider.SettingsRegistryPath);

            var data = Data.CreateDataStorage();

            defaultUserStorage.SetData(data);

            // Store default settings and then load the machine defaults from HKEY_USERS\.DEFAULT to give them prefrence
            defaultSettings.StoreValues(data, "");
            defaultUserStorage.ReadData("", false);

            // And then load the combined settings with default user overriding our defaults
            var settings = profileBuilder.CreateEmptySettings(regStorage);

            settings.ReadValues(data, "");

            return(settings);
        }