public static void DirectedGraphViaVisio()
        {
            var page1 = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var directed_graph_drawing = DirectGraphLayoutSamples.get_dg_drawing();

            var visio_options = new DGMODEL.VisioLayoutOptions();
            directed_graph_drawing.Render(page1, visio_options);

            var padding = new VA.Drawing.Size(0.5, 0.5);
            page1.ResizeToFitContents(padding);
        }
        public static void DirectedGraphViaVisio()
        {
            var page1 = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var directed_graph_drawing = DirectGraphLayoutSamples.get_dg_drawing();

            var visio_options = new DGMODEL.VisioLayoutOptions();

            directed_graph_drawing.Render(page1, visio_options);

            var padding = new VA.Drawing.Size(0.5, 0.5);

            page1.ResizeToFitContents(padding);
        }
Beispiel #3
0
        public void Render(IVisio.Page page, VisioLayoutOptions options)
        {
            var vr = new VisioRenderer();

            vr.Render(page, this, options);
        }
 public void Render(IVisio.Page page, VisioLayoutOptions options)
 {
     var vr = new VisioRenderer();
     vr.Render(page, this, options);
 }
        private void buttonGraph_Click(object sender, RibbonControlEventArgs e)
        {
            var form = new FormDirectedGraph();
            var result = form.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var text = form.GraphText.Trim();
            var lines = text.Split('\n').Select(s => s.Trim()).Where( s=>s.Length>0).ToList();

            var model = new VA.Models.DirectedGraph.Drawing();

            int cn = 0;
            var dic = new Dictionary<string, VA.Models.DirectedGraph.Shape>();
            foreach (var line in lines)
            {
                var tokens = line.Split(new[] {"->"}, System.StringSplitOptions.RemoveEmptyEntries);
                if (tokens.Length==0)
                {
                    // do nothing
                }
                else if (tokens.Length==1)
                {
                    string from = tokens[0];
                    if (dic.ContainsKey(from))
                    {
                        
                    }
                    else
                    {
                    }
                }
                else if (tokens.Length >=2 )
                {
                    string from = tokens[0];
                    string to = tokens[1];

                    VA.Models.DirectedGraph.Shape fromnode;
                    VA.Models.DirectedGraph.Shape tonode;
                    if (!dic.ContainsKey(from))
                    {
                        fromnode = model.AddShape(from, from, "basic_u.vss", "rectangle");
                        fromnode.Label = from;
                        dic[from] = fromnode;
                    }
                    else
                    {
                        fromnode = dic[from];
                    }

                    if (!dic.ContainsKey(to))
                    {
                        tonode= model.AddShape(to, to, "basic_u.vss", "rectangle");
                        tonode.Label = to;
                        dic[to] = tonode;
                    }
                    else
                    {
                        tonode = dic[to];
                    }

                    model.AddConnection("C" + cn.ToString(), fromnode, tonode);
                    cn +=1;

                }
            }


            var app = Globals.ThisAddIn.Application;
            var doc = Globals.ThisAddIn.Application.ActiveDocument;
            IVisio.Page page;
            if (doc==null)
            {
                var docs = app.Documents;
                doc = docs.Add("");
                var pages = doc.Pages;
                page = pages[1];
            }
            else
            {
                page = doc.Pages.Add();                
            }

            var visio_options = new DGMODEL.VisioLayoutOptions();
            model.Render(page,visio_options);

            var pl = new VA.Pages.PageLayout.FlowchartLayout();
            pl.ConnectorStyle = VisioAutomation.Pages.PageLayout.ConnectorStyle.Flowchart;
            pl.ConnectorAppearance = VisioAutomation.Pages.PageLayout.ConnectorAppearance.Curved;
            pl.Apply(page);

            page.ResizeToFitContents();

        }
        private void buttonGraph_Click(object sender, RibbonControlEventArgs e)
        {
            var form   = new FormDirectedGraph();
            var result = form.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var text  = form.GraphText.Trim();
            var lines = text.Split('\n').Select(s => s.Trim()).Where(s => s.Length > 0).ToList();

            var model = new VA.Models.DirectedGraph.Drawing();

            int cn  = 0;
            var dic = new Dictionary <string, VA.Models.DirectedGraph.Shape>();

            foreach (var line in lines)
            {
                var tokens = line.Split(new[] { "->" }, System.StringSplitOptions.RemoveEmptyEntries);
                if (tokens.Length == 0)
                {
                    // do nothing
                }
                else if (tokens.Length == 1)
                {
                    string from = tokens[0];
                    if (dic.ContainsKey(from))
                    {
                    }
                    else
                    {
                    }
                }
                else if (tokens.Length >= 2)
                {
                    string from = tokens[0];
                    string to   = tokens[1];

                    VA.Models.DirectedGraph.Shape fromnode;
                    VA.Models.DirectedGraph.Shape tonode;
                    if (!dic.ContainsKey(from))
                    {
                        fromnode       = model.AddShape(from, from, "basic_u.vss", "rectangle");
                        fromnode.Label = from;
                        dic[from]      = fromnode;
                    }
                    else
                    {
                        fromnode = dic[from];
                    }

                    if (!dic.ContainsKey(to))
                    {
                        tonode       = model.AddShape(to, to, "basic_u.vss", "rectangle");
                        tonode.Label = to;
                        dic[to]      = tonode;
                    }
                    else
                    {
                        tonode = dic[to];
                    }

                    model.AddConnection("C" + cn.ToString(), fromnode, tonode);
                    cn += 1;
                }
            }


            var app = Globals.ThisAddIn.Application;
            var doc = Globals.ThisAddIn.Application.ActiveDocument;

            IVisio.Page page;
            if (doc == null)
            {
                var docs = app.Documents;
                doc = docs.Add("");
                var pages = doc.Pages;
                page = pages[1];
            }
            else
            {
                page = doc.Pages.Add();
            }

            var visio_options = new DGMODEL.VisioLayoutOptions();

            model.Render(page, visio_options);

            var pl = new VA.Pages.PageLayout.FlowchartLayout();

            pl.ConnectorStyle      = VisioAutomation.Pages.PageLayout.ConnectorStyle.Flowchart;
            pl.ConnectorAppearance = VisioAutomation.Pages.PageLayout.ConnectorAppearance.Curved;
            pl.Apply(page);

            page.ResizeToFitContents();
        }