コード例 #1
0
 private void ResetStateDefinitionGraph()
 {
     _StatedefinitionGraph = null;
     OnPropertyChanged("StateDefinitionGraph");
 }
コード例 #2
0
        private void CreateStateDefinitionGraph()
        {
            _StatedefinitionGraph = new StateDefinitionGraph(true);
            if (SelectedStateDefinition == null)
            {
                return;
            }

            // Actions ------------------------------
            var scheduledActions = SelectedStateDefinition.StateDefinition.Actions.OfType <wf.ScheduledActionDefinition>().ToList();

            foreach (var action in scheduledActions)
            {
                _StatedefinitionGraph.AddVertex(ToActionViewModel(action));
            }
            foreach (var action in SelectedStateDefinition.StateDefinition.Actions.Except(scheduledActions))
            {
                _StatedefinitionGraph.AddVertex(ToActionViewModel(action));
            }
            _StatedefinitionGraph.AddVertex(_hiddenAction);

            // State changes ------------------------------
            foreach (var change in SelectedStateDefinition.StateDefinition.StateChanges)
            {
                _StatedefinitionGraph.AddVertex(ToStateChangeViewModel(change));
            }
            _StatedefinitionGraph.AddVertex(_hiddenStateChange);

            // State definitions ------------------------------
            foreach (var state in WFDefinition.StateDefinitions)
            {
                _StatedefinitionGraph.AddVertex(ToStateDefinitionViewModel(state));
            }

            // edges ------------------------------
            foreach (var change in SelectedStateDefinition.StateDefinition.StateChanges)
            {
                foreach (var action in change.InvokedByActions)
                {
                    _StatedefinitionGraph.AddEdge(new TaggedEdge <object, StateChangeGraphViewModel>(ToActionViewModel(action), ToStateChangeViewModel(change), ToStateChangeViewModel(change)));
                }

                foreach (wf.StateDefinition dest in change.NextStates)
                {
                    _StatedefinitionGraph.AddEdge(new TaggedEdge <object, StateChangeGraphViewModel>(ToStateChangeViewModel(change), ToStateDefinitionViewModel(dest), ToStateChangeViewModel(change)));
                }
            }

            foreach (var vertex in _StatedefinitionGraph.Vertices)
            {
                if (_StatedefinitionGraph.IsInEdgesEmpty(vertex))
                {
                    if (vertex is StateChangeGraphViewModel)
                    {
                        _StatedefinitionGraph.AddEdge(new TaggedEdge <object, HiddenGraphElementViewModel>(_hiddenAction, vertex, _hiddenStateChange));
                    }
                    else if (vertex is StateDefinitionGraphViewModel)
                    {
                        _StatedefinitionGraph.AddEdge(new TaggedEdge <object, HiddenGraphElementViewModel>(_hiddenStateChange, vertex, _hiddenStateChange));
                    }
                }
            }

            foreach (var schedulerAction in SelectedStateDefinition.StateDefinition.Actions.OfType <wf.ScheduledActionDefinition>())
            {
                if (schedulerAction.InvokeAction != null)
                {
                    _StatedefinitionGraph.AddEdge(new TaggedEdge <object, ActionGraphViewModel>(ToActionViewModel(schedulerAction), ToActionViewModel(schedulerAction.InvokeAction), ToActionViewModel(schedulerAction)));
                }
            }

            _StatedefinitionGraph.AddEdge(new TaggedEdge <object, HiddenGraphElementViewModel>(_hiddenAction, _hiddenStateChange, _hiddenStateChange));
        }