Stroke.GetPacketValuesByProperty 方法 (Guid, Int32, Int32)
傳回 Stroke 物件中某個封包範圍所指定 packet 屬性的資料。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public Function GetPacketValuesByProperty ( _
id As Guid, _
index As Integer, _
count As Integer _
) As Integer()
'用途
Dim instance As Stroke
Dim id As Guid
Dim index As Integer
Dim count As Integer
Dim returnValue As Integer()
returnValue = instance.GetPacketValuesByProperty(id, _
index, count)
public int[] GetPacketValuesByProperty(
Guid id,
int index,
int count
)
public:
array<int>^ GetPacketValuesByProperty(
Guid id,
int index,
int count
)
public int[] GetPacketValuesByProperty(
Guid id,
int index,
int count
)
public function GetPacketValuesByProperty(
id : Guid,
index : int,
count : int
) : int[]
參數
- id
型別:System.Guid
PacketProperty 物件中的 Guid 識別項,這個物件用來選取要擷取哪些封包資料。
- index
型別:System.Int32
Stroke 物件內某個封包的以零起始索引的起點。
- count
型別:System.Int32
構成筆劃資料的點數。
傳回值
型別:array<System.Int32[]
傳回帶正負號的 32 位元整數的陣列,這個陣列針對向 Stroke 物件要求的每個點指定所要求 PacketProperty 物件的值。
備註
特定封包屬性可能無法用於特定 Stroke 物件。Tablet PC 可能有一個以上的使用者輸入手寫板。Tablets 集合包含 Tablet PC 中所有附加的手寫板清單。使用 IsPacketPropertySupported 方法可判斷特殊封包屬性是由特定 Tablet 物件或是所有可用的 Tablet 支援。此外,使用 InkCollector.DesiredPacketDescription、InkOverlay.DesiredPacketDescription 或 InkPicture.DesiredPacketDescription 屬性,控制在新筆劃上收集哪些封包屬性。
範例
在這個範例中,InkOverlay 物件的每個已選取 Stroke 物件都會經過修改,使筆劃前半部的每個點都會包含允許的最小 NormalPressure 封包值。
若使用 GetPacketValuesByProperty 方法,則會取得 Stroke 物件前半部的 NormalPressure 封包值。接著這些值會設定為允許的最小值 (透過 GetPacketDescriptionPropertyMetrics 方法取得),並且使用 SetPacketValuesByProperty 方法再次套用至筆劃。
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)
' we want to get half of the NormalPressure values
Dim halfWayPt As Integer = S.PacketCount / 2
' get the NormalPressure values for the first half of the packets
Dim npValues() As Integer = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt)
' set the NormalPressure values to min
For k As Integer = 0 To npValues.Length - 1
npValues(k) = metrics.Minimum
Next
' set the NormalPressure values for the first half of the packets
S.SetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt, 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);
// we want to get half of the NormalPressure values
int halfWayPt = S.PacketCount / 2;
// get the NormalPressure values for the first half of the packets
int[] npValues = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt);
// set the NormalPressure values to min
for (int k = 0; k < npValues.Length; k++)
{
npValues[k] = metrics.Minimum;
}
// set the NormalPressure values for the first half of the packets
S.SetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt, 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
請參閱
參考
InkCollector.DesiredPacketDescription
InkOverlay.DesiredPacketDescription
InkPicture.DesiredPacketDescription