private static void AddTOCLinkToPage(Visio.Page page) { int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddTOCLinkToPage"); // Clear out any existing link. foreach (Visio.Shape shape in page.Shapes) { if (shape.Text == "Table of Contents" || shape.Name == "TOCLink") { shape.Delete(); } } Visio.Shape tocShape = page.DrawRectangle( cTOC_Page_Initial_xLoc, cTOC_PageLink_Initial_yLoc, cTOC_Page_Initial_xLoc + cTOC_PageLink_Width, cTOC_PageLink_Initial_yLoc + cTOC_PageLink_Height); tocShape.Name = "TOCLink"; tocShape.Text = "Table of Contents"; tocShape.TextStyle = "Normal"; tocShape.LineStyle = "Text Only"; tocShape.FillStyle = "Text Only"; tocShape.Characters.Begin = 0; tocShape.Characters.End = 0; tocShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, 6); Visio.Hyperlink hlink = tocShape.Hyperlinks.Add(); // hlink.Name = "do we need a name?"; hlink.SubAddress = "Table of Contents"; Globals.ThisAddIn.Application.EndUndoScope(undoScope, true); }
private static void AddTOCLinkToPage(Visio.Page page) { VisioHelper.DisplayInWatchWindow(string.Format("{0}()", System.Reflection.MethodBase.GetCurrentMethod().Name)); if (page.Background != 0) { // Skip background pages return; } int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddTOCLinkToPage"); // Clear out any existing link. foreach (Visio.Shape shape in page.Shapes) { if (shape.Text == "Table of Contents" || shape.Name == "TOCLink") { shape.Delete(); } } Visio.Shape tocShape = page.DrawRectangle( cTOC_Page_Initial_xLoc, cTOC_PageLink_Initial_yLoc, cTOC_Page_Initial_xLoc + cTOC_PageLink_Width, cTOC_PageLink_Initial_yLoc + cTOC_PageLink_Height); tocShape.Name = "TOCLink"; tocShape.Text = "Table of Contents"; tocShape.TextStyle = "Normal"; tocShape.LineStyle = "Text Only"; tocShape.FillStyle = "Text Only"; tocShape.Characters.Begin = 0; tocShape.Characters.End = 0; tocShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, 6); Visio.Hyperlink hlink = tocShape.Hyperlinks.Add(); // hlink.Name = "do we need a name?"; hlink.SubAddress = "Table of Contents"; Globals.ThisAddIn.Application.EndUndoScope(undoScope, true); }
private static void AddPageLinkToTOCPage(Visio.Page pageTOC, Visio.Page page, double xLoc, double yLoc) { int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddPageLinkToTOCPage"); Visio.Shape pageLinkShape = pageTOC.DrawRectangle(xLoc, yLoc, xLoc + cTOC_Link_Width, yLoc + cTOC_Link_Height); pageLinkShape.TextStyle = "Normal"; pageLinkShape.LineStyle = "Text Only"; pageLinkShape.FillStyle = "Text Only"; pageLinkShape.Characters.Begin = 0; pageLinkShape.Characters.End = 0; pageLinkShape.Text = page.Name; pageLinkShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, cTOC_Link_FontSize); Visio.Hyperlink hlink = pageLinkShape.Hyperlinks.Add(); // hlink.Name = "do we need a name?"; hlink.SubAddress = page.Name; Globals.ThisAddIn.Application.EndUndoScope(undoScope, true); }