Going Offline

Next, we look at the smart tag's behavior when the computer is no longer connected to the Internet. Whenever the Recognize method is called, it first looks to see whether there is a network connection, and it adds the smart tags only if a connection exists.

1. Close the actions pane and take the computer offline (for example, disconnect your computer from the Internet).

2. Add the following text under the first paragraph: This is an example of a SmartTag and an ActionsPane. The new text should not contain the dotted line (or smart tag), but the original text still does.

3. Move your cursor over a recognized word in the original text. When you click the drop-down button of the Smart Tags Action button, the caption will read "Windows Live Search is unavailable (Offline)," as shown in Figure 9.20.

WordDocumentl.doc - Microsoft Word iQSHBi^aiyiaiJt^a^i'i'C'it.saBii'öi^iir. i5°%

File Edit View Insert Format Tools Table Window Help I Final Showing Markup - Show

44 Normal ▼ Times New Roman » 12 B I U SI H ^ ^ T | i= *=

This is fin example of a

This is an example of a

This is fin example of a

This is an example of a

Offline Example: SmartTag

lie

Windows Live Search is unavailable (Offline)

Remove this Smart Tag ^

Stop Recognizing "SmartTag" ►

Smart Tag Options...

lie

Figure 9.20. Selecting actions on a custom smart tag

If the user clicks the action, the Web page is not displayed in the actions pane because the OpenActionsPane method is not called when the computer is offline. If you go back online, the caption should change back to "Windows Live Search," but you'll need to recheck the text before all the matched words appear with smart tags. You can either place your cursor in the paragraph where the smart tag should appear and press the space bar, or call the RecheckSmartTags method on the document. This method calls into the Recognize method that you wrote, so if there is a lot of code or if the document contains a lot of smart tags, it may take a few seconds to complete the recheck. If you want to ensure that the doc ument is rechecked for smart tags each time it is opened, you can call the RecheckSmartTags method in the document's Startup event handler.

0 0

Post a comment