Ejemplo n.º 1
0
        /// <summary>
        ///     Load the settings. If no valid settings exist for this user, default settings will be created.
        /// </summary>
        private static void LoadSettings()
        {
            var settingsMover = new SettingsMover();

            if (settingsMover.MoveRequired())
            {
                settingsMover.MoveSettings();
            }

            _settings = CreateEmptySettings();

            if (UserSettingsExist())
            {
                _settings.LoadData(_settings.GetStorage(), "", UpgradeSettings);
            }

            if (!CheckValidSettings(_settings))
            {
                if (DefaultUserSettingsExist())
                {
                    _settings.LoadData(new RegistryStorage(RegistryHive.Users, @".DEFAULT\" + SETTINGS_REG_PATH), "", UpgradeSettings);
                }
                else
                {
                    _settings = CreateDefaultSettings();
                }
            }

            CheckAndAddMissingDefaultProfile(_settings);

            CheckPrinterMappings();

            CheckTitleReplacement();

            if (_settings.ApplicationSettings.Language == "")
            {
                var language = TranslationHelper.Instance.LanguageLoader.FindBestLanguage(CultureInfo.CurrentCulture);

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

            //Determine language considering GPO
            var applicationLanguage = GpoSettings.Language ?? Settings.ApplicationSettings.Language;

            TranslationHelper.Instance.InitTranslator(applicationLanguage);
            LoggingHelper.ChangeLogLevel(_settings.ApplicationSettings.LoggingLevel);
            TranslationHelper.Instance.TranslateProfileList(Settings.ConversionProfiles);

            if (_logger.IsTraceEnabled)
            {
                _logger.Trace("Profiles:");
                foreach (var conversionProfile in _settings.ConversionProfiles)
                {
                    _logger.Trace(conversionProfile.Name);
                }
            }
        }
        public PdfCreatorSettings CreateDefaultSettings(PdfCreatorSettings currentSettings)
        {
            var primaryPrinter  = currentSettings.ApplicationSettings.PrimaryPrinter;
            var storage         = currentSettings.GetStorage();
            var defaultLanguage = currentSettings.ApplicationSettings.Language;

            return(CreateDefaultSettings(primaryPrinter, storage, defaultLanguage));
        }