public void OrgChart_MultipleOrgCharts() { // Verify that we can create multiple org charts in one // document var orgchart = new VAORGCHART.OrgChartDocument(); var n_a = new VAORGCHART.Node("A"); var n_b = new VAORGCHART.Node("B"); var n_c = new VAORGCHART.Node("C"); var n_d = new VAORGCHART.Node("D"); var n_e = new VAORGCHART.Node("E"); n_a.Children.Add(n_b); n_a.Children.Add(n_c); n_c.Children.Add(n_d); n_c.Children.Add(n_e); n_a.Size = new VA.Geometry.Size(4, 2); orgchart.OrgCharts.Add(n_a); orgchart.OrgCharts.Add(n_a); var app = new IVisio.Application(); orgchart.Render(app); app.Quit(true); }
public void OrgChart_FiveNodes() { // Verify that basic org chart connectivity is maintained var orgchart_doc = new VAORGCHART.OrgChartDocument(); var n_a = new VAORGCHART.Node("A"); var n_b = new VAORGCHART.Node("B"); var n_c = new VAORGCHART.Node("C"); var n_d = new VAORGCHART.Node("D"); var n_e = new VAORGCHART.Node("E"); n_a.Children.Add(n_b); n_a.Children.Add(n_c); n_c.Children.Add(n_d); n_c.Children.Add(n_e); n_a.Size = new VA.Geometry.Size(4, 2); orgchart_doc.OrgCharts.Add(n_a); var app = new IVisio.Application(); orgchart_doc.Render(app); var active_page = app.ActivePage; var page = active_page; page.ResizeToFitContents(); var shapes = active_page.Shapes.ToList(); var shapes_2d = shapes.Where(s => s.OneD == 0).ToList(); var shapes_1d = shapes.Where(s => s.OneD != 0).ToList(); var shapes_connector = shapes.Where(s => s.Master.NameU == "Dynamic connector").ToList(); Assert.AreEqual(5 + 4, shapes.Count); Assert.AreEqual(5, shapes_2d.Count); Assert.AreEqual(4, shapes_1d.Count); Assert.AreEqual(4, shapes_connector.Count); Assert.AreEqual("A", n_a.VisioShape.Text.Trim()); // trimming because extra ending space is added (don't know why) Assert.AreEqual("B", n_b.VisioShape.Text.Trim()); Assert.AreEqual("C", n_c.VisioShape.Text.Trim()); Assert.AreEqual("D", n_d.VisioShape.Text.Trim()); Assert.AreEqual("E", n_e.VisioShape.Text.Trim()); Assert.AreEqual(new VA.Geometry.Size(4, 2), VisioAutomationTest.GetSize(n_a.VisioShape)); Assert.AreEqual(orgchart_doc.LayoutOptions.DefaultNodeSize, VisioAutomationTest.GetSize(n_b.VisioShape)); app.Quit(true); }
public static VAORGCHART.OrgChartDocument LoadFromXml(Client client, SXL.XDocument xdoc) { var root = xdoc.Root; var dic = new Dictionary <string, VAORGCHART.Node>(); VAORGCHART.Node ocroot = null; client.WriteVerbose("Walking XML"); foreach (var ev in root.Elements()) { if (ev.Name == "shape") { string id = ev.Attribute("id").Value; string parentid = ev.GetAttributeValue("parentid", null); var name = ev.Attribute("name").Value; client.WriteVerbose("Loading shape: {0} {1} {2}", id, name, parentid); var new_ocnode = new VAORGCHART.Node(name); if (ocroot == null) { ocroot = new_ocnode; } dic[id] = new_ocnode; if (parentid != null) { if (dic.ContainsKey(parentid)) { var parent = dic[parentid]; parent.Children.Add(new_ocnode); } } } } client.WriteVerbose("Finished Walking XML"); var oc = new VAORGCHART.OrgChartDocument(); oc.OrgCharts.Add(ocroot); client.WriteVerbose("Finished Creating OrgChart model"); return(oc); }
public static void OrgChart() { // This creates a new document var orgchart = new OCMODEL.OrgChartDocument(); var bob = new OCMODEL.Node("Bob"); var ted = new OCMODEL.Node("Ted"); var alice = new OCMODEL.Node("Alice"); bob.Children.Add(ted); bob.Children.Add(alice); orgchart.OrgCharts.Add(bob); orgchart.Render(SampleEnvironment.Application); var bordersize = new VA.Drawing.Size(1, 1); SampleEnvironment.Application.ActivePage.ResizeToFitContents(bordersize); }
public void OrgChart_SingleNode() { // Draw the minimum org chart - a chart with one nod var orgchart = new VAORGCHART.OrgChartDocument(); var n_a = new VAORGCHART.Node("A"); n_a.Size = new VA.Geometry.Size(4, 2); orgchart.OrgCharts.Add(n_a); var app = new IVisio.Application(); orgchart.Render(app); var active_page = app.ActivePage; var page = active_page; page.ResizeToFitContents(); app.Quit(true); }