private Task ViewModelOnSavedAsync(object sender, EventArgs e) { var type = ((TypeViewModel)sender).Type; _globalService.GlobalTypes.Add(type); _typesService.UpdateTypesUsages(); SelectedType = _typesService.GetTypeUsageByType(type); return(Task.CompletedTask); }
public TypesCharacteristicsViewModel(DataPersisterService dataPersisterService, GlobalService globalService, IUIVisualizerService visualizerService, IViewModelFactory viewModelFactory, CharacteristicsService characteristicsService, TypesService typesService, IAdvancedMessageService advancedMessageService) { _dataPersisterService = dataPersisterService; _visualizerService = visualizerService; _viewModelFactory = viewModelFactory; _globalService = globalService; _characteristicsService = characteristicsService; _typesService = typesService; _advancedMessageService = advancedMessageService; Title = "Edit Types / Characteristics"; AddTypeCommand = new TaskCommand(OnAddTypeCommandExecuteAsync); EditTypeCommand = new TaskCommand(OnEditTypeCommandExecuteAsync, EditTypeCanExecute); DeleteTypeCommand = new TaskCommand(OnDeleteTypeCommandExecuteAsync, DeleteTypeCanExecute); ShowTypeUsageCommand = new TaskCommand(OnShowTypeUsageCommandExecuteAsync, ShowTypeUsageCanExecute); AddCharacteristicCommand = new TaskCommand(OnAddCharacteristicCommandExecuteAsync); EditCharacteristicCommand = new TaskCommand(OnEditCharacteristicCommandExecuteAsync, EditCharacteristicCanExecute); DeleteCharacteristicCommand = new TaskCommand(OnDeleteCharacteristicCommandExecuteAsync, DeleteCharacteristicCanExecute); ShowCharacteristicUsageCommand = new TaskCommand(OnShowCharacteristicUsageCommandExecuteAsync, ShowCharacteristicUsageCanExecute); SelectedTypes.CollectionChanged += SelectedTypesOnCollectionChanged; SelectedCharacteristics.CollectionChanged += SelectedCharacteristicsOnCollectionChanged; Types = _typesService.TypeUsages; Characteristics = _characteristicsService.CharacteristicUsages; _characteristicsService.UpdateCharacteristicsUsages(); _typesService.UpdateTypesUsages(); TypesView = (ListCollectionView)CollectionViewSource.GetDefaultView(_typesService.TypeUsages); TypesView.IsLiveSorting = false; TypesView.IsLiveFiltering = false; CharacteristicsView = (ListCollectionView)CollectionViewSource.GetDefaultView( _characteristicsService.CharacteristicUsages); CharacteristicsView.IsLiveSorting = false; CharacteristicsView.IsLiveFiltering = false; }