示例#1
0
        public static void SnapSize(IVisio.Page page, VisioScripting.Models.TargetShapeIDs target, VisioAutomation.Geometry.Size snapsize, VisioAutomation.Geometry.Size minsize)
        {
            var input_xfrms = VisioScripting.Models.ShapeXFormData.Get(page, target);
            var sizes       = new List <VisioAutomation.Geometry.Size>(input_xfrms.Count);

            var grid = new VisioScripting.Models.SnappingGrid(snapsize);

            foreach (var input_xfrm in input_xfrms)
            {
                // First snap the size to the grid
                double old_w        = input_xfrm.Width;
                double old_h        = input_xfrm.Height;
                var    input_size   = new VisioAutomation.Geometry.Size(old_w, old_h);
                var    snapped_size = grid.Snap(input_size);

                // then account for any minum size requirements
                double new_w = System.Math.Max(snapped_size.Width, minsize.Width);
                double new_h = System.Math.Max(snapped_size.Height, minsize.Height);

                sizes.Add(new VisioAutomation.Geometry.Size(new_w, new_h));
            }

            // Now apply the updates to the sizes
            ModifySizes(page, target.ShapeIDs, sizes);
        }
示例#2
0
        public static void SnapCorner(IVisio.Page page, VisioScripting.Models.TargetShapeIDs target, VisioAutomation.Geometry.Size snapsize, VisioScripting.Models.SnapCornerPosition corner)
        {
            // First caculate the new transforms
            var snap_grid    = new VisioScripting.Models.SnappingGrid(snapsize);
            var input_xfrms  = VisioScripting.Models.ShapeXFormData.Get(page, target);
            var output_xfrms = new List <VisioAutomation.Geometry.Point>(input_xfrms.Count);

            foreach (var input_xfrm in input_xfrms)
            {
                var old_rect         = input_xfrm.GetRectangle();
                var old_lower_left   = old_rect.LowerLeft;
                var new_lower_left   = snap_grid.Snap(old_lower_left);
                var new_pin_position = ArrangeHelper.GetPinPositionForCorner(input_xfrm, new_lower_left, corner);
                var output_xfrm      = new VisioAutomation.Geometry.Point(new_pin_position.X, new_pin_position.Y);
                output_xfrms.Add(output_xfrm);
            }

            ModifyPinPositions(page, target.ShapeIDs, output_xfrms);
        }