次の方法で共有


RecognitionResult.ModifyTopAlternate メソッド

既知の RecognitionAlternate オブジェクトを使用して、RecognitionResult オブジェクトを変更します。

名前空間 :  Microsoft.Ink
アセンブリ :  Microsoft.Ink (Microsoft.Ink.dll 内)

構文

'宣言
Public Sub ModifyTopAlternate ( _
    alternate As RecognitionAlternate _
)
'使用
Dim instance As RecognitionResult
Dim alternate As RecognitionAlternate

instance.ModifyTopAlternate(alternate)
public void ModifyTopAlternate(
    RecognitionAlternate alternate
)
public:
void ModifyTopAlternate(
    RecognitionAlternate^ alternate
)
public void ModifyTopAlternate(
    RecognitionAlternate alternate
)
public function ModifyTopAlternate(
    alternate : RecognitionAlternate
)

パラメータ

解説

既定の設定では、RecognitionResult オブジェクトの TopString プロパティは TopAlternate プロパティに対応していますが、このメソッドを使用すると、結果の中の最上位代替候補以外の代替候補を使用できます。最上位代替候補以外の代替候補を選択すると、結果に関連付けられた代替候補のラティスの中の別のパスを選択したことになります。

RecognitionResult オブジェクトの変更に使用可能な RecognitionAlternate オブジェクトを取得するには、GetAlternatesFromSelection メソッドを呼び出します。

このメソッドで使用する代替候補として、文全体の中の単語代替候補を指定することができます。たとえば、"Hello World" に対して GetAlternatesFromSelection(0,5) を呼び出して取得した代替候補に対して ModifyTopAlternate メソッドを呼び出すと、"Hello" が変更され、"World" は変更されずにそのままになります。

ms569793.alert_note(ja-jp,VS.90).gifメモ :

ModifyTopAlternate メソッドを呼び出すと、RecognitionResult オブジェクトの TopString プロパティおよび TopAlternate プロパティが変更される場合があります。

この C# の例では、RecognitionResult オブジェクトとその RecognitionAlternate オブジェクトを追跡します。次に、RecognitionResult オブジェクトを、認識された Stroke オブジェクトを使用して保存します。この処理には、SetResultOnStrokes メソッドを使用します。最後に、ユーザー入力に基づいて RecognitionResult オブジェクトの TopAlternate プロパティを変更します。

[C#]

// Declarations...
InkCollector theInkCollector;
Strokes theStrokes;
RecognizerContext theRecognizerContext;
RecognitionResult theRecognitionResult;

// Initialization...

// Initialize the recognizer's strokes
// and assign them to the context.
theStrokes = theInkCollector.Ink.Strokes;
theRecognizerContext = new RecognizerContext();
theRecognizerContext.Strokes = theStrokes;

// Install event handlers.
theRecognizerContext.RecognitionWithAlternates +=
    new RecognizerContextRecognitionWithAlternatesEventHandler(
        RecognitionWithAlternates_Event);

//...

// Recognition Event Handler
private void RecognitionWithAlternates_Event(
    object sender,
    RecognizerContextRecognitionWithAlternatesEventArgs e)
{
    // Save the RecognitionResult, and copy it to the strokes
    theRecognitionResult = e.Result;
    theRecognitionResult.SetResultOnStrokes();
}

// Modify the TopAlternate of the result
private void buttonAlt2_Click(object sender, System.EventArgs e)
{
    RecognitionAlternates theRecognitionAlternates =
        theRecognitionResult.GetAlternatesFromSelection(0, -1);
    theRecognitionResult.ModifyTopAlternate(theRecognitionAlternates[2]);
}

この Microsoft® Visual Basic® .NET の例では、RecognitionResult オブジェクトとその RecognitionAlternate オブジェクトを追跡します。次に、RecognitionResult オブジェクトを、認識された Stroke オブジェクトを使用して保存します。この処理には、SetResultOnStrokes メソッドを使用します。最後に、ユーザー入力に基づいて RecognitionResult オブジェクトの TopAlternate プロパティを変更します。

[Visual Basic]

'Declarations...
Dim theInkCollector As InkCollector
Dim theStrokes As Strokes
Dim theRecognizerContext As RecognizerContext
Dim theRecognitionResult As RecognitionResult

'Initialization...

'Initialize the recognizer's strokes
'and assign them to the context.
theStrokes = theInkCollector.Ink.Strokes
theRecognizerContext = new RecognizerContext()
theRecognizerContext.Strokes = theStrokes

'Install event handlers.
AddHandler theRecognizerContext.RecognitionWithAlternates, _
AddressOf RecognitionWithAlternates_Event

'...

'Recognition Event Handler
Private Sub RecognitionWithAlternates_Event( _
ByVal sender As Object, _
ByVal e As RecognizerContextRecognitionWithAlternatesEventArgs)
    'Save the RecognitionResult, and copy it to the strokes.
    theRecognitionResult = e.Result
    theRecognitionResult.SetResultOnStrokes()
End Sub

'Modify the TopAlternate of the result
Private Sub ButtonAlt2_Click(object sender, System.EventArgs e) _
Handles ButtonAlt2.Click
    RecognitionAlternates theRecognitionAlternates =
        theRecognitionResult.GetAlternatesFromSelection(0, -1)
    theRecognitionResult.ModifyTopAlternate(theRecognitionAlternates(2))
End Sub

プラットフォーム

Windows Vista

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

RecognitionResult クラス

RecognitionResult メンバ

Microsoft.Ink 名前空間

RecognitionAlternate

RecognitionResult.GetAlternatesFromSelection

RecognitionResult.TopAlternate

RecognitionResult.TopString