Example #1
0
        static State CreateEdge(State previousState, CreateEdgeAction action)
        {
            var        graphModel      = (VSGraphModel)previousState.CurrentGraphModel;
            IPortModel outputPortModel = action.OutputPortModel;
            IPortModel inputPortModel  = action.InputPortModel;

            if (inputPortModel.NodeModel is LoopStackModel loopStackModel)
            {
                if (!loopStackModel.MatchingStackedNodeType.IsInstanceOfType(outputPortModel.NodeModel))
                {
                    return(previousState);
                }
            }

            CreateItemizedNode(previousState, graphModel, ref outputPortModel);
            graphModel.CreateEdge(inputPortModel, outputPortModel);

            if (action.EdgeModelsToDelete != null)
            {
                graphModel.DeleteEdges(action.EdgeModelsToDelete);
            }

            if (action.PortAlignment.HasFlag(CreateEdgeAction.PortAlignmentType.Input))
            {
                graphModel.LastChanges.ModelsToAutoAlign.Add(inputPortModel.NodeModel);
            }
            if (action.PortAlignment.HasFlag(CreateEdgeAction.PortAlignmentType.Output))
            {
                graphModel.LastChanges.ModelsToAutoAlign.Add(outputPortModel.NodeModel);
            }

            return(previousState);
        }
Example #2
0
        static State CreateEdge(State previousState, CreateEdgeAction action)
        {
            var        graphModel      = (VSGraphModel)previousState.CurrentGraphModel;
            IPortModel outputPortModel = action.OutputPortModel;
            IPortModel inputPortModel  = action.InputPortModel;

            if (inputPortModel.NodeModel is LoopStackModel loopStackModel)
            {
                if (!loopStackModel.MatchingStackedNodeType.IsInstanceOfType(outputPortModel.NodeModel))
                {
                    return(previousState);
                }
            }

            CreateItemizedNode(previousState, graphModel, inputPortModel, ref outputPortModel);
            graphModel.CreateEdge(inputPortModel, outputPortModel);

            if (action.EdgeModelsToDelete?.Count > 0)
            {
                graphModel.DeleteEdges(action.EdgeModelsToDelete);
            }

            return(previousState);
        }