Ink.DeleteStrokes (Método) (Strokes)
Actualización: noviembre 2007
Elimina la colección Strokes especificada del objeto Ink.
Espacio de nombres: Microsoft.Ink
Ensamblado: Microsoft.Ink (en Microsoft.Ink.dll)
Sintaxis
'Declaración
Public Sub DeleteStrokes ( _
strokes As Strokes _
)
'Uso
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
)
Parámetros
- strokes
Tipo: Microsoft.Ink.Strokes
La colección Strokes que se va a eliminar.
Comentarios
El objeto Ink vuelve a numerar los índices de los objetos Stroke restantes en el objeto Ink si los objetos Stroke que se eliminaron no están al final de la colección Strokes del objeto Ink.
El método DeleteStrokes puede producir un error si se llama mientras el usuario está disponiendo entradas manuscritas de forma activa.
Nota
Una colección Strokes que señala a una propiedad Ink.Strokes se vuelve no válida cuando los objetos Stroke incluidos en la colección original se eliminan del objeto Ink. Por ejemplo, si hay una colección Strokes con nombre, theStrokesToo, que está basada en la propiedad Strokes de un objeto Ink, theStrokes y se llaman al método DeleteStrokes en theStrokes, theStrokesToo se vuelve no válida.
Para eliminar solamente un objeto Stroke a la vez, llame al método DeleteStroke.
Ejemplos
En este ejemplo se incluye una función de ejemplo que elimina todos los objetos Stroke del objeto InkOverlay pasado que contienen un punto Point a la izquierda (en espacio en píxeles) del parámetro LeftInPixels.
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();
}
Plataformas
Windows Vista
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Información de versión
.NET Framework
Compatible con: 3.0