変換用の Graphics オブジェクトを使用して、ピクセル空間座標での位置を、インク空間座標での位置に変換します。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Sub PixelToInkSpace ( _
g As Graphics, _
ByRef pt As Point _
)
'使用
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
)
パラメータ
- g
型 : System.Drawing.Graphics
変換に使用する Graphics オブジェクト。これは、多くの場合 System.Windows.Forms.Control.CreateGraphics メソッドまたはイベント引数から取得されます。
- pt
型 : System.Drawing.Point%
インク空間位置に変換するポイント。
解説
PixelToInkSpace メソッドは、ピクセル空間からインク空間に変換し (1 HIMETRIC 単位 = 0.01mm)、ビュー変換の逆を適用して、オブジェクト変換を適用します。
例
この例では、渡された 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