Stroke.GetPacketValuesByProperty 方法 (Guid, Int32)

返回 Stroke 对象中一个数据包的指定数据包 属性的数据。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Function GetPacketValuesByProperty ( _
    id As Guid, _
    index As Integer _
) As Integer()
用法
Dim instance As Stroke
Dim id As Guid
Dim index As Integer
Dim returnValue As Integer()

returnValue = instance.GetPacketValuesByProperty(id, _
    index)
public int[] GetPacketValuesByProperty(
    Guid id,
    int index
)
public:
array<int>^ GetPacketValuesByProperty(
    Guid id, 
    int index
)
public int[] GetPacketValuesByProperty(
    Guid id,
    int index
)
public function GetPacketValuesByProperty(
    id : Guid, 
    index : int
) : int[]

参数

  • index
    类型:System.Int32
    Stroke 对象中数据包的从零开始的索引的起始点。

返回值

类型:array<System.Int32[]
返回一个有符号 32 位整数数组,该数组指定对 Stroke 对象中的每个请求点所请求的 PacketProperty 对象的值。

备注

特定的 Stroke 对象可能未提供特定的数据包属性。一台 Tablet PC 可能有多个 Tablet 可供用户输入。Tablets 集合包含附加到 Tablet PC 的所有 Tablet 的列表。使用 IsPacketPropertySupported 方法可确定特定的 Tablet 对象或所有可用 Tablet 是否支持特定的数据包属性。此外,使用 InkCollector.DesiredPacketDescriptionInkOverlay.DesiredPacketDescriptionInkPicture.DesiredPacketDescription 属性还可以控制收集新笔画的哪些数据包属性。

示例

在此示例中,修改 InkOverlay 对象的所有选定 Stroke 对象,以便该笔画的后半部分的每个点包含允许的最大 NormalPressure 数据包值。

使用 GetPacketValuesByProperty 方法获取 Stroke 对象的后半部分的 NormalPressure 数据包值。然后,使用 SetPacketValuesByProperty 方法将这些值设置为最大允许值(通过 GetPacketDescriptionPropertyMetrics 方法获取),并将这些值重新应用于该笔画。

Try
    For Each S As Stroke In mInkOverlay.Selection
        ' get the PacketProperty.NormalPressure metrics for the stroke
        Dim metrics As TabletPropertyMetrics = S.GetPacketDescriptionPropertyMetrics(PacketProperty.NormalPressure)
        ' get the starting point
        Dim startPt As Integer = S.PacketCount / 2
        ' get the NormalPressure values starting at startPt
        Dim npValues() As Integer = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, startPt)
        ' set the NormalPressure values to max
        For k As Integer = 0 To npValues.Length - 1
            npValues(k) = metrics.Maximum
        Next
        ' set the NormalPressure values starting at startPt
        S.SetPacketValuesByProperty(PacketProperty.NormalPressure, startPt, npValues)
    Next

Catch ex As ArgumentException
    ' This exception will be raised if PacketProperty.NormalPressure is not supported
    ' This will be the case if creating strokes with a mouse
End Try
try
{
    foreach (Stroke S in mInkOverlay.Selection)
    {
        // get the PacketProperty.NormalPressure metrics for the stroke
        TabletPropertyMetrics metrics = S.GetPacketDescriptionPropertyMetrics(PacketProperty.NormalPressure);
        // get the starting point
        int startPt = S.PacketCount / 2;
        // get the NormalPressure values starting at startPt
        int[] npValues = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, startPt);
        // set the NormalPressure values to max
        for (int k = 0; k < npValues.Length; k++)
        {
            npValues[k] = metrics.Maximum;
        }
        // set the NormalPressure values starting at startPt
        S.SetPacketValuesByProperty(PacketProperty.NormalPressure, startPt, npValues);
    }
}
catch (ArgumentException)
{
    // This exception will be raised if PacketProperty.NormalPressure is not supported
    // This will be the case if creating strokes with a mouse
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Stroke 类

Stroke 成员

GetPacketValuesByProperty 重载

Microsoft.Ink 命名空间

InkCollector.DesiredPacketDescription

InkOverlay.DesiredPacketDescription

InkPicture.DesiredPacketDescription

PacketProperty

Tablet

Tablet.IsPacketPropertySupported

Tablets

Tablets.IsPacketPropertySupported