Renderer.Draw メソッド (Graphics, Stroke)
指定した Graphics サーフェイスで Stroke オブジェクトを描画します。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Sub Draw ( _
g As Graphics, _
stroke As Stroke _
)
'使用
Dim instance As Renderer
Dim g As Graphics
Dim stroke As Stroke
instance.Draw(g, stroke)
public void Draw(
Graphics g,
Stroke stroke
)
public:
void Draw(
Graphics^ g,
Stroke^ stroke
)
public void Draw(
Graphics g,
Stroke stroke
)
public function Draw(
g : Graphics,
stroke : Stroke
)
パラメータ
- g
型 : System.Drawing.Graphics
描画に使用する Graphics オブジェクト。
- stroke
型 : Microsoft.Ink.Stroke
描画する Stroke オブジェクト。
解説
メモ : |
---|
可能な場合は必ず、IntPtr を受け入れるオーバーロードではなく、Graphics オブジェクトを受け入れる適切なオーバーロードを使用します。 |
ペンの幅は、SetViewTransform メソッドをどのように使用するかに基づいて適切に調整されます。具体的には、ペンの幅がビュー変換の行列式の平方根で乗算 (またはスケーリング) されます。
メモ : |
---|
ペンの幅を明示的に設定していない場合は、既定値の 53 になります。正しい境界ボックスを生成するためには、ペンの幅を行列式の平方根で乗算する必要があります。境界ボックスの高さと幅はそれぞれ、この計算結果値の 1/2 だけ拡大されます。 |
たとえば、ペンの幅が 53 で行列式の平方根が 50、境界ボックスが (0,0,1000,1000) であるとします。ペンの幅は (53 * 50) / 2 の計算結果に従って、境界ボックスの各方向に対して調整され、右側と下側は 1 ずつ増分されます。この結果、(-1325,-1325, 2326, 2326) の境界ボックスが描画されます。
Renderer オブジェクトは、ビューポートとウィンドウの原点を強制的に 0,0 にします。既存の設定は保存されて復元されますが、Renderer によっては使用されません。スクロールを実行するには、Renderer オブジェクトの GetViewTransform メソッドおよび GetObjectTransform メソッドを使用します。
例
この例では、Ink オブジェクト内に Stroke オブジェクトが作成されます。ストロークは、インク領域の左上隅から右下隅に引かれます。オブジェクトが作成されると、InkOverlay オブジェクトに関連付けられた Panel に加えて、もう一方のパネルにもストロークが表示されます。これは、Draw メソッドを 2 回呼び出し、g パラメータに異なる Graphics オブジェクトを渡すことによって実現されます。
' get the bottom right point of the client area for ink
' Note: InkOverlay.AttachedControl property must be set
Dim bottomRight As Point = New Point(mInkOverlay.AttachedControl.ClientSize)
Using g1 As Graphics = mInkOverlay.AttachedControl.CreateGraphics()
' convert to HIMETRIC units
mInkOverlay.Renderer.PixelToInkSpace(g1, bottomRight)
' create the stroke
Dim strokePoints As Point() = New Point(1) {New Point(0), bottomRight}
Dim oneStroke As Stroke = mInkOverlay.Ink.CreateStroke(strokePoints)
' draw the stroke on the control attached to InkOverlay
mInkOverlay.Renderer.Draw(g1, oneStroke)
' now draw the stroke on another control also
Using g2 As Graphics = Me.panelForDraw.CreateGraphics()
mInkOverlay.Renderer.Draw(g2, oneStroke)
End Using
End Using
// get the bottom right point of the client area for ink
// Note: InkOverlay.AttachedControl property must be set
Point bottomRight = new Point(mInkOverlay.AttachedControl.ClientSize);
using (Graphics g1 = mInkOverlay.AttachedControl.CreateGraphics())
{
// convert to HIMETRIC units
mInkOverlay.Renderer.PixelToInkSpace(g1, ref bottomRight);
// create the stroke
Point[] strokePoints = new Point[2] { new Point(0), bottomRight };
Stroke oneStroke = mInkOverlay.Ink.CreateStroke(strokePoints);
// draw the stroke on the control attached to InkOverlay
mInkOverlay.Renderer.Draw(g1, oneStroke);
// now draw the stroke on another control also
using (Graphics g2 = this.panelForDraw.CreateGraphics())
{
mInkOverlay.Renderer.Draw(g2, oneStroke);
}
}
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0