HyperlinkAction.cs
  1. //
  2. // This code is part of Document Solutions for Word demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Xml;
  11. using GrapeCity.Documents.Word;
  12.  
  13. namespace DsWordWeb.Demos
  14. {
  15. // This demo shows how to associate hyperlink behavior with a shape in a DOCX.
  16. public class HyperlinkAction
  17. {
  18. public GcWordDocument CreateDocx()
  19. {
  20. var doc = new GcWordDocument();
  21.  
  22. var run = doc.Body.AddParagraph().AddRun();
  23. var shape = run.GetRange().Shapes.Add(200, 200, GeometryType.Pentagon);
  24. shape.Fill.Type = FillType.Solid;
  25. shape.Fill.SolidFill.RGB = Color.Coral;
  26. shape.Line.Width = 3;
  27. shape.Line.Fill.SolidFill.RGB = Color.CadetBlue;
  28. shape.AddTextFrame("This shape has HyperlinkOnClick and HyperlinkOnHover properties specified.");
  29. shape.Size.EffectExtent.AllEdges = 8;
  30.  
  31. // HyperlinkOnClick properties:
  32. shape.HyperlinkOnClick.Address = new Uri("https://www.google.com/maps", UriKind.RelativeOrAbsolute);
  33. shape.HyperlinkOnClick.ScreenTip = "Go to Google Maps";
  34. shape.HyperlinkOnClick.HighlightClick = true;
  35.  
  36. // HyperlinkOnHover properties:
  37. shape.HyperlinkOnHover.Address = new Uri("https://www.google.com", UriKind.RelativeOrAbsolute);
  38. shape.HyperlinkOnHover.ScreenTip = "Just Google";
  39. shape.HyperlinkOnHover.HighlightClick = true;
  40.  
  41. // Done:
  42. return doc;
  43. }
  44. }
  45. }
  46.