Пример #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);
                }
            }
        }
Пример #2
0
        public void SetUp()
        {
            Assembly a      = Assembly.GetExecutingAssembly();
            string   appDir = Path.GetDirectoryName(a.CodeBase.Replace(@"file:///", ""));

            if (appDir == null)
            {
                throw new InvalidDataException("The app dir may never be null");
            }

            _languagePath = FindTranslationFolder();

            Assert.True(Directory.Exists(_languagePath), "Could not find language path: " + _languagePath);

            _translations = Translator.FindTranslations(_languagePath);

            _settings = new PdfCreatorSettings(new IniStorage());
            _settings.LoadData("settings.ini");

            IAssemblyHelper assemblyHelper = Substitute.For <IAssemblyHelper>();

            assemblyHelper.GetCurrentAssemblyDirectory().Returns(Path.Combine(_languagePath, ".."));

            LoggingHelper.InitConsoleLogger("PDFCreator-TranslationTest", LoggingLevel.Error);
            TranslationHelper.Instance.InitTranslator(_settings.ApplicationSettings.Language, assemblyHelper);
        }
Пример #3
0
        public void SetUp()
        {
            _translationTestHelper = new TranslationTestHelper();

            var a      = Assembly.GetExecutingAssembly();
            var appDir = Path.GetDirectoryName(a.CodeBase.Replace(@"file:///", ""));

            if (appDir == null)
            {
                throw new InvalidDataException("The app dir may never be null");
            }

            _languagePath = _translationTestHelper.FindTranslationFolder();

            Assert.True(Directory.Exists(_languagePath), "Could not find language path: " + _languagePath);

            var languageLoader = new LanguageLoader(_languagePath);

            _translations = languageLoader.GetAvailableLanguages().ToList();

            _settings = new PdfCreatorSettings(new IniStorage());
            _settings.LoadData("settings.ini");

            var assemblyHelper = Substitute.For <IAssemblyHelper>();

            assemblyHelper.GetPdfforgeAssemblyDirectory().Returns(Path.Combine(_languagePath, ".."));

            LoggingHelper.InitConsoleLogger("PDFCreator-TranslationTest", LoggingLevel.Error);
            var settingsProvider = new DefaultSettingsProvider();

            settingsProvider.UpdateSettings(_settings);

            _translationProxy = new MappedTranslationProxy(new TranslationProxy(), _languagePath + "\\_sectionMappings.txt");

            _translationHelper = new TranslationHelper(_translationProxy, settingsProvider, assemblyHelper);
            _translationHelper.InitTranslator(_settings.ApplicationSettings.Language);

            // TODO extact stuff into separate classes, so this test only contains the actual test code
        }