共用方式為


RecognitionAlternate.GetPropertyValue 方法

傳回 RecognitionAlternate 物件的指定之 RecognitionProperty 的值。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public Function GetPropertyValue ( _
    g As Guid _
) As Byte()
'用途
Dim instance As RecognitionAlternate
Dim g As Guid
Dim returnValue As Byte()

returnValue = instance.GetPropertyValue(g)
public byte[] GetPropertyValue(
    Guid g
)
public:
array<unsigned char>^ GetPropertyValue(
    Guid g
)
public byte[] GetPropertyValue(
    Guid g
)
public function GetPropertyValue(
    g : Guid
) : byte[]

參數

傳回值

型別:array<System.Byte[]
以位元組陣列格式傳回屬性型別的值。各屬性型別之傳回值的解譯不盡相同。

備註

這個方法可以用來為 RecognitionAlternate 物件上沒有對應之 Helper 屬性的 RecognitionProperty 物件取得屬性值。RecognitionAlternate 物件上的 Helper 屬性包括 ConfidenceLineNumber 屬性。

下表說明以位元組陣列方式傳回的型別值。

RecognitionProperty 型別

描述

ConfidenceLevel

RecognitionConfidence 列舉值

HotPoint

Point (英文) 物件

LineMetrics

相當於 LATTICE_METRICS Structure 結構

LineNumber

Int32 (英文) 值

MaximumStrokeCount

未使用

PointsPerInch

未使用

Segmentation

未使用。請改用 AlternatesWithConstantPropertyValues 方法。

若要知道哪些 Recognizer 屬性公開在替代項目上,請先使用 SupportedProperties 屬性查看可能可用的屬性。這些屬性不一定會傳遞至 RecognitionAlternate。然後,使用 GetPropertyValue 確定哪些屬性公開在 RecognitionAlternate 上。

ms569785.alert_note(zh-tw,VS.90).gif注意事項:

並非所有 Recognizer 屬性都會傳遞至 RecognitionAlternate 物件,例如 Microsoft® 筆勢辨識器會公開只能透過 SupportedProperties 屬性來查詢的 HotPointHotPoint 屬性未公開在 RecognitionAlternate 上。

範例

這個 C# 範例會顯示 Strokes 集合辨識所使用的基線。GetPropertyValue 方法會從最佳替代項目取得行度量資訊 (Metric)。然後,Renderer 物件會附加至 InkOverlay (變數名稱為 theInkOverlay),它是用來將筆墨空間座標轉換為像素座標。最後,會將基線繪製成綠色。這個範例假設您已經確定 SupportedProperties 屬性有支援 LineMetrics 屬性。

[C#]

using Microsoft.Ink;
using System.Drawing.Drawing2D;
using System.IO;
//...
    private void DrawBaseline(Strokes theStrokes)
    {
        // Get the top alternate for all the strokes
        RecognizerContext context = new RecognizerContext();
        context.Strokes = theStrokes;
        RecognitionStatus status = new RecognitionStatus();
        RecognitionResult result = context.Recognize(out status);
        RecognitionAlternate topAlternate = result.TopAlternate;

        // Get the line metrics from the top alternate
        byte [] byteArray = topAlternate.GetPropertyValue(RecognitionProperty.LineMetrics);
        using (MemoryStream stream = new MemoryStream(byteArray))
        using (BinaryReader reader = new BinaryReader(stream))
        {
            int startX = reader.ReadInt32();
            int startY = reader.ReadInt32();
            int endX = reader.ReadInt32();
            int endY = reader.ReadInt32();

            // Convert baseline to pixel coordinates
            Graphics tempGraphics = CreateGraphics();
            Point startPoint = new Point(startX, startY);
            Point endPoint = new Point(endX, endY);
            theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, ref startPoint);
            theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, ref endPoint);
            tempGraphics.DrawLine(new Pen(Color.Green), startPoint, endPoint);

            // Dispose of temporary graphics
            tempGraphics.Dispose();
        }
    }

這個 Microsoft Visual Basic® .NET 範例會顯示 Strokes 集合辨識所使用的基線。GetPropertyValue 方法會從最佳替代項目取得行度量資訊。然後,Renderer 物件會附加至 InkOverlay (變數名稱為 theInkOverlay),它是用來將筆墨空間座標轉換為像素座標。最後,會將基線繪製成綠色。這個範例假設您已經確定 SupportedProperties 屬性有支援 LineMetrics 屬性。

[Visual Basic]

Imports Microsoft.Ink
Imports System.Drawing.Drawing2D
Imports System.IO
'...
    Private Sub DrawBaseline(ByVal theStrokes As Strokes)
        ' Get the top alternate for all the strokes
        Dim context As New RecognizerContext()
        context.Strokes = theStrokes
        Dim status As New RecognitionStatus()
        Dim result As RecognitionResult = context.Recognize(status)
        Dim topAlternate As RecognitionAlternate = result.TopAlternate

        ' Get the line metrics from the top alternate
        Dim byteArray() As Byte = topAlternate.GetPropertyValue(RecognitionProperty.LineMetrics)
        Dim stream As New MemoryStream(byteArray)
        Dim reader As New BinaryReader(stream)

        Dim startX As Integer = reader.ReadInt32()
        Dim startY As Integer = reader.ReadInt32()
        Dim endX As Integer = reader.ReadInt32()
        Dim endY As Integer = reader.ReadInt32()

        ' Convert baseline to pixel coordinates
        Dim tempGraphics As Graphics = CreateGraphics()
        Dim startPoint As New Point(startX, startY)
        Dim endPoint As New Point(endX, endY)
        theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, startPoint)
        theInkOverlay.Renderer.InkSpaceToPixel(tempGraphics, endPoint)
        tempGraphics.DrawLine(New Pen(Color.Green), startPoint, endPoint)

        ' Clean up
        tempGraphics.Dispose()
        reader.Close()
        stream.Close()
    End Sub

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

RecognitionAlternate 類別

RecognitionAlternate 成員

Microsoft.Ink 命名空間

RecognitionAlternate.AlternatesWithConstantPropertyValues

RecognitionProperty