示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        public void DrawOrgChart(VisioScripting.TargetPage targetpage, ORG.OrgChartDocument chartdocument)
        {
            targetpage = targetpage.ResolveToPage(this._client);

            this._client.Output.WriteVerbose("Start OrgChart Rendering");

            var application = targetpage.Page.Application;

            chartdocument.Render(application);

            targetpage.Page.ResizeToFitContents();
            this._client.Output.WriteVerbose("Finished OrgChart Rendering");
        }
示例#4
0
        public void OrgChart(VAORGCHART.OrgChartDocument orgChartDocument)
        {
            this._client.WriteVerbose("Start OrgChart Rendering");
            this._client.Application.AssertApplicationAvailable();

            var application = this._client.Application.Get();

            orgChartDocument.Render(application);
            var active_page = application.ActivePage;

            active_page.ResizeToFitContents();
            this._client.WriteVerbose("Finished OrgChart Rendering");
        }
        public void NewOrgChartDocument(ORG.OrgChartDocument chartdocument)
        {
            var cmdtarget = this._client.GetCommandTargetApplication();

            this._client.Output.WriteVerbose("Start OrgChart Rendering");

            var application = cmdtarget.Application;

            chartdocument.Render(application);
            var active_page = application.ActivePage;

            active_page.ResizeToFitContents();
            this._client.Output.WriteVerbose("Finished OrgChart Rendering");
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        public void OrgChart_MustHaveContent()
        {
            // Before an Org Chart is rendered it must have at least one node
            bool caught   = false;
            var  orgcgart = new VAORGCHART.OrgChartDocument();
            var  page1    = this.GetNewPage(this.StandardPageSize);

            try
            {
                var application = page1.Application;
                orgcgart.Render(application);
            }
            catch (Exception)
            {
                page1.Delete(0);
                caught = true;
            }
            if (caught == false)
            {
                Assert.Fail("Did not catch expected exception");
            }
        }