public void RenderDirectedGraphWithCustomProps()
        {
            var d = new VA.Models.DirectedGraph.Drawing();

            var n0 = d.AddShape("n0", "Untitled Node", "basflo_u.vss",
                                   "Decision");
            n0.Size = new VA.Drawing.Size(3, 2);
            n0.CustomProperties = new Dictionary<string, CustomPropertyCells>();
            n0.CustomProperties["p1"] = new CustomPropertyCells("v1");
            n0.CustomProperties["p2"] = new CustomPropertyCells("v2");
            n0.CustomProperties["p3"] = new CustomPropertyCells("v3");

            var options = new VA.Models.DirectedGraph.MSAGLLayoutOptions();
            options.UseDynamicConnectors = true;

            var visapp = this.GetVisioApplication();
            var doc = this.GetNewDoc();
            var page1 = visapp.ActivePage;

            d.Render(page1, options);

            Assert.IsNotNull(n0.VisioShape);
            var props_dic = CustomPropertyHelper.Get(n0.VisioShape);
            Assert.IsTrue(props_dic.Count>=3);
            Assert.AreEqual("\"v1\"",props_dic["p1"].Value.Formula);
            Assert.AreEqual("\"v2\"", props_dic["p2"].Value.Formula);
            Assert.AreEqual("\"v3\"", props_dic["p3"].Value.Formula);

            page1.Application.ActiveWindow.ViewFit = (short) IVisio.VisWindowFit.visFitPage;

            doc.Close(true);
        }
Пример #2
0
        public void RenderDirectedGraphWithCustomProps()
        {
            var d = new VA.Models.DirectedGraph.Drawing();

            var n0 = d.AddShape("n0", "Untitled Node", "basflo_u.vss",
                                "Decision");

            n0.Size                   = new VA.Drawing.Size(3, 2);
            n0.CustomProperties       = new Dictionary <string, CustomPropertyCells>();
            n0.CustomProperties["p1"] = new CustomPropertyCells("v1");
            n0.CustomProperties["p2"] = new CustomPropertyCells("v2");
            n0.CustomProperties["p3"] = new CustomPropertyCells("v3");

            var options = new VA.Models.DirectedGraph.MSAGLLayoutOptions();

            options.UseDynamicConnectors = true;

            var visapp = this.GetVisioApplication();
            var doc    = this.GetNewDoc();
            var page1  = visapp.ActivePage;

            d.Render(page1, options);

            Assert.IsNotNull(n0.VisioShape);
            var props_dic = CustomPropertyHelper.Get(n0.VisioShape);

            Assert.IsTrue(props_dic.Count >= 3);
            Assert.AreEqual("\"v1\"", props_dic["p1"].Value.Formula);
            Assert.AreEqual("\"v2\"", props_dic["p2"].Value.Formula);
            Assert.AreEqual("\"v3\"", props_dic["p3"].Value.Formula);

            page1.Application.ActiveWindow.ViewFit = (short)IVisio.VisWindowFit.visFitPage;

            doc.Close(true);
        }
        public void DirectedGraph_WithBezierConnectors()
        {
            var directed_graph_drawing = this.create_sample_graph();

            var options = new DG.MSAGLLayoutOptions();
            options.UseDynamicConnectors = false;

            var visapp = this.GetVisioApplication();
            var doc = this.GetNewDoc();
            var page = visapp.ActivePage;
            directed_graph_drawing.Render(page,options);
            doc.Close(true);
        }
Пример #4
0
        public void DirectedGraph_WithDynamicConnectors()
        {
            var directed_graph_drawing = this.create_sample_graph();

            var options = new VA.Models.DirectedGraph.MSAGLLayoutOptions();

            options.UseDynamicConnectors = true;

            var visapp = this.GetVisioApplication();
            var doc    = this.GetNewDoc();
            var page1  = visapp.ActivePage;

            directed_graph_drawing.Render(page1, options);
            doc.Close(true);
        }
Пример #5
0
        public void DirectedGraph(IList <DGMODEL.Drawing> directedgraphs)
        {
            this.AssertApplicationAvailable();

            this.Client.WriteVerbose("Start rendering directed graph");
            var app = this.Client.VisioApplication;


            this.Client.WriteVerbose("Creating a New Document For the Directed Graphs");
            var doc = this.Client.Document.New(null);

            int num_pages_created = 0;
            var doc_pages         = doc.Pages;

            foreach (int i in Enumerable.Range(0, directedgraphs.Count))
            {
                var dg = directedgraphs[i];


                var options = new DGMODEL.MSAGLLayoutOptions();
                options.UseDynamicConnectors = false;

                // if this is the first page to drawe
                // then reuse the initial empty page in the document
                // otherwise, create a new page.
                var page = num_pages_created == 0 ? app.ActivePage : doc_pages.Add();

                this.Client.WriteVerbose("Rendering page: {0}", i + 1);
                dg.Render(page, options);
                this.Client.Page.ResizeToFitContents(new VA.Drawing.Size(1.0, 1.0), true);
                this.Client.View.Zoom(VA.Scripting.Zoom.ToPage);
                this.Client.WriteVerbose("Finished rendering page");

                num_pages_created++;
            }

            this.Client.WriteVerbose("Finished rendering all pages");
            this.Client.WriteVerbose("Finished rendering directed graph.");
        }
