Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }