protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); var t = this.Client.Text.Get(targets); this.WriteObject(t); }
public void Scripting_Distribute() { var client = this.GetScriptingClient(); var pagesize = new VA.Drawing.Size(4, 4); client.Document.New(); client.Page.New(pagesize, false); var s1 = client.Draw.Rectangle(new VA.Drawing.Rectangle(new VA.Drawing.Point(1, 1), new VA.Drawing.Size(0.5, 0.5))); var s2 = client.Draw.Rectangle(new VA.Drawing.Rectangle(new VA.Drawing.Point(2, 2), new VA.Drawing.Size(1.0, 1.0))); var s3 = client.Draw.Rectangle(new VA.Drawing.Rectangle(new VA.Drawing.Point(4, 4), new VA.Drawing.Size(1.5, 1.5))); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var targets = new VisioAutomation.Scripting.TargetShapes(); client.Distribute.DistributeHorizontal(targets, AlignmentHorizontal.Center); VisioAutomation.Shapes.XFormCells.GetCells(client.Page.Get(), new[] { s1.ID, s2.ID, s3.ID }); client.Document.Close(true); }
public void Scripting_Nudge() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VA.Drawing.Size(4, 4), false); var s1 = client.Draw.Rectangle(1, 1, 1.25, 1.5); var s2 = client.Draw.Rectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.Rectangle(4.5, 2.5, 6, 3.5); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var targets = new VisioAutomation.Scripting.TargetShapes(); client.Arrange.Nudge(targets, 1, -1); var xforms = VisioAutomation.Shapes.XFormCells.GetCells(client.Page.Get(), new[] { s1.ID, s2.ID, s3.ID }); AssertUtil.AreEqual(2.125, 0.25, xforms[0].GetPinPosResult(), 0.00001); AssertUtil.AreEqual(3.25, 2.25, xforms[1].GetPinPosResult(), 0.00001); AssertUtil.AreEqual(6.25, 2, xforms[2].GetPinPosResult(), 0.00001); client.Document.Close(true); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); var dic = this.Client.ConnectionPoint.Get(targets); if (this.GetCells) { this.WriteObject(dic); return; } foreach (var shape_points in dic) { var shape = shape_points.Key; var points = shape_points.Value; int shapeid = shape.ID; foreach (var point_cells in points) { var cp = new Model.ConnectionPointValues(shapeid, point_cells); this.WriteObject(cp); } } }
public void Scripting_Grouping() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VisioAutomation.Drawing.Size(4, 4), false); var shape_rect = client.Draw.Rectangle(1, 1, 3, 3); var shape_line = client.Draw.Line(0.5, 0.5, 3.5, 3.5); var shape_oval1 = client.Draw.Oval(0.2, 1, 3.8, 2); var shape_oval2 = client.Draw.Oval(new VisioAutomation.Drawing.Point(2, 2), 0.5); client.Selection.SelectAll(); var s0 = client.Selection.GetShapes(); Assert.AreEqual(4, s0.Count); var g = client.Grouping.Group(); client.Selection.SelectNone(); client.Selection.SelectAll(); var s1 = client.Selection.GetShapes(); Assert.AreEqual(1, s1.Count); var targets = new VisioAutomation.Scripting.TargetShapes(); client.Grouping.Ungroup(targets); client.Selection.SelectAll(); var s2 = client.Selection.GetShapes(); Assert.AreEqual(4, s2.Count); client.Document.Close(true); }
public void Scripting_ShapeSheet_SetNoShapes() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VA.Drawing.Size(4, 4), false); var s1 = client.Draw.Rectangle(1, 1, 1.25, 1.5); var s2 = client.Draw.Rectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.Rectangle(4.5, 2.5, 6, 3.5); client.Selection.SelectNone(); var shapes = new VisioAutomation.Scripting.TargetShapes(s1, s2, s3); var shape_ids = shapes.ToShapeIDs(); var page = client.Page.Get(); var writer = client.ShapeSheet.GetWriter(page); foreach (var shape_id in shape_ids.ShapeIDs) { writer.SetFormula((short)shape_id, VA.ShapeSheet.SrcConstants.XFormPinX, "1.0"); } writer.Commit(); client.Document.Close(true); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); var dic = this.Client.CustomProp.Get(targets); if (this.GetCells) { this.WriteObject(dic); return; } foreach (var shape_propdic_pair in dic) { var shape = shape_propdic_pair.Key; var propdic = shape_propdic_pair.Value; int shape_id = shape.ID; foreach (var propname_propcells_pair in propdic) { string propname = propname_propcells_pair.Key; var propcells = propname_propcells_pair.Value; var cpf = new Model.CustomPropertyValues(shape_id, propname, propcells); this.WriteObject(cpf); } } }
public void Scripting_Distribute_With_Spacing() { var client = this.GetScriptingClient(); var pagesize = new VA.Drawing.Size(4, 4); client.Document.New(); client.Page.New(pagesize, false); var s1 = client.Draw.Rectangle(new VA.Drawing.Rectangle(new VA.Drawing.Point(1, 1), new VA.Drawing.Size(0.5, 0.5))); var s2 = client.Draw.Rectangle(new VA.Drawing.Rectangle(new VA.Drawing.Point(2, 2), new VA.Drawing.Size(1.0, 1.0))); var s3 = client.Draw.Rectangle(new VA.Drawing.Rectangle(new VA.Drawing.Point(4, 4), new VA.Drawing.Size(1.5, 1.5))); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var targets = new VA.Scripting.TargetShapes(); client.Distribute.DistributeOnAxis(targets, Axis.XAxis, 0.25); client.Distribute.DistributeOnAxis(targets, Axis.YAxis, 1.0); var out_xfrms = VisioAutomation.Shapes.XFormCells.GetCells(client.Page.Get(), new[] { s1.ID, s2.ID, s3.ID }); var out_positions = out_xfrms.Select(xfrm => TestExtensions.ToPoint(xfrm.PinX.Result, xfrm.PinY.Result)).ToArray(); Assert.AreEqual(1.25, out_positions[0].X); Assert.AreEqual(1.25, out_positions[0].Y); Assert.AreEqual(2.25, out_positions[1].X); Assert.AreEqual(3.00, out_positions[1].Y); Assert.AreEqual(3.75, out_positions[2].X); Assert.AreEqual(5.25, out_positions[2].Y); client.Document.Close(true); }
public void Scripting_ConnectionPoints_Scenarios() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VisioAutomation.Drawing.Size(4, 4), false); var s1 = client.Draw.Rectangle(1, 1, 1.25, 1.5); var s2 = client.Draw.Rectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.Rectangle(4.5, 2.5, 6, 3.5); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var indices0 = client.ConnectionPoint.Add("0", "Width*0.67", ConnectionPointType.Outward); Assert.AreEqual(3, indices0.Count); Assert.AreEqual(0, indices0[0]); Assert.AreEqual(0, indices0[1]); Assert.AreEqual(0, indices0[2]); var targets = new VisioAutomation.Scripting.TargetShapes(); var dic = client.ConnectionPoint.Get(targets); Assert.AreEqual(3, dic.Count); Assert.AreEqual("Width*0.67", dic[s1][0].Y.Formula); Assert.AreEqual("Width*0.67", dic[s2][0].Y.Formula); Assert.AreEqual("Width*0.67", dic[s2][0].Y.Formula); client.ConnectionPoint.Delete(targets, 0); client.Document.Close(true); }
protected override void ProcessRecord() { var target_shapes = this.Shapes ?? this.Client.Selection.GetShapes(); var targets = new VisioAutomation.Scripting.TargetShapes(target_shapes); var dic = Set_VisioPageCell.CellHashtableToDictionary(this.Hashtable); this.Client.ShapeSheet.SetShapeCells(targets, dic, this.BlastGuards, this.TestCircular); }
private void SetFromParameters() { var cp = new VACUSTPROP.CustomPropertyCells(); cp.Value = this.Value; if (this.Label != null) { cp.Label = this.Label; } if (this.Format != null) { cp.Format = this.Format; } if (this.Prompt != null) { cp.Prompt = this.Prompt; } if (this.LangId >= 0) { cp.LangId = this.LangId; } if (this.SortKey >= 0) { cp.SortKey = this.SortKey; } if (this.Type >= 0) { cp.Type = this.Type; } if (this.Ask >= 0) { cp.Ask = this.Ask; } if (this.Calendar >= 0) { cp.Calendar = this.Calendar; } if (this.Invisible >= 0) { cp.Invisible = this.Invisible; } var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); this.Client.CustomProp.Set(targets, this.Name, cp); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); var userprop = new VisioAutomation.Shapes.UserDefinedCells.UserDefinedCell(this.Name, this.Value); if (this.Prompt != null) { userprop.Prompt = this.Prompt; } this.Client.UserDefinedCell.Set(targets, userprop); }
protected override void ProcessRecord() { var target_pages = this.Pages ?? new[] { this.Client.Page.Get() }; foreach (var page in target_pages) { var pagesheet = page.PageSheet; var t = new VisioAutomation.Scripting.TargetShapes(pagesheet); var dic = CellHashtableToDictionary(this.Hashtable); this.Client.ShapeSheet.SetPageCells(t, dic, this.BlastGuards, this.TestCircular); } }
public void Scripting_Controls_Scenarios() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VisioAutomation.Drawing.Size(4, 4), false); var s1 = client.Draw.Rectangle(1, 1, 1.5, 1.5); var s2 = client.Draw.Rectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.Rectangle(1.5, 3.5, 2, 4.0); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var targets = new VisioAutomation.Scripting.TargetShapes(); var controls0 = client.Control.Get(targets); int found_controls = controls0.Count; Assert.AreEqual(3, controls0.Count); Assert.AreEqual(0, controls0[s1].Count); Assert.AreEqual(0, controls0[s2].Count); Assert.AreEqual(0, controls0[s3].Count); var ctrl = new VACONTROL.ControlCells(); ctrl.X = "Width*0.5"; ctrl.Y = "0"; client.Control.Add(targets, ctrl); var controls1 = client.Control.Get(targets); Assert.AreEqual(3, controls1.Count); Assert.AreEqual(1, controls1[s1].Count); Assert.AreEqual(1, controls1[s2].Count); Assert.AreEqual(1, controls1[s3].Count); client.Control.Delete(targets, 0); var controls2 = client.Control.Get(targets); Assert.AreEqual(3, controls0.Count); Assert.AreEqual(0, controls2[s1].Count); Assert.AreEqual(0, controls2[s2].Count); Assert.AreEqual(0, controls2[s3].Count); client.Document.Close(true); }
public void Scripting_Hyperlinks_Scenarios() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VisioAutomation.Drawing.Size(4, 4), false); var s1 = client.Draw.Rectangle(1, 1, 1.5, 1.5); var s2 = client.Draw.Rectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.Rectangle(1.5, 3.5, 2, 4.0); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var targets = new VisioAutomation.Scripting.TargetShapes(); var hyperlinks0 = client.Hyperlink.Get(targets); Assert.AreEqual(3, hyperlinks0.Count); Assert.AreEqual(0, hyperlinks0[s1].Count); Assert.AreEqual(0, hyperlinks0[s2].Count); Assert.AreEqual(0, hyperlinks0[s3].Count); var hyperlink = new VisioAutomation.Shapes.Hyperlinks.HyperlinkCells(); hyperlink.Address = "http://www.microsoft.com"; client.Hyperlink.Add(targets, hyperlink); var hyperlinks1 = client.Hyperlink.Get(targets); Assert.AreEqual(3, hyperlinks1.Count); Assert.AreEqual(1, hyperlinks1[s1].Count); Assert.AreEqual(1, hyperlinks1[s2].Count); Assert.AreEqual(1, hyperlinks1[s3].Count); client.Hyperlink.Delete(targets, 0); var hyperlinks2 = client.Hyperlink.Get(targets); Assert.AreEqual(3, hyperlinks0.Count); Assert.AreEqual(0, hyperlinks2[s1].Count); Assert.AreEqual(0, hyperlinks2[s2].Count); Assert.AreEqual(0, hyperlinks2[s3].Count); client.Document.Close(true); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); if (this.Font != null) { this.Client.Text.SetFont(targets, this.Font); } if (this.Togglecase) { this.Client.Text.ToogleCase(targets); } }
public void Copy(IVisio.Shape target_shape, FormatCategory category) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var targets = new VisioAutomation.Scripting.TargetShapes(target_shape); var shapes = targets.ResolveShapes(this._client); if (shapes.Shapes.Count < 1) { return; } var shape = shapes.Shapes[0]; this.cache.CopyFormat(shape, category); }
protected override void ProcessRecord() { var ctrl = new VA.Shapes.Controls.ControlCells(); ctrl.XDynamics = this.XDynamics; ctrl.YDynamics = this.YDynamics; ctrl.XBehavior = this.XBehavior; ctrl.YBehavior = this.YBehavior; ctrl.X = this.X; ctrl.Y = this.Y; ctrl.CanGlue = Convert.BoolToFormula(this.CanGlue); ctrl.Tip = this.Tip; var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); this.Client.Control.Add(targets, ctrl); }
public void Scripting_Shape_Text_Set() { var page1 = this.GetNewPage(); var stencil = "basic_u.vss"; short flags = (short)IVisio.VisOpenSaveArgs.visOpenRO | (short)IVisio.VisOpenSaveArgs.visOpenDocked; var app = page1.Application; var documents = app.Documents; var stencil_doc = documents.OpenEx(stencil, flags); var masters1 = stencil_doc.Masters; var masters = new[] { masters1["Rounded Rectangle"], masters1["Ellipse"] }; var point0 = new VA.Drawing.Point(1, 2); var point1 = new VA.Drawing.Point(3, 4); var points = new[] { point0, point1 }; Assert.AreEqual(0, page1.Shapes.Count); var shapeids = page1.DropManyU(masters, points); Assert.AreEqual(2, page1.Shapes.Count); Assert.AreEqual(2, shapeids.Length); var shapes = page1.Shapes.GetShapesFromIDs(shapeids); var client = this.GetScriptingClient(); var names = new[] { "TestName", "TestName2" }; var texts = names.ToArray(); var targets = new VA.Scripting.TargetShapes(shapes); client.Text.Set(targets, texts); client.ShapeSheet.SetName(targets, names); for (int i = 0; i < page1.Shapes.Count; i++) { var shape = shapes[i]; var name = names[i]; var text = texts[i]; Assert.AreEqual(name, shape.Name); Assert.AreEqual(text, shape.Text); } page1.Delete(0); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); if (this.NudgeX != 0.0 || this.NudgeY != 0.0) { this.Client.Arrange.Nudge(targets, this.NudgeX, this.NudgeY); } if (this.DistributeHorizontal) { if (this.Distance < 0) { this.Client.Distribute.DistributeOnAxis(targets, Axis.XAxis); } else { this.Client.Distribute.DistributeOnAxis(targets, Axis.XAxis, this.Distance); } } if (this.DistributeVertical) { if (this.Distance < 0) { this.Client.Distribute.DistributeOnAxis(targets, Axis.YAxis); } else { this.Client.Distribute.DistributeOnAxis(targets, Axis.YAxis, this.Distance); } } if (this.AlignVertical != Model.VerticalAlignment.None) { this.Client.Align.AlignVertical(targets, (AlignmentVertical)this.AlignVertical); } if (this.AlignHorizontal != Model.HorizontalAlignment.None) { this.Client.Align.AlignHorizontal(targets, (AlignmentHorizontal)this.AlignHorizontal); } }
protected override void ProcessRecord() { var hlink = new VA.Shapes.Hyperlinks.HyperlinkCells(); hlink.Address = this.Address; hlink.Description = this.Description; hlink.ExtraInfo = this.ExtraInfo; hlink.Frame = this.Frame; hlink.SortKey = this.SortKey; hlink.SubAddress = this.SubAddress; hlink.Default = Convert.BoolToFormula(this.Default); hlink.NewWindow = Convert.BoolToFormula(this.NewWindow); hlink.Invisible = Convert.BoolToFormula(this.Invisible); var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); this.Client.Hyperlink.Add(targets, hlink); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); var dic = this.Client.UserDefinedCell.Get(targets); if (this.GetCells) { this.WriteObject(dic); return; } foreach (var kv in dic) { int shapeid = kv.Key.ID; foreach (var udc in kv.Value) { var udcell_vals = new Model.UserDefinedCellvalues(shapeid, udc.Name, udc.Value.Formula.Value, udc.Prompt.Formula.Value); this.WriteObject(udcell_vals); } } }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); var dic = this.Client.Hyperlink.Get(targets); if (this.GetCells) { this.WriteObject(dic); return; } foreach (var shape_points in dic) { var shape = shape_points.Key; var hyperlinks = shape_points.Value; int shapeid = shape.ID; foreach (var hyperlink in hyperlinks) { var hl_formulas = new HyperlinkFormulas(); hl_formulas.ShapeID = shapeid; hl_formulas.Address = hyperlink.Address.Formula.Value; hl_formulas.Default = hyperlink.Default.Formula.Value; hl_formulas.Description = hyperlink.Description.Formula.Value; hl_formulas.ExtraInfo = hyperlink.ExtraInfo.Formula.Value; hl_formulas.Frame = hyperlink.Frame.Formula.Value; hl_formulas.Invisible = hyperlink.Invisible.Formula.Value; hl_formulas.NewWindow = hyperlink.NewWindow.Formula.Value; hl_formulas.SortKey = hyperlink.SortKey.Formula.Value; hl_formulas.SubAddress = hyperlink.SubAddress.Formula.Value; this.WriteObject(hl_formulas); } } }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); var dic = this.Client.Control.Get(targets); if (this.GetCells) { this.WriteObject(dic); return; } foreach (var shape_points in dic) { var shape = shape_points.Key; var points = shape_points.Value; int shapeid = shape.ID; foreach (var point in points) { var cp = new ControlFormulas(); cp.ShapeID = shapeid; cp.CanGlue = point.CanGlue.Formula.Value; cp.Tip = point.Tip.Formula.Value; cp.X = point.X.Formula.Value; cp.Y = point.Y.Formula.Value; cp.XBehavior = point.XBehavior.Formula.Value; cp.YBehavior = point.YBehavior.Formula.Value; cp.XDynamics = point.XDynamics.Formula.Value; cp.YDynamics = point.YDynamics.Formula.Value; this.WriteObject(cp); } } }
private void SetFromHashTable() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); if (this.HashTable.Count < 1) { return; } foreach (object key in this.HashTable.Keys) { if (!(key is string)) { string msg = "Property Names must be strings"; throw new ArgumentOutOfRangeException(msg); } string key_string = (string)key; object value = this.HashTable[key]; var cp = VACUSTPROP.CustomPropertyCells.FromValue(value); this.Client.CustomProp.Set(targets, key_string, cp); } }
public void Scripting_Nudge2() { var client = this.GetScriptingClient(); client.Document.New(); client.Page.New(new VA.Drawing.Size(4, 4), false); var size1 = new VA.Drawing.Size(0.5, 0.5); var size2 = new VA.Drawing.Size(1.0, 1.0); var size3 = new VA.Drawing.Size(1.5, 1.5); var r1 = new VA.Drawing.Rectangle(new VA.Drawing.Point(1, 1), size1); var r2 = new VA.Drawing.Rectangle(new VA.Drawing.Point(2, 2), size2); var r3 = new VA.Drawing.Rectangle(new VA.Drawing.Point(4, 4), size3); var s1 = client.Draw.Rectangle(r1); var s2 = client.Draw.Rectangle(r2); var s3 = client.Draw.Rectangle(r3); client.Selection.SelectNone(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var targets = new VisioAutomation.Scripting.TargetShapes(); client.Arrange.Nudge(targets, 0.50, -0.25); var shapeids = new[] { s1.ID, s2.ID, s3.ID }; var xforms = VisioAutomation.Shapes.XFormCells.GetCells(client.Page.Get(), shapeids); AssertUtil.AreEqual((1.75, 1), xforms[0].GetPinPosResult(), 0.00001); AssertUtil.AreEqual((3, 2.25), xforms[1].GetPinPosResult(), 0.00001); AssertUtil.AreEqual((5.25, 4.5), xforms[2].GetPinPosResult(), 0.00001); client.Document.Close(true); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); this.Client.UserDefinedCell.Delete(targets, this.Name); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); this.Client.Selection.Duplicate(targets); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); this.Client.Text.Set(targets, this.Text); }
protected override void ProcessRecord() { var targets = new VisioAutomation.Scripting.TargetShapes(this.Shapes); this.Client.Grouping.Ungroup(targets); }