private DG.Drawing create_sample_graph() { var d = new DG.Drawing(); var basic_stencil = "basic_u.vss"; var n0 = d.AddShape("n0", "Node 0", basic_stencil, "Rectangle"); n0.Size = new VA.Drawing.Size(3, 2); var n1 = d.AddShape("n1", "Node 1", basic_stencil, "Rectangle"); var n2 = d.AddShape("n2", "Node 2", basic_stencil, "Rectangle"); var n3 = d.AddShape("n3", "Node 3", basic_stencil, "Rectangle"); var n4 = d.AddShape("n4", "Node 4\nUnconnected", basic_stencil, "Rectangle"); var c0 = d.AddConnection("c0", n0, n1, "0 -> 1", VACONNECT.ConnectorType.Curved); var c1 = d.AddConnection("c1", n1, n2, "1 -> 2", VACONNECT.ConnectorType.RightAngle); var c2 = d.AddConnection("c2", n1, n0, "0 -> 1", VACONNECT.ConnectorType.Curved); var c3 = d.AddConnection("c3", n0, n2, "0 -> 2", VACONNECT.ConnectorType.Straight); var c4 = d.AddConnection("c4", n2, n3, "2 -> 3", VACONNECT.ConnectorType.Curved); var c5 = d.AddConnection("c5", n3, n0, "3 -> 0", VACONNECT.ConnectorType.Curved); return(d); }
private static DGMODEL.Drawing get_dg_drawing() { var ver = VA.Application.ApplicationHelper.GetVersion(SampleEnvironment.Application); string server_stencil = (ver.Major >= 15) ? "server_u.vssx" : "server_u.vss"; string basflo_stencil = (ver.Major >= 15) ? "basflo_u.vssx" : "basflo_u.vss"; var directed_graph_drawing = new DGMODEL.Drawing(); // Create a Node 0 var n0 = directed_graph_drawing.AddShape("n0", "N0 Untitled Node", basflo_stencil, "Decision"); // Format Node 0 n0.Size = new VA.Drawing.Size(3, 2); // Create Node 1 var n1 = directed_graph_drawing.AddShape("n1", "N1", basflo_stencil, "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_stencil, "Server"); // Create Node 3 var n3 = directed_graph_drawing.AddShape("n3", "N3", basflo_stencil, "Data"); // Create Node 4 var n4 = directed_graph_drawing.AddShape("n4", "N4", basflo_stencil, "Data"); // Create the connectors to join the nodes // Note that Node 4 is deliberately not connected to any other node var curved = VA.Shapes.Connections.ConnectorType.Curved; var rightangle = VA.Shapes.Connections.ConnectorType.RightAngle; var c0 = directed_graph_drawing.AddConnection("c0", n0, n1, null, curved); var c1 = directed_graph_drawing.AddConnection("c1", n1, n2, "YES", rightangle); var c2 = directed_graph_drawing.AddConnection("c2", n3, n4, "NO", curved); var c3 = directed_graph_drawing.AddConnection("c3", n0, n2, null, rightangle); var c4 = directed_graph_drawing.AddConnection("c4", n2, n3, null, curved); var c5 = directed_graph_drawing.AddConnection("c5", n3, n0, null, 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; return directed_graph_drawing; }
private static DGMODEL.Drawing get_dg_drawing() { var ver = VA.Application.ApplicationHelper.GetVersion(SampleEnvironment.Application); string server_stencil = (ver.Major >= 15) ? "server_u.vssx" : "server_u.vss"; string basflo_stencil = (ver.Major >= 15) ? "basflo_u.vssx" : "basflo_u.vss"; var directed_graph_drawing = new DGMODEL.Drawing(); // Create a Node 0 var n0 = directed_graph_drawing.AddShape("n0", "N0 Untitled Node", basflo_stencil, "Decision"); // Format Node 0 n0.Size = new VA.Drawing.Size(3, 2); // Create Node 1 var n1 = directed_graph_drawing.AddShape("n1", "N1", basflo_stencil, "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_stencil, "Server"); // Create Node 3 var n3 = directed_graph_drawing.AddShape("n3", "N3", basflo_stencil, "Data"); // Create Node 4 var n4 = directed_graph_drawing.AddShape("n4", "N4", basflo_stencil, "Data"); // Create the connectors to join the nodes // Note that Node 4 is deliberately not connected to any other node var curved = VA.Shapes.Connections.ConnectorType.Curved; var rightangle = VA.Shapes.Connections.ConnectorType.RightAngle; var c0 = directed_graph_drawing.AddConnection("c0", n0, n1, null, curved); var c1 = directed_graph_drawing.AddConnection("c1", n1, n2, "YES", rightangle); var c2 = directed_graph_drawing.AddConnection("c2", n3, n4, "NO", curved); var c3 = directed_graph_drawing.AddConnection("c3", n0, n2, null, rightangle); var c4 = directed_graph_drawing.AddConnection("c4", n2, n3, null, curved); var c5 = directed_graph_drawing.AddConnection("c5", n3, n0, null, 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; return(directed_graph_drawing); }
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 DG.Drawing create_sample_graph() { var d = new DG.Drawing(); var basic_stencil = "basic_u.vss"; var n0 = d.AddShape("n0", "Node 0", basic_stencil, "Rectangle"); n0.Size = new VA.Drawing.Size(3, 2); var n1 = d.AddShape("n1", "Node 1", basic_stencil, "Rectangle"); var n2 = d.AddShape("n2", "Node 2", basic_stencil, "Rectangle"); var n3 = d.AddShape("n3", "Node 3", basic_stencil, "Rectangle"); var n4 = d.AddShape("n4", "Node 4\nUnconnected", basic_stencil, "Rectangle"); var c0 = d.AddConnection("c0", n0, n1, "0 -> 1", VACONNECT.ConnectorType.Curved); var c1 = d.AddConnection("c1", n1, n2, "1 -> 2", VACONNECT.ConnectorType.RightAngle); var c2 = d.AddConnection("c2", n1, n0, "0 -> 1", VACONNECT.ConnectorType.Curved); var c3 = d.AddConnection("c3", n0, n2, "0 -> 2", VACONNECT.ConnectorType.Straight); var c4 = d.AddConnection("c4", n2, n3, "2 -> 3", VACONNECT.ConnectorType.Curved); var c5 = d.AddConnection("c5", n3, n0, "3 -> 0", VACONNECT.ConnectorType.Curved); return d; }
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(); }