예제 #1
0
        public static void Render(IVisio.Page page, DirectedGraphLayout directedGraphLayout, MsaglLayoutOptions options)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var renderer = new MsaglRenderer();

            renderer.LayoutOptions = options;
            renderer.Render(directedGraphLayout, page);
            page.ResizeToFitContents(renderer.LayoutOptions.ResizeBorderWidth);
        }
        public void DirectedGraph_WithDynamicConnectors()
        {
            var directed_graph_drawing = this.create_sample_graph();

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

            var renderer = new VADG.MsaglRenderer();

            renderer.LayoutOptions.UseDynamicConnectors = true;
            renderer.Render(page1, directed_graph_drawing);

            string output_filename = TestGlobals.TestHelper.GetOutputFilename(nameof(DirectedGraph_WithDynamicConnectors), ".vsd");

            doc.SaveAs(output_filename);
            doc.Close();
        }
예제 #3
0
        public void DrawDirectedGraphDocument(GRAPH.DirectedGraphDocument dgdoc, GRAPH.DirectedGraphStyling dgstyling)
        {
            var cmdtarget = this._client.GetCommandTarget(CommandTargetFlags.RequireApplication);

            this._client.Output.WriteVerbose("Start rendering directed graph");
            var app = cmdtarget.Application;

            this._client.Output.WriteVerbose("Creating a New Document For the Directed Graphs");
            this._client.Output.WriteVerbose("Number of Layouts: {0}", dgdoc.Layouts.Count);
            this._client.Output.WriteVerbose("Template: {0}", dgdoc.Template);
            var doc = this._client.Document.NewDocumentFromTemplate(dgdoc.Template);

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

            foreach (int i in Enumerable.Range(0, dgdoc.Layouts.Count))
            {
                var dg_layout = dgdoc.Layouts[i];

                // if this is the first page to draw
                // 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.Output.WriteVerbose("Rendering on page: \"{0}\",{1}", page.Name, i + 1);

                var renderer = new GRAPH.MsaglRenderer();
                renderer.LayoutOptions.UseDynamicConnectors = false;
                renderer.Render(page, dg_layout);

                var targetpages = new VisioScripting.TargetPages(page);

                this._client.Page.ResizePageToFitContents(targetpages, dgdoc.BorderSize);
                this._client.View.SetZoomToObject(VisioScripting.TargetWindow.Auto, VisioScripting.Models.ZoomToObject.Page);
                this._client.Output.WriteVerbose("Finished rendering page");

                num_pages_created++;
            }

            this._client.Output.WriteVerbose("Finished rendering all pages");
            this._client.Output.WriteVerbose("Finished rendering directed graph.");
        }
        public void RenderDirectedGraphWithCustomProps()
        {
            var d = new VADG.DirectedGraphLayout();

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

            n0.Size                   = new VA.Geometry.Size(3, 2);
            n0.CustomProperties       = new CustomPropertyDictionary();
            n0.CustomProperties["p1"] = new CustomPropertyCells("\"v1\"");
            n0.CustomProperties["p2"] = new CustomPropertyCells("\"v2\"");
            n0.CustomProperties["p3"] = new CustomPropertyCells("\"v3\"");

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

            var renderer = new VADG.MsaglRenderer();

            renderer.LayoutOptions.UseDynamicConnectors = true;
            renderer.Render(page1, d);

            Assert.IsNotNull(n0.VisioShape);
            var props_dic = CustomPropertyHelper.GetDictionary(n0.VisioShape, CellValueType.Formula);

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

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

            string output_filename = TestGlobals.TestHelper.GetOutputFilename(nameof(RenderDirectedGraphWithCustomProps), ".vsd");

            doc.SaveAs(output_filename);
            doc.Close();
        }
 public void Render(IVisio.Page page, MsaglLayoutOptions options)
 {
     MsaglRenderer.Render(page, this, options);
 }