Exemple #1
0
        public BooleanCodeStyleOptionViewModel(
            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, info, options, groupName, preferences, notificationPreferences)
        {
            _truePreview  = truePreview;
            _falsePreview = falsePreview;

            var optionValue = options.GetOption(new OptionKey(option, option.IsPerLanguage ? info.Language : null));

            if (!(optionValue is CodeStyleOption <bool> codeStyleOption))
            {
                throw new InvalidOperationException(optionValue + " is no CodeStyleOption<bool>. Queried option: " + option);
            }
            _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));
        }
Exemple #2
0
        public BooleanCodeStyleOptionViewModel(
            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, info, options, groupName, preferences, notificationPreferences)
        {
            _truePreview  = truePreview;
            _falsePreview = falsePreview;

            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,
            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);

            _enumValues = enumValues.ToImmutableArray();
            _previews   = previews.ToImmutableArray();

            var codeStyleOption = (CodeStyleOption <T>)options.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.Value == codeStyleOption.Notification.Value);

            _selectedNotificationPreference = NotificationPreferences.Single(p => p.Notification.Value == notificationViewModel.Notification.Value);

            NotifyPropertyChanged(nameof(SelectedPreference));
            NotifyPropertyChanged(nameof(SelectedNotificationPreference));
        }