public void CheckHomogenousUpdates_ResultTypes() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(ShapeSheet_Update_Tests.src_linepat, "7", IVisio.VisUnitCodes.visNumber); update.SetResult(VA.ShapeSheet.SRCConstants.PinX, 2, IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.AddCell(ShapeSheet_Update_Tests.src_linepat, "LinePattern"); var col_pinx = query.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); // Retrieve the values var data = query.GetCellData <double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat]); AssertVA.AreEqual("2 in", 2, data[col_pinx]); page1.Delete(0); }
public void CheckHomogenousUpdates_ResultTypes() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(ShapeSheet_Update_Tests.src_linepat, "7", IVisio.VisUnitCodes.visNumber); update.SetResult(VA.ShapeSheet.SRCConstants.PinX, 2, IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.AddCell(ShapeSheet_Update_Tests.src_linepat, "LinePattern"); var col_pinx = query.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); // Retrieve the values var data = query.GetCellData<double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat]); AssertVA.AreEqual("2 in", 2, data[col_pinx]); page1.Delete(0); }
public void ShapeSheet_Query_TestDuplicates() { // Ensure that duplicate cells are caught var q1 = new VA.ShapeSheet.Query.CellQuery(); q1.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); bool caught_exc1 = false; try { q1.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); } catch (VA.AutomationException) { caught_exc1 = true; } Assert.IsTrue(caught_exc1); // Ensure that duplicate sections are caught var q2 = new VA.ShapeSheet.Query.CellQuery(); q2.AddSection(IVisio.VisSectionIndices.visSectionObject); bool caught_exc2 = false; try { q2.AddSection(IVisio.VisSectionIndices.visSectionObject); } catch (VA.AutomationException) { caught_exc2 = true; } Assert.IsTrue(caught_exc2); // Ensure that Duplicates in Section Queries Are caught - var q3 = new VA.ShapeSheet.Query.CellQuery(); var sec = q3.AddSection(IVisio.VisSectionIndices.visSectionObject); sec.AddCell(VA.ShapeSheet.SRCConstants.PinX.Cell, "PinX"); bool caught_exc3 = false; try { sec.AddCell(VA.ShapeSheet.SRCConstants.PinX.Cell, "PinX"); } catch (VA.AutomationException) { caught_exc3 = true; } Assert.IsTrue(caught_exc3); }
public static VisioAutomation.Drawing.Size GetSize(IVisio.Shape shape) { var query = new VisioAutomation.ShapeSheet.Query.CellQuery(); var col_w = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Width,"Width"); var col_h = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Height,"Height"); var table = query.GetResults<double>(shape); double w = table[col_w]; double h = table[col_h]; var size = new VisioAutomation.Drawing.Size(w, h); return size; }
public void ShapeSheet_Query_Demo_MultipleShapes_Verify_Out_Of_order() { var page1 = this.GetNewPage(new VisioAutomation.Drawing.Size(10, 10)); // draw a simple shape var sa = page1.DrawRectangle(-1, -1, 0, 0); var s1 = page1.DrawRectangle(0, 0, 2, 2); var sb = page1.DrawRectangle(-1, -1, 0, 0); var s2 = page1.DrawRectangle(4, 4, 6, 6); var s3 = page1.DrawRectangle(5, 5, 7, 7); // notice that the shapes are created as 0, 1,2,3 // but are queried as 2, 3, 1 var shapeids = new List <int> { s2.ID, s3.ID, s1.ID }; Assert.AreEqual(5, page1.Shapes.Count); var query = new VA.ShapeSheet.Query.CellQuery(); var col_pinx = query.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); var col_piny = query.AddCell(VA.ShapeSheet.SRCConstants.PinY, "PinY"); var rf = query.GetFormulas(page1, shapeids); var rr = query.GetResults <double>(page1, shapeids); var expected_formulas = new[, ] { { "5 in", "5 in" }, { "6 in", "6 in" }, { "1 in", "1 in" } }; var expected_results = new[, ] { { 5.0, 5.0 }, { 6.0, 6.0 }, { 1.0, 1.0 } }; for (int row = 0; row < rr.Count; row++) { for (int col = 0; col < query.CellColumns.Count; col++) { Assert.AreEqual(expected_formulas[row, col], rf[row][col]); Assert.AreEqual(expected_results[row, col], rr[row][col]); } } page1.Delete(0); }
public static VisioAutomation.Drawing.Size GetSize(IVisio.Shape shape) { var query = new VisioAutomation.ShapeSheet.Query.CellQuery(); var col_w = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Width, "Width"); var col_h = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Height, "Height"); var table = query.GetResults <double>(shape); double w = table[col_w]; double h = table[col_h]; var size = new VisioAutomation.Drawing.Size(w, h); return(size); }
public static VA.Drawing.Size GetPageSize(IVisio.Page page) { if (page == null) { throw new System.ArgumentNullException("page"); } var query = new VA.ShapeSheet.Query.CellQuery(); var col_height = query.AddCell(VA.ShapeSheet.SRCConstants.PageHeight,"PageHeight"); var col_width = query.AddCell(VA.ShapeSheet.SRCConstants.PageWidth, "PageWidth"); var results = query.GetResults<double>(page.PageSheet); double height = results[col_height]; double width = results[col_width]; var s = new VA.Drawing.Size(width, height); return s; }
public static VA.Drawing.Size GetPageSize(IVisio.Page page) { if (page == null) { throw new System.ArgumentNullException("page"); } var query = new VA.ShapeSheet.Query.CellQuery(); var col_height = query.AddCell(VA.ShapeSheet.SRCConstants.PageHeight, "PageHeight"); var col_width = query.AddCell(VA.ShapeSheet.SRCConstants.PageWidth, "PageWidth"); var results = query.GetResults <double>(page.PageSheet); double height = results[col_height]; double width = results[col_width]; var s = new VA.Drawing.Size(width, height); return(s); }
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.SectionColumn>(); foreach (var kv in name_to_src) { var name = kv.Key; var src = kv.Value; if (src.Section == (short)IVisio.VisSectionIndices.visSectionObject) { query.AddCell(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.SectionColumn sec; if (!section_to_secquery.ContainsKey(src.Section)) { sec = query.AddSection((IVisio.VisSectionIndices)src.Section); section_to_secquery[src.Section] = sec; } else { sec = section_to_secquery[src.Section]; } sec.AddCell(src.Cell, name); } } var formulas1 = query.GetFormulas(s1); var formulas2 = query.GetFormulas(page1, new [] { s1.ID, s2.ID }); doc1.Close(true); }
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.SectionColumn>(); foreach (var kv in name_to_src) { var name = kv.Key; var src = kv.Value; if (src.Section == (short) IVisio.VisSectionIndices.visSectionObject) { query.AddCell(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.SectionColumn sec; if (!section_to_secquery.ContainsKey(src.Section)) { sec = query.AddSection((IVisio.VisSectionIndices)src.Section); section_to_secquery[src.Section] = sec; } else { sec = section_to_secquery[src.Section]; } sec.AddCell(src.Cell, name); } } var formulas1 = query.GetFormulas(s1); var formulas2 = query.GetFormulas(page1,new [] {s1.ID,s2.ID}); doc1.Close(true); }
public void ShapeSheet_Update_Formulas_MultipleShapes() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(-1, -1, 0, 0); var shape2 = page1.DrawRectangle(-1, -1, 0, 0); var shape3 = page1.DrawRectangle(-1, -1, 0, 0); // Set the formulas var update = new VA.ShapeSheet.Update(); update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_pinx, 0.5); update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_piny, 0.5); update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_pinx, 1.5); update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_piny, 1.5); update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_pinx, 2.5); update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_piny, 2.5); update.Execute(page1); // Verify that the formulas were set var query = new VA.ShapeSheet.Query.CellQuery(); var col_pinx = query.AddCell(ShapeSheet_Update_Tests.src_pinx, "PinX"); var col_piny = query.AddCell(ShapeSheet_Update_Tests.src_piny, "PinY"); var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID }; var rf = query.GetFormulas(page1, shapeids); var rr = query.GetResults <double>(page1, shapeids); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx], rr[0][col_pinx]); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny], rr[0][col_piny]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx], rr[1][col_pinx]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny], rr[1][col_piny]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx], rr[2][col_pinx]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny], rr[2][col_piny]); page1.Delete(0); }
public void ShapeSheet_Update_Formulas_MultipleShapes() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(-1, -1, 0, 0); var shape2 = page1.DrawRectangle(-1, -1, 0, 0); var shape3 = page1.DrawRectangle(-1, -1, 0, 0); // Set the formulas var update = new VA.ShapeSheet.Update(); update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_pinx, 0.5); update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_piny, 0.5); update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_pinx, 1.5); update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_piny, 1.5); update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_pinx, 2.5); update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_piny, 2.5); update.Execute(page1); // Verify that the formulas were set var query = new VA.ShapeSheet.Query.CellQuery(); var col_pinx = query.AddCell(ShapeSheet_Update_Tests.src_pinx, "PinX"); var col_piny = query.AddCell(ShapeSheet_Update_Tests.src_piny, "PinY"); var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID }; var rf = query.GetFormulas(page1, shapeids); var rr = query.GetResults<double>(page1, shapeids); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx], rr[0][col_pinx]); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny], rr[0][col_piny]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx], rr[1][col_pinx]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny], rr[1][col_piny]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx], rr[2][col_pinx]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny], rr[2][col_piny]); page1.Delete(0); }
public void ShapeSheet_Query_GetResults_MultipleShapes() { var page1 = this.GetNewPage(); // 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.ResultIU = 2.0; //red bg_cell.ResultIU = 3.0; //green pat_cell.ResultIU = 40.0; var src_fg = VA.ShapeSheet.SRCConstants.FillForegnd; var src_bg = VA.ShapeSheet.SRCConstants.FillBkgnd; var src_filpat = VA.ShapeSheet.SRCConstants.FillPattern; // now retrieve the formulas with GetFormulas var query = new VA.ShapeSheet.Query.CellQuery(); var col_fg = query.AddCell(src_fg, "FillForegnd"); var col_bg = query.AddCell(src_bg, "FillBkgnd"); var col_filpat = query.AddCell(src_filpat, "FillPattern"); var shapeids = new[] {s1_id}; var formulas = query.GetFormulas(page1, shapeids); // now verify that the formulas were actually set Assert.AreEqual("2", formulas[0][col_fg]); Assert.AreEqual("3", formulas[0][col_bg]); Assert.AreEqual("40", formulas[0][col_filpat]); // now retrieve the results with GetResults as floats var float_results = query.GetResults<double>(page1,shapeids); Assert.AreEqual(2.0, float_results[0][col_fg]); Assert.AreEqual(3.0, float_results[0][col_bg]); Assert.AreEqual(40.0, float_results[0][col_filpat]); // now retrieve the results with GetResults as ints var int_results = query.GetResults<int>(page1,shapeids); Assert.AreEqual(2, int_results[0][col_fg]); Assert.AreEqual(3, int_results[0][col_bg]); Assert.AreEqual(40, int_results[0][col_filpat]); // now retrieve the results with GetResults as strings var string_results = query.GetResults<string>(page1,shapeids); Assert.AreEqual("2", string_results[0][col_fg]); Assert.AreEqual("3", string_results[0][col_bg]); Assert.AreEqual("40", string_results[0][col_filpat]); page1.Delete(0); }
public void ShapeSheet_Query_Demo_MultipleShapes_Verify_Out_Of_order() { var page1 = this.GetNewPage(new VisioAutomation.Drawing.Size(10, 10)); // draw a simple shape var sa = page1.DrawRectangle(-1, -1, 0, 0); var s1 = page1.DrawRectangle(0, 0, 2, 2); var sb = page1.DrawRectangle(-1, -1, 0, 0); var s2 = page1.DrawRectangle(4, 4, 6, 6); var s3 = page1.DrawRectangle(5, 5, 7, 7); // notice that the shapes are created as 0, 1,2,3 // but are queried as 2, 3, 1 var shapeids = new List<int> { s2.ID, s3.ID, s1.ID }; Assert.AreEqual(5, page1.Shapes.Count); var query = new VA.ShapeSheet.Query.CellQuery(); var col_pinx = query.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); var col_piny = query.AddCell(VA.ShapeSheet.SRCConstants.PinY, "PinY"); var rf = query.GetFormulas(page1, shapeids); var rr = query.GetResults<double>(page1, shapeids); var expected_formulas = new[,] { {"5 in", "5 in"}, {"6 in", "6 in"}, {"1 in", "1 in"} }; var expected_results = new[,] { {5.0, 5.0}, {6.0, 6.0}, {1.0, 1.0} }; for (int row = 0; row < rr.Count; row++) { for (int col = 0; col < query.CellColumns.Count; col++) { Assert.AreEqual(expected_formulas[row, col], rf[row][col]); Assert.AreEqual(expected_results[row, col], rr[row][col]); } } page1.Delete(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.AddCell(src_fg, "FillForegnd"); var col_bg = query.AddCell(src_bg, "FillBkgnd"); var col_filpat = query.AddCell(src_filpat, "FillPattern"); var sec_char = query.AddSection(IVisio.VisSectionIndices.visSectionCharacter); Assert.AreEqual("Character",sec_char.Name); var col_charcase = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharCase, "CharCase"); var col_charcolor = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharColor, "CharColor"); var col_chartrans = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharColorTrans, "CharColorTrans"); 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]); Assert.AreEqual("RGB(0,0,255)", formulas[0][col_bg]); Assert.AreEqual("40", formulas[0][col_filpat]); // 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]); // now retrieve the results with GetResults as ints var int_results = query.GetResults<int>(page1,shapeids); Assert.AreEqual(40, int_results[0][col_filpat]); // 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]); Assert.AreEqual("RGB(0, 0, 255)", string_results[0][col_bg]); Assert.AreEqual("40", string_results[0][col_filpat]); page1.Delete(0); doc1.Close(true); }
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.AddCell(src_fg, "FillForegnd"); var col_bg = query.AddCell(src_bg, "FillBkgnd"); var col_filpat = query.AddCell(src_filpat, "FillPattern"); var sec_char = query.AddSection(IVisio.VisSectionIndices.visSectionCharacter); Assert.AreEqual("Character", sec_char.Name); var col_charcase = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharCase, "CharCase"); var col_charcolor = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharColor, "CharColor"); var col_chartrans = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharColorTrans, "CharColorTrans"); 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]); Assert.AreEqual("RGB(0,0,255)", formulas[0][col_bg]); Assert.AreEqual("40", formulas[0][col_filpat]); // 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]); // now retrieve the results with GetResults as ints var int_results = query.GetResults <int>(page1, shapeids); Assert.AreEqual(40, int_results[0][col_filpat]); // 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]); Assert.AreEqual("RGB(0, 0, 255)", string_results[0][col_bg]); Assert.AreEqual("40", string_results[0][col_filpat]); page1.Delete(0); doc1.Close(true); }
public void ShapeSheet_Query_TestDuplicates() { // Ensure that duplicate cells are caught var q1 = new VA.ShapeSheet.Query.CellQuery(); q1.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); bool caught_exc1 = false; try { q1.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); } catch (VA.AutomationException) { caught_exc1 = true; } Assert.IsTrue(caught_exc1); // Ensure that duplicate sections are caught var q2 = new VA.ShapeSheet.Query.CellQuery(); q2.AddSection(IVisio.VisSectionIndices.visSectionObject); bool caught_exc2 = false; try { q2.AddSection(IVisio.VisSectionIndices.visSectionObject); } catch (VA.AutomationException) { caught_exc2 = true; } Assert.IsTrue(caught_exc2); // Ensure that Duplicates in Section Queries Are caught - var q3 = new VA.ShapeSheet.Query.CellQuery(); var sec = q3.AddSection(IVisio.VisSectionIndices.visSectionObject); sec.AddCell(VA.ShapeSheet.SRCConstants.PinX.Cell,"PinX"); bool caught_exc3 = false; try { sec.AddCell(VA.ShapeSheet.SRCConstants.PinX.Cell, "PinX"); } catch (VA.AutomationException) { caught_exc3 = true; } Assert.IsTrue(caught_exc3); }
public void ShapeSheet_Query_GetResults_MultipleShapes() { var page1 = this.GetNewPage(); // 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.ResultIU = 2.0; //red bg_cell.ResultIU = 3.0; //green pat_cell.ResultIU = 40.0; var src_fg = VA.ShapeSheet.SRCConstants.FillForegnd; var src_bg = VA.ShapeSheet.SRCConstants.FillBkgnd; var src_filpat = VA.ShapeSheet.SRCConstants.FillPattern; // now retrieve the formulas with GetFormulas var query = new VA.ShapeSheet.Query.CellQuery(); var col_fg = query.AddCell(src_fg, "FillForegnd"); var col_bg = query.AddCell(src_bg, "FillBkgnd"); var col_filpat = query.AddCell(src_filpat, "FillPattern"); var shapeids = new[] { s1_id }; var formulas = query.GetFormulas(page1, shapeids); // now verify that the formulas were actually set Assert.AreEqual("2", formulas[0][col_fg]); Assert.AreEqual("3", formulas[0][col_bg]); Assert.AreEqual("40", formulas[0][col_filpat]); // now retrieve the results with GetResults as floats var float_results = query.GetResults <double>(page1, shapeids); Assert.AreEqual(2.0, float_results[0][col_fg]); Assert.AreEqual(3.0, float_results[0][col_bg]); Assert.AreEqual(40.0, float_results[0][col_filpat]); // now retrieve the results with GetResults as ints var int_results = query.GetResults <int>(page1, shapeids); Assert.AreEqual(2, int_results[0][col_fg]); Assert.AreEqual(3, int_results[0][col_bg]); Assert.AreEqual(40, int_results[0][col_filpat]); // now retrieve the results with GetResults as strings var string_results = query.GetResults <string>(page1, shapeids); Assert.AreEqual("2", string_results[0][col_fg]); Assert.AreEqual("3", string_results[0][col_bg]); Assert.AreEqual("40", string_results[0][col_filpat]); page1.Delete(0); }