private static Drawing.Point GetPinPositionForCorner(ShapeXFormData input_xfrm, Drawing.Point new_lower_left, SnapCornerPosition corner) { var size = new Drawing.Size(input_xfrm.Width, input_xfrm.Height); var locpin = new Drawing.Point(input_xfrm.LocPinX, input_xfrm.LocPinY); switch (corner) { case SnapCornerPosition.LowerLeft: { return(new_lower_left.Add(locpin.X, locpin.Y)); } case SnapCornerPosition.UpperRight: { return(new_lower_left.Subtract(size.Width, size.Height).Add(locpin.X, locpin.Y)); } case SnapCornerPosition.LowerRight: { return(new_lower_left.Subtract(size.Width, 0).Add(locpin.X, locpin.Y)); } case SnapCornerPosition.UpperLeft: { return(new_lower_left.Subtract(0, size.Height).Add(locpin.X, locpin.Y)); } default: { throw new System.ArgumentOutOfRangeException(nameof(corner), "Unsupported corner"); } } }
public static void DistributeWithSpacing(IVisio.Page page, IList <int> shapeids, Drawing.Axis axis, double spacing) { if (spacing < 0.0) { throw new System.ArgumentOutOfRangeException(nameof(spacing)); } if (shapeids.Count < 2) { return; } // Calculate the new Xfrms var sortpos = axis == Drawing.Axis.XAxis ? RelativePosition.PinX : RelativePosition.PinY; var delta = axis == Drawing.Axis.XAxis ? new Drawing.Size(spacing, 0) : new Drawing.Size(0, spacing); var sorted_shape_ids = ArrangeHelper.SortShapesByPosition(page, shapeids, sortpos); var input_xfrms = Shapes.XFormCells.GetCells(page, sorted_shape_ids); var output_xfrms = new List <Shapes.XFormCells>(input_xfrms.Count); var bb = ArrangeHelper.GetBoundingBox(input_xfrms); var cur_pos = new Drawing.Point(bb.Left, bb.Bottom); foreach (var input_xfrm in input_xfrms) { var new_pinpos = axis == Drawing.Axis.XAxis ? new Drawing.Point(cur_pos.X + input_xfrm.LocPinX.Result, input_xfrm.PinY.Result) : new Drawing.Point(input_xfrm.PinX.Result, cur_pos.Y + input_xfrm.LocPinY.Result); var output_xfrm = new Shapes.XFormCells(); output_xfrm.PinX = new_pinpos.X; output_xfrm.PinY = new_pinpos.Y; output_xfrms.Add(output_xfrm); cur_pos = cur_pos.Add(input_xfrm.Width.Result, input_xfrm.Height.Result).Add(delta); } // Apply the changes ArrangeHelper.update_xfrms(page, sorted_shape_ids, output_xfrms); }
public static void DistributeWithSpacing(IVisio.Page page, TargetShapeIDs target, Axis axis, double spacing) { if (spacing < 0.0) { throw new System.ArgumentOutOfRangeException(nameof(spacing)); } if (target.ShapeIDs.Count < 2) { return; } // Calculate the new Xfrms var sortpos = axis == Axis.XAxis ? ShapeRelativePosition.PinX : ShapeRelativePosition.PinY; var delta = axis == Axis.XAxis ? new Drawing.Size(spacing, 0) : new Drawing.Size(0, spacing); var input_xfrms = ShapeXFormData.Get(page, target); var bb = ShapeXFormData.GetBoundingBox(input_xfrms); var cur_pos = new Drawing.Point(bb.Left, bb.Bottom); var newpositions = new List <VisioAutomation.Drawing.Point>(target.ShapeIDs.Count); foreach (var input_xfrm in input_xfrms) { var new_pinpos = axis == Axis.XAxis ? new Drawing.Point(cur_pos.X + input_xfrm.LocPinX, input_xfrm.PinY) : new Drawing.Point(input_xfrm.PinX, cur_pos.Y + input_xfrm.LocPinY); newpositions.Add(new_pinpos); cur_pos = cur_pos.Add(input_xfrm.Width, input_xfrm.Height).Add(delta); } // Apply the changes var sorted_shape_ids = ArrangeHelper.SortShapesByPosition(page, target, sortpos); ModifyPinPositions(page, sorted_shape_ids, newpositions); }
private void second_walk(Node <T> node, int level, Drawing.Point p) { /*------------------------------------------------------ * During a second pre-order walk, each node is given a * final x-coordinate by summing its preliminary * x-coordinate and the modifiers of all the node's * ancestors. The y-coordinate depends on the height of * the tree. (The roles of x and y are reversed for * RootOrientations of EAST or WEST.) * Returns: TRUE if no errors, otherwise returns FALSE. *----------------------------------------- ----------*/ if (level > this.Options.MaximumDepth) { return; } var temp_point = this.root_offset.Add(node.prelim_x, 0) + p; double maxsizeTmp = 0; double nodesizeTmp = 0; bool flag = false; switch (this.Options.Direction) { case LayoutDirection.Up: case LayoutDirection.Down: { maxsizeTmp = this.max_level_height[level]; nodesizeTmp = node.Size.Height; break; } case LayoutDirection.Left: case LayoutDirection.Right: { maxsizeTmp = this.max_level_width[level]; flag = true; nodesizeTmp = node.Size.Width; break; } } switch (this.Options.Alignment) { case Drawing.AlignmentVertical.Top: node.Position = temp_point; break; case Drawing.AlignmentVertical.Center: node.Position = temp_point.Add(0, (maxsizeTmp - nodesizeTmp) / 2.0); break; case Drawing.AlignmentVertical.Bottom: node.Position = temp_point.Add(0, maxsizeTmp - nodesizeTmp); break; } if (flag) { // QUESTION: Why is this step performed? node.Position = new Drawing.Point(node.Position.Y, node.Position.X); } switch (this.Options.Direction) { case LayoutDirection.Down: { node.Position = new Drawing.Point(node.Position.X, -node.Position.Y - nodesizeTmp); break; } case LayoutDirection.Left: { node.Position = new Drawing.Point(-node.Position.X - nodesizeTmp, node.Position.Y); break; } } if (node.ChildCount != 0) { /* Apply the flModifier value for this */ /* node to all its offspring. */ var np = p.Add(node.modifier, maxsizeTmp + this.Options.LevelSeparation); this.second_walk(node.FirstChild, level + 1, np); } if (node.RightSibling != null) { this.second_walk(node.RightSibling, level, p); } }
public static void DistributeWithSpacing(IVisio.Page page, IList<int> shapeids, Drawing.Axis axis, double spacing) { if (spacing < 0.0) { throw new System.ArgumentOutOfRangeException(nameof(spacing)); } if (shapeids.Count < 2) { return; } // Calculate the new Xfrms var sortpos = axis == Drawing.Axis.XAxis ? RelativePosition.PinX : RelativePosition.PinY; var delta = axis == Drawing.Axis.XAxis ? new Drawing.Size(spacing, 0) : new Drawing.Size(0, spacing); var sorted_shape_ids = ArrangeHelper.SortShapesByPosition(page, shapeids, sortpos); var input_xfrms = Shapes.XFormCells.GetCells(page, sorted_shape_ids); var output_xfrms = new List<Shapes.XFormCells>(input_xfrms.Count); var bb = ArrangeHelper.GetBoundingBox(input_xfrms); var cur_pos = new Drawing.Point(bb.Left, bb.Bottom); foreach (var input_xfrm in input_xfrms) { var new_pinpos = axis == Drawing.Axis.XAxis ? new Drawing.Point(cur_pos.X + input_xfrm.LocPinX.Result, input_xfrm.PinY.Result) : new Drawing.Point(input_xfrm.PinX.Result, cur_pos.Y + input_xfrm.LocPinY.Result); var output_xfrm = new Shapes.XFormCells(); output_xfrm.PinX = new_pinpos.X; output_xfrm.PinY = new_pinpos.Y; output_xfrms.Add(output_xfrm); cur_pos = cur_pos.Add(input_xfrm.Width.Result, input_xfrm.Height.Result).Add(delta); } // Apply the changes ArrangeHelper.update_xfrms(page, sorted_shape_ids, output_xfrms); }