public void ConnectShapes(ShapeWrapper shapeFrom, ShapeWrapper shapeTo, NodesBranchRelation nodesBranchRelation, ShapeConnectionType connectionType) { var connectorMaster = GetConnectionMasterFromConnectionType(connectionType, nodesBranchRelation); ConnectShapes(shapeFrom, shapeTo, connectorMaster, connectionType); }
public void ConnectShapes(ShapeWrapper shapeFrom, ShapeWrapper shapeTo, NodesBranchRelation nodesBranchRelation = NodesBranchRelation.SAME_BRANCH) { var connectionType = BuilderUtils.DefineConnectionType(shapeFrom, shapeTo, nodesBranchRelation); ConnectShapes(shapeFrom, shapeTo, nodesBranchRelation, connectionType); }
public void ConnectShapes(ShapeWrapper shapeFrom, ShapeWrapper shapeTo, NodesBranchRelation nodesBranchRelation = NodesBranchRelation.SAME_BRANCH) { var connectionType = BuilderUtils.DefineConnectionType(shapeFrom, shapeTo, nodesBranchRelation); var connectorMaster = GetConnectionMasterFromConnectionType(connectionType, nodesBranchRelation); BuilderUtils.GetCellsAlignsFromConnectionType(out var connectionFromType, out var connectionToType, connectionType); ConnectWithDynamicGlueAndConnector(shapeFrom, shapeTo, connectorMaster, connectionFromType, connectionToType); }
public BranchContext(ShapeWrapper branchParent, NodesBranchRelation branchRelation = NodesBranchRelation.SAME_BRANCH, Point branchOffset = default) { BranchParent = branchParent; ShapeToContinueThree = branchParent; BranchRelation = branchRelation; LastBranchShape = branchParent; BranchOffset = branchOffset; }
/// <summary> /// Define connection type between two shapes /// </summary> /// <param name="lastPlacedShape">shape from connection</param> /// <param name="oldShape">shape to connection (or parent shape)</param> /// <param name="nodesBranchRelation">shapes ('from shape' for 'to shape') relations</param> /// <returns>connection type</returns> public static ShapeConnectionType DefineConnectionType(ShapeWrapper lastPlacedShape, ShapeWrapper oldShape, NodesBranchRelation nodesBranchRelation = NodesBranchRelation.SAME_BRANCH) { if (nodesBranchRelation == NodesBranchRelation.SAME_BRANCH) { return(ShapeConnectionType.FROM_TOP_TO_BOT); } else if (nodesBranchRelation == NodesBranchRelation.IF_BRANCH) { return(ShapeConnectionType.FROM_TOP_TO_LEFT); } else if (nodesBranchRelation == NodesBranchRelation.ELSE_BRANCH) { return(ShapeConnectionType.FROM_TOP_TO_RIGHT); } else if (nodesBranchRelation == NodesBranchRelation.OTHER_BRANCH) { if (oldShape.IsCommonShape || oldShape.ShapeForm == ShapeForm.DO_WHILE) { return(ShapeConnectionType.FROM_TOP_TO_BOT); } return(ShapeConnectionType.FROM_TOP_TO_RIGHT); } else if (nodesBranchRelation == NodesBranchRelation.PARENT) { if (!lastPlacedShape.IsCommonShape) { if (lastPlacedShape.ShapeForm == ShapeForm.DO_WHILE) { return(ShapeConnectionType.FROM_LEFT_TO_LEFT); } if (!oldShape.IsCommonShape) { return(ShapeConnectionType.FROM_RIGHT_TO_LEFT); } throw new Exception("Parent shape can't be common!"); } else if (lastPlacedShape.IsCommonShape && (!oldShape.IsCommonShape || oldShape.ShapeForm == ShapeForm.INVISIBLE_BLOCK)) { return(ShapeConnectionType.FROM_BOT_TO_LEFT); } } return(ShapeConnectionType.FROM_TOP_TO_BOT); }
protected Master GetConnectionMasterFromConnectionType(ShapeConnectionType connectionType, NodesBranchRelation nodesBranchRelation) { if (nodesBranchRelation == NodesBranchRelation.SAME_BRANCH || nodesBranchRelation == NodesBranchRelation.ELSE_BRANCH || nodesBranchRelation == NodesBranchRelation.IF_BRANCH) { return(Line); } else if (nodesBranchRelation == NodesBranchRelation.PARENT) { switch (connectionType) { case ShapeConnectionType.FROM_RIGHT_TO_LEFT: case ShapeConnectionType.FROM_BOT_TO_LEFT: case ShapeConnectionType.FROM_LEFT_TO_LEFT: return(Arrow); default: return(Line); } } switch (connectionType) { case ShapeConnectionType.FROM_TOP_TO_BOT: case ShapeConnectionType.FROM_TOP_TO_RIGHT: return(Line); case ShapeConnectionType.FROM_RIGHT_TO_LEFT: return(Arrow); default: return(Line); } }