Renderer.PixelToInkSpace-Methode (Graphics, Point%)
Konvertiert eine Position in Pixelbereichkoordinaten mithilfe eines Graphics-Objekts in eine Position in Freihandbereichkoordinaten.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Sub PixelToInkSpace ( _
g As Graphics, _
ByRef pt As Point _
)
'Usage
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
)
Parameter
- g
Typ: System.Drawing.Graphics
Das Graphics-Objekt, das für die Konvertierung verwendet werden soll. Die Quelle hierfür sind i. d. R. Ereignisargumente oder die System.Windows.Forms.Control.CreateGraphics-Methode.
- pt
Typ: System.Drawing.Point%
Der Punkt, der in eine Freihandbereichsposition konvertiert werden soll.
Hinweise
Die PixelToInkSpace-Methode führt eine Konvertierung von Pixel in Freihandbereicheinheiten durch (wobei eine HIMETRIC-Einheit = 0,01 mm ist), wendet die Umkehrung der Ansichtstransformation und anschließend die Objekttransformation an.
Beispiele
Dieses Beispiel zeigt eine Methode, die alle Stroke-Objekte des übergebenen InkOverlay-Objekts löscht, die einen Point links (im Pixelbereich) vom Parameter LeftInPixels enthalten.
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();
}
Plattformen
Windows Vista
.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.
Versionsinformationen
.NET Framework
Unterstützt in: 3.0