Пример #6
0
        public void DirectedGraph(IList<DGMODEL.Drawing> directedgraphs)
        {
            this.AssertApplicationAvailable();

            this.Client.WriteVerbose("Start rendering directed graph");
            var app = this.Client.VisioApplication;

            this.Client.WriteVerbose("Creating a New Document For the Directed Graphs");
            var doc = this.Client.Document.New(null);

            int num_pages_created = 0;
            var doc_pages = doc.Pages;

            foreach (int i in Enumerable.Range(0, directedgraphs.Count))
            {
                var dg = directedgraphs[i];

                var options = new DGMODEL.MSAGLLayoutOptions();
                options.UseDynamicConnectors = false;

                // if this is the first page to drawe
                // then reuse the initial empty page in the document
                // otherwise, create a new page.
                var page = num_pages_created == 0 ? app.ActivePage : doc_pages.Add();

                this.Client.WriteVerbose("Rendering page: {0}", i + 1);
                dg.Render(page, options);
                this.Client.Page.ResizeToFitContents(new VA.Drawing.Size(1.0, 1.0), true);
                this.Client.View.Zoom(VA.Scripting.Zoom.ToPage);
                this.Client.WriteVerbose("Finished rendering page");

                num_pages_created++;
            }

            this.Client.WriteVerbose("Finished rendering all pages");
            this.Client.WriteVerbose("Finished rendering directed graph.");
        }
Пример #7
0
 private static void GetRenderOptionsFromXml(SXL.XElement el, VA.Models.DirectedGraph.MSAGLLayoutOptions options)
 {
     options.UseDynamicConnectors = VA.Scripting.XmlUtil.GetAttributeValue(el, "usedynamicconnectors", bool.Parse);
     options.ScalingFactor        = VA.Scripting.XmlUtil.GetAttributeValue(el, "scalingfactor", double.Parse);
 }
        public static void DirectedGraphViaVisio()
        {
            var page1 = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var directed_graph_drawing = new DGMODEL.Drawing();

            // Create a Node 0
            var n0 = directed_graph_drawing.AddShape("n0", "N0 Untitled Node", "basflo_u.vss", "Decision");

            // Format Node 0
            n0.Size = new VA.Drawing.Size(3, 2);

            // Create Node 1
            var n1 = directed_graph_drawing.AddShape("n1", "N1", "basflo_u.vss", "Decision");

            // Format Node 1
            n1.Cells = new VA.DOM.ShapeCells();
            n1.Cells.FillForegnd = "rgb(255,0,0)";
            n1.Cells.FillBkgnd = "rgb(255,255,0)";
            n1.Cells.FillPattern = 40;

            // Create Node 2
            var n2 = directed_graph_drawing.AddShape("n2", "N2 MailServer", "server_u.vss", "Server");

            // Create Node 3

            var n3 = directed_graph_drawing.AddShape("n3", "N3", "basflo_u.vss", "Data");

            // Create Node 4
            var n4 = directed_graph_drawing.AddShape("n4", "N4", "basflo_u.vss", "Data");

            // Create the connectors to join the nodes
            // Note that Node 4 is deliberately not connected to any other node
            var c0 = directed_graph_drawing.Connect("c0", n0, n1, null, ConnectorType.Curved);
            var c1 = directed_graph_drawing.Connect("c1", n1, n2, "YES", ConnectorType.RightAngle);
            var c2 = directed_graph_drawing.Connect("c2", n3, n4, "NO", ConnectorType.Curved);
            var c3 = directed_graph_drawing.Connect("c3", n0, n2, null, ConnectorType.Straight);
            var c4 = directed_graph_drawing.Connect("c4", n2, n3, null, ConnectorType.Curved);
            var c5 = directed_graph_drawing.Connect("c5", n3, n0, null, ConnectorType.Curved);

            // Format connector 0 to point "back"
            c0.Cells = new VA.DOM.ShapeCells();
            c0.Cells.BeginArrow = 1;
            c0.Cells.LineWeight = 0.10;

            // Format connector 1 to point "forward"
            c1.Cells = new VA.DOM.ShapeCells();
            c1.Cells.EndArrow = 1;
            c1.Cells.LineWeight = 0.10;

            // Format connector 2 to point "back" and "forward"
            c2.Cells = new VA.DOM.ShapeCells();
            c2.Cells.EndArrow = 1;
            c2.Cells.BeginArrow = 1;
            c2.Cells.LineWeight = 0.10;

            // Perform the rendering
            var options = new DGMODEL.MSAGLLayoutOptions();
            options.UseDynamicConnectors = false;

            directed_graph_drawing.Render(page1);

            var layout_config = new VA.Pages.PageLayout.HierarchyLayout();
            layout_config.Direction = VA.Pages.PageLayout.Direction.BottomToTop;
            layout_config.HorizontalAlignment = VA.Pages.PageLayout.HorizontalAlignment.Center;
            layout_config.AvenueSize = new VA.Drawing.Size(1, 1);
            layout_config.ConnectorAppearance = VA.Pages.PageLayout.ConnectorAppearance.Curved;
            layout_config.Apply(page1);

            page1.ResizeToFitContents(new VA.Drawing.Size(0.5, 0.5));
        }
Пример #9
0
        public static void Render(IVisio.Page page, VisioAutomation.Models.DirectedGraph.Drawing drawing, DGMODEL.MSAGLLayoutOptions options)
        {
            var renderer = new VA.Models.DirectedGraph.MSAGLRenderer();

            renderer.LayoutOptions = options;
            renderer.Render(drawing, page);
            page.ResizeToFitContents(renderer.LayoutOptions.ResizeBorderWidth);
        }
Пример #10
0
        public static void DirectedGraphViaVisio()
        {
            var page1 = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var directed_graph_drawing = new DGMODEL.Drawing();

            // Create a Node 0
            var n0 = directed_graph_drawing.AddShape("n0", "N0 Untitled Node", "basflo_u.vss", "Decision");

            // Format Node 0
            n0.Size = new VA.Drawing.Size(3, 2);

            // Create Node 1
            var n1 = directed_graph_drawing.AddShape("n1", "N1", "basflo_u.vss", "Decision");

            // Format Node 1
            n1.Cells             = new VA.DOM.ShapeCells();
            n1.Cells.FillForegnd = "rgb(255,0,0)";
            n1.Cells.FillBkgnd   = "rgb(255,255,0)";
            n1.Cells.FillPattern = 40;

            // Create Node 2
            var n2 = directed_graph_drawing.AddShape("n2", "N2 MailServer", "server_u.vss", "Server");

            // Create Node 3

            var n3 = directed_graph_drawing.AddShape("n3", "N3", "basflo_u.vss", "Data");

            // Create Node 4
            var n4 = directed_graph_drawing.AddShape("n4", "N4", "basflo_u.vss", "Data");

            // Create the connectors to join the nodes
            // Note that Node 4 is deliberately not connected to any other node
            var c0 = directed_graph_drawing.Connect("c0", n0, n1, null, ConnectorType.Curved);
            var c1 = directed_graph_drawing.Connect("c1", n1, n2, "YES", ConnectorType.RightAngle);
            var c2 = directed_graph_drawing.Connect("c2", n3, n4, "NO", ConnectorType.Curved);
            var c3 = directed_graph_drawing.Connect("c3", n0, n2, null, ConnectorType.Straight);
            var c4 = directed_graph_drawing.Connect("c4", n2, n3, null, ConnectorType.Curved);
            var c5 = directed_graph_drawing.Connect("c5", n3, n0, null, ConnectorType.Curved);

            // Format connector 0 to point "back"
            c0.Cells            = new VA.DOM.ShapeCells();
            c0.Cells.BeginArrow = 1;
            c0.Cells.LineWeight = 0.10;

            // Format connector 1 to point "forward"
            c1.Cells            = new VA.DOM.ShapeCells();
            c1.Cells.EndArrow   = 1;
            c1.Cells.LineWeight = 0.10;

            // Format connector 2 to point "back" and "forward"
            c2.Cells            = new VA.DOM.ShapeCells();
            c2.Cells.EndArrow   = 1;
            c2.Cells.BeginArrow = 1;
            c2.Cells.LineWeight = 0.10;

            // Perform the rendering
            var options = new DGMODEL.MSAGLLayoutOptions();

            options.UseDynamicConnectors = false;

            directed_graph_drawing.Render(page1);

            var layout_config = new VA.Pages.PageLayout.HierarchyLayout();

            layout_config.Direction           = VA.Pages.PageLayout.Direction.BottomToTop;
            layout_config.HorizontalAlignment = VA.Pages.PageLayout.HorizontalAlignment.Center;
            layout_config.AvenueSize          = new VA.Drawing.Size(1, 1);
            layout_config.ConnectorAppearance = VA.Pages.PageLayout.ConnectorAppearance.Curved;
            layout_config.Apply(page1);

            page1.ResizeToFitContents(new VA.Drawing.Size(0.5, 0.5));
        }