private StateDefinitionGraphViewModel ToStateDefinitionViewModel(wf.StateDefinition state) { if (!_stateViewModels.ContainsKey(state)) { var vm = _stateViewModels[state] = ViewModelFactory.CreateViewModel <StateDefinitionGraphViewModel.Factory>().Invoke(DataContext, this, state); vm.IsSelectedChanged += (s, e) => { var sender = (StateDefinitionGraphViewModel)s; if (sender.IsSelected) { _stateViewModels.Values.Except(new[] { sender }).ForEach(i => i.IsSelected = false); SelectedStateDefinition = sender; } else if (SelectedStateDefinition == sender) { SelectedStateDefinition = null; } }; vm.IsSelectedDestinationChanged += (s, e) => { var sender = (StateDefinitionGraphViewModel)s; if (sender.IsSelectedDestination) { _stateViewModels.Values.Except(new[] { sender }).ForEach(i => i.IsSelectedDestination = false); SelectedDestinationStateDefinition = sender; } else if (SelectedDestinationStateDefinition == sender) { SelectedDestinationStateDefinition = null; } }; } return(_stateViewModels[state]); }
public StateDefinitionGraphViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent, wf.StateDefinition stateDef) : base(appCtx, dataCtx, parent) { StateDefinition = stateDef; }