示例#1
0
        public void Dom_DropShapes()
        {
            // Render it
            var app        = this.GetVisioApplication();
            var doc        = this.GetNewDoc();
            var stencil    = app.Documents.OpenStencil(this.node_stencil_name);
            var rectmaster = stencil.Masters[this.node_master_name];


            // Create the doc
            var shape_nodes = new VADOM.ShapeList();

            shape_nodes.DrawRectangle(0, 0, 1, 1);
            shape_nodes.Drop(rectmaster, 3, 3);

            shape_nodes.Render(app.ActivePage);

            app.ActiveDocument.Close(true);
        }
示例#2
0
        public void Dom_CustomProperties()
        {
            // Create the doc
            var shape_nodes = new VADOM.ShapeList();
            var vrect1      = new VADOM.Rectangle(1, 1, 9, 9);

            vrect1.Text = new VisioAutomation.Models.Text.Element("HELLO WORLD");

            vrect1.CustomProperties = new VA.Shapes.CustomPropertyDictionary();

            var cp1 = new VA.Shapes.CustomPropertyCells();

            cp1.Value = "\"FOOVALUE\"";
            cp1.Label = "\"Foo Label\"";

            var cp2 = new VA.Shapes.CustomPropertyCells();

            cp2.Value = "\"BARVALUE\"";
            cp2.Label = "\"Bar Label\"";

            vrect1.CustomProperties["FOO"] = cp1;
            vrect1.CustomProperties["BAR"] = cp2;

            shape_nodes.Add(vrect1);

            // Render it
            var app = this.GetVisioApplication();
            var doc = this.GetNewDoc();

            shape_nodes.Render(app.ActivePage);

            // Verify
            Assert.IsNotNull(vrect1.VisioShape);
            Assert.AreEqual("HELLO WORLD", vrect1.VisioShape.Text);
            Assert.IsTrue(VA.Shapes.CustomPropertyHelper.Contains(vrect1.VisioShape, "FOO"));
            Assert.IsTrue(VA.Shapes.CustomPropertyHelper.Contains(vrect1.VisioShape, "BAR"));

            doc.Close(true);
        }
示例#3
0
        public static void BoxLayout_TwoLevelGrouping()
        {
            int num_types      = 10;
            int max_properties = 50;

            var types = typeof(VA.Shapes.UserDefinedCellCells).Assembly.GetExportedTypes().Take(num_types).ToList();

            var data = new List <string[]>();

            foreach (var type in types)
            {
                var properties = type.GetProperties().Take(max_properties).ToList();
                foreach (var property in properties)
                {
                    var item = new[] { type.Name, property.Name[0].ToString().ToUpper(), property.Name };
                    data.Add(item);
                }
            }

            var layout1 = BoxLayout2Samples.CreateTwoLevelLayout(data);


            layout1.PerformLayout();

            // Create a blank canvas in Visio
            var app       = SampleEnvironment.Application;
            var documents = app.Documents;
            var doc       = documents.Add(string.Empty);
            var page      = app.ActivePage;


            var domshapescol = new VADOM.ShapeList();

            //var rect_master = dom.m
            foreach (var item in layout1.Nodes)
            {
                if (item.Data == null)
                {
                    continue;
                }
                var info = (TwoLevelInfo)item.Data;

                if (!info.Render)
                {
                    continue;
                }

                var shape = domshapescol.Drop("Rectangle", "Basic_U.VSS", item.Rectangle);

                if (info.Text != null)
                {
                    shape.Text = new VisioAutomation.Models.Text.Element(info.Text);
                }

                shape.Cells = info.ShapeCells.ShallowCopy();
            }
            domshapescol.Render(page);

            var bordersize = new VA.Geometry.Size(0.5, 0.5);

            page.ResizeToFitContents(bordersize);
        }