예제 #1
0
        private void InitiateStateMachineViewModel(StateMachine stateMachineModel)
        {
            StateMachine = ApplicationContainer.Container.Resolve <StateMachineViewModel>
                           (
                new TypedParameter(typeof(StateMachine), stateMachineModel),
                new TypedParameter(typeof(IUndoProvider), this),
                new TypedParameter(typeof(IDirtyService), DirtyService)
                           );

            Inputs = new OrderedListDesigner <StateMachineInputViewModel>(CreateInput, StateMachine.Inputs, addedAction: ConnectorAdded, deletedAction: InputDeleted);
            _inputs.ListChanged += ChildListChanged;

            Outputs = new OrderedListDesigner <StateMachineOutputActionViewModel>(CreateOutput, StateMachine.Outputs, addedAction: OutputAdded, deletedAction: OutputDeleted);
            _outputs.ListChanged += ChildListChanged;
        }
        public TransitionEditorViewModel(
            StateMachineTransition model,
            StateMachineViewModel parent,
            Action <StateMachineTransition> updateParentModel,
            IMessageBoxService messageBoxService)
        {
            _model             = model ?? throw new ArgumentNullException(nameof(model));
            _updateParentModel = updateParentModel;
            _parent            = parent ?? throw new ArgumentNullException(nameof(parent));
            _messageBoxService = messageBoxService ?? throw new ArgumentNullException(nameof(messageBoxService));

            Inputs      = new ObservableCollection <StateMachineInputViewModel>(parent.Inputs);
            Outputs     = new ObservableCollection <StateMachineOutputActionViewModel>(parent.Outputs);
            _transition = ApplicationContainer.Container.Resolve <TransitionViewModel>(
                new TypedParameter(typeof(StateMachineViewModel), parent),
                new TypedParameter(typeof(StateMachineTransition), model)
                );

            Actions = new OrderedListDesigner <StateMachineOutputActionViewModel>(NewFactory, parent.Outputs.Where(o => _transition.Actions.Contains(o.Id)));
            _actions.ListChanged += ActionsOnListChanged;

            Name = Transition.Name;

            Criteria = new CriteriaTransitionViewModel(this, _messageBoxService);

            OkCommand = new RelayCommand(Ok);
            _dirtyService.MarkClean();


            RecalculateConditionText();

            Criteria.PropertyChanged += CriteriaPropertyChanged;

            if (Criteria.RootCondition != null)
            {
                Criteria.RootCondition.ConditionChanged += RootConditionChanged;
            }
        }
예제 #3
0
        private void InitializeActions()
        {
            var entryActions = new List <StateMachineOutputActionViewModel>();
            var exitActions  = new List <StateMachineOutputActionViewModel>();

            if (_model.EntryActions != null)
            {
                foreach (var item in _model.EntryActions)
                {
                    var action = _parent.Outputs.FirstOrDefault(o => o.Id == item);

                    if (action != null)
                    {
                        entryActions.Add(action);
                    }
                }
            }

            if (_model.ExitActions != null)
            {
                foreach (var item in _model.ExitActions)
                {
                    var action = _parent.Outputs.FirstOrDefault(o => o.Id == item);

                    if (action != null)
                    {
                        exitActions.Add(action);
                    }
                }
            }

            EntryActions = new OrderedListDesigner <StateMachineOutputActionViewModel>(() => new StateMachineOutputActionViewModel(), entryActions);
            ExitActions  = new OrderedListDesigner <StateMachineOutputActionViewModel>(() => new StateMachineOutputActionViewModel(), exitActions);
            _entryActions.ListChanged += ActionsListChanged;
            _exitActions.ListChanged  += ActionsListChanged;
        }