Beispiel #1
0
        public void OrgChart_MultipleOrgCharts()
        {
            // Verify that we can create multiple org charts in one
            // document

            var orgchart = new OCMODEL.OrgChartDocument();

            var n_a = new OCMODEL.Node("A");
            var n_b = new OCMODEL.Node("B");
            var n_c = new OCMODEL.Node("C");
            var n_d = new OCMODEL.Node("D");
            var n_e = new OCMODEL.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.Drawing.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_MultipleOrgCharts()
        {
            // Verify that we can create multiple org charts in one
            // document

            var orgchart = new OCMODEL.OrgChartDocument();

            var n_a = new OCMODEL.Node("A");
            var n_b = new OCMODEL.Node("B");
            var n_c = new OCMODEL.Node("C");
            var n_d = new OCMODEL.Node("D");
            var n_e = new OCMODEL.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.Drawing.Size(4, 2);

            orgchart.OrgCharts.Add(n_a);
            orgchart.OrgCharts.Add(n_a);

            var app = new IVisio.Application();

            orgchart.Render(app);

            app.Quit(true);
        }
Beispiel #3
0
        public void OrgChart_FiveNodes()
        {
            // Verify that basic org chart connectivity is maintained

            var orgchart_doc = new OCMODEL.OrgChartDocument();

            var n_a = new OCMODEL.Node("A");
            var n_b = new OCMODEL.Node("B");
            var n_c = new OCMODEL.Node("C");
            var n_d = new OCMODEL.Node("D");
            var n_e = new OCMODEL.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.Drawing.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.AsEnumerable().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.Drawing.Size(4, 2), VisioAutomationTest.GetSize(n_a.VisioShape));
            Assert.AreEqual(orgchart_doc.LayoutOptions.DefaultNodeSize, VisioAutomationTest.GetSize(n_b.VisioShape));

            app.Quit(true);
        }
        public void OrgChart_FiveNodes()
        {
            // Verify that basic org chart connectivity is maintained

            var orgchart_doc = new OCMODEL.OrgChartDocument();

            var n_a = new OCMODEL.Node("A");
            var n_b = new OCMODEL.Node("B");
            var n_c = new OCMODEL.Node("C");
            var n_d = new OCMODEL.Node("D");
            var n_e = new OCMODEL.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.Drawing.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.AsEnumerable().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.Drawing.Size(4, 2), VisioAutomationTest.GetSize(n_a.VisioShape));
            Assert.AreEqual(orgchart_doc.LayoutOptions.DefaultNodeSize,  VisioAutomationTest.GetSize(n_b.VisioShape));

            app.Quit(true);
        }
Beispiel #5
0
        public static OCMODEL.OrgChartDocument LoadFromXML(Client client,
                                                           SXL.XDocument xdoc)
        {
            var root = xdoc.Root;

            var dic = new Dictionary <string, OCMODEL.Node>();

            OCMODEL.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 = VA.Scripting.XmlUtil.GetAttributeValue(ev, "parentid", null);
                    var    name     = ev.Attribute("name").Value;

                    client.WriteVerbose("Loading shape: {0} {1} {2}", id, name, parentid);
                    var new_ocnode = new OCMODEL.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 OCMODEL.OrgChartDocument();

            oc.OrgCharts.Add(ocroot);
            client.WriteVerbose("Finished Creating OrgChart model");
            return(oc);
        }
        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.Drawing.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);
        }
        public static OCMODEL.OrgChartDocument LoadFromXML(Client client,
            SXL.XDocument xdoc)
        {
            var root = xdoc.Root;

            var dic = new Dictionary<string, OCMODEL.Node>();
            OCMODEL.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 = VA.Scripting.XmlUtil.GetAttributeValue(ev, "parentid", null);
                    var name = ev.Attribute("name").Value;

                    client.WriteVerbose( "Loading shape: {0} {1} {2}", id, name, parentid);
                    var new_ocnode = new OCMODEL.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 OCMODEL.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 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);
        }
Beispiel #10
0
        public void OrgChart_SingleNode()
        {
            // Draw the minimum org chart - a chart with one nod
            var orgchart = new OCMODEL.OrgChartDocument();

            var n_a = new OCMODEL.Node("A");

            n_a.Size = new VA.Drawing.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);
        }
 private InternalTree.Node<object> node_to_layout_node(Node n)
 {
     var nodesize = n.Size.GetValueOrDefault(this.LayoutOptions.DefaultNodeSize);
     var newnode = new InternalTree.Node<object>(nodesize, n);
     return newnode;
 }