Example #1
0
        private static void SnapSize(IVisio.Page page, IList <int> shapeids, Drawing.Size snapsize, Drawing.Size minsize)
        {
            var input_xfrms  = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List <Shapes.XFormCells>(input_xfrms.Count);

            var grid = new Drawing.SnappingGrid(snapsize);

            foreach (var input_xfrm in input_xfrms)
            {
                var    inut_size    = new Drawing.Size(input_xfrm.Width.Result, input_xfrm.Height.Result);
                var    snapped_size = grid.Snap(inut_size);
                double max_w        = System.Math.Max(snapped_size.Width, minsize.Width);
                double max_h        = System.Math.Max(snapped_size.Height, minsize.Height);
                var    new_size     = new Drawing.Size(max_w, max_h);

                var output_xfrm = new Shapes.XFormCells();
                output_xfrm.Width  = new_size.Width;
                output_xfrm.Height = new_size.Height;

                output_xfrms.Add(output_xfrm);
            }

            // Now apply them
            ArrangeCommands.update_xfrms(page, shapeids, output_xfrms);
        }
Example #2
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);
        }
Example #3
0
        public static void SnapSize(IVisio.Page page, IList <int> shapeids, Drawing.Size snapsize, Drawing.Size minsize)
        {
            var input_xfrms  = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List <Shapes.XFormCells>(input_xfrms.Count);

            var grid = new Drawing.SnappingGrid(snapsize);

            foreach (var input_xfrm in input_xfrms)
            {
                // First snap the size to the grid
                double old_w        = input_xfrm.Width.Result;
                double old_h        = input_xfrm.Height.Result;
                var    input_size   = new Drawing.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);
                var    output_size = new Drawing.Size(new_w, new_h);

                // Output the new size for the shape if the size of the shape changed
                bool different_widths  = (old_w != new_w);
                bool different_heights = (old_h != new_h);
                if (different_widths || different_heights)
                {
                    var output_xfrm = new Shapes.XFormCells();
                    if (different_widths)
                    {
                        output_xfrm.Width = output_size.Width;
                    }
                    if (different_heights)
                    {
                        output_xfrm.Height = output_size.Height;
                    }
                    output_xfrms.Add(output_xfrm);
                }
            }

            // Now apply the updates to the sizes
            ArrangeHelper.update_xfrms(page, shapeids, output_xfrms);
        }
        private static void SnapSize(IVisio.Page page, IList<int> shapeids, Drawing.Size snapsize, Drawing.Size minsize)
        {
            var input_xfrms = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List<Shapes.XFormCells>(input_xfrms.Count);

            var grid = new Drawing.SnappingGrid(snapsize);
            foreach (var input_xfrm in input_xfrms)
            {
                var inut_size = new Drawing.Size(input_xfrm.Width.Result, input_xfrm.Height.Result);
                var snapped_size = grid.Snap(inut_size);
                double max_w = System.Math.Max(snapped_size.Width, minsize.Width);
                double max_h = System.Math.Max(snapped_size.Height, minsize.Height);
                var new_size = new Drawing.Size(max_w, max_h);

                var output_xfrm = new Shapes.XFormCells();
                output_xfrm.Width = new_size.Width;
                output_xfrm.Height = new_size.Height;

                output_xfrms.Add(output_xfrm);
            }

            // Now apply them
            ArrangeCommands.update_xfrms(page, shapeids, output_xfrms);
        }
        public static void SnapSize(IVisio.Page page, IList<int> shapeids, Drawing.Size snapsize, Drawing.Size minsize)
        {
            var input_xfrms = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List<Shapes.XFormCells>(input_xfrms.Count);

            var grid = new Drawing.SnappingGrid(snapsize);
            foreach (var input_xfrm in input_xfrms)
            {
                // First snap the size to the grid
                double old_w = input_xfrm.Width.Result;
                double old_h = input_xfrm.Height.Result;
                var input_size = new Drawing.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);
                var output_size = new Drawing.Size(new_w, new_h);
                
                // Output the new size for the shape if the size of the shape changed
                bool different_widths = (old_w != new_w);
                bool different_heights = (old_h != new_h);
                if (different_widths || different_heights)
                {
                    var output_xfrm = new Shapes.XFormCells();
                    if (different_widths) 
                    {
                        output_xfrm.Width = output_size.Width;                    
                    }
                    if (different_heights)
                    {
                        output_xfrm.Height = output_size.Height;
                    }
                    output_xfrms.Add(output_xfrm);
                }
            }

            // Now apply the updates to the sizes
            ArrangeHelper.update_xfrms(page, shapeids, output_xfrms);
        }
        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);
        }