Пример #1
0
 public void Apply(ShapeSheet.Update update, short shapeid_label, short shapeid_box)
 {
     update.SetFormulas(shapeid_label, this.CharacterCells, 0);
     update.SetFormulas(shapeid_label, this.ParagraphCells, 0);
     update.SetFormulas(shapeid_box, this.FormatCells);
     update.SetFormulas(shapeid_label, this.TextBlockCells);
 }
Пример #2
0
        public void ApplyFormus(ShapeSheet.Update update)
        {
            short titleshape_id = this.VisioShape.ID16;

            update.SetFormulas(titleshape_id, this.TextBlockCells);
            update.SetFormulas(titleshape_id, this.ParagraphCells, 0);
            update.SetFormulas(titleshape_id, this.CharacterCells, 0);
            update.SetFormulas(titleshape_id, this.FormatCells);
        }
Пример #3
0
        public void ToogleCase(IList <IVisio.Shape> target_shapes)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

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

            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("Toggle Shape Text Case"))
            {
                var shapeids = shapes.Select(s => s.ID).ToList();

                var page = application.ActivePage;
                // Store all the formatting
                var formats = Text.TextFormat.GetFormat(page, shapeids);

                // Change the text - this will wipe out all the character and paragraph formatting
                foreach (var shape in shapes)
                {
                    string t = shape.Text;
                    if (t.Length < 1)
                    {
                        continue;
                    }
                    shape.Text = TextCommandsUtil.toggle_case(t);
                }

                // Now restore all the formatting - based on any initial formatting from the text

                var update = new ShapeSheet.Update();
                for (int i = 0; i < shapes.Count; i++)
                {
                    var format = formats[i];

                    if (format.CharacterFormats.Count > 0)
                    {
                        var fmt = format.CharacterFormats[0];
                        update.SetFormulas((short)shapeids[i], fmt, 0);
                    }

                    if (format.ParagraphFormats.Count > 0)
                    {
                        var fmt = format.ParagraphFormats[0];
                        update.SetFormulas((short)shapeids[i], fmt, 0);
                    }
                }

                update.Execute(page);
            }
        }
Пример #4
0
        public void Finish()
        {
            var update = new ShapeSheet.Update();

            foreach (var block in this.Blocks)
            {
                update.SetFormulas((short)block.VisioShapeID, block.FormatCells);
                update.SetFormulas((short)block.VisioShapeID, block.TextBlockCells);
                update.SetFormulas((short)block.VisioShapeID, block.ParagraphCells, 0);
                update.SetFormulas((short)block.VisioShapeID, block.CharacterCells, 0);
            }
            update.Execute(this.page);
        }
        public IVisio.Page CreatePage(FormPage formpage)
        {
            this.FormPage = formpage;

            this.page = this.VisioPages.Add();
            this.page.Name = formpage.Name;

            // Update the Page Cells
            var pagesheet = this.page.PageSheet;
            var pageupdate = new ShapeSheet.Update();

            var pagecells = new Pages.PageCells();
            pagecells.PageWidth = formpage.Size.Width;
            pagecells.PageHeight = formpage.Size.Height;
            pagecells.PageLeftMargin = formpage.Margin.Left;
            pagecells.PageRightMargin = formpage.Margin.Right;
            pagecells.PageTopMargin = formpage.Margin.Top;
            pagecells.PageBottomMargin = formpage.Margin.Bottom;
            pageupdate.SetFormulas(pagecells);
            pageupdate.Execute(pagesheet);


            this.Reset();
            return this.page;
        }
Пример #6
0
        public IVisio.Page CreatePage(FormPage formpage)
        {
            this.FormPage = formpage;

            this.page      = this.VisioPages.Add();
            this.page.Name = formpage.Name;

            // Update the Page Cells
            var pagesheet  = this.page.PageSheet;
            var pageupdate = new ShapeSheet.Update();

            var pagecells = new Pages.PageCells();

            pagecells.PageWidth        = formpage.Size.Width;
            pagecells.PageHeight       = formpage.Size.Height;
            pagecells.PageLeftMargin   = formpage.Margin.Left;
            pagecells.PageRightMargin  = formpage.Margin.Right;
            pagecells.PageTopMargin    = formpage.Margin.Top;
            pagecells.PageBottomMargin = formpage.Margin.Bottom;
            pageupdate.SetFormulas(pagecells);
            pageupdate.Execute(pagesheet);


            this.Reset();
            return(this.page);
        }
