public void ConnectShapes(ShapeWrapper shapeFrom, ShapeWrapper shapeTo, ConnectionMaserType connectionMaserType, ShapeConnectionType connectionType) { var connectorMaster = GetConnectionMasterFromConnectionMasterType(connectionMaserType); ConnectShapes(shapeFrom, shapeTo, connectorMaster, connectionType); }
/// <summary> /// Actually connect two shapes using Visio API /// </summary> /// <param name="shapeFrom">first shape</param> /// <param name="shapeTo">sec shape</param> /// <param name="shapeToWrap"></param> /// <param name="connectorMaster">shape wich connect shapes</param> /// <param name="fromPoint">point to connect on first shape</param> /// <param name="toPoint">point to connect on sec shape</param> /// <param name="shapeFromWrap"></param> protected void ConnectWithDynamicGlueAndConnector( ShapeWrapper shapeFromWrap, ShapeWrapper shapeToWrap, Master connectorMaster, VisCellIndices fromPoint, VisCellIndices toPoint, double x = 10, double y = 10) { Shape shapeFrom = shapeFromWrap.Shape; Shape shapeTo = shapeToWrap.Shape; Page visioPage = VisioApp.ActivePage; var connector = visioPage.Drop(connectorMaster, x, y); var beginXCell = connector.CellsSRC[(short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowXForm1D, (short)VisCellIndices.vis1DBeginX]; beginXCell.GlueTo(shapeFrom.CellsSRC[(short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowAlign, (short)fromPoint]); var endXCell = connector.CellsSRC[(short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowXForm1D, (short)VisCellIndices.vis1DEndX]; endXCell.GlueTo(shapeTo.CellsSRC[(short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowAlign, (short)toPoint]); }
public void ConnectShapes(ShapeWrapper shapeFrom, ShapeWrapper shapeTo, NodesBranchRelation nodesBranchRelation, ShapeConnectionType connectionType) { var connectorMaster = GetConnectionMasterFromConnectionType(connectionType, nodesBranchRelation); ConnectShapes(shapeFrom, shapeTo, connectorMaster, connectionType); }
/// <summary> /// Place common text field /// </summary> /// <param name="text">shape text</param> /// <param name="x">shape x</param> /// <param name="y">shape y</param> /// <returns>placed shape</returns> public ShapeWrapper addTextField(String text, double x, double y) { Page visioPage = visioApp.ActivePage; ShapeWrapper shape = dropShape(ShapeForm.TEXT_FIELD, text, x, y); return(shape); }
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 void ConnectShapes(ShapeWrapper shapeFrom, ShapeWrapper shapeTo, Master connectorMaster, ShapeConnectionType connectionType) { if (shapeFrom.ShapeForm != ShapeForm.INIT_SHAPE && shapeTo.ShapeForm != ShapeForm.INIT_SHAPE) { BuilderUtils.GetCellsAlignsFromConnectionType(out var connectionFromType, out var connectionToType, connectionType); ConnectWithDynamicGlueAndConnector(shapeFrom, shapeTo, connectorMaster, connectionFromType, connectionToType); } }
/// <summary> /// Place common shape with text /// </summary> /// <param name="viosioShapeForm">visio shape form to place</param> /// <param name="text">shape text</param> /// <param name="x">shape x</param> /// <param name="y">shape y</param> /// <returns>placed shape</returns> public ShapeWrapper dropShape(ShapeForm viosioShapeForm, String text, double x, double y) { Master shapeMaster = getShapeMasterByShapeType(viosioShapeForm); Page visioPage = visioApp.ActivePage; Shape shapeToDrop = visioPage.Drop(shapeMaster, x, y); shapeToDrop.Text = text; ShapeWrapper dropedShape = new ShapeWrapper(shapeToDrop, viosioShapeForm); return(dropedShape); }
/// <summary> /// Connect last if/else branch shape with invisibe shape (connect both branches in one place) /// </summary> /// <param name="invisibleBlock">invisible block shape wrapper</param> /// <param name="lastBranchShape">last branch shape wrapper</param> public void connectLastShapeToInvisibleBlock(ShapeWrapper invisibleBlock, ShapeWrapper lastBranchShape, double x = 4.25, double y = 10) { if (lastBranchShape.isCommonShape()) { connectShapes(invisibleBlock.shape, lastBranchShape.shape, ShapeForm.LINE, ShapeConnectionType.FROM_BOT_TO_CENTER, x, y); } else { connectShapes(invisibleBlock.shape, lastBranchShape.shape, ShapeForm.LINE, ShapeConnectionType.FROM_RIGHT_TO_CENTER, x, y); } }
/// <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); }
private static Point MoveToNextShapePos(ShapeWrapper lastShape, Node newShapeNode = null, Point pos = default) { if (pos == default) { pos = lastShape.CurrentPos; } var resOffsetPoint = GetNextShapeOffsetWithPrevShape(lastShape); if (newShapeNode != null) { var nextShapeOffsetPoint = GetNextShapeOffsetWithNextShape(newShapeNode); resOffsetPoint.Offset(nextShapeOffsetPoint.X, nextShapeOffsetPoint.Y); } return(new Point(pos.X + resOffsetPoint.X, pos.Y + resOffsetPoint.Y)); }
/// <summary> /// Place shape based on node /// </summary> /// <param name="shapeMaster">shape master to place</param> /// <param name="node">shape node</param> /// <param name="x">shape x</param> /// <param name="y">shape x</param> /// <returns>placed shape</returns> public ShapeWrapper dropShape(Node node, double x, double y) { Master shapeMaster = begin; Page visioPage = visioApp.ActivePage; ShapeForm newShapeType = ShapeForm.BEGIN; if (node != null) { shapeMaster = getShapeMasterByShapeType(node.shapeForm); } Shape shapeToDrop = visioPage.Drop(shapeMaster, x, y); if (node != null) { newShapeType = node.shapeForm; shapeToDrop.Text = node.nodeText; } ShapeWrapper dropedShape = new ShapeWrapper(shapeToDrop, newShapeType); return(dropedShape); }
/// <summary> /// Define connection type between two shapes (none of the shapes is parent shape) /// </summary> /// <param name="firstShape">up shape</param> /// <param name="secShape">down shape</param> /// <returns>connection type</returns> public static ShapeConnectionType defineConnectionType(ShapeWrapper firstShape, ShapeWrapper secShape, bool isSameBranch) { bool firstShapeIsCommon = firstShape.isCommonShape(); bool secShapeIsCommon = secShape.isCommonShape(); ShapeConnectionType shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_RIGHT; if (!firstShapeIsCommon && secShapeIsCommon) { if (isSameBranch) { shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_BOT; } else { shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_RIGHT; } } else if (firstShapeIsCommon && !secShapeIsCommon) { shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_BOT; } else if (!firstShapeIsCommon && !secShapeIsCommon) { if (isSameBranch) { shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_BOT; } else { shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_RIGHT; } } else if (firstShapeIsCommon && secShapeIsCommon) { shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_BOT; } return(shapeConnectionType); }
private static Point GetNextShapeOffsetWithPrevShape(ShapeWrapper lastShape) { var offsetPoint = new Point(0, 0); var lastShapeType = lastShape.ShapeForm; if (lastShapeType == ShapeForm.BEGIN_END) { offsetPoint.Offset(0, -0.75); } else if (lastShapeType == ShapeForm.IF) { offsetPoint.Offset(0, -0.8); } else if (lastShapeType == ShapeForm.INVISIBLE_BLOCK || lastShapeType == ShapeForm.DO) { offsetPoint.Offset(0, -0.5); } else { offsetPoint.Offset(0, -1); } return(offsetPoint); }
/// <summary> /// Define connection type between two shapes (first shape is parent shape) /// </summary> /// <param name="chainParentShape">parent shape</param> /// <param name="lastBranchShape">child shape</param> /// <returns>connection type</returns> public static ShapeConnectionType defineConnectionTypeWithBranchParent(ShapeWrapper chainParentShape, ShapeWrapper lastBranchShape) { bool lastBranchShapeIsCommon = lastBranchShape.isCommonShape(); ShapeConnectionType shapeConnectionType = ShapeConnectionType.FROM_TOP_TO_RIGHT; if (chainParentShape.shapeType == ShapeForm.FOR && lastBranchShapeIsCommon) { shapeConnectionType = ShapeConnectionType.FROM_BOT_TO_LEFT; } else if (chainParentShape.shapeType == ShapeForm.FOR && !lastBranchShapeIsCommon) { shapeConnectionType = ShapeConnectionType.FROM_RIGHT_TO_LEFT; } else if (chainParentShape.shapeType == ShapeForm.WHILE && lastBranchShapeIsCommon) { shapeConnectionType = ShapeConnectionType.FROM_BOT_TO_CENTER; } else if (chainParentShape.shapeType == ShapeForm.WHILE && !lastBranchShapeIsCommon) { shapeConnectionType = ShapeConnectionType.FROM_LEFT_TO_CENTER; } return(shapeConnectionType); }