Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

Building a thumbnail navigation index

This source code snippet requires TX Text Control .NET
Author:TX Text Control Support Department
Language:Visual Basic .NET
Version:1.0
Released:December 01, 2004
Last modified:January 11, 2008
Requirements:TX Text Control .NET with Visual Basic .NET
Download code:tx_sample_dotnet_thumbs.zip Download [127.44 KB, ZIP]

How to build a document thumbnail navigation index

Click to enlarge

An interesting navigation feature to add to a word processor is that of thumbnail navigation -- create a thumbnail of every page in a document and display it on the left of the currently active document (as illustrated in the screenshot to the right).

In this sample application, you will learn how to create such navigation by using a small, zoomed TX Text Control. Every page of the current document is displayed on a separate TX Text Control that is added to a scrollable panel control.

First of all, we have to create a new TX Text Control for every page and copy the current page using the Load and Save methods into the small thumbnail TX Text Control. Consider the following code:

  1. For pageCount = 1 To TextControl1.Pages
  2. Dim thumb As New TXTextControl.TextControl
  3. Dim dataBuffer() As Byte
  4.  
  5. With thumb
  6. [...]
  7. TextControl1.Selection.Save(dataBuffer, TXTextControl.BinaryStreamType.InternalFormat)
  8. AddHandler .Click, AddressOf thumb_Click
  9. AddHandler .MouseHover, AddressOf thumb_Hover
  10. AddHandler .MouseLeave, AddressOf thumb_Leave
  11. End With
  12.  
  13. Panel2.Controls.Add(thumb)
  14.  
  15. If Not dataBuffer Is Nothing Then
  16. thumb.Load(dataBuffer, TXTextControl.BinaryStreamType.InternalFormat)
  17. End If
  18. Next

Additionally, we add some event handlers for the thumbnails: a Click, a MouseHover and a MouseLeave event. The current page is stored in the Tag property of the current control, so that this value can be used to navigate to the specified page and to display the page number, if the user moves the mouse over the thumbnail.

  1. Private Sub thumb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  2. Dim myThumb As New TXTextControl.TextControl
  3.  
  4. For Each myThumb In Panel2.Controls
  5. myThumb.BackColor = System.Drawing.Color.White
  6. Next
  7.  
  8. myThumb = sender
  9. myThumb.BackColor = System.Drawing.Color.Beige
  10. TextControl1.Focus()
  11. TextControl1.InputPosition = New TXTextControl.InputPosition(myThumb.Tag, 1, 0)
  12. End Sub

The thumbs are updated, if a new page is inserted to the document. You can also force the update by pressing the 'Update...' button.

The minimum requirements for this sample application are TX Text Control .NET trial or TX Text Control .NET Enterprise retail version and Visual Studio .NET 2003.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place