Exemple #1
0
        public SettingsViewModel(IUILanguageProvider uiLanguageProvider,
                                 SidekickSettings sidekickSettings,
                                 INativeKeyboard nativeKeyboard,
                                 ILeagueDataService leagueDataService,
                                 IKeybindEvents keybindEvents)
        {
            this.uiLanguageProvider = uiLanguageProvider;
            this.sidekickSettings   = sidekickSettings;
            this.nativeKeyboard     = nativeKeyboard;
            this.keybindEvents      = keybindEvents;
            this.leagueDataService  = leagueDataService;

            Settings = new SidekickSettings();
            AssignValues(sidekickSettings, Settings);

            Keybinds.Clear();
            Settings.GetType()
            .GetProperties()
            .Where(x => x.Name.StartsWith("Key"))
            .ToList()
            .ForEach(x => Keybinds.Add(x.Name, x.GetValue(Settings).ToString()));

            WikiOptions.Add("POE Wiki", WikiSetting.PoeWiki.ToString());
            WikiOptions.Add("POE Db", WikiSetting.PoeDb.ToString());
            this.leagueDataService.Leagues.ForEach(x => LeagueOptions.Add(x.Id, x.Text));
            uiLanguageProvider.AvailableLanguages.ForEach(x => UILanguageOptions.Add(x.NativeName.First().ToString().ToUpper() + x.NativeName.Substring(1), x.Name));

            nativeKeyboard.OnKeyDown += NativeKeyboard_OnKeyDown;
        }