public ThemeSelectSettingItemViewModel(string label, ApplicationSettings applicationSettings, IEventAggregator eventAggregator) { Label = label; _eventAggregator = eventAggregator; SelectedTheme = applicationSettings.ToReactivePropertyAsSynchronized(x => x.Theme); _themeChangedSubscriber = SelectedTheme.Subscribe(theme => { _eventAggregator.GetEvent <ThemeChangeRequestEvent>().Publish(theme); }); }
private void LoadedAction() { var preferences = PreferencesService.GetPreferences(); Delimiter.Value = preferences.Delimiter; var count = 1; foreach (var modifierKey in ModifierKey1.Where(x => x != ModifierKeys.None && preferences.ShowHideShortcut.ModifierKeys.HasFlag(x))) { if (count == 1) { var modifierKeyIndex = ModifierKey1.IndexOf(modifierKey); SelectedModifierKey1.Value = modifierKeyIndex < 0 ? ModifierKeys.None : ModifierKey1[modifierKeyIndex]; } if (count == 2) { var modifierKeyIndex = ModifierKey2.IndexOf(modifierKey); SelectedModifierKey2.Value = modifierKeyIndex < 0 ? ModifierKeys.None : ModifierKey2[modifierKeyIndex]; break; } count++; } var keyIndex = Keys.IndexOf(preferences.ShowHideShortcut.Key); SelectedKey.Value = keyIndex < 0 ? Key.None : Keys[keyIndex]; Delimiter.Subscribe(_ => ClearMessage()); SelectedModifierKey1.Subscribe(_ => ClearMessage()); SelectedModifierKey2.Subscribe(_ => ClearMessage()); SelectedKey.Subscribe(_ => ClearMessage()); SelectedTheme.Subscribe(_ => ClearMessage()); AutoLaunch.Subscribe(_ => ClearMessage()); var themeIndex = ThemeNames.IndexOf(preferences.ThemeName); SelectedTheme.Value = themeIndex < 0 ? AppTheme.GenerateDefault().ThemeName : ThemeNames[themeIndex]; AutoLaunch.Value = preferences.AutoLaunch; }