public void Scripting_Drop_Many()
        {
            var pagesize = new VA.Geometry.Size(10, 10);
            var client   = this.GetScriptingClient();

            // Create the Page
            client.Document.NewDocument();
            client.Page.NewPage(pagesize, false);

            // Load the stencils and find the masters
            var basic_stencil = client.Document.OpenStencilDocument("Basic_U.VSS");
            var stencil_tdoc  = new VisioScripting.Models.TargetDocument(basic_stencil);
            var m1            = client.Master.GetMasterWithNameInDocument(stencil_tdoc, "Rectangle");
            var m2            = client.Master.GetMasterWithNameInDocument(stencil_tdoc, "Ellipse");

            // Drop the Shapes
            var masters = new[] { m1, m2 };
            var xys     = new[] { 1.0, 2.0, 3.0, 4.0, 1.5, 4.5, 5.7, 2.4 };
            var points  = VA.Geometry.Point.FromDoubles(xys).ToList();

            client.Master.DropMastersOnActivePage(masters, points);

            // Verify
            var application = client.Application.GetActiveApplication();

            Assert.AreEqual(4, application.ActivePage.Shapes.Count);

            // Cleanup
            client.Document.CloseActiveDocument(true);
        }
示例#2
0
        protected override void ProcessRecord()
        {
            var target_doc = new VisioScripting.Models.TargetDocument(this.Document);

            target_doc.Resolve(this.Client);

            bool master_specified = this.Name != null;
            bool doc_specified    = this.Document != null;

            if (master_specified)
            {
                foreach (var name in this.Name)
                {
                    var masters = this.Client.Master.FindMastersInDocumentByName(target_doc, name);
                    this.WriteObject(masters, true);
                }
            }
            else
            {
                // master name is not specified
                if (doc_specified)
                {
                    this.WriteVerbose("Get all masters from specified document");
                    var masters = this.Client.Master.GetAllMastersInDocument(target_doc);
                    this.WriteObject(masters, true);
                }
                else
                {
                    this.WriteVerbose("Get all masters from active document");
                    var masters = this.Client.Master.GetAllMastersInDocument(target_doc);
                    this.WriteObject(masters, true);
                }
            }
        }
        public void Scripting_Drop_Master()
        {
            var pagesize = new VA.Geometry.Size(4, 4);
            var client   = this.GetScriptingClient();

            // Create the page
            client.Document.NewDocument();
            client.Page.NewPage(pagesize, false);

            // Load the stencils and find the masters
            var basic_stencil = client.Document.OpenStencilDocument("Basic_U.VSS");
            var stencil_tdoc  = new VisioScripting.Models.TargetDocument(basic_stencil);
            var master        = client.Master.GetMasterWithNameInDocument(stencil_tdoc, "Rectangle");

            // Frop the Shapes
            client.Master.DropMasterOnActivePage(master, new VA.Geometry.Point(2, 2));

            // Verify
            var application = client.Application.GetActiveApplication();
            var active_page = application.ActivePage;
            var shapes      = active_page.Shapes;

            Assert.AreEqual(1, shapes.Count);

            // cleanup
            client.Document.CloseActiveDocument(true);
        }
        public void Scripting_Drop_Container_Master_Object()
        {
            var pagesize = new VA.Geometry.Size(4, 4);
            var client   = this.GetScriptingClient();

            // Create the page
            client.Document.NewDocument();
            client.Page.NewPage(pagesize, false);

            var application = client.Application.GetActiveApplication();
            var active_page = application.ActivePage;

            // Load the stencils and find the masters
            var basic_stencil = client.Document.OpenStencilDocument("Basic_U.VSS");
            var stencil_tdoc  = new VisioScripting.Models.TargetDocument(basic_stencil);
            var master        = client.Master.GetMasterWithNameInDocument(stencil_tdoc, "Rectangle");

            // Drop the rectangle
            client.Master.DropMasterOnActivePage(master, new VA.Geometry.Point(2, 2));

            // Select the rectangle... it should already be selected, but just make sure
            client.Selection.SelectAllShapes();

            // Drop the container... since the rectangle is selected... it will automatically make it a member of the container
            var app = active_page.Application;

            var ver = client.Application.ApplicationVersion;
            var cont_master_name = ver.Major >= 15 ? "Plain" : "Container 1";

            var stencil_type       = IVisio.VisBuiltInStencilTypes.visBuiltInStencilContainers;
            var measurement_system = IVisio.VisMeasurementSystem.visMSUS;
            var containers_file    = app.GetBuiltInStencilFile(stencil_type, measurement_system);
            var containers_doc     = app.Documents.OpenStencil(containers_file);
            var masters            = containers_doc.Masters;
            var container_master   = masters.ItemU[cont_master_name];
            var dropped_container  = client.Master.DropContainerMaster(container_master);

            // Verify
            var shapes = active_page.Shapes;

            // There should be two shapes... the rectangle and the container
            Assert.AreEqual(2, shapes.Count);

            // Verify that we did indeed drop a container

            var results_dic = VisioAutomation.Shapes.UserDefinedCellHelper.GetCellsAsDictionary(dropped_container, VA.ShapeSheet.CellValueType.Result);

            Assert.IsTrue(results_dic.ContainsKey("msvStructureType"));
            var prop = results_dic["msvStructureType"];

            Assert.AreEqual("Container", prop.Value.Value);

            // cleanup
            client.Document.CloseActiveDocument(true);
        }
示例#5
0
        public void Scripting_Connects_Scenario_1()
        {
            var client = this.GetScriptingClient();

            client.Document.NewDocument();
            var pagesize = new VA.Geometry.Size(4, 4);

            client.Page.NewPage(pagesize, false);

            var s1 = client.Draw.DrawRectangle(1, 1, 1.25, 1.5);

            var s2 = client.Draw.DrawRectangle(2, 3, 2.5, 3.5);

            var s3 = client.Draw.DrawRectangle(4.5, 2.5, 6, 3.5);

            client.Selection.SelectNone();
            client.Selection.SelectShapesById(s1);
            client.Selection.SelectShapesById(s2);
            client.Selection.SelectShapesById(s3);

            client.Document.OpenStencilDocument("basic_u.vss");
            var connec_stencil        = client.Document.OpenStencilDocument("connec_u.vss");
            var connec_tdoc           = new VisioScripting.Models.TargetDocument(connec_stencil);
            var master                = client.Master.GetMasterWithNameInDocument(connec_tdoc, "Dynamic Connector");
            var undirected_connectors = client.Connection.ConnectShapes(new [] { s1, s2 }, new [] { s2, s3 }, master);

            var h1 = new VisioAutomation.DocumentAnalysis.ConnectorHandling();

            h1.NoArrowsHandling = NoArrowsHandling.ExcludeEdge;

            var directed_edges0 = client.Connection.GetDirectedEdgesOnActivePage(h1);

            Assert.AreEqual(0, directed_edges0.Count);

            var h7 = new VA.DocumentAnalysis.ConnectorHandling();

            h7.NoArrowsHandling = NoArrowsHandling.TreatEdgeAsBidirectional;

            var directed_edges1 = client.Connection.GetDirectedEdgesOnActivePage(h7);

            Assert.AreEqual(4, directed_edges1.Count);

            var h8 = new VA.DocumentAnalysis.ConnectorHandling();

            h8.DirectionSource = DirectionSource.UseConnectionOrder;

            var undirected_edges0 = client.Connection.GetDirectedEdgesOnActivePage(h8);

            Assert.AreEqual(2, undirected_edges0.Count);

            client.Document.CloseActiveDocument(true);
        }
        public void Scripting_Draw_Grid()
        {
            var origin   = new VisioAutomation.Geometry.Point(0, 4);
            var pagesize = new VisioAutomation.Geometry.Size(4, 4);
            var cellsize = new VisioAutomation.Geometry.Size(0.5, 0.25);
            int cols     = 3;
            int rows     = 6;

            // Create the Page
            var client = this.GetScriptingClient();

            client.Document.NewDocument();
            client.Page.NewPage(pagesize, false);

            // Find the stencil and master
            var stencildoc   = client.Document.OpenStencilDocument("basic_u.vss");
            var stencil_tdoc = new VisioScripting.Models.TargetDocument(stencildoc);
            var master       = client.Master.GetMasterWithNameInDocument(stencil_tdoc, "Rectangle");

            // Draw the grid
            var page = client.Page.GetActivePage();
            var grid = new GRID.GridLayout(cols, rows, cellsize, master);

            grid.Origin = origin;
            grid.Render(page);

            // Verify
            int total_shapes_expected = cols * rows;
            var shapes = page.Shapes.ToList();
            int total_shapes_actual = shapes.Count;

            Assert.AreEqual(total_shapes_expected, total_shapes_actual);

            // Cleanup
            client.Document.CloseActiveDocument(true);
        }
示例#7
0
        public void Scripting_Connects_Scenario_0()
        {
            var client = this.GetScriptingClient();

            client.Document.NewDocument();
            var pagesize = new VA.Geometry.Size(4, 4);

            client.Page.NewPage(pagesize, false);

            var s1 = client.Draw.DrawRectangle(1, 1, 1.25, 1.5);
            var s2 = client.Draw.DrawRectangle(2, 3, 2.5, 3.5);
            var s3 = client.Draw.DrawRectangle(4.5, 2.5, 6, 3.5);

            client.Selection.SelectNone();
            client.Selection.SelectShapesById(s1);
            client.Selection.SelectShapesById(s2);
            client.Selection.SelectShapesById(s3);

            client.Document.OpenStencilDocument("basic_u.vss");
            var connec_stencil = client.Document.OpenStencilDocument("connec_u.vss");

            var tdoc                = new VisioScripting.Models.TargetDocument(connec_stencil);
            var master              = client.Master.GetMasterWithNameInDocument(tdoc, "Dynamic Connector");
            var fromshapes          = new [] { s1, s2 };
            var toshapes            = new [] { s2, s3 };
            var directed_connectors = client.Connection.ConnectShapes(fromshapes, toshapes, master);

            client.Selection.SelectNone();
            client.Selection.SelectShapes(directed_connectors);

            var page   = client.Page.GetActivePage();
            var writer = client.ShapeSheet.GetWriterForPage(page);

            var shapes = client.Selection.GetShapesInSelection();

            foreach (var shape in shapes)
            {
                writer.SetFormula(shape.ID16, VA.ShapeSheet.SrcConstants.LineEndArrow, "13");
            }
            writer.Commit();

            var ch = new VA.DocumentAnalysis.ConnectorHandling();

            ch.DirectionSource = DirectionSource.UseConnectionOrder;
            var undirected_edges0 = client.Connection.GetDirectedEdgesOnActivePage(ch);

            Assert.AreEqual(2, undirected_edges0.Count);

            var h0 = new VisioAutomation.DocumentAnalysis.ConnectorHandling();

            h0.NoArrowsHandling = NoArrowsHandling.ExcludeEdge;

            var h1 = new VisioAutomation.DocumentAnalysis.ConnectorHandling();

            h1.NoArrowsHandling = NoArrowsHandling.TreatEdgeAsBidirectional;

            var directed_edges0 = client.Connection.GetDirectedEdgesOnActivePage(h0);

            Assert.AreEqual(2, directed_edges0.Count);

            var directed_edges1 = client.Connection.GetDirectedEdgesOnActivePage(h1);

            Assert.AreEqual(2, directed_edges1.Count);

            client.Document.CloseActiveDocument(true);
        }