public FormatPaintCell(VA.ShapeSheet.SRC src, string name, FormatCategory category)
 {
     this.Category = category;
     this.Name = name;
     this.SRC = src;
     this.Formula = null;
     this.Result = null;
 }
        public void Copy(IVisio.Shape target_shape, FormatCategory category)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var shape = GetTargetShape(target_shape);
            if (shape == null)
            {
                return;
            }

            this.cache.CopyFormat(shape, category);
        }
 public bool MatchesCategory(FormatCategory category)
 {
     return ((this.Category & category) != 0);
 }
 public void Add(FormatCategory category, string name, VA.ShapeSheet.SRC src)
 {
     var format_cell = new FormatPaintCell(src, name, category);
     this.Cells.Add(format_cell);
 }
        public void PasteFormat(IVisio.Page page, IList<int> shapeids, FormatCategory category, bool applyformulas)
        {
            var update = new VA.ShapeSheet.Update();

            foreach (var shape_id in shapeids)
            {
                foreach (var cellrec in this.Cells)
                {
                    if (!cellrec.MatchesCategory(category))
                    {
                        continue;
                    }

                    var sidsrc = new VA.ShapeSheet.SIDSRC((short)shape_id, cellrec.SRC);

                    if (applyformulas)
                    {
                        update.SetFormula(sidsrc, cellrec.Formula);

                    }
                    else
                    {
                        if (cellrec.Result != null)
                        {
                            update.SetFormula(sidsrc, cellrec.Result);
                        }
                    }
                }
            }

            update.Execute(page);
        }
        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 Paste(IList<IVisio.Shape> target_shapes, FormatCategory category, bool apply_formulas)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);
            if (shapes.Count < 1)
            {
                return;
            }
 
            var shapeids = target_shapes.Select(s=>s.ID).ToList();
            var application = this.Client.Application.Get();
            var active_page = application.ActivePage;

            this.cache.PasteFormat(active_page, shapeids, category, apply_formulas);
        }