Example #1
0
        private static double GetPositionOnShape(Shapes.XFormCells xform, RelativePosition pos)
        {
            switch (pos)
            {
            case RelativePosition.PinY:
                return(xform.PinY.Result);

            case RelativePosition.PinX:
                return(xform.PinX.Result);
            }

            var r = ArrangeHelper.GetRectangle(xform);

            switch (pos)
            {
            case RelativePosition.Left:
                return(r.Left);

            case RelativePosition.Right:
                return(r.Right);

            case RelativePosition.Top:
                return(r.Top);

            case RelativePosition.Bottom:
                return(r.Bottom);
            }

            throw new System.ArgumentOutOfRangeException(nameof(pos));
        }
Example #2
0
        public static VA.Drawing.Rectangle GetBoundingBox(IEnumerable <VA.Shapes.XFormCells> xfrms)
        {
            var bb = new VA.Drawing.BoundingBox(xfrms.Select(i => ArrangeHelper.GetRectangle(i)));

            if (!bb.HasValue)
            {
                throw new System.ArgumentException("Could not calculate bounding box");
            }
            else
            {
                return(bb.Rectangle);
            }
        }
Example #3
0
        public static void SnapCorner(IVisio.Page page, IList <int> shapeids, VA.Drawing.Size snapsize, VA.Arrange.SnapCornerPosition corner)
        {
            // First caculate the new transforms
            var snap_grid    = new VA.Drawing.SnappingGrid(snapsize);
            var input_xfrms  = ArrangeHelper.GetXForm(page, shapeids);
            var output_xfrms = new List <VA.Shapes.XFormCells>(input_xfrms.Count);

            foreach (var input_xfrm in input_xfrms)
            {
                var old_lower_left = ArrangeHelper.GetRectangle(input_xfrm).LowerLeft;
                var new_lower_left = snap_grid.Snap(old_lower_left);
                var output_xfrm    = _SnapCorner(corner, new_lower_left, input_xfrm);
                output_xfrms.Add(output_xfrm);
            }

            // Now apply them
            update_xfrms(page, shapeids, output_xfrms);
        }