public void SetLock(TargetShapes targets, LockCells lockcells) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var page = this._client.Page.Get(); var target_shapeids = targets.ToShapeIDs(); var writer = new SidSrcWriter(); foreach (int shapeid in target_shapeids.ShapeIDs) { lockcells.SetFormulas((short)shapeid, writer); } using (var undoscope = this._client.Application.NewUndoScope("Set Lock Properties")) { writer.Commit(page); } }
public void SetShapeCells(TargetShapes targets, Dictionary <string, string> hashtable, bool blast_guards, bool test_circular) { targets = targets.ResolveShapes(this._client); var target_ids = targets.ToShapeIDs(); this.SetShapeCells(target_ids, hashtable, blast_guards, test_circular); }
public IDictionary <IVisio.Shape, CustomPropertyDictionary> Get(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var prop_dic = new Dictionary <IVisio.Shape, CustomPropertyDictionary>(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(prop_dic); } var application = this._client.Application.Get(); var page = application.ActivePage; var list_custom_props = CustomPropertyHelper.Get(page, targets.Shapes); for (int i = 0; i < targets.Shapes.Count; i++) { var shape = targets.Shapes[i]; var props = list_custom_props[i]; prop_dic[shape] = props; } return(prop_dic); }
public void Set(TargetShapes targets, string name, CustomPropertyCells customprop) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (customprop == null) { throw new System.ArgumentNullException(nameof(customprop)); } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Set Custom Property")) { foreach (var shape in targets.Shapes) { CustomPropertyHelper.Set(shape, name, customprop); } } }
public void Delete(TargetShapes targets, string name) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (name == null) { throw new System.ArgumentNullException(nameof(name)); } if (name.Length < 1) { throw new System.ArgumentException("name cannot be empty", nameof(name)); } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Delete Custom Property")) { foreach (var shape in targets.Shapes) { CustomPropertyHelper.Delete(shape, name); } } }
public List <int> Add(TargetShapes targets, HyperlinkCells ctrl) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (ctrl == null) { throw new System.ArgumentNullException(nameof(ctrl)); } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new List <int>(0)); } var hyperlink_indices = new List <int>(); using (var undoscope = this._client.Application.NewUndoScope("Add Control")) { foreach (var shape in targets.Shapes) { int hi = HyperlinkHelper.Add(shape, ctrl); hyperlink_indices.Add(hi); } } return(hyperlink_indices); }
public void Set(TargetShapes targets, IList <string> texts) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (texts == null || texts.Count < 1) { return; } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Set Shape Text")) { // Apply text to each shape // if there are fewer texts than shapes then // start reusing the texts from the beginning int count = 0; foreach (var shape in targets.Shapes) { string text = texts[count % texts.Count]; if (text != null) { shape.Text = text; } count++; } } }
public void SetSize(TargetShapes targets, double?w, double?h) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var active_page = this._client.Page.Get(); var shapeids = targets.ToShapeIDs(); var writer = new SidSrcWriter(); foreach (int shapeid in shapeids.ShapeIDs) { if (w.HasValue && w.Value >= 0) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SrcConstants.XFormWidth, w.Value); } if (h.HasValue && h.Value >= 0) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SrcConstants.XFormHeight, h.Value); } } using (var undoscope = this._client.Application.NewUndoScope("Set Shape Size")) { writer.Commit(active_page); } }
public Dictionary <IVisio.Shape, IList <VA_UDC.UserDefinedCell> > Get(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var prop_dic = new Dictionary <IVisio.Shape, IList <VA_UDC.UserDefinedCell> >(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(prop_dic); } var application = this._client.Application.Get(); var page = application.ActivePage; var list_user_props = VA_UDC.UserDefinedCellHelper.Get(page, targets.Shapes); for (int i = 0; i < targets.Shapes.Count; i++) { var shape = targets.Shapes[i]; var props = list_user_props[i]; prop_dic[shape] = props; } return(prop_dic); }
public void ToogleCase(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var application = this._client.Application.Get(); using (var undoscope = this._client.Application.NewUndoScope("Toggle Shape Text Case")) { var shapeids = targets.Shapes.Select(s => s.ID).ToList(); var page = application.ActivePage; // Store all the formatting var formats = Text.TextFormat.GetFormat(page, shapeids); // Change the text - this will wipe out all the character and paragraph formatting foreach (var shape in targets.Shapes) { string t = shape.Text; if (t.Length < 1) { continue; } shape.Text = TextHelper.toggle_case(t); } // Now restore all the formatting - based on any initial formatting from the text var writer = new FormulaWriterSIDSRC(); for (int i = 0; i < targets.Shapes.Count; i++) { var format = formats[i]; if (format.CharacterFormats.Count > 0) { var fmt = format.CharacterFormats[0]; fmt.SetFormulas((short)shapeids[i], writer, 0); } if (format.ParagraphFormats.Count > 0) { var fmt = format.ParagraphFormats[0]; fmt.SetFormulas((short)shapeids[i], writer, 0); } } writer.Commit(page); } }
public void DistributeOnAxis(TargetShapes targets, Axis axis, double spacing) { if (!this._client.Document.HasActiveDocument) { return; } var page = this._client.Page.Get(); targets = targets.ResolveShapes(this._client); var targetids = targets.ToShapeIDs(); using (var undoscope = this._client.Application.NewUndoScope("Distribute on Axis")) { ArrangeHelper.DistributeWithSpacing(page, targetids, axis, spacing); } }
public List <string> Get(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new List <string>(0)); } var texts = targets.Shapes.Select(s => s.Text).ToList(); return(texts); }
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, FormatCategory 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, category, apply_formulas); }
public List <bool> Contains(TargetShapes targets, string name) { if (name == null) { throw new System.ArgumentNullException(nameof(name)); } targets = targets.ResolveShapes(this._client); var results = new List <bool>(targets.Shapes.Count); foreach (var shape in targets.Shapes) { results.Add(CustomPropertyHelper.Contains(shape, name)); } return(results); }
public IList <Shapes.ShapeFormatCells> Get(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new List <Shapes.ShapeFormatCells>(0)); } var shapeids = targets.Shapes.Select(s => s.ID).ToList(); var application = this._client.Application.Get(); var fmts = Shapes.ShapeFormatCells.GetCells(application.ActivePage, shapeids); return(fmts); }
public List <Text.TextFormat> GetFormat(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new List <Text.TextFormat>(0)); } var selection = this._client.Selection.Get(); var shapeids = selection.GetIDs(); var application = this._client.Application.Get(); var formats = Text.TextFormat.GetFormat(application.ActivePage, shapeids); return(formats); }
public void Delete(TargetShapes targets, int n) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Delete Control")) { foreach (var shape in targets.Shapes) { HyperlinkHelper.Delete(shape, n); } } }
public void Set(TargetShapes targets, UserDefinedCellCells userdefinedcell) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Set User-Defined Cell")) { foreach (var shape in targets.Shapes) { UserDefinedCellHelper.Set(shape, userdefinedcell.Name, userdefinedcell.Value.Formula.Value, userdefinedcell.Prompt.Formula.Value); } } }
public Dictionary <IVisio.Shape, IList <HyperlinkCells> > Get(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new Dictionary <IVisio.Shape, IList <HyperlinkCells> >(0)); } var dic = new Dictionary <IVisio.Shape, IList <HyperlinkCells> >(); foreach (var shape in targets.Shapes) { var hyperlinks = HyperlinkCells.GetCells(shape); dic[shape] = hyperlinks; } return(dic); }
internal void __SetCells(TargetShapes targets, VisioAutomation.ShapeSheet.CellGroups.CellGroupBase cells, IVisio.Page page) { targets = targets.ResolveShapes(this._client); var shape_ids = targets.ToShapeIDs(); var writer = new VisioAutomation.ShapeSheet.Writers.FormulaWriterSIDSRC(); foreach (var shape_id in shape_ids.ShapeIDs) { if (cells is VisioAutomation.ShapeSheet.CellGroups.CellGroupMultiRow) { var cells_mr = (VisioAutomation.ShapeSheet.CellGroups.CellGroupMultiRow)cells; cells_mr.SetFormulas((short)shape_id, writer, 0); } else { var cells_sr = (VisioAutomation.ShapeSheet.CellGroups.CellGroupSingleRow)cells; cells_sr.SetFormulas((short)shape_id, writer); } } writer.Commit(page); }
public void Delete(TargetShapes targets, int index) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var shapes = targets.ResolveShapes(this._client); if (shapes.Shapes.Count < 1) { return; } var target_shapes = shapes.Shapes.Where(shape => ConnectionPointHelper.GetCount(shape) > index); using (var undoscope = this._client.Application.NewUndoScope("Delete Connection Point")) { foreach (var shape in target_shapes) { ConnectionPointHelper.Delete(shape, index); } } }
public List <bool> Contains(TargetShapes targets, string name) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (name == null) { throw new System.ArgumentNullException(nameof(name)); } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new List <bool>()); } var all_shapes = this._client.Selection.GetShapes(); var results = all_shapes.Select(s => UserDefinedCellHelper.Contains(s, name)).ToList(); return(results); }
public void PasteSize(TargetShapes targets, bool paste_width, bool paste_height) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } if ((!this.cached_size_width.HasValue) && (!this.cached_size_height.HasValue)) { return; } var writer = new FormulaWriterSIDSRC(); var shapeids = targets.Shapes.Select(s => s.ID).ToList(); foreach (var shapeid in shapeids) { if (paste_width) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.Width, this.cached_size_width.Value); } if (paste_height) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.Height, this.cached_size_height.Value); } } var application = this._client.Application.Get(); var active_page = application.ActivePage; writer.Commit(active_page); }
public List <int> Add(TargetShapes targets, string fx, string fy, ConnectionPointType type) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new List <int>(0)); } int dirx = 0; int diry = 0; var indices = new List <int>(targets.Shapes.Count); using (var undoscope = this._client.Application.NewUndoScope("Add Connection Point")) { var cp = new ConnectionPointCells(); cp.X = fx; cp.Y = fy; cp.DirX = dirx; cp.DirY = diry; cp.Type = (int)type; foreach (var shape in targets.Shapes) { int index = ConnectionPointHelper.Add(shape, cp); indices.Add(index); } } return(indices); }
public void MoveTextToBottom(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var writer = new FormulaWriterSIDSRC(); foreach (var shape in targets.Shapes) { if (0 == shape.RowExists[ (short)IVisio.VisSectionIndices.visSectionObject, (short)IVisio.VisRowIndices.visRowTextXForm, (short)IVisio.VisExistsFlags.visExistsAnywhere]) { shape.AddRow((short)IVisio.VisSectionIndices.visSectionObject, (short)IVisio.VisRowIndices.visRowTextXForm, (short)IVisio.VisRowTags.visTagDefault); } } var application = this._client.Application.Get(); var shapeids = targets.Shapes.Select(s => s.ID); foreach (int shapeid in shapeids) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.TxtHeight, "Height*0"); writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.TxtPinY, "Height*0"); writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.VerticalAlign, "0"); } var active_page = application.ActivePage; writer.Commit(active_page); }
public void SetName(TargetShapes targets, IList <string> names) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (names == null || names.Count < 1) { // do nothing return; } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Application.NewUndoScope("Set Shape Text")) { int numnames = names.Count; int up_to = System.Math.Min(numnames, targets.Shapes.Count); for (int i = 0; i < up_to; i++) { var new_name = names[i]; if (new_name != null) { var shape = targets.Shapes[i]; shape.Name = new_name; } } } }
public void SetFont(TargetShapes targets, string fontname) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var application = this._client.Application.Get(); var active_document = application.ActiveDocument; var active_doc_fonts = active_document.Fonts; var font = active_doc_fonts[fontname]; var page = this._client.Page.Get(); var cells = new VisioAutomation.Text.CharacterCells(); cells.Font = font.ID; this._client.ShapeSheet.__SetCells(targets, cells, page); }
public void Set(TargetShapes targets, Shapes.ShapeFormatCells format) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var writer = new FormulaWriterSIDSRC(); var shapeids = targets.Shapes.Select(s => s.ID).ToList(); foreach (int shapeid in shapeids) { format.SetFormulas((short)shapeid, writer); } var application = this._client.Application.Get(); writer.Commit(application.ActivePage); }