Пример #7
0
        public void SetLock(IList <IVisio.Shape> target_shapes, Shapes.LockCells lockcells)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

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

            var selection = this.Client.Selection.Get();
            var shapeids  = selection.GetIDs();
            var update    = new ShapeSheet.Update();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, lockcells);
            }

            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("Set Shape Lock Properties"))
            {
                var active_page = application.ActivePage;
                update.Execute(active_page);
            }
        }
Пример #8
0
        public static int Set(
            IVisio.Shape shape,
            short row,
            ControlCells ctrl)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }


            if (!ctrl.XDynamics.Formula.HasValue)
            {
                ctrl.XDynamics = $"Controls.Row_{row + 1}";
            }

            if (!ctrl.YDynamics.Formula.HasValue)
            {
                ctrl.YDynamics = $"Controls.Row_{row + 1}.Y";
            }

            var update = new ShapeSheet.Update();
            update.SetFormulas(ctrl, row);
            update.Execute(shape);

            return row;
        }
        public static int Add(
            IVisio.Shape shape,
            ConnectionPointCells cp)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            if (!cp.X.Formula.HasValue)
            {
                throw new System.ArgumentException("Must provide an X Formula");
            }

            if (!cp.Y.Formula.HasValue)
            {
                throw new System.ArgumentException("Must provide an Y Formula");
            }

            var n = shape.AddRow((short)IVisio.VisSectionIndices.visSectionConnectionPts,
                                 (short)IVisio.VisRowIndices.visRowLast,
                                 (short)IVisio.VisRowTags.visTagCnnctPt);

            var update = new ShapeSheet.Update();
            update.SetFormulas(cp,n);
            update.Execute(shape);

            return n;
        }
Пример #10
0
        public static int Add(
            IVisio.Shape shape,
            ConnectionPointCells connection_point_cells)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            if (!connection_point_cells.X.Formula.HasValue)
            {
                string msg = "Must provide an X Formula";
                throw new System.ArgumentException(msg, nameof(connection_point_cells));
            }

            if (!connection_point_cells.Y.Formula.HasValue)
            {
                string msg = "Must provide an Y Formula";
                throw new System.ArgumentException(msg, nameof(connection_point_cells));
            }

            var n = shape.AddRow((short)IVisio.VisSectionIndices.visSectionConnectionPts,
                                 (short)IVisio.VisRowIndices.visRowLast,
                                 (short)IVisio.VisRowTags.visTagCnnctPt);

            var update = new ShapeSheet.Update();

            update.SetFormulas(connection_point_cells, n);
            update.Execute(shape);

            return(n);
        }
        public static int Set(
            IVisio.Shape shape,
            short row,
            ControlCells ctrl)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }


            if (!ctrl.XDynamics.Formula.HasValue)
            {
                ctrl.XDynamics = $"Controls.Row_{row + 1}";
            }

            if (!ctrl.YDynamics.Formula.HasValue)
            {
                ctrl.YDynamics = $"Controls.Row_{row + 1}.Y";
            }

            var update = new ShapeSheet.Update();
            update.SetFormulas(ctrl, row);
            update.Execute(shape);

            return row;
        }
Пример #12
0
        public void Render(IVisio.Page page)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException(nameof(page));
            }


            // First handle any page properties
            if (this.Name!=null)
            {
                page.NameU = this.Name;
            }

            this.VisioPage = page;

            var page_sheet = page.PageSheet;

            var app = page.Application;


            using (var perfscope = new Application.PerfScope(app, this.PerfSettings))
            {
                if (this.Size.HasValue)
                {
                    this.PageCells.PageHeight = this.Size.Value.Height;
                    this.PageCells.PageWidth = this.Size.Value.Width;
                }

                var update = new ShapeSheet.Update();
                update.SetFormulas((short)page_sheet.ID, this.PageCells);
                update.Execute(page);
                
                // Then render the shapes
                this.Shapes.Render(page);

                // Perform any additional layout
                if (this.Layout != null)
                {
                    this.Layout.Apply(page);
                }

                // Optionally, perform page resizing to fit contents
                if (this.ResizeToFit)
                {
                    if (this.ResizeToFitMargin.HasValue)
                    {
                        page.ResizeToFitContents(this.ResizeToFitMargin.Value);
                    }
                    else
                    {
                        page.ResizeToFitContents();
                    }
                }
            }

        }
