Compartir a través de


Renderer.PixelToInkSpace (Método) (Graphics, Point%)

Actualización: noviembre 2007

Convierte una ubicación que está en coordenadas espaciales en píxeles a coordenadas espaciales de entrada manuscrita utilizando un objeto Graphics para la conversión.

Espacio de nombres:  Microsoft.Ink
Ensamblado:  Microsoft.Ink (en Microsoft.Ink.dll)

Sintaxis

'Declaración
Public Sub PixelToInkSpace ( _
    g As Graphics, _
    ByRef pt As Point _
)
'Uso
Dim instance As Renderer
Dim g As Graphics
Dim pt As Point

instance.PixelToInkSpace(g, pt)
public void PixelToInkSpace(
    Graphics g,
    ref Point pt
)
public:
void PixelToInkSpace(
    Graphics^ g, 
    Point% pt
)
public void PixelToInkSpace(
    Graphics g,
    /** @ref */Point pt
)
public function PixelToInkSpace(
    g : Graphics, 
    pt : Point
)

Parámetros

  • pt
    Tipo: System.Drawing.Point%
    Punto que se desea convertir en una ubicación espacial de entrada manuscrita.

Comentarios

El método PixelToInkSpace convierte los píxeles en espacio de entrada manuscrita (en el que una unidad HIMETRIC = 0,01 mm), aplica el inverso de la transformación de vista y, a continuación, aplica la transformación de objeto.

Ejemplos

En este ejemplo se muestra un método que elimina todos los objetos Stroke del objeto InkOverlay pasado que contienen un 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

Vea también

Referencia

Renderer (Clase)

Renderer (Miembros)

PixelToInkSpace (Sobrecarga)

Microsoft.Ink (Espacio de nombres)

Renderer.InkSpaceToPixel