public ClassificationOptionViewModel(ClassificationData option, IResetValuesProvider resetValuesProvider) { // TODO: it will invoke one event at invocation of clear and by one event per added item // Write custom BulkObservableCollection to avoid so many events _languages.Clear(); foreach (var language in option.Languages) { _languages.Add(new ClassificationLanguageViewModel(language, resetValuesProvider)); } Languages = CollectionViewSource.GetDefaultView(_languages); Languages.SortDescriptions.Add(new SortDescription(nameof(ClassificationLanguageViewModel.Name), ListSortDirection.Ascending)); }
public PresetsViewModel( ICollection <Preset> presets, IClassificationProvider provider, IResetValuesProvider resetValuesProvider) { foreach (var item in presets) { _presets.Add(new PresetViewModel(item, Apply, Delete)); } PresetsView = CollectionViewSource.GetDefaultView(_presets); PresetsView.SortDescriptions.Add(new SortDescription(nameof(PresetViewModel.Name), ListSortDirection.Ascending)); CreatePreset = new DelegateCommand(Create, CanCreate); _provider = provider; _resetValuesProvider = resetValuesProvider; }
public ClassificationLanguageViewModel(ClassificationLanguage language, IResetValuesProvider resetValuesProvider) { Name = language.Name; ClassificationsContainer = new ClassificationsViewModel(language.Classifications, resetValuesProvider); PresetsContainer = new PresetsViewModel(language.Presets, this, resetValuesProvider); ClassificationsContainer.IsActive = true; ActivateClassifications = new DelegateCommand(() => { PresetsContainer.IsActive = false; ClassificationsContainer.IsActive = true; }); ActivatePresets = new DelegateCommand(() => { ClassificationsContainer.IsActive = false; PresetsContainer.IsActive = true; }); }
public ClassificationViewModel(Classification classification, IResetValuesProvider resetValuesProvider) { _classificationName = classification.Name; _isDisabled = classification.IsDisabled; _IsDisabledInEditor = classification.IsDisabledInEditor; _IsDisabledInQuickInfo = classification.IsDisabledInQuickInfo; _isDisabledInXml = classification.IsDisabledInXml; _isBold = classification.IsBold; _isOverline = classification.IsOverline; _isUnderline = classification.IsUnderline; _isStrikethrough = classification.IsStrikethrough; _isBaseLine = classification.IsBaseline; _fontRenderingSize = classification.FontRenderingSize; FontFamiliesContainer = new FontFamiliesViewModel(classification.FontFamily); FontStylesContainer = new FontStylesViewModel(classification.FontStyle, classification.FontFamily); FontStretchesContainer = new FontStretchesViewModel( classification.FontStretch, classification.FontFamily, classification.FontStyle); FontFamiliesContainer.PropertyChanged += FontStylesContainer.OnSelectedFontFamilyChanged; FontFamiliesContainer.PropertyChanged += FontStretchesContainer.OnSelectedFontFamilyChanged; FontStylesContainer.PropertyChanged += FontStretchesContainer.OnSelectedFontStyleChanged; Foreground = new ClassificationColorViewModel( _classificationName, classification.Foreground, classification.ForegroundWasReset, resetValuesProvider); Background = new ClassificationColorViewModel( _classificationName, classification.Background, classification.BackgroundWasReset, resetValuesProvider); _fontRenderingSizeWasReset = classification.FontRenderingSizeWasReset; DisplayName = classification.DisplayName; ResetFontRenderingSize = new DelegateCommand(() => { SetProperty(ref _fontRenderingSize, resetValuesProvider.GetFontRenderingSize(_classificationName), nameof(Size)); _fontRenderingSizeWasReset = true; }); }
public ClassificationsViewModel(ICollection <Classification> classifications, IResetValuesProvider resetValuesProvider) { foreach (var classification in classifications) { var classificationViewModel = new ClassificationViewModel(classification, resetValuesProvider); _classifications.Add(classificationViewModel); } ClassificationsView = CollectionViewSource.GetDefaultView(_classifications); ClassificationsView.SortDescriptions.Add( new SortDescription(nameof(ClassificationViewModel.DisplayName), ListSortDirection.Ascending)); }
public ClassificationColorViewModel( string classificationName, Color classificationColor, bool colorWasReset, IResetValuesProvider resetValuesProvider) { _color = classificationColor; _colorText = _color.ToString(); ColorWasReset = colorWasReset; CustomizeColor = new DelegateCommand(() => { if (TryGetColor(out var color)) { Color = color; } }); ResetColor = new DelegateCommand(() => { Color = resetValuesProvider.GetForeground(classificationName); ColorWasReset = true; }); ColorLostFocus = new DelegateCommand(SetColorText); }