Ink.DeleteStrokes メソッド (Strokes)
指定した Strokes コレクションを Ink オブジェクトから削除します。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Sub DeleteStrokes ( _
strokes As Strokes _
)
'使用
Dim instance As Ink
Dim strokes As Strokes
instance.DeleteStrokes(strokes)
public void DeleteStrokes(
Strokes strokes
)
public:
void DeleteStrokes(
Strokes^ strokes
)
public void DeleteStrokes(
Strokes strokes
)
public function DeleteStrokes(
strokes : Strokes
)
パラメータ
- strokes
型 : Microsoft.Ink.Strokes
削除する Strokes コレクション。
解説
削除された Stroke オブジェクトが Ink オブジェクトの Strokes コレクションの最後でない場合、Ink オブジェクトは Ink オブジェクト内の残りの Stroke オブジェクトのインデックスの番号を振り直します。
DeleteStrokes メソッドは、ユーザーがインクを書き込んでいる間に呼び出されるとエラーになります。
メモ : |
---|
元のコレクションに含まれている Stroke オブジェクトが Ink オブジェクトから削除されると、Ink.Strokes プロパティを指す Strokes コレクションが無効になります。たとえば、名前付き Strokes コレクション theStrokesToo があり、これは Ink オブジェクトの Strokes プロパティ theStrokes に基づいているとします。この場合に theStrokes の DeleteStrokes メソッドを呼び出すと、theStrokesToo は無効になります。 |
一度に 1 つの Stroke オブジェクトだけを削除するには、DeleteStroke メソッドを呼び出します。
例
この例には、渡された InkOverlay オブジェクトの中で、パラメータ LeftInPixels よりも (ピクセル空間で) 左側にある Point を含むすべての Stroke オブジェクトを削除するサンプル関数が含まれます。
Private Sub DeleteStrokesByLeft(ByVal mInkOverlay As InkOverlay, ByVal LeftInPixels As Integer)
' Create a Point object based upon the Left parameter
Dim ptLeft As Point = New Point(LeftInPixels, 0)
' Convert the point from pixel space to ink space dimensions
' InkOverlay.AttachedControl must be set
Using g As Graphics = mInkOverlay.AttachedControl.CreateGraphics()
mInkOverlay.Renderer.PixelToInkSpace(g, ptLeft)
End Using
' Create a Strokes object to hold strokes to be deleted
Dim strokesToDelete As Strokes = mInkOverlay.Ink.CreateStrokes()
' Access to the Strokes property returns a copy of the Strokes object.
' This copy must be implicitly (via using statement) or explicitly
' disposed of in order to avoid a memory leak.
Using currentStrokes As Strokes = mInkOverlay.Ink.Strokes
For Each S As Stroke In currentStrokes
For Each strokePoint As Point In S.GetPoints()
If (strokePoint.X < ptLeft.X) Then
' Note: A particluar Stroke object might have several
' points to the left of ptLeft.X - Therefore, the
' following statement will be executed multiple times.
' Even so, the Add method will not add the same stroke twice.
strokesToDelete.Add(S)
End If
Next
Next
End Using
If strokesToDelete.Count > 0 Then
mInkOverlay.Ink.DeleteStrokes(strokesToDelete)
mInkOverlay.AttachedControl.Invalidate()
End If
strokesToDelete.Dispose()
End Sub
private void DeleteStrokesByLeft(InkOverlay mInkOverlay, int LeftInPixels)
{
// Create a Point object based upon the Left parameter
Point ptLeft = new Point(LeftInPixels, 0);
// Convert the point from pixel space to ink space dimensions
// InkOverlay.AttachedControl must be set
using (Graphics g = mInkOverlay.AttachedControl.CreateGraphics())
{
mInkOverlay.Renderer.PixelToInkSpace(g, ref ptLeft);
}
// Create a Strokes object to hold strokes to be deleted
Strokes strokesToDelete = mInkOverlay.Ink.CreateStrokes();
// Access to the Strokes property returns a copy of the Strokes object.
// This copy must be implicitly (via using statement) or explicitly
// disposed of in order to avoid a memory leak.
using (Strokes currentStrokes = mInkOverlay.Ink.Strokes)
{
foreach (Stroke S in currentStrokes)
{
foreach (Point strokePoint in S.GetPoints())
{
if (strokePoint.X < ptLeft.X)
{
// Note: A particluar Stroke object might have several
// points to the left of ptLeft.X - Therefore, the
// following statement will be executed multiple times.
// Even so, the Add method will not add the same stroke twice.
strokesToDelete.Add(S);
}
}
}
}
if (strokesToDelete.Count > 0)
{
mInkOverlay.Ink.DeleteStrokes(strokesToDelete);
mInkOverlay.AttachedControl.Invalidate();
}
strokesToDelete.Dispose();
}
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0