コード例 #1
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.Value == null)
            {
                string msg = "Must provide an X Formula";
                throw new System.ArgumentException(msg, nameof(connection_point_cells));
            }

            if (connection_point_cells.Y.Value == null)
            {
                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 writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(connection_point_cells, n);

            writer.Commit(shape, VASS.CellValueType.Formula);

            return(n);
        }
コード例 #2
0
        private static void _verify_page_size_to_fit(IVisio.Document doc,
                                                     VA.Geometry.Size bottomleft_margin,
                                                     VA.Geometry.Size upperright_margin,
                                                     VA.Geometry.Size shape_size,
                                                     VA.Geometry.Size padding_size,
                                                     double expected_pinx,
                                                     double expected_piny)
        {
            var page = doc.Pages.Add();

            var pagecells = new VA.Pages.PagePrintCells();

            pagecells.TopMargin    = upperright_margin.Height;
            pagecells.BottomMargin = bottomleft_margin.Height;
            pagecells.LeftMargin   = bottomleft_margin.Width;
            pagecells.RightMargin  = upperright_margin.Width;

            var page_writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            page_writer.SetValues(pagecells);

            page_writer.Commit(page.PageSheet, CellValueType.Formula);


            var shape = page.DrawRectangle(5, 5, 5 + shape_size.Width, 5 + shape_size.Height);

            page.ResizeToFitContents(padding_size);
            var xform  = VA.Shapes.ShapeXFormCells.GetCells(shape, CellValueType.Result);
            var pinpos = xform.GetPinPosResult();

            Assert.AreEqual(expected_pinx, pinpos.X, 0.1);
            Assert.AreEqual(expected_piny, pinpos.Y, 0.1);
            page.Delete(0);
        }
コード例 #3
0
        public void Page_Query()
        {
            var size           = new VA.Geometry.Size(4, 3);
            var page1          = this.GetNewPage(size);
            var page_fmt_cells = VA.Pages.PageFormatCells.GetCells(page1.PageSheet, CellValueType.Formula);

            Assert.AreEqual("4 in", page_fmt_cells.Width.Value);
            Assert.AreEqual("3 in", page_fmt_cells.Height.Value);

            // Double each side
            var page_fmt_cells1 = page_fmt_cells;

            page_fmt_cells1.Width  = "8";
            page_fmt_cells1.Height = "6";

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(page_fmt_cells1);

            writer.Commit(page1.PageSheet, CellValueType.Formula);

            var actual_page_format_cells = VA.Pages.PageFormatCells.GetCells(page1.PageSheet, CellValueType.Result);

            Assert.AreEqual("8.0000 in.", actual_page_format_cells.Width.Value);
            Assert.AreEqual("6.0000 in.", actual_page_format_cells.Height.Value);
            page1.Delete(0);
        }
コード例 #4
0
        public static int Set(IVisio.Shape shape, short row, ControlCells ctrl)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }


            if (ctrl.XDynamics.Value == null)
            {
                ctrl.XDynamics = string.Format("Controls.Row_{0}", row + 1);
            }

            if (ctrl.YDynamics.Value == null)
            {
                ctrl.YDynamics = string.Format("Controls.Row_{0}.Y", row + 1);
            }

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(ctrl, row);

            writer.CommitFormulas(shape);

            return(row);
        }
コード例 #5
0
        public static void Set(IVisio.Shape shape, short row, CustomPropertyCells cp)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(cp, row);

            writer.CommitFormulas(shape);
        }
コード例 #6
0
        public void Apply(IVisio.Page page)
        {
            var page_layout_cells = new VisioAutomation.Pages.PageLayoutCells();

            this.SetPageCells(page_layout_cells);

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(page_layout_cells);

            writer.CommitFormulas(page.PageSheet);
            page.Layout();
        }
コード例 #7
0
        public void SetPageFormatCells(Models.TargetPages targetpages, VisioAutomation.Pages.PageFormatCells cells)
        {
            var pages = targetpages.Resolve(this._client);

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageFormatCells)))
            {
                foreach (var page in pages)
                {
                    var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();
                    writer.SetValues(cells);
                    writer.BlastGuards = true;
                    writer.CommitFormulas(page);
                }
            }
        }
コード例 #8
0
        public static int Set(
            IVisio.Shape shape,
            short row,
            ConnectionPointCells cpcells)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(cpcells, row);

            writer.Commit(shape, VASS.CellValueType.Formula);

            return(row);
        }
コード例 #9
0
        public static int Set(
            IVisio.Shape shape,
            short row,
            HyperlinkCells hyperlink)
        {
            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(hyperlink, row);

            writer.CommitFormulas(shape);

            return(row);
        }
コード例 #10
0
        public IVisio.Document NewDocumentFromTemplate(VisioAutomation.Geometry.Size size, string template)
        {
            var cmdtarget = this._client.GetCommandTargetApplication();

            var doc       = this.NewDocumentFromTemplate(template);
            var pagecells = new VisioAutomation.Pages.PageFormatCells();

            pagecells.Width  = size.Width;
            pagecells.Height = size.Height;

            var pages = doc.Pages;
            var page  = pages[1];

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetValues(pagecells);
            writer.Commit(page.PageSheet, CellValueType.Formula);

            return(doc);
        }
コード例 #11
0
        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 = string.Format("Could not retrieve cell for custom property \"{0}\"", full_prop_name);
                    throw new Exceptions.InternalAssertionException(msg);
                }

                var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();
                writer.SetValues(cp, cell_propname.Row);

                writer.CommitFormulas(shape);

                return;
            }

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

            CustomPropertyHelper.Set(shape, row, cp);
        }