Esempio n. 1
0
        public void Page_SwitchPages()
        {
            var app = this.GetVisioApplication();

            var documents     = app.Documents;
            int old_doc_count = documents.Count;

            var doc1 = this.GetNewDoc();

            Assert.AreEqual(documents.Count, old_doc_count + 1);
            Assert.AreEqual(doc1.Pages.Count, 1);
            var page1 = doc1.Pages[1];

            Assert.AreEqual(app.ActivePage, page1);

            var page2 = doc1.Pages.Add();

            page2.Background = 0;
            VisioAutomationTest.SetPageSize(page2, this.StandardPageSize);

            var active_window = app.ActiveWindow;

            Assert.AreEqual(app.ActivePage, page2);
            active_window.Page = page1;
            Assert.AreEqual(app.ActivePage, page1);
            active_window.Page = page2;
            Assert.AreEqual(app.ActivePage, page2);
            doc1.Close(true);
        }
Esempio n. 2
0
        public void ShapeSheet_Query_Demo_AllCellsAndSections()
        {
            var doc1  = this.GetNewDoc();
            var page1 = doc1.Pages[1];

            VisioAutomationTest.SetPageSize(page1, this.StandardPageSize);

            // draw simple shapes
            var s1 = page1.DrawRectangle(0, 0, 1, 1);
            var s2 = page1.DrawRectangle(2, 2, 3, 3);


            var query = new VA.ShapeSheet.Query.CellQuery();

            var name_to_src         = VA.ShapeSheet.SRCConstants.GetSRCDictionary();
            var section_to_secquery = new Dictionary <short, VA.ShapeSheet.Query.CellQuery.SectionQuery>();

            foreach (var kv in name_to_src)
            {
                var name = kv.Key;
                var src  = kv.Value;

                if (src.Section == (short)IVisio.VisSectionIndices.visSectionObject)
                {
                    query.Columns.Add(src, name);
                }
                else if ((src.Section == (short)IVisio.VisSectionIndices.visSectionFirst) ||
                         (src.Section == (short)IVisio.VisSectionIndices.visSectionFirstComponent) ||
                         (src.Section == (short)IVisio.VisSectionIndices.visSectionLast) ||
                         (src.Section == (short)IVisio.VisSectionIndices.visSectionInval) ||
                         (src.Section == (short)IVisio.VisSectionIndices.visSectionNone) ||
                         (src.Section == (short)IVisio.VisSectionIndices.visSectionFirst) ||
                         (src.Section == (short)IVisio.VisSectionIndices.visSectionLastComponent)
                         )
                {
                    //skip
                }
                else
                {
                    VA.ShapeSheet.Query.CellQuery.SectionQuery sec;
                    if (!section_to_secquery.ContainsKey(src.Section))
                    {
                        sec = query.Sections.Add((IVisio.VisSectionIndices)src.Section);
                        section_to_secquery[src.Section] = sec;
                    }
                    else
                    {
                        sec = section_to_secquery[src.Section];
                    }
                    sec.Columns.Add(src.Cell, name);
                }
            }

            var formulas1 = query.GetFormulas(s1);
            var formulas2 = query.GetFormulas(page1, new [] { s1.ID, s2.ID });

            doc1.Close(true);
        }
        public IVisio.Page GetNewPage(VisioAutomation.Drawing.Size s)
        {
            var app       = this.GetVisioApplication();
            var documents = app.Documents;

            if (documents.Count < 1)
            {
                documents.Add(string.Empty);
            }
            var active_document = app.ActiveDocument;
            var pages           = active_document.Pages;
            var page            = pages.Add();

            page.Background = 0;
            VisioAutomationTest.SetPageSize(page, s);

            return(page);
        }
Esempio n. 4
0
        public void DOM_DrawSimpleShape()
        {
            // Create the doc
            var page_node = new VA.DOM.Page();
            var vrect1    = new VA.DOM.Rectangle(1, 1, 9, 9);

            vrect1.Text = new VA.Text.Markup.TextElement("HELLO WORLD");
            vrect1.Cells.FillForegnd = "rgb(255,0,0)";
            page_node.Shapes.Add(vrect1);

            // Render it
            var app = this.GetVisioApplication();
            var doc = this.GetNewDoc();

            VisioAutomationTest.SetPageSize(app.ActivePage, new VA.Drawing.Size(10, 10));
            var page = page_node.Render(app.ActiveDocument);

            // Verify
            Assert.IsNotNull(vrect1.VisioShape);
            Assert.AreEqual("HELLO WORLD", vrect1.VisioShape.Text);

            app.ActiveDocument.Close(true);
        }
Esempio n. 5
0
        public void ShapeSheet_Query_GetResults_SingleShape()
        {
            var doc1  = this.GetNewDoc();
            var page1 = doc1.Pages[1];

            VisioAutomationTest.SetPageSize(page1, this.StandardPageSize);

            // draw a simple shape
            var s1    = page1.DrawRectangle(this.StandardPageSizeRect);
            int s1_id = s1.ID;

            // format it with setformulas
            var fg_cell  = s1.Cells["FillForegnd"];
            var bg_cell  = s1.Cells["FillBkgnd"];
            var pat_cell = s1.Cells["FillPattern"];

            fg_cell.FormulaU  = "RGB(255,0,0)";
            bg_cell.FormulaU  = "RGB(0,0,255)";
            pat_cell.FormulaU = "40";

            // now retrieve the formulas with GetFormulas

            var src_fg     = VA.ShapeSheet.SRCConstants.FillForegnd;
            var src_bg     = VA.ShapeSheet.SRCConstants.FillBkgnd;
            var src_filpat = VA.ShapeSheet.SRCConstants.FillPattern;

            var query         = new VA.ShapeSheet.Query.CellQuery();
            var col_fg        = query.Columns.Add(src_fg, "Foreground");
            var col_bg        = query.Columns.Add(src_bg, "Background");
            var col_filpat    = query.Columns.Add(src_filpat, "FillPattern");
            var sec_char      = query.Sections.Add(IVisio.VisSectionIndices.visSectionCharacter);
            var col_charcase  = sec_char.Columns.Add(VA.ShapeSheet.SRCConstants.CharCase, "Case");
            var col_charcolor = sec_char.Columns.Add(VA.ShapeSheet.SRCConstants.CharColor, "Color");
            var col_chartrans = sec_char.Columns.Add(VA.ShapeSheet.SRCConstants.CharColorTrans, "ColorTrans");

            var shapeids = new[] { s1_id };

            var formulas = query.GetFormulas(page1, shapeids);

            // now verify that the formulas were actually set
            Assert.AreEqual("RGB(255,0,0)", formulas[0][col_fg.Ordinal]);
            Assert.AreEqual("RGB(0,0,255)", formulas[0][col_bg.Ordinal]);
            Assert.AreEqual("40", formulas[0][col_filpat.Ordinal]);

            // now retrieve the results with GetResults as floats
            var float_results = query.GetResults <double>(page1, shapeids);

            Assert.IsNotNull(float_results);
            Assert.AreEqual(40.0, float_results[0][col_filpat.Ordinal]);

            // now retrieve the results with GetResults as ints
            var int_results = query.GetResults <int>(page1, shapeids);

            Assert.AreEqual(40, int_results[0][col_filpat.Ordinal]);

            // now retrieve the results with GetResults as strings

            var string_results = query.GetResults <string>(page1, shapeids);

            Assert.AreEqual("RGB(255, 0, 0)", string_results[0][col_fg.Ordinal]);
            Assert.AreEqual("RGB(0, 0, 255)", string_results[0][col_bg.Ordinal]);
            Assert.AreEqual("40", string_results[0][col_filpat.Ordinal]);

            page1.Delete(0);
            doc1.Close(true);
        }