public void CheckHomogenousUpdates_ResultTypes() { var page1 = GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(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.Columns.Add(src_linepat,"LinePattern"); var col_pinx = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinX,"PinX"); // Retrieve the values var data = query.GetFormulasAndResults<double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]); AssertVA.AreEqual("2 in", 2, data[col_pinx.Ordinal]); page1.Delete(0); }
public void CheckHomogenousUpdates_ResultTypes() { var page1 = GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(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.Columns.Add(src_linepat, "LinePattern"); var col_pinx = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinX, "PinX"); // Retrieve the values var data = query.GetFormulasAndResults <double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]); AssertVA.AreEqual("2 in", 2, data[col_pinx.Ordinal]); page1.Delete(0); }
public void CopyFormat(IVisio.Shape shape, FormatCategory category) { // Build the Query var query = new VA.ShapeSheet.Query.CellQuery(); var desired_cells = this.Cells.Where(cell => cell.MatchesCategory(category)).ToList(); foreach (var cell in desired_cells) { query.Columns.Add(cell.SRC, null); } // Retrieve the values for the cells var dataset = query.GetFormulasAndResults <string>(shape); // Now store the values for (int col = 0; col < query.Columns.Count; col++) { var cellrec = desired_cells[col]; var result = dataset[col].Result; var formula = dataset[col].Formula; cellrec.Result = result; cellrec.Formula = formula.Value; } }
protected static T _GetCells <T, RT>( IVisio.Shape shape, VA.ShapeSheet.Query.CellQuery query, RowToObject <T, RT> row_to_object) { check_query(query); var data_for_shape = query.GetFormulasAndResults <RT>(shape); var cells = row_to_object(data_for_shape.Cells); return(cells); }
protected static IList <T> _GetCells <T, RT>( IVisio.Page page, IList <int> shapeids, VA.ShapeSheet.Query.CellQuery query, RowToObject <T, RT> row_to_object) { check_query(query); var data_for_shapes = query.GetFormulasAndResults <RT>(new VA.Drawing.DrawingSurface(page), shapeids); var list = new List <T>(shapeids.Count); foreach (var data_for_shape in data_for_shapes) { var cells = row_to_object(data_for_shape.Cells); list.Add(cells); } return(list); }
public void ShapeSheet_Query_SectionRowHandling() { var page1 = GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); var s2 = page1.DrawRectangle(2, 1, 3, 3); var s3 = page1.DrawRectangle(3, 1, 4, 2); var s4 = page1.DrawRectangle(4, -1, 5, 1); VACUSTOMPROP.CustomPropertyHelper.Set(s1, "S1P1", "1"); VACUSTOMPROP.CustomPropertyHelper.Set(s2, "S2P1", "2"); VACUSTOMPROP.CustomPropertyHelper.Set(s2, "S2P2", "3"); //set nothing for s3 VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P1", "4"); VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P2", "5"); VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P3", "6"); var query = new VA.ShapeSheet.Query.CellQuery(); var sec = query.Sections.Add(IVisio.VisSectionIndices.visSectionProp); sec.Columns.Add(VA.ShapeSheet.SRCConstants.Prop_Value, "Value"); var shapeids = new[] { s1.ID, s2.ID, s3.ID, s4.ID }; var table = query.GetFormulasAndResults <double>( page1, shapeids); Assert.AreEqual(4, table.Count); Assert.AreEqual(1, table[0].SectionCells[sec.Ordinal].Count); Assert.AreEqual(2, table[1].SectionCells[sec.Ordinal].Count); Assert.AreEqual(0, table[2].SectionCells[sec.Ordinal].Count); Assert.AreEqual(3, table[3].SectionCells[sec.Ordinal].Count); AssertVA.AreEqual("\"1\"", 1.0, table[0].SectionCells[sec.Ordinal][0][0]); AssertVA.AreEqual("\"2\"", 2.0, table[1].SectionCells[sec.Ordinal][0][0]); AssertVA.AreEqual("\"3\"", 3.0, table[1].SectionCells[sec.Ordinal][1][0]); AssertVA.AreEqual("\"4\"", 4.0, table[3].SectionCells[sec.Ordinal][0][0]); AssertVA.AreEqual("\"5\"", 5.0, table[3].SectionCells[sec.Ordinal][1][0]); AssertVA.AreEqual("\"6\"", 6.0, table[3].SectionCells[sec.Ordinal][2][0]); page1.Delete(0); }
public void ShapeSheet_Update_ResultsInt_SingleShape() { var page1 = GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(src_linepat, 7, IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.Columns.Add(src_linepat, "LinePattern"); // Retrieve the values var data = query.GetFormulasAndResults <double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]); page1.Delete(0); }
public void CopyFormat(IVisio.Shape shape, FormatCategory category) { // Build the Query var query = new VA.ShapeSheet.Query.CellQuery(); var desired_cells = this.Cells.Where(cell => cell.MatchesCategory(category)).ToList(); foreach (var cell in desired_cells) { query.Columns.Add(cell.SRC,null); } // Retrieve the values for the cells var dataset = query.GetFormulasAndResults<string>(shape); // Now store the values for (int col = 0; col < query.Columns.Count; col++) { var cellrec = desired_cells[col]; var result = dataset[col].Result; var formula = dataset[col].Formula; cellrec.Result = result; cellrec.Formula = formula.Value; } }
public void ShapeSheet_Update_ResultsInt_SingleShape() { var page1 = GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(src_linepat, 7, IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.Columns.Add(src_linepat,"LinePattern"); // Retrieve the values var data = query.GetFormulasAndResults<double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]); page1.Delete(0); }
public void ShapeSheet_Query_SectionRowHandling() { var page1 = GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 2, 2); var s2 = page1.DrawRectangle(2, 1, 3, 3); var s3 = page1.DrawRectangle(3, 1, 4, 2); var s4 = page1.DrawRectangle(4, -1, 5, 1); VACUSTOMPROP.CustomPropertyHelper.Set(s1, "S1P1", "1"); VACUSTOMPROP.CustomPropertyHelper.Set(s2, "S2P1", "2"); VACUSTOMPROP.CustomPropertyHelper.Set(s2, "S2P2", "3"); //set nothing for s3 VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P1", "4"); VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P2", "5"); VACUSTOMPROP.CustomPropertyHelper.Set(s4, "S3P3", "6"); var query = new VA.ShapeSheet.Query.CellQuery(); var sec = query.Sections.Add(IVisio.VisSectionIndices.visSectionProp); sec.Columns.Add(VA.ShapeSheet.SRCConstants.Prop_Value, "Value"); var shapeids = new[] { s1.ID, s2.ID, s3.ID, s4.ID }; var table = query.GetFormulasAndResults<double>( page1, shapeids); Assert.AreEqual(4, table.Count); Assert.AreEqual(1, table[0].SectionCells[sec.Ordinal].Count); Assert.AreEqual(2, table[1].SectionCells[sec.Ordinal].Count); Assert.AreEqual(0, table[2].SectionCells[sec.Ordinal].Count); Assert.AreEqual(3, table[3].SectionCells[sec.Ordinal].Count); AssertVA.AreEqual("\"1\"", 1.0, table[0].SectionCells[sec.Ordinal][0][0]); AssertVA.AreEqual("\"2\"", 2.0, table[1].SectionCells[sec.Ordinal][0][0]); AssertVA.AreEqual("\"3\"", 3.0, table[1].SectionCells[sec.Ordinal][1][0]); AssertVA.AreEqual("\"4\"", 4.0, table[3].SectionCells[sec.Ordinal][0][0]); AssertVA.AreEqual("\"5\"", 5.0, table[3].SectionCells[sec.Ordinal][1][0]); AssertVA.AreEqual("\"6\"", 6.0, table[3].SectionCells[sec.Ordinal][2][0]); page1.Delete(0); }