public void Scripting_Hyperlinks_Scenarios()
        {
            var client = this.GetScriptingClient();

            client.Document.NewDocument();
            client.Page.NewPage(new VisioAutomation.Geometry.Size(4, 4), false);

            var s1 = client.Draw.DrawRectangle(1, 1, 1.5, 1.5);
            var s2 = client.Draw.DrawRectangle(2, 3, 2.5, 3.5);
            var s3 = client.Draw.DrawRectangle(1.5, 3.5, 2, 4.0);

            client.Selection.SelectNone();
            client.Selection.SelectShapesById(s1);
            client.Selection.SelectShapesById(s2);
            client.Selection.SelectShapesById(s3);

            var targetshapes = new VisioScripting.TargetShapes();

            var hyperlinks0 = client.Hyperlink.GetHyperlinks(targetshapes, VASS.CellValueType.Formula);

            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 VA.Shapes.HyperlinkCells();

            hyperlink.Address = "http://www.microsoft.com";
            client.Hyperlink.AddHyperlink(targetshapes, hyperlink);

            var hyperlinks1 = client.Hyperlink.GetHyperlinks(targetshapes, VASS.CellValueType.Formula);

            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.DeleteHyperlinkAtIndex(targetshapes, 0);
            var hyperlinks2 = client.Hyperlink.GetHyperlinks(targetshapes, VASS.CellValueType.Formula);

            Assert.AreEqual(3, hyperlinks0.Count);
            Assert.AreEqual(0, hyperlinks2[s1].Count);
            Assert.AreEqual(0, hyperlinks2[s2].Count);
            Assert.AreEqual(0, hyperlinks2[s3].Count);

            var targetdoc = new VisioScripting.TargetDocument();

            client.Document.CloseDocument(targetdoc, true);
        }
Пример #2
0
        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, VA.Shapes.HyperlinkHelper.GetCount(s1));

            // Add the first hyperlink

            var h1 = new VA.Shapes.HyperlinkCells();

            h1.Address = "http://microsoft.com";
            int h1_row = VA.Shapes.HyperlinkHelper.Add(s1, h1);

            Assert.AreEqual(1, VA.Shapes.HyperlinkHelper.GetCount(s1));

            // Add the second control
            var h2 = new VA.Shapes.HyperlinkCells();

            h2.Address = "http://google.com";
            int h2_row = VA.Shapes.HyperlinkHelper.Add(s1, h2);

            Assert.AreEqual(2, VA.Shapes.HyperlinkHelper.GetCount(s1));

            // retrieve the control information
            var hlinks = VA.Shapes.HyperlinkCells.GetCells(s1, VASS.CellValueType.Formula);

            // verify that the hyperlinks were set propery
            Assert.AreEqual(2, hlinks.Count);
            Assert.AreEqual("\"http://microsoft.com\"", hlinks[0].Address.Value);
            Assert.AreEqual("\"http://google.com\"", hlinks[1].Address.Value);

            // Delete both hyperlinks
            VA.Shapes.HyperlinkHelper.Delete(s1, 0);
            Assert.AreEqual(1, VA.Shapes.HyperlinkHelper.GetCount(s1));
            VA.Shapes.HyperlinkHelper.Delete(s1, 0);
            Assert.AreEqual(0, VA.Shapes.HyperlinkHelper.GetCount(s1));

            page1.Delete(0);
        }
Пример #3
0
        protected override void ProcessRecord()
        {
            var hlink = new VisioAutomation.Shapes.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   = this.Default;
            hlink.NewWindow = this.NewWindow;
            hlink.Invisible = this.Invisible;

            var targets = new VisioScripting.Models.TargetShapes(this.Shapes);

            this.Client.Hyperlink.AddHyperlink(targets, hlink);
        }