public void CopyFormat(IVisio.Shape shape, FormatPaintCategory paint_category) { // Build the Query var query = new ShapeSheetQuery(); var desired_cells = this.Cells.Where(cell => cell.MatchesCategory(paint_category)).ToList(); foreach (var cell in desired_cells) { query.AddCell(cell.Src, null); } // Retrieve the values for the cells var dataset = query.GetFormulasAndResults(shape); // Now store the values for (int col = 0; col < query.Cells.Count; col++) { var result = dataset.Cells[col].Result; var formula = dataset.Cells[col].Formula; var cellrec = desired_cells[col]; cellrec.Result = result; cellrec.Formula = formula.Value; } }
public void ShapeSheet_Query_SectionRowHandling() { var page1 = this.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); VACUSTPROP.CustomPropertyHelper.Set(s1, "S1P1", "1"); VACUSTPROP.CustomPropertyHelper.Set(s2, "S2P1", "2"); VACUSTPROP.CustomPropertyHelper.Set(s2, "S2P2", "3"); //set nothing for s3 VACUSTPROP.CustomPropertyHelper.Set(s4, "S3P1", "4"); VACUSTPROP.CustomPropertyHelper.Set(s4, "S3P2", "5"); VACUSTPROP.CustomPropertyHelper.Set(s4, "S3P3", "6"); var query = new ShapeSheetQuery(); var prop_sec = query.AddSubQuery(IVisio.VisSectionIndices.visSectionProp); var value_col = prop_sec.AddCell(VA.ShapeSheet.SrcConstants.CustomPropValue, "Value"); var shapeids = new[] { s1.ID, s2.ID, s3.ID, s4.ID }; var data = query.GetFormulasAndResults(page1, shapeids); Assert.AreEqual(4, data.Count); Assert.AreEqual(1, data[0].Sections[prop_sec].Rows.Count); Assert.AreEqual(2, data[1].Sections[prop_sec].Rows.Count); Assert.AreEqual(0, data[2].Sections[prop_sec].Rows.Count); Assert.AreEqual(3, data[3].Sections[prop_sec].Rows.Count); Assert.AreEqual("\"1\"", data[0].Sections[prop_sec].Rows[0].Cells[0].Formula); Assert.AreEqual("\"2\"", data[1].Sections[prop_sec].Rows[0].Cells[0].Formula); Assert.AreEqual("\"3\"", data[1].Sections[prop_sec].Rows[1].Cells[0].Formula); Assert.AreEqual("\"4\"", data[3].Sections[prop_sec].Rows[0].Cells[0].Formula); Assert.AreEqual("\"5\"", data[3].Sections[prop_sec].Rows[1].Cells[0].Formula); Assert.AreEqual("\"6\"", data[3].Sections[prop_sec].Rows[2].Cells[0].Formula); Assert.AreEqual("1", data[0].Sections[prop_sec].Rows[0].Cells[0].Result); Assert.AreEqual("2", data[1].Sections[prop_sec].Rows[0].Cells[0].Result); Assert.AreEqual("3", data[1].Sections[prop_sec].Rows[1].Cells[0].Result); Assert.AreEqual("4", data[3].Sections[prop_sec].Rows[0].Cells[0].Result); Assert.AreEqual("5", data[3].Sections[prop_sec].Rows[1].Cells[0].Result); Assert.AreEqual("6", data[3].Sections[prop_sec].Rows[2].Cells[0].Result); page1.Delete(0); }