Пример #13
0
        public void Render(IVisio.Page page)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException(nameof(page));
            }


            // First handle any page properties
            if (this.Name != null)
            {
                page.NameU = this.Name;
            }

            this.VisioPage = page;

            var page_sheet = page.PageSheet;

            var app = page.Application;


            using (var perfscope = new Application.PerfScope(app, this.PerfSettings))
            {
                if (this.Size.HasValue)
                {
                    this.PageCells.PageHeight = this.Size.Value.Height;
                    this.PageCells.PageWidth  = this.Size.Value.Width;
                }

                var update = new ShapeSheet.Update();
                update.SetFormulas((short)page_sheet.ID, this.PageCells);
                update.Execute(page);

                // Then render the shapes
                this.Shapes.Render(page);

                // Perform any additional layout
                if (this.Layout != null)
                {
                    this.Layout.Apply(page);
                }

                // Optionally, perform page resizing to fit contents
                if (this.ResizeToFit)
                {
                    if (this.ResizeToFitMargin.HasValue)
                    {
                        page.ResizeToFitContents(this.ResizeToFitMargin.Value);
                    }
                    else
                    {
                        page.ResizeToFitContents();
                    }
                }
            }
        }
Пример #14
0
        public void Apply(IVisio.Page page)
        {
            var pagecells = new PageCells();
            this.SetPageCells(pagecells);

            var update = new ShapeSheet.Update();
            update.SetFormulas(pagecells);
            var pagesheet = page.PageSheet;
            update.Execute(pagesheet);
            page.Layout();
        }
Пример #15
0
        private static void SetSize(IVisio.Page page, Drawing.Size size)
        {
            var page_cells = new PageCells();

            page_cells.PageHeight = size.Height;
            page_cells.PageWidth  = size.Width;
            var pageupdate = new ShapeSheet.Update();

            pageupdate.SetFormulas(page_cells);
            pageupdate.Execute(page.PageSheet);
        }
        public static void Set(IVisio.Shape shape, short row, CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var update = new ShapeSheet.Update();
            update.SetFormulas(cp, row);
            update.Execute(shape);
        }
Пример #17
0
        private static void update_xfrms(IVisio.Page page, IList <int> shapeids, IList <Shapes.XFormCells> xfrms)
        {
            var update = new ShapeSheet.Update();

            for (int i = 0; i < shapeids.Count; i++)
            {
                var shape_id = shapeids[i];
                var xfrm     = xfrms[i];
                update.SetFormulas((short)shape_id, xfrm);
            }
            update.Execute(page);
        }
Пример #18
0
        public static void Set(IVisio.Shape shape, short row, CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var update = new ShapeSheet.Update();

            update.SetFormulas(cp, row);
            update.Execute(shape);
        }
Пример #19
0
        public void Apply(IVisio.Page page)
        {
            var pagecells = new PageCells();

            this.SetPageCells(pagecells);

            var update = new ShapeSheet.Update();

            update.SetFormulas(pagecells);
            var pagesheet = page.PageSheet;

            update.Execute(pagesheet);
            page.Layout();
        }
Пример #20
0
        public static int Set(
            IVisio.Shape shape,
            short row,
            HyperlinkCells hyperlink)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var update = new ShapeSheet.Update();

            update.SetFormulas(hyperlink, row);
            update.Execute(shape);

            return(row);
        }
Пример #21
0
        private static short[] DropManyU(
            IVisio.Page page,
            IList <IVisio.Master> masters,
            IList <Drawing.Rectangle> rects)
        {
            var points   = rects.Select(r => r.Center).ToList();
            var shapeids = Pages.PageHelper.DropManyU(page, masters, points);

            var xfrm = new Shapes.XFormCells();

            var update = new ShapeSheet.Update(points.Count * 2);

            for (int i = 0; i < rects.Count(); i++)
            {
                xfrm.Width  = rects[i].Width;
                xfrm.Height = rects[i].Height;
                update.SetFormulas(shapeids[i], xfrm);
            }
            update.Execute(page);

            return(shapeids);
        }
        public static void Set(
            IVisio.Shape shape,
            string name,
            CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            CustomPropertyHelper.CheckValidCustomPropertyName(name);

            if (CustomPropertyHelper.Contains(shape, name))
            {
                string full_prop_name = CustomPropertyHelper.GetRowName(name);
                var cell_propname = shape.CellsU[full_prop_name];

                if (cell_propname == null)
                {
                    string msg = $"Could not retrieve cell for custom property \"{full_prop_name}\"";
                    throw new AutomationException(msg);
                }

                var update = new ShapeSheet.Update();
                update.SetFormulas(cp, cell_propname.Row);
                update.Execute(shape);

                return;

            }

            short row = shape.AddNamedRow(
                (short)IVisio.VisSectionIndices.visSectionProp,
                name,
                (short)IVisio.VisRowIndices.visRowProp);

            CustomPropertyHelper.Set(shape, row, cp);
        }
        public void Set(IList<IVisio.Shape> target_shapes, Shapes.FormatCells format)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

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

            var update = new ShapeSheet.Update();
            var shapeids = shapes.Select(s => s.ID).ToList();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, format);
            }

            var application = this.Client.Application.Get();
            update.Execute(application.ActivePage);            
        }
