Stroke オブジェクトをパケット データから作成します。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Function CreateStroke ( _
packetData As Integer(), _
tabletPropertyDescriptionCollection As TabletPropertyDescriptionCollection _
) As Stroke
'使用
Dim instance As Ink
Dim packetData As Integer()
Dim tabletPropertyDescriptionCollection As TabletPropertyDescriptionCollection
Dim returnValue As Stroke
returnValue = instance.CreateStroke(packetData, _
tabletPropertyDescriptionCollection)
public Stroke CreateStroke(
int[] packetData,
TabletPropertyDescriptionCollection tabletPropertyDescriptionCollection
)
public:
Stroke^ CreateStroke(
array<int>^ packetData,
TabletPropertyDescriptionCollection^ tabletPropertyDescriptionCollection
)
public Stroke CreateStroke(
int[] packetData,
TabletPropertyDescriptionCollection tabletPropertyDescriptionCollection
)
public function CreateStroke(
packetData : int[],
tabletPropertyDescriptionCollection : TabletPropertyDescriptionCollection
) : Stroke
パラメータ
- packetData
型 : array<System.Int32[]
Stroke オブジェクトを構成するために使用されるパケット データの配列。
- tabletPropertyDescriptionCollection
型 : Microsoft.Ink.TabletPropertyDescriptionCollection
packetData 配列内のプロパティを記述する TabletPropertyDescriptionCollection コレクション。
戻り値
型 : Microsoft.Ink.Stroke
新しく作成されたストローク。
新しく作成された Stroke オブジェクト。
解説
packetData パラメータ内の配列のサイズは、tabletPropertyDescriptionCollection パラメータのサイズで割り切れる必要があります。
![]() |
---|
packetData パラメータ内の各パケットの最初の 2 つの要素は X と Y であることが必要です。各パケットの 1 番目の位置に X、2 番目の位置に Y が指定されていない場合は、ArgumentException がスローされます。 |
例
この例では、ランダムなパケット データから不規則な正弦波を表すストロークが作成されます。まず、PacketPropertyX および Y の TabletPropertyMetrics が取得され、これらの PacketProperty 型の TabletPropertyDescription オブジェクトで TabletPropertyDescriptionCollection が初期化されます。既定のタブレットで NormalPressure がサポートされている場合は、これもこのコレクションに追加されます。次に、実際のパケット データが作成され、CreateStroke メソッドに渡されます。
Dim allTablets As Tablets = New Tablets()
' get the property metrics for X and Y
Dim MetricX As TabletPropertyMetrics = allTablets.DefaultTablet.GetPropertyMetrics(PacketProperty.X)
Dim MetricY As TabletPropertyMetrics = allTablets.DefaultTablet.GetPropertyMetrics(PacketProperty.Y)
' create the TabletPropertyDescriptionCollection, add X and Y
Dim tpDescCollection As TabletPropertyDescriptionCollection = New TabletPropertyDescriptionCollection()
tpDescCollection.Add(New TabletPropertyDescription(PacketProperty.X, MetricX))
tpDescCollection.Add(New TabletPropertyDescription(PacketProperty.Y, MetricY))
' see if the default tablet supports pressure
Dim supportPressure As Boolean = allTablets.DefaultTablet.IsPacketPropertySupported(PacketProperty.NormalPressure)
' if so, add NormalPressure to TabletPropertyDescriptionCollection
If supportPressure Then
Dim MetricP As TabletPropertyMetrics = allTablets.DefaultTablet.GetPropertyMetrics(PacketProperty.NormalPressure)
tpDescCollection.Add(New TabletPropertyDescription(PacketProperty.NormalPressure, MetricP))
End If
' init random number generator
Dim R As Random = New Random()
' init total PacketCount, slotPerPacket and packet data array
Const PACKET_COUNT As Integer = 250
Dim slotPerPacket As Integer = tpDescCollection.Count
Dim pData((PACKET_COUNT * slotPerPacket) - 1) As Integer
' assign packet values
For k As Integer = 0 To PACKET_COUNT - 1
' assign X - X will increment by 106
pData(k * slotPerPacket) = (k * 106)
' assign Y - Y will be 6000 +- 1500
pData((k * slotPerPacket) + 1) = 6000 + R.Next(-1500, 1500)
' assign Pressure if supported, 25-255
If (supportPressure) Then
pData((k * slotPerPacket) + 2) = R.Next(25, 255)
End If
next
' create the Stroke
mInkOverlay.Ink.CreateStroke(pData, tpDescCollection)
mInkOverlay.AttachedControl.Invalidate()
Tablets allTablets = new Tablets();
// get the property metrics for X and Y
TabletPropertyMetrics MetricX = allTablets.DefaultTablet.GetPropertyMetrics(PacketProperty.X);
TabletPropertyMetrics MetricY = allTablets.DefaultTablet.GetPropertyMetrics(PacketProperty.Y);
// create the TabletPropertyDescriptionCollection, add X and Y
TabletPropertyDescriptionCollection tpDescCollection = new TabletPropertyDescriptionCollection();
tpDescCollection.Add(new TabletPropertyDescription(PacketProperty.X, MetricX));
tpDescCollection.Add(new TabletPropertyDescription(PacketProperty.Y, MetricY));
// see if the default tablet supports pressure
bool supportPressure = allTablets.DefaultTablet.IsPacketPropertySupported(PacketProperty.NormalPressure);
// if so, add NormalPressure to TabletPropertyDescriptionCollection
if (supportPressure)
{
TabletPropertyMetrics MetricP = allTablets.DefaultTablet.GetPropertyMetrics(PacketProperty.NormalPressure);
tpDescCollection.Add(new TabletPropertyDescription(PacketProperty.NormalPressure, MetricP));
}
// init random number generator
Random R = new Random();
// init total PacketCount, slotPerPacket and packet data array
const int PACKET_COUNT = 250;
int slotPerPacket = tpDescCollection.Count;
int[] pData = new int[PACKET_COUNT*slotPerPacket];
// assign packet values
for (int k = 0; k < PACKET_COUNT; k++)
{
// assign X - X will increment by 106
pData[k * slotPerPacket] = (k * 106);
// assign Y - Y will be 6000 +- 1500
pData[(k * slotPerPacket) + 1] = 6000 + R.Next(-1500, 1500);
// assign Pressure if supported, 25-255
if (supportPressure)
{
pData[(k * slotPerPacket) + 2] = R.Next(25, 255);
}
}
// create the Stroke
mInkOverlay.Ink.CreateStroke(pData, tpDescCollection);
mInkOverlay.AttachedControl.Invalidate();
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0
参照
参照
TabletPropertyDescriptionCollection.InkToDeviceScaleX