Esempio n. 1
0
        private void DeleteEdge(FSMEdgeView edge)
        {
            edge.input.Disconnect(edge);
            edge.output.Disconnect(edge);

            edge.output = null;
            edge.input  = null;

            RemoveElement(edge);
            _stateMachineGraph.RemoveTransition(edge.Transition);
        }
Esempio n. 2
0
        public void LoadGraph(FSMGraph stateMachineGraph)
        {
            // Clear
            edges.ToList().ForEach(e => RemoveElement(e));
            nodes.ToList().ForEach(n => RemoveElement(n));

            _stateMachineGraph = stateMachineGraph;

            // Load nodes
            foreach (var node in stateMachineGraph.Nodes)
            {
                var nodeView = new FSMNodeView(node);
                AddElement(nodeView);
            }

            // Restore connections
            foreach (var transition in stateMachineGraph.Transitions)
            {
                var viewFrom = ViewFor(transition.From);
                var viewTo   = ViewFor(transition.To);

                Port outputPort = viewFrom.outputContainer.Query <Port>().First();
                Port inputPort  = viewTo.inputContainer.Query <Port>().First();

                var edge = new FSMEdgeView(transition)
                {
                    input  = inputPort,
                    output = outputPort,
                };

                outputPort.Connect(edge);
                inputPort.Connect(edge);

                AddElement(edge);
            }
        }