public void Reset() { var accent = Settings.GetById(SettingKeys.Accent).Value; var theme = Settings.GetById(SettingKeys.Theme).Value; SelectedAccent = AvailableAccents.FirstOrDefault(a => a.Name == accent); SelectedTheme = AvailableThemes.FirstOrDefault(t => t.Name == theme); ExpandEntries = Settings.GetById(SettingKeys.ExpandEntries).Get <bool>(); StartMinimized = Settings.GetById(SettingKeys.StartMinimized).Get <bool>(); StartWithWindows = Settings.GetById(SettingKeys.StartWithWindows).Get <bool>(); CloseToTray = Settings.GetById(SettingKeys.CloseToTray).Get <bool>(); var lang = Settings.GetById(SettingKeys.Language).Value; ChangeLanguage = false; SelectedLanguage = AvailableLanguages.FirstOrDefault(l => l.IetfLanguageTag.Equals(lang)) ?? AvailableLanguages.FirstOrDefault(l => l.IetfLanguageTag.Equals("en-US")); ChangeLanguage = true; var path = Settings.GetById(SettingKeys.DatabasePath)?.Value; if (string.IsNullOrWhiteSpace(path)) { path = Constants.DefaultDatabasePath; } DatabasePath = path; }
public GeneralSettings(IConfig currentConfig, ILanguageProvider languageProvider) { var langs = languageProvider.AvailableLanguages.ToList(); for (int i = 0; i < langs.Count; ++i) { if (langs[i].Equals(CultureInfo.InvariantCulture)) { langs[i] = CultureInfo.CreateSpecificCulture("en-US"); } } var neutrals = langs.Where(l => l.IsNeutralCulture).ToArray(); foreach (var neutral in neutrals.Where(neutral => langs.Any(l => neutral.Equals(l.Parent)))) { langs.Remove(neutral); } AvailableLanguages = langs.Distinct().OrderBy(l => l.NativeName).ToList(); AvailableFetchCounts = new[] { 20, 50, 100, 200 }; var english = AvailableLanguages.FirstOrDefault(IsEnglish); RealtimeStreaming = currentConfig.General.RealtimeStreaming; SelectedLanguage = AvailableLanguages.SingleOrDefault(l => l.Name == currentConfig.General.Language) ?? english; CheckForUpdates = currentConfig.General.CheckForUpdates; IncludePrereleaseUpdates = currentConfig.General.IncludePrereleaseUpdates; TweetFetchCount = currentConfig.General.TweetFetchCount; FilterSensitiveTweets = currentConfig.General.FilterSensitiveTweets; SendVersionStats = currentConfig.General.SendVersionStats; }
private void SetupLanguages() { foreach (var lang in this.languageService.GetLanguages()) { AvailableLanguages.Add(lang); } CurrentLanguage = AvailableLanguages.FirstOrDefault(v => v.Id == this.languageService.DefaultLanguage.Id); }
/// <summary> /// Every item should start with Rarity in the first line. /// This will force the TradeClient to refetch the Public API's data if needed. /// </summary> public async Task FindAndSetLanguage(string itemDescription) { var language = AvailableLanguages.FirstOrDefault(x => itemDescription.Contains(x.DescriptionRarity)); if (language != null && SetLanguage(language.Name)) { await initializeService.Initialize(); } }
private MainViewModel() { AddLanguage = new Action(AddLanguageLogic); RemoveLanguage = new Action <object>(RemoveLanguageLogic); ParseNewLanguagesToProject = new Action(MobiriseProjectViewModel.Get.ParseNewPagesToProject); OpenProjectFileSearchDialog = new Action(SearchProjectFile); _currentSelectedLanguageCulture = AvailableLanguages.FirstOrDefault(x => x.ThreeLetterISOLanguageName == CultureInfo.CurrentCulture.ThreeLetterISOLanguageName); }
public UILanguageProvider(SidekickSettings settings) { AvailableLanguages = SupportedLanguages .Select(x => new CultureInfo(x)) .ToList(); var current = AvailableLanguages.FirstOrDefault(x => x.Name == settings.Language_UI); if (current != null) { SetLanguage(settings.Language_UI); } else { SetLanguage(SupportedLanguages.FirstOrDefault()); } }
private bool SetLanguage(string name) { var language = AvailableLanguages.FirstOrDefault(x => x.Name == name); if (language == null) { logger.Log($"Couldn't find language {language.Name}."); return(false); } if (Language == null || Language.DescriptionRarity != language.DescriptionRarity) { logger.Log($"Changed language support to {language.Name}."); Language = (ILanguage)Activator.CreateInstance(language.ImplementationType); settings.Language_Parser = name; settings.Save(); return(true); } return(false); }