Пример #24
0
        public static void Set(
            IVisio.Shape shape,
            string name,
            CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException("shape");
            }

            CheckValidCustomPropertyName(name);

            if (Contains(shape, name))
            {
                string full_prop_name = GetRowName(name);
                var    cell_propname  = shape.CellsU[full_prop_name];

                if (cell_propname == null)
                {
                    string msg = String.Format("Could not retrieve cell for custom property \"{0}\"", full_prop_name);
                    throw new AutomationException(msg);
                }

                var update = new ShapeSheet.Update();
                update.SetFormulas(cp, cell_propname.Row);
                update.Execute(shape);

                return;
            }

            short row = shape.AddNamedRow(
                (short)IVisio.VisSectionIndices.visSectionProp,
                name,
                (short)IVisio.VisRowIndices.visRowProp);

            Set(shape, row, cp);
        }
Пример #25
0
        public void Set(IList <IVisio.Shape> target_shapes, Shapes.FormatCells format)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

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

            var update   = new ShapeSheet.Update();
            var shapeids = shapes.Select(s => s.ID).ToList();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, format);
            }

            var application = this.Client.Application.Get();

            update.Execute(application.ActivePage);
        }
        public static void Duplicate(
            IVisio.Page src_page,
            IVisio.Page dest_page)
        {
            var app = src_page.Application;
            short copy_paste_flags = (short)IVisio.VisCutCopyPasteCodes.visCopyPasteNoTranslate;

            // handle the source page
            if (src_page == null)
            {
                throw new System.ArgumentNullException(nameof(src_page));
            }

            if (dest_page == null)
            {
                throw new System.ArgumentNullException(nameof(dest_page));
            }

            if (dest_page == src_page)
            {
                throw new AutomationException("Destination Page cannot be Source Page");
            }


            if (src_page != app.ActivePage)
            {
                throw new AutomationException("Source page must be active page.");
            }

            var src_page_shapes = src_page.Shapes;
            int num_src_shapes=src_page_shapes.Count;

            if (num_src_shapes > 0)
            {
                var active_window = app.ActiveWindow;
                active_window.SelectAll();
                var selection = active_window.Selection;
                selection.Copy(copy_paste_flags);
                active_window.DeselectAll();
            }

            var src_pagesheet = src_page.PageSheet;
            var pagecells = PageCells.GetCells(src_pagesheet);


            // handle the dest page

            // first update all the page cells
            var dest_pagesheet = dest_page.PageSheet;
            var update = new ShapeSheet.Update();
            update.SetFormulas(pagecells);
            update.Execute(dest_pagesheet);

            // make sure the new page looks like the old page
            dest_page.Background = src_page.Background;
            
            // then paste any contents from the first page
            if (num_src_shapes>0)
            {
                dest_page.Paste(copy_paste_flags);                
            }
        }
 public void Finish()
 {
     var update = new ShapeSheet.Update();
     foreach (var block in this.Blocks)
     {
         update.SetFormulas((short)block.VisioShapeID,block.FormatCells);
         update.SetFormulas((short)block.VisioShapeID,block.TextBlockCells);
         update.SetFormulas((short)block.VisioShapeID,block.ParagraphCells, 0);
         update.SetFormulas((short)block.VisioShapeID,block.CharacterCells, 0);
     }
     update.Execute(this.page);
 }
        public void SetLock(IList<IVisio.Shape> target_shapes, Shapes.LockCells lockcells)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

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

            var selection = this.Client.Selection.Get();
            var shapeids = selection.GetIDs();
            var update = new ShapeSheet.Update();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, lockcells);
            }

            var application = this.Client.Application.Get();
            using (var undoscope = this.Client.Application.NewUndoScope("Set Shape Lock Properties"))
            {
                var active_page = application.ActivePage;
                update.Execute(active_page);
            }
        }
        private static void update_xfrms(IVisio.Page page, IList<int> shapeids, IList<Shapes.XFormCells> xfrms)
        {

            var update = new ShapeSheet.Update();
            for (int i = 0; i < shapeids.Count; i++)
            {
                var shape_id = shapeids[i];
                var xfrm = xfrms[i];
                update.SetFormulas((short)shape_id, xfrm);
            }
            update.Execute(page);
        }
 private static void SetSize(IVisio.Page page, Drawing.Size size)
 {
     var page_cells = new PageCells();
     page_cells.PageHeight = size.Height;
     page_cells.PageWidth = size.Width;
     var pageupdate = new ShapeSheet.Update();
     pageupdate.SetFormulas(page_cells);
     pageupdate.Execute(page.PageSheet);
 }
Пример #31
0
        public static void Duplicate(
            IVisio.Page src_page,
            IVisio.Page dest_page)
        {
            var   app = src_page.Application;
            short copy_paste_flags = (short)IVisio.VisCutCopyPasteCodes.visCopyPasteNoTranslate;

            // handle the source page
            if (src_page == null)
            {
                throw new System.ArgumentNullException(nameof(src_page));
            }

            if (dest_page == null)
            {
                throw new System.ArgumentNullException(nameof(dest_page));
            }

            if (dest_page == src_page)
            {
                throw new AutomationException("Destination Page cannot be Source Page");
            }


            if (src_page != app.ActivePage)
            {
                throw new AutomationException("Source page must be active page.");
            }

            var src_page_shapes = src_page.Shapes;
            int num_src_shapes  = src_page_shapes.Count;

            if (num_src_shapes > 0)
            {
                var active_window = app.ActiveWindow;
                active_window.SelectAll();
                var selection = active_window.Selection;
                selection.Copy(copy_paste_flags);
                active_window.DeselectAll();
            }

            var src_pagesheet = src_page.PageSheet;
            var pagecells     = PageCells.GetCells(src_pagesheet);


            // handle the dest page

            // first update all the page cells
            var dest_pagesheet = dest_page.PageSheet;
            var update         = new ShapeSheet.Update();

            update.SetFormulas(pagecells);
            update.Execute(dest_pagesheet);

            // make sure the new page looks like the old page
            dest_page.Background = src_page.Background;

            // then paste any contents from the first page
            if (num_src_shapes > 0)
            {
                dest_page.Paste(copy_paste_flags);
            }
        }
        private static short[] DropManyU(
            IVisio.Page page,
            IList<IVisio.Master> masters,
            IList<Drawing.Rectangle> rects)
        {
            var points = rects.Select(r => r.Center).ToList();
            var shapeids = Pages.PageHelper.DropManyU(page, masters, points);

            var xfrm = new Shapes.XFormCells();

            var update = new ShapeSheet.Update(points.Count*2);
            for (int i = 0; i < rects.Count(); i++)
            {
                xfrm.Width = rects[i].Width;
                xfrm.Height = rects[i].Height;
                update.SetFormulas(shapeids[i], xfrm);
            }
            update.Execute(page);

            return shapeids;
        }
        public void ToogleCase(IList<IVisio.Shape> target_shapes)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();
            
            var shapes = this.GetTargetShapes(target_shapes);

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

            var application = this.Client.Application.Get();
            using (var undoscope = this.Client.Application.NewUndoScope("Toggle Shape Text Case"))
            {
                var shapeids = shapes.Select(s => s.ID).ToList();

                var page = application.ActivePage;
                // Store all the formatting
                var formats = Text.TextFormat.GetFormat(page, shapeids);

                // Change the text - this will wipe out all the character and paragraph formatting
                foreach (var shape in shapes)
                {
                    string t = shape.Text;
                    if (t.Length < 1)
                    {
                        continue;
                    }
                    shape.Text = TextCommandsUtil.toggle_case(t);
                }

                // Now restore all the formatting - based on any initial formatting from the text

                var update = new ShapeSheet.Update();
                for (int i = 0; i < shapes.Count; i++)
                {
                    var format = formats[i];

                    if (format.CharacterFormats.Count>0)
                    {
                        var fmt = format.CharacterFormats[0];
                        update.SetFormulas((short) shapeids[i], fmt, 0);
                    }

                    if (format.ParagraphFormats.Count > 0)
                    {
                        var fmt = format.ParagraphFormats[0];
                        update.SetFormulas((short)shapeids[i], fmt, 0);
                    }
                }

                update.Execute(page);
            }
        }