Private Sub LoadNavItems(ByVal theFilePath As String, ByVal theNavToolbar As NavigationToolbar)
'This is the file that contains the History Items.
Dim theNavItemsFile As New FileInfo(theFilePath)
'This list represents the Forward History Items.
Dim theForwardHistoryItems As New List(Of NavigationHistoryItem)()
'This list represents the Back History Items.
Dim theBackHistoryItems As New List(Of NavigationHistoryItem)()
'This represents the Current History item.
Dim theCurrentNavItem As NavigationHistoryItem = Nothing
'This stream reader will be used to get each line of text from the file.
Dim theStreamReader As StreamReader = theNavItemsFile.OpenText()
'Used to represent the current line item read from the File.
Dim theLineItem As String = theStreamReader.ReadLine()
While ((theLineItem) IsNot Nothing)
'Each line item has been formatted in the following fashion:
'BAC#www.infragistics.com
'FWD#www.amazon.com
'CUR#www.cnn.com
'We are splitting each line item and checking to see if
'it is a Back, Forward or Current item.
Dim theHistItem As String() = theLineItem.Split("#".ToCharArray())
Select Case theHistItem(0)
Case "BAC"
'Add it to the Back History List.
theBackHistoryItems.Add(New NavigationHistoryItem(theHistItem(1)))
Exit Select
Case "FWD"
'Add it to the Forward History List.
theForwardHistoryItems.Add(New NavigationHistoryItem(theHistItem(1)))
Exit Select
Case "CUR"
'Create a Current Navigation History Item.
theCurrentNavItem = New NavigationHistoryItem(theHistItem(1))
Exit Select
End Select
theLineItem = theStreamReader.ReadLine()
End While
'Cleanup.
theStreamReader.Close()
theStreamReader.Dispose()
'Use the InitializeHistory method to populate the
'Navigation Toolbar's Back, Forward and Current History Items.
theNavToolbar.InitializeHistory(theBackHistoryItems.ToArray(), theForwardHistoryItems.ToArray(), theCurrentNavItem)
End Sub