Пример #1
0
        public static void DirectedGraphViaMsagl()
        {
            var page1 = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var directed_graph_drawing = DirectedGraphLayoutSamples.get_dg_drawing();
            var options = new DGMODEL.MsaglLayoutOptions();

            options.UseDynamicConnectors = false;
            directed_graph_drawing.Render(page1, options);
        }
        public void DirectedGraph_WithDynamicConnectors()
        {
            var directed_graph_drawing = this.create_sample_graph();

            var options = new DG.MsaglLayoutOptions();

            options.UseDynamicConnectors = true;

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

            directed_graph_drawing.Render(page1, options);

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

            doc.SaveAs(output_filename);
            doc.Close();
        }
        public void NewDirectedGraphDocument(IList <GRAPH.DirectedGraphLayout> graph)
        {
            var cmdtarget = this._client.GetCommandTargetApplication();

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

            this._client.Output.WriteVerbose("Creating a New Document For the Directed Graphs");
            string template = null;
            var    doc      = this._client.Document.NewDocumentFromTemplate(template);

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

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


                var options = new GRAPH.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.Output.WriteVerbose("Rendering page: {0}", i + 1);
                dg.Render(page, options);

                var tp = new VisioScripting.Models.TargetPages(page);
                this._client.Page.ResizePageToFitContents(tp, new VisioAutomation.Geometry.Size(1.0, 1.0));
                this._client.View.SetActiveWindowZoomToObject(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.");
        }
Пример #4
0
        public void DirectedGraph(IList <GRAPH.DirectedGraphLayout> graph)
        {
            this._client.Application.AssertApplicationAvailable();

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


            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, graph.Count))
            {
                var dg = graph[i];


                var options = new GRAPH.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 VisioAutomation.Geometry.Size(1.0, 1.0), true);
                this._client.View.Zoom(VisioScripting.Models.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.");
        }
        public void RenderDirectedGraphWithCustomProps()
        {
            var d = new DG.DirectedGraphLayout();

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

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

            var options = new DG.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 = VACUSTPROP.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;

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

            doc.SaveAs(output_filename);
            doc.Close();
        }
Пример #6
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 Render(IVisio.Page page, MsaglLayoutOptions options)
 {
     MsaglRenderer.Render(page, this, options);
 }