Le proprietà di Recognizer
Analizziamo qui di seguito le varie proprietà ed il
metodo recognizer della classe recognizer.
Proprietà Desc
Ha il compito di dare una descrizione alla classe Recognizer
Public ReadOnly Property Desc(ByVal LocaleID As
Integer) As String Implements Microsoft.Office.Interop.SmartTag.ISmartTagRecognizer.Desc
Get
'descrizione
della classe recognizer
Return "Descrizione
Recognizer"
End
Get
End Property
Proprietà Name:
Questa proprietà ha il compito di visualizzare
il nome nell'elenco degli smarttag (figura 5) situati nella pagina smart
tag, della finestra che viene aperta facendo click sulla voce di menu opzioni
di correzione automatica in strumenti di Word.

Figura
5
Public ReadOnly Property Name(ByVal LocaleID As
Integer) As String Implements Microsoft.Office.Interop.SmartTag.ISmartTagRecognizer.Name
Get
'nome
dello smart tag che verrà visualizzata nella finestra dei smart tag
Return "Smart
tag di Esempio"
End
Get
End Property
Proprietà ProgId:
Questa proprietà ritorna il valore id della classe Recognizer:
Public ReadOnly Property ProgId() As String Implements
Microsoft.Office.Interop.SmartTag.ISmartTagRecognizer.ProgId
Get
'ritorna
il valore dell id della classe di Recognizer
Return "SmartTagE
manuele.Recognizer"
End
Get
End Property
Metodo Recognize:
Questo metodo ha il compito di ricercare nel documento la parola "e
manuele" se viene trovata visualizza sotto la medesima parola
una sottolineatura di colore viola, che posizionando il mouse in prossimità di
essa visualizzerà l'icona dei smart Tag.
Public Sub Recognize(ByVal Text As String, ByVal
DataType As Microsoft.Office.Interop.SmartTag.IF_TYPE, ByVal LocaleID As Integer,
ByVal RecognizerSite As Microsoft.Office.Interop.SmartTag.ISmartTagRecognizerSite)
Implements Microsoft.Office.Interop.SmartTag.ISmartTagRecognizer.Recognize
'gestisco
gli eventuali errori
Try
'verifico
che il testo esista
Dim
IntPosizione As Integer
IntPosizione
= InStr(Text, "E
manuele", CompareMethod.Text) 'Text.IndexOf("Ema")
'
If
IntPosizione > 0 Then
'creo
un property bag
Dim
propbag As Microsoft.Office.Interop.SmartTag.ISmartTagProperties
propbag
= RecognizerSite.GetNewPropertyBag
Dim
StrTipoProperty As String
Select
Case DataType
Case
IF_TYPE.IF_TYPE_CELL
StrTipoProperty
= "IF_TYPE_CELL"
Case
IF_TYPE.IF_TYPE_CHAR
StrTipoProperty
= "IF_TYPE_CHAR"
Case
IF_TYPE.IF_TYPE_PARA
StrTipoProperty
= "IF_TYPE_PARA"
Case
IF_TYPE.IF_TYPE_REGEXP
StrTipoProperty
= "IF_TYPE_REGEXP"
Case
IF_TYPE.IF_TYPE_SINGLE_WD
StrTipoProperty
= "IF_TYPE_SINGLE_WD"
End
Select
propbag.Write("DataType",
StrTipoProperty)
'aggiongo
il testo alla funzione testo
propbag.Write("Text",
Text)
'aggiungo
l'id
propbag.Write("LocaleID",
LocaleID.ToString())
RecognizerSite.CommitSmartTag("urn:esempio-smarttag#SmartTagE
manuele", IntPosizione + 1, 8, propbag)
End
If
Catch
ex As Exception
EventLog.WriteEntry("SmartTag",
ex.Message, EventLogEntryType.Error)
End
Try
End Sub
|