Beispiel #1
0
        public List <VA.DocumentAnalysis.ConnectorEdge> GetDirectedEdgesOnActivePage(VA.DocumentAnalysis.ConnectorHandling flag)
        {
            var cmdtarget = this._client.GetCommandTargetPage();

            var directed_edges = VA.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(cmdtarget.ActivePage, flag);

            return(directed_edges);
        }
        /// <summary>
        /// Returns all the connected pairs of shapes in the active page
        /// </summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public List <VA.DocumentAnalysis.ConnectorEdge> GetTransitiveClosure(VA.DocumentAnalysis.ConnectorHandling flag)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var app = this._client.Application.Get();

            return(VA.DocumentAnalysis.ConnectionAnalyzer.GetTransitiveClosure(app.ActivePage, flag));
        }
        public List <VA.DocumentAnalysis.ConnectorEdge> GetDirectedEdges(VA.DocumentAnalysis.ConnectorHandling flag)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var application    = this._client.Application.Get();
            var directed_edges = VA.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(application.ActivePage, flag);

            return(directed_edges);
        }
        public void Connects_GetDirectedEdges_EdgesWithoutArrowsAreExcluded_withArrowHeads2()
        {
            var page1  = this.GetNewPage();
            var shapes = this.draw_standard_shapes(page1);

            this.connect(shapes[0], shapes[1], true, true);
            this.connect(shapes[1], shapes[2], true, true);

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

            ch1.NoArrowsHandling = VisioAutomation.DocumentAnalysis.NoArrowsHandling.ExcludeEdge;

            var edges1 = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(page1, ch1);
            var map1   = new ConnectivityMap(edges1);

            Assert.AreEqual(3, map1.CountFromNodes());
            Assert.IsTrue(map1.HasConnectionFromTo("A", "B"));
            Assert.IsTrue(map1.HasConnectionFromTo("B", "A"));
            Assert.IsTrue(map1.HasConnectionFromTo("B", "C"));
            Assert.IsTrue(map1.HasConnectionFromTo("C", "B"));
            Assert.AreEqual(1, map1.CountConnectionsFrom("A"));
            Assert.AreEqual(2, map1.CountConnectionsFrom("B"));
            Assert.AreEqual(1, map1.CountConnectionsFrom("C"));

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

            ch2.NoArrowsHandling = VisioAutomation.DocumentAnalysis.NoArrowsHandling.TreatEdgeAsBidirectional;

            var edges2 = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetTransitiveClosure(page1, ch2);
            var map2   = new ConnectivityMap(edges2);

            Assert.AreEqual(3, map2.CountFromNodes());
            Assert.IsTrue(map2.HasConnectionFromTo("A", "B"));
            Assert.IsTrue(map2.HasConnectionFromTo("B", "A"));
            Assert.IsTrue(map2.HasConnectionFromTo("B", "C"));
            Assert.IsTrue(map2.HasConnectionFromTo("C", "B"));
            Assert.IsTrue(map2.HasConnectionFromTo("A", "C"));
            Assert.IsTrue(map2.HasConnectionFromTo("C", "A"));

            Assert.AreEqual(2, map2.CountConnectionsFrom("A"));
            Assert.AreEqual(2, map2.CountConnectionsFrom("B"));
            Assert.AreEqual(2, map2.CountConnectionsFrom("C"));


            page1.Delete(0);
        }
Beispiel #5
0
        private VA.DocumentAnalysis.ConnectorHandling get_DirectedEdgeHandling()
        {
            var flag = new VA.DocumentAnalysis.ConnectorHandling();

            flag.NoArrowsHandling = VA.DocumentAnalysis.NoArrowsHandling.ExcludeEdge;

            if (this.Raw)
            {
                flag.DirectionSource = VA.DocumentAnalysis.DirectionSource.UseConnectionOrder;
            }
            else
            {
                flag.DirectionSource  = VA.DocumentAnalysis.DirectionSource.UseConnectorArrows;
                flag.NoArrowsHandling = this.TreatUndirectedAsBidirectional ?
                                        VA.DocumentAnalysis.NoArrowsHandling.TreatEdgeAsBidirectional
                    : VA.DocumentAnalysis.NoArrowsHandling.ExcludeEdge;
            }
            return(flag);
        }
        public void PathAnalysis_GetDirectEdgesRaw()
        {
            var page1  = this.GetNewPage();
            var shapes = this.draw_standard_shapes(page1);

            this.connect(shapes[0], shapes[1], false, false);
            this.connect(shapes[1], shapes[2], false, false);

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

            ch.DirectionSource = VisioAutomation.DocumentAnalysis.DirectionSource.UseConnectionOrder;

            var edges = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(page1, ch);
            var map   = new ConnectivityMap(edges);

            Assert.AreEqual(2, map.CountFromNodes());
            Assert.IsTrue(map.HasConnectionFromTo("A", "B"));
            Assert.IsTrue(map.HasConnectionFromTo("B", "C"));
            Assert.AreEqual(1, map.CountConnectionsFrom("A"));
            Assert.AreEqual(1, map.CountConnectionsFrom("B"));
            page1.Delete(0);
        }
        public void Connects_GetDirectedEdges_EdgesWithoutArrowsAreExcluded()
        {
            var page1  = this.GetNewPage();
            var shapes = this.draw_standard_shapes(page1);

            this.connect(shapes[0], shapes[1], false, false);
            this.connect(shapes[1], shapes[2], false, false);

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

            ch.NoArrowsHandling = VisioAutomation.DocumentAnalysis.NoArrowsHandling.ExcludeEdge;

            var edges1 = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(page1, ch);
            var map1   = new ConnectivityMap(edges1);

            Assert.AreEqual(0, map1.CountFromNodes());

            var edges2 = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetTransitiveClosure(page1, ch);
            var map2   = new ConnectivityMap(edges2);

            Assert.AreEqual(0, map2.CountFromNodes());

            page1.Delete(0);
        }
Beispiel #8
0
        public static void PathAnalysis()
        {
            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            page.DrawRectangle(0, 0, 1, 1);

            var s0 = page.DrawRectangle(0, 0, 1, 1);
            var s1 = page.DrawRectangle(3, 0, 4, 1);
            var s2 = page.DrawRectangle(1.5, 1.5, 2.5, 2.5);
            var s3 = page.DrawRectangle(0, 3, 1, 4);
            var s4 = page.DrawRectangle(3, 3, 4, 4);
            var s5 = page.DrawRectangle(3, 6, 4, 7);
            var s6 = page.DrawRectangle(7, 8, 8, 9);

            s0.Text = "s0";
            s1.Text = "s1";
            s2.Text = "s2";
            s3.Text = "s3";
            s4.Text = "s4";
            s5.Text = "s5";
            s6.Text = "s6";

            var stencil   = page.Application.Documents.OpenStencil("basic_u.vss");
            var connector = stencil.Masters["Dynamic Connector"];

            // connect shapes - but leave s0 alone
            var dir = IVisio.VisAutoConnectDir.visAutoConnectDirNone;

            s1.AutoConnect(s2, dir, null);
            s2.AutoConnect(s3, dir, null);
            s3.AutoConnect(s2, dir, null);
            s3.AutoConnect(s4, dir, null);
            s5.AutoConnect(s6, dir, null);

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

            ch.DirectionSource = VisioAutomation.DocumentAnalysis.DirectionSource.UseConnectionOrder;

            var normal_edges = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(page, ch);

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

            ch0.NoArrowsHandling = VisioAutomation.DocumentAnalysis.NoArrowsHandling.ExcludeEdge;

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

            ch1.NoArrowsHandling = VisioAutomation.DocumentAnalysis.NoArrowsHandling.TreatEdgeAsBidirectional;

            var tc_edges_0 = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetTransitiveClosure(page, ch0);
            var tc_edges_1 = VisioAutomation.DocumentAnalysis.ConnectionAnalyzer.GetTransitiveClosure(page, ch1);

            var legend0 = page.DrawRectangle(5, 0, 6.5, 6);
            var sb0     = new System.Text.StringBuilder();

            sb0.AppendLine("Connections");

            foreach (var e in normal_edges)
            {
                string s = string.Format("{0} - {1}", e.From.Text, e.To.Text);
                sb0.AppendLine(s);
            }

            legend0.Text = sb0.ToString();

            var legend1 = page.DrawRectangle(6.5, 0, 8.5, 6);
            var sb1     = new System.Text.StringBuilder();

            sb1.AppendLine("Transitive closure (treat edges as bidirectional)");

            foreach (var e in tc_edges_1)
            {
                string s = string.Format("{0} -> {1}", e.From.Text, e.To.Text);
                sb1.AppendLine(s);
            }

            legend1.Text = sb1.ToString();
        }
Beispiel #9
0
        /// <summary>
        /// Returns all the connected pairs of shapes in the active page
        /// </summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public List <VA.DocumentAnalysis.ConnectorEdge> GetTransitiveClosureOnActivePage(VA.DocumentAnalysis.ConnectorHandling flag)
        {
            var cmdtarget = this._client.GetCommandTargetPage();

            return(VA.DocumentAnalysis.ConnectionAnalyzer.GetTransitiveClosure(cmdtarget.ActivePage, flag));
        }