Renderer.PixelToInkSpace, méthode (Graphics, Point%)
Mise à jour : November 2007
Convertit un emplacement en pixels en emplacement selon les coordonnées de l'espace d'entrée manuscrite, à l'aide d'un objet Graphics (page pouvant être en anglais).
Espace de noms : Microsoft.Ink
Assembly : Microsoft.Ink (dans Microsoft.Ink.dll)
Syntaxe
'Déclaration
Public Sub PixelToInkSpace ( _
g As Graphics, _
ByRef pt As Point _
)
'Utilisation
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
)
Paramètres
- g
Type : System.Drawing.Graphics
Objet Graphics (page pouvant être en anglais) à utiliser pour la conversion. Il provient généralement des arguments d'un événement ou de la méthode System.Windows.Forms.Control.CreateGraphics (page pouvant être en anglais).
- pt
Type : System.Drawing.Point%
Le point à convertir dans un emplacement d'espace d'entrée manuscrite.
Notes
La méthode PixelToInkSpace convertit les pixels en espace d'entrée manuscrite (où une unité HIMETRIC = 0,01 mm), applique l'inverse de la transformation d'affichage, puis applique la transformation de l'objet.
Exemples
Cet exemple montre une méthode qui supprime tous les objets Stroke de l'objet InkOverlay passé qui contiennent un Point à gauche (en pixels) du paramètre 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();
}
Plateformes
Windows Vista
Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Informations de version
.NET Framework
Pris en charge dans : 3.0