public IList <int> Add(IList <IVisio.Shape> target_shapes, VAHLINK.HyperlinkCells ctrl) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); if (ctrl == null) { throw new System.ArgumentNullException(nameof(ctrl)); } var shapes = this.GetTargetShapes(target_shapes); if (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 shapes) { int hi = VAHLINK.HyperlinkHelper.Add(shape, ctrl); hyperlink_indices.Add(hi); } } return(hyperlink_indices); }
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.None(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); var hyperlinks0 = client.Hyperlink.Get(null); 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 VAHYPERLINK.HyperlinkCells(); hyperlink.Address = "http://www.microsoft.com"; client.Hyperlink.Add(null, hyperlink); var hyperlinks1 = client.Hyperlink.Get(null); 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(null, 0); var hyperlinks2 = client.Hyperlink.Get(null); 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); }
public static int Set( IVisio.Shape shape, short row, HyperlinkCells hyperlink) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } var update = new ShapeSheet.Update(); update.SetFormulas(hyperlink, row); update.Execute(shape); return(row); }
public static int Set( IVisio.Shape shape, short row, HyperlinkCells hyperlink) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } var writer = new FormulaWriterSRC(); hyperlink.SetFormulas(writer, row); writer.Commit(shape); return(row); }
public static int Add( IVisio.Shape shape, HyperlinkCells hyperlink) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } if (hyperlink == null) { throw new ArgumentNullException(nameof(hyperlink)); } if (hyperlink.Address.Formula.Value == null) { throw new ArgumentException("Address is null", nameof(hyperlink)); } /* * TODO: Why doesn't this work? * short row = shape.AddRow((short)IVisio.VisSectionIndices.visSectionHyperlink, * (short)IVisio.VisRowIndices.visRowLast, * (short)IVisio.VisRowTags.visTagDefault); * * HyperlinkHelper.Set(shape, row, hyperlink); * */ var hlinks_collection = shape.Hyperlinks; var hlinks_object = hlinks_collection.Add(); hlinks_object.Address = hyperlink.Address.Formula.Value; hlinks_object.Description = hyperlink.Description.Formula.Value; hlinks_object.ExtraInfo = hyperlink.ExtraInfo.Formula.Value; hlinks_object.Frame = hyperlink.Frame.Formula.Value; hlinks_object.SubAddress = hyperlink.SubAddress.Formula.Value; hlinks_object.ExtraInfo = hyperlink.ExtraInfo.Formula.Value; //hlinks_object.NewWindow = hyperlink.NewWindow.Formula.Value; //hlinks_object.IsDefaultLink = hyperlink.Default.Formula.Value; // hlinks_object.XXX = hyperlink.Invisible.Formula.Value; return(hlinks_object.Row); }
public void Hyperlinks_AddRemove() { var page1 = this.GetNewPage(); var s1 = page1.DrawRectangle(0, 0, 4, 1); // Ensure we start with 0 hyperlinks Assert.AreEqual(0, VAHLINK.HyperlinkHelper.GetCount(s1)); // Add the first hyperlink var h1 = new VAHLINK.HyperlinkCells(); h1.Address = "http://microsoft.com"; int h1_row = VAHLINK.HyperlinkHelper.Add(s1, h1); Assert.AreEqual(1, VAHLINK.HyperlinkHelper.GetCount(s1)); // Add the second control var h2 = new VAHLINK.HyperlinkCells(); h2.Address = "http://google.com"; int h2_row = VAHLINK.HyperlinkHelper.Add(s1, h2); Assert.AreEqual(2, VAHLINK.HyperlinkHelper.GetCount(s1)); // retrieve the control information var hlinks = VAHLINK.HyperlinkCells.GetCells(s1); // verify that the hyperlinks were set propery Assert.AreEqual(2, hlinks.Count); Assert.AreEqual("\"http://microsoft.com\"", hlinks[0].Address.Formula); Assert.AreEqual("\"http://google.com\"", hlinks[1].Address.Formula); // Delete both hyperlinks VAHLINK.HyperlinkHelper.Delete(s1, 0); Assert.AreEqual(1, VAHLINK.HyperlinkHelper.GetCount(s1)); VAHLINK.HyperlinkHelper.Delete(s1, 0); Assert.AreEqual(0, VAHLINK.HyperlinkHelper.GetCount(s1)); page1.Delete(0); }