public void DistributeVertical(Models.TargetShapes targets, Models.AlignmentVertical valign) { var cmdtarget = this._client.GetCommandTargetDocument(); int shape_count = targets.SelectShapesAndCount(this._client); if (shape_count < 1) { return; } IVisio.VisUICmds cmd; switch (valign) { case VisioScripting.Models.AlignmentVertical.Top: cmd = IVisio.VisUICmds.visCmdDistributeTop; break; case VisioScripting.Models.AlignmentVertical.Center: cmd = IVisio.VisUICmds.visCmdDistributeMiddle; break; case VisioScripting.Models.AlignmentVertical.Bottom: cmd = IVisio.VisUICmds.visCmdDistributeBottom; break; default: throw new System.ArgumentOutOfRangeException(); } cmdtarget.Application.DoCmd((short)cmd); }
public List <int> AddHyperlink(Models.TargetShapes targets, HyperlinkCells hlink) { if (hlink == null) { throw new System.ArgumentNullException(nameof(hlink)); } 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.Undo.NewUndoScope(nameof(AddHyperlink))) { foreach (var shape in targets.Shapes) { int hi = HyperlinkHelper.Add(shape, hlink); hyperlink_indices.Add(hi); } } return(hyperlink_indices); }
public void DistributeShapesHorizontal(Models.TargetShapes targets, Models.AlignmentHorizontal halign) { var cmdtarget = this._client.GetCommandTargetDocument(); int shape_count = targets.SelectShapesAndCount(this._client); if (shape_count < 1) { return; } IVisio.VisUICmds cmd; switch (halign) { case VisioScripting.Models.AlignmentHorizontal.Left: cmd = IVisio.VisUICmds.visCmdDistributeLeft; break; case VisioScripting.Models.AlignmentHorizontal.Center: cmd = IVisio.VisUICmds.visCmdDistributeCenter; break; case VisioScripting.Models.AlignmentHorizontal.Right: cmd = IVisio.VisUICmds.visCmdDistributeRight; break; default: throw new System.ArgumentOutOfRangeException(); } cmdtarget.Application.DoCmd((short)cmd); }
public void SetShapeText(Models.TargetShapes targets, IList <string> texts) { if (texts == null || texts.Count < 1) { return; } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetShapeText))) { // 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 DeleteCustomPropertyWithName(Models.TargetShapes targets, string name) { 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.Undo.NewUndoScope(nameof(DeleteCustomPropertyWithName))) { foreach (var shape in targets.Shapes) { CustomPropertyHelper.Delete(shape, name); } } }
public void SetShapeName(Models.TargetShapes targets, IList <string> names) { 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.Undo.NewUndoScope(nameof(SetShapeName))) { 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 List <int> AddControlToShapes(Models.TargetShapes targets, ControlCells ctrl) { 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 control_indices = new List <int>(); using (var undoscope = this._client.Undo.NewUndoScope(nameof(AddControlToShapes))) { foreach (var shape in targets.Shapes) { int ci = ControlHelper.Add(shape, ctrl); control_indices.Add(ci); } } return(control_indices); }
public Dictionary <int, LockCells> GetLockCells(Models.TargetShapes targets, VASS.CellValueType cvt) { var cmdtarget = this._client.GetCommandTargetPage(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new Dictionary <int, LockCells>()); } var dic = new Dictionary <int, LockCells>(); var page = cmdtarget.ActivePage; var target_shapeids = targets.Shapes.Select(s => (int)s.ID16).ToList(); var cells = VisioAutomation.Shapes.LockCells.GetCells(page, target_shapeids, cvt); for (int i = 0; i < target_shapeids.Count; i++) { var shapeid = target_shapeids[i]; var cur_cells = cells[i]; dic[shapeid] = cur_cells; } return(dic); }
public List <int> AddConnectionPoint( string fx, string fy, Models.ConnectionPointType type) { var targets = new Models.TargetShapes(); return(this.AddConnectionPoint(targets, fx, fy, type)); }
public List <string> GetShapeText(Models.TargetShapes targets) { 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 DistributeSelectionOnAxis(Models.TargetShapes targets, Models.Axis axis, double spacing) { var cmdtarget = this._client.GetCommandTargetPage(); var page = cmdtarget.ActivePage; targets = targets.ResolveShapes(this._client); var targetids = targets.ToShapeIDs(); using (var undoscope = this._client.Undo.NewUndoScope(nameof(DistributeSelectionOnAxis))) { VisioScripting.Helpers.ArrangeHelper.DistributeWithSpacing(page, targetids, axis, spacing); } }
public List <bool> ContainCustomPropertyWithName(Models.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); var values = targets.Shapes.Select(shape => CustomPropertyHelper.Contains(shape, name)); results.AddRange(values); return(results); }
public List <VisioAutomation.Text.TextFormat> GetShapeTextFormat(Models.TargetShapes targets) { var cmdtarget = this._client.GetCommandTargetDocument(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new List <VisioAutomation.Text.TextFormat>(0)); } var pairs = targets.ToShapeIdPairs(); var application = cmdtarget.Application; var formats = VisioAutomation.Text.TextFormat.GetFormat(application.ActivePage, pairs, CellValueType.Formula); return(formats); }
public void SetUserDefinedCell(Models.TargetShapes targets, Models.UserDefinedCell userdefinedcell) { targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetUserDefinedCell))) { foreach (var shape in targets.Shapes) { VA.Shapes.UserDefinedCellHelper.Set(shape, userdefinedcell.Name, userdefinedcell.Cells); } } }
public Dictionary <IVisio.Shape, IList <ControlCells> > GetControls(Models.TargetShapes targets, CellValueType cvt) { targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new Dictionary <IVisio.Shape, IList <ControlCells> >(0)); } var dic = new Dictionary <IVisio.Shape, IList <ControlCells> >(targets.Shapes.Count); foreach (var shape in targets.Shapes) { var controls = ControlCells.GetCells(shape, cvt); dic[shape] = controls; } return(dic); }
public List <bool> ContainsUserDefinedCellsWithName(Models.TargetShapes targets, string name) { 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.GetShapesInSelection(); var results = all_shapes.Select(s => VA.Shapes.UserDefinedCellHelper.Contains(s, name)).ToList(); return(results); }
public void DuplicateSelectedShapes(Models.TargetShapes target_shapes) { var cmdtarget = this._client.GetCommandTargetDocument(); int n = target_shapes.SelectShapesAndCount(this._client); this._client.Output.WriteVerbose("Number of shapes to duplicate: {0}", n); if (n < 1) { this._client.Output.WriteVerbose("Zero shapes to duplicate. No duplication operation performed"); return; } var active_window = cmdtarget.Application.ActiveWindow; var selection = active_window.Selection; selection.Duplicate(); }
public void DeleteControlWithIndex(Models.TargetShapes targets, int index) { targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } // restrict the operation to those shapes that actually have enough // controls to qualify for deleting var qualified_shapes = targets.Shapes.Where(shape => ControlHelper.GetCount(shape) > index); using (var undoscope = this._client.Undo.NewUndoScope(nameof(DeleteControlWithIndex))) { foreach (var shape in qualified_shapes) { ControlHelper.Delete(shape, index); } } }
internal void __SetCells(Models.TargetShapes targets, VASS.CellGroups.CellGroup cells, IVisio.Page page) { targets = targets.ResolveShapes(this._client); var shapeids = targets.ToShapeIDs(); var writer = new VASS.Writers.SidSrcWriter(); foreach (var shapeid in shapeids.ShapeIDs) { if (cells is VASS.CellGroups.CellGroup) { var cells_mr = (VASS.CellGroups.CellGroup)cells; writer.SetValues((short)shapeid, cells_mr, 0); } else { var cells_sr = (VASS.CellGroups.CellGroup)cells; writer.SetValues((short)shapeid, cells_sr); } } writer.CommitFormulas(page); }
public void UngroupSelectedShapes(Models.TargetShapes targets) { var cmdtarget = this._client.GetCommandTargetApplication(); var window = cmdtarget.Application.ActiveWindow; var selection = window.Selection; if (targets.Shapes == null) { if (selection.Count >= 1) { var application = cmdtarget.Application; application.DoCmd((short)IVisio.VisUICmds.visCmdObjectUngroup); } } else { foreach (var shape in targets.Shapes) { shape.Ungroup(); } } }
public void SetCustomProperty(Models.TargetShapes targets, string name, CustomPropertyCells customprop) { if (customprop == null) { throw new System.ArgumentNullException(nameof(customprop)); } targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } customprop.EncodeValues(); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetCustomProperty))) { foreach (var shape in targets.Shapes) { CustomPropertyHelper.Set(shape, name, customprop); } } }
public List <int> AddConnectionPoint( Models.TargetShapes targets, string fx, string fy, Models.ConnectionPointType type) { 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.Undo.NewUndoScope(nameof(AddConnectionPoint))) { 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 SetLockCells(Models.TargetShapes targets, LockCells lockcells) { var cmdtarget = this._client.GetCommandTargetPage(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var page = cmdtarget.ActivePage; var target_shapeids = targets.ToShapeIDs(); var writer = new VASS.Writers.SidSrcWriter(); foreach (int shapeid in target_shapeids.ShapeIDs) { writer.SetValues((short)shapeid, lockcells); } using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetLockCells))) { writer.CommitFormulas(page); } }
public Dictionary <IVisio.Shape, VA.Shapes.UserDefinedCellDictionary> GetUserDefinedCells(Models.TargetShapes targets, VASS.CellValueType cvt) { var cmdtarget = this._client.GetCommandTargetPage(); var dicof_shape_to_udcelldic = new Dictionary <IVisio.Shape, VA.Shapes.UserDefinedCellDictionary>(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(dicof_shape_to_udcelldic); } var page = cmdtarget.ActivePage; var shapeidpairs = VisioAutomation.ShapeIDPairs.FromShapes(targets.Shapes); var listof_udcelldic = VA.Shapes.UserDefinedCellHelper.GetCellsAsDictionary((IVisio.Page)page, shapeidpairs, cvt); for (int i = 0; i < targets.Shapes.Count; i++) { var shape = targets.Shapes[i]; var props = listof_udcelldic[i]; dicof_shape_to_udcelldic[shape] = props; } return(dicof_shape_to_udcelldic); }
public IDictionary <IVisio.Shape, IList <ConnectionPointCells> > GetConnectionPoints(Models.TargetShapes targets) { targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(new Dictionary <IVisio.Shape, IList <ConnectionPointCells> >()); } var dic = new Dictionary <IVisio.Shape, IList <ConnectionPointCells> >(); foreach (var shape in targets.Shapes) { var cp = VisioAutomation.Shapes.ConnectionPointCells.GetCells(shape, CellValueType.Formula); dic[shape] = cp; } return(dic); }
public IDictionary <IVisio.Shape, CustomPropertyDictionary> GetCustomProperties(Models.TargetShapes targets) { var cmdtarget = this._client.GetCommandTargetPage(); var dicof_shape_to_cpdic = new Dictionary <IVisio.Shape, CustomPropertyDictionary>(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return(dicof_shape_to_cpdic); } var listof_cpdic = CustomPropertyHelper.GetCellsAsDictionary(cmdtarget.ActivePage, targets.Shapes, CellValueType.Formula); for (int i = 0; i < targets.Shapes.Count; i++) { var shape = targets.Shapes[i]; var cpdic = listof_cpdic[i]; dicof_shape_to_cpdic[shape] = cpdic; } return(dicof_shape_to_cpdic); }