public BooleanCodeStyleOptionViewModel( IOption option, string description, string truePreview, string falsePreview, AbstractOptionPreviewViewModel info, OptionStore optionStore, string groupName, List <CodeStylePreference> preferences = null, List <NotificationOptionViewModel> notificationPreferences = null) : base(option, description, info, groupName, preferences, notificationPreferences) { _truePreview = truePreview; _falsePreview = falsePreview; var codeStyleOption = ((CodeStyleOption <bool>)optionStore.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null))); _selectedPreference = Preferences.Single(c => c.IsChecked == codeStyleOption.Value); var notificationViewModel = NotificationPreferences.Single(i => i.Notification.Severity == codeStyleOption.Notification.Severity); _selectedNotificationPreference = NotificationPreferences.Single(p => p.Notification.Severity == notificationViewModel.Notification.Severity); NotifyPropertyChanged(nameof(SelectedPreference)); NotifyPropertyChanged(nameof(SelectedNotificationPreference)); }
public EnumCodeStyleOptionViewModel( Option <CodeStyleOption <T> > option, string description, T[] enumValues, string[] previews, AbstractOptionPreviewViewModel info, OptionSet options, string groupName, List <CodeStylePreference> preferences) : base(option, description, info, options, groupName, preferences) { Debug.Assert(preferences.Count == enumValues.Length); Debug.Assert(previews.Length == enumValues.Length); var expectedEnumValues = Enum.GetValues(typeof(T)); Debug.Assert(expectedEnumValues.Length == enumValues.Length, "Enum was updated, but UI wasn't."); _enumValues = enumValues.ToImmutableArray(); _previews = previews.ToImmutableArray(); var codeStyleOption = options.GetOption(option); var enumIndex = _enumValues.IndexOf(codeStyleOption.Value); _selectedPreference = Preferences[enumIndex]; var notificationViewModel = NotificationPreferences.Single(i => i.Notification.Value == codeStyleOption.Notification.Value); _selectedNotificationPreference = NotificationPreferences.Single(p => p.Notification.Value == notificationViewModel.Notification.Value); NotifyPropertyChanged(nameof(SelectedPreference)); NotifyPropertyChanged(nameof(SelectedNotificationPreference)); }
public SimpleCodeStyleOptionViewModel( IOption option, string description, string truePreview, string falsePreview, AbstractOptionPreviewViewModel info, OptionSet options, string groupName, List<CodeStylePreference> preferences = null, List<NotificationOptionViewModel> notificationPreferences = null) : base(option, description, truePreview, falsePreview, info, options, groupName, preferences, notificationPreferences) { var codeStyleOption = ((CodeStyleOption<bool>)options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null))); _selectedPreference = Preferences.Single(c => c.IsChecked == codeStyleOption.Value); var notificationViewModel = NotificationPreferences.Single(i => i.Notification.Value == codeStyleOption.Notification.Value); _selectedNotificationPreference = NotificationPreferences.Single(p => p.Notification.Value == notificationViewModel.Notification.Value); NotifyPropertyChanged(nameof(SelectedPreference)); NotifyPropertyChanged(nameof(SelectedNotificationPreference)); }
private EnumCodeStyleOptionViewModel( IOption option, string language, string description, T[] enumValues, string[] previews, AbstractOptionPreviewViewModel info, OptionStore optionStore, string groupName, List <CodeStylePreference> preferences) : base(option, description, info, groupName, preferences) { Debug.Assert(preferences.Count == enumValues.Length); Debug.Assert(previews.Length == enumValues.Length); _enumValues = enumValues.ToImmutableArray(); _previews = previews.ToImmutableArray(); var codeStyleOption = (CodeStyleOption <T>)optionStore.GetOption(new OptionKey(option, language)); var enumIndex = _enumValues.IndexOf(codeStyleOption.Value); if (enumIndex < 0 || enumIndex >= Preferences.Count) { enumIndex = 0; } _selectedPreference = Preferences[enumIndex]; var notificationViewModel = NotificationPreferences.Single(i => i.Notification.Severity == codeStyleOption.Notification.Severity); _selectedNotificationPreference = NotificationPreferences.Single(p => p.Notification.Severity == notificationViewModel.Notification.Severity); NotifyPropertyChanged(nameof(SelectedPreference)); NotifyPropertyChanged(nameof(SelectedNotificationPreference)); }