public void Scripting_ShapeSheet_SetNoShapes() { var client = this.GetScriptingClient(); client.Document.NewDocument(); client.Page.NewPage(VisioScripting.TargetDocument.Auto, new VA.Geometry.Size(4, 4), false); var s1 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 1, 1, 1.25, 1.5); var s2 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 2, 3, 2.5, 3.5); var s3 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 4.5, 2.5, 6, 3.5); client.Selection.SelectNone(VisioScripting.TargetWindow.Auto); var targetshapes = new VisioScripting.TargetShapes(s1, s2, s3); var targetshapeids = targetshapes.ToShapeIDs(); var writer = client.ShapeSheet.GetWriterForPage(VisioScripting.TargetPage.Auto); foreach (var shapeid in targetshapeids) { writer.SetFormula((short)shapeid, VA.ShapeSheet.SrcConstants.XFormPinX, "1.0"); } writer.Commit(); client.Document.CloseDocument(VisioScripting.TargetDocuments.Auto); }
protected override void ProcessRecord() { if (this.Cells == null) { return; } if (this.Cells.Length < 1) { return; } var target_shapes = this.Shapes ?? this.Client.Selection.GetShapesInSelection(); if (target_shapes.Count < 1) { return; } var targetshapes = new VisioScripting.TargetShapes(target_shapes).Resolve(this.Client); var targetshapeids = targetshapes.ToShapeIDs(); var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter(); writer.BlastGuards = this.BlastGuards; writer.TestCircular = this.TestCircular; foreach (int i in Enumerable.Range(0, targetshapeids.Count)) { var shapeid = targetshapeids[i]; var shape_cells = this.Cells[i % this.Cells.Length]; shape_cells.Apply(writer, (short)shapeid); } var surface = this.Client.ShapeSheet.GetShapeSheetSurface(); this.Client.Output.WriteVerbose("BlastGuards: {0}", this.BlastGuards); this.Client.Output.WriteVerbose("TestCircular: {0}", this.TestCircular); this.Client.Output.WriteVerbose("Number of Shapes : {0}", targetshapeids.Count); using (var undoscope = this.Client.Undo.NewUndoScope(nameof(SetVisioShapeCells))) { this.Client.Output.WriteVerbose("Start Update"); writer.CommitFormulas(surface); this.Client.Output.WriteVerbose("End Update"); } }