Ejemplo n.º 1
0
        private static Shapes.XFormCells _SnapCorner(SnapCornerPosition corner, Drawing.Point new_lower_left, Shapes.XFormCells input_xfrm)
        {
            var new_pin_position = ArrangeHelper.GetPinPositionForCorner(input_xfrm, new_lower_left, corner);

            var output_xfrm = new Shapes.XFormCells();

            if (new_pin_position.X != input_xfrm.PinX.Result)
            {
                output_xfrm.PinX = new_pin_position.X;
            }
            if (new_pin_position.Y != input_xfrm.PinY.Result)
            {
                output_xfrm.PinY = new_pin_position.Y;
            }
            return(output_xfrm);
        }
Ejemplo n.º 2
0
        public void SnapCorner(TargetShapes targets, double w, double h, SnapCornerPosition corner)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var shapes = targets.ResolveShapes2D(this._client);

            if (shapes.Shapes.Count < 1)
            {
                return;
            }

            var application = this._client.Application.Get();
            var page        = application.ActivePage;
            var target_ids  = targets.ToShapeIDs();

            using (var undoscope = this._client.Application.NewUndoScope("Snap Shape Corner"))
            {
                ArrangeHelper.SnapCorner(page, target_ids, new Drawing.Size(w, h), corner);
            }
        }
        public void SnapCorner(IList<IVisio.Shape> target_shapes, double w, double h, SnapCornerPosition corner)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes2D(target_shapes);
            if (shapes.Count < 1)
            {
                return;
            }

            var shapeids = shapes.Select(s => s.ID).ToList();
            var application = this.Client.Application.Get();
            using (var undoscope = this.Client.Application.NewUndoScope("SnapCorner"))
            {
                var active_page = application.ActivePage;
                ArrangeHelper.SnapCorner(active_page, shapeids, new Drawing.Size(w, h), corner);
            }
        }
Ejemplo n.º 4
0
        public void SnapCorner(IList <IVisio.Shape> target_shapes, double w, double h, SnapCornerPosition corner)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes2D(target_shapes);

            if (shapes.Count < 1)
            {
                return;
            }

            var shapeids    = shapes.Select(s => s.ID).ToList();
            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("SnapCorner"))
            {
                var active_page = application.ActivePage;
                ArrangeHelper.SnapCorner(active_page, shapeids, new Drawing.Size(w, h), corner);
            }
        }
        private static Drawing.Point GetPinPositionForCorner(Shapes.XFormCells input_xfrm, Drawing.Point new_lower_left, SnapCornerPosition corner)
        {
            var size = new Drawing.Size(input_xfrm.Width.Result, input_xfrm.Height.Result);
            var locpin = new Drawing.Point(input_xfrm.LocPinX.Result, input_xfrm.LocPinY.Result);

            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");
                    }
            }
        }
        private static Shapes.XFormCells _SnapCorner(SnapCornerPosition corner, Drawing.Point new_lower_left, Shapes.XFormCells input_xfrm)
        {
            var new_pin_position = ArrangeHelper.GetPinPositionForCorner(input_xfrm, new_lower_left, corner);

            var output_xfrm = new Shapes.XFormCells();
            if (new_pin_position.X != input_xfrm.PinX.Result)
            {
                output_xfrm.PinX = new_pin_position.X;
            }
            if (new_pin_position.Y != input_xfrm.PinY.Result)
            {
                output_xfrm.PinY = new_pin_position.Y;
            }
            return output_xfrm;
        }
        public static void SnapCorner(IVisio.Page page, IList<int> shapeids, Drawing.Size snapsize, SnapCornerPosition corner)
        {
            // First caculate the new transforms
            var snap_grid = new Drawing.SnappingGrid(snapsize);
            var input_xfrms = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List<Shapes.XFormCells>(input_xfrms.Count);

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

            // Now apply them
            ArrangeHelper.update_xfrms(page, shapeids, output_xfrms);
        }
Ejemplo n.º 8
0
        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");
            }
            }
        }
Ejemplo n.º 9
0
        public static void SnapCorner(IVisio.Page page, TargetShapeIDs target, Drawing.Size snapsize, SnapCornerPosition corner)
        {
            // First caculate the new transforms
            var snap_grid    = new SnappingGrid(snapsize);
            var input_xfrms  = ShapeXFormData.Get(page, target);
            var output_xfrms = new List <VisioAutomation.Drawing.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.Drawing.Point(new_pin_position.X, new_pin_position.Y);
                output_xfrms.Add(output_xfrm);
            }

            ModifyPinPositions(page, target.ShapeIDs, output_xfrms);
        }
Ejemplo n.º 10
0
        public static void SnapCorner(IVisio.Page page, IList <int> shapeids, Drawing.Size snapsize, SnapCornerPosition corner)
        {
            // First caculate the new transforms
            var snap_grid    = new Drawing.SnappingGrid(snapsize);
            var input_xfrms  = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List <Shapes.XFormCells>(input_xfrms.Count);

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

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