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 FormatPaintCell(VisioAutomation.ShapeSheet.Src src, string name, FormatPaintCategory paint_category) { this.PaintCategory = paint_category; this.Name = name; this.Src = src; this.Formula = null; this.Result = null; }
public void Copy(IVisio.Shape target_shape, FormatPaintCategory paint_category) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var targets = new TargetShapes(target_shape); var shapes = targets.ResolveShapes(this._client); if (shapes.Shapes.Count < 1) { return; } var shape = shapes.Shapes[0]; this.cache.CopyFormat(shape, paint_category); }
public void Paste(TargetShapes targets, FormatPaintCategory paint_category, bool apply_formulas) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var shapeids = targets.Shapes.Select(s => s.ID).ToList(); var application = this._client.Application.Get(); var active_page = application.ActivePage; this.cache.PasteFormat(active_page, shapeids, paint_category, apply_formulas); }
public void PasteFormat(IVisio.Page page, IList <int> shapeids, FormatPaintCategory paint_category, bool applyformulas) { // Find all the cells that are going to be pasted var matching_cells = this.Cells.Where(c => c.MatchesCategory(paint_category)).ToArray(); // Apply those matched cells to each shape var writer = new SidSrcWriter(); foreach (var shape_id in shapeids) { foreach (var cell in matching_cells) { var sidsrc = new VisioAutomation.ShapeSheet.SidSrc((short)shape_id, cell.Src); var new_formula = applyformulas ? cell.Formula : cell.Result; writer.SetFormula(sidsrc, new_formula); } } writer.Commit(page); }
public void Add(VisioAutomation.ShapeSheet.Src src, FormatPaintCategory paint_category, string name) { var format_cell = new FormatPaintCell(src, name, paint_category); this.Cells.Add(format_cell); }
public bool MatchesCategory(FormatPaintCategory paint_category) { return((this.PaintCategory & paint_category) != 0); }