次の方法で共有


Renderer.Draw メソッド (Graphics, Stroke, DrawingAttributes)

指定した Graphics サーフェイスで、DrawingAttributes を使用して Stroke オブジェクトを描画します。

名前空間 :  Microsoft.Ink
アセンブリ :  Microsoft.Ink (Microsoft.Ink.dll 内)

構文

'宣言
Public Sub Draw ( _
    g As Graphics, _
    stroke As Stroke, _
    da As DrawingAttributes _
)
'使用
Dim instance As Renderer
Dim g As Graphics
Dim stroke As Stroke
Dim da As DrawingAttributes

instance.Draw(g, stroke, da)
public void Draw(
    Graphics g,
    Stroke stroke,
    DrawingAttributes da
)
public:
void Draw(
    Graphics^ g, 
    Stroke^ stroke, 
    DrawingAttributes^ da
)
public void Draw(
    Graphics g,
    Stroke stroke,
    DrawingAttributes da
)
public function Draw(
    g : Graphics, 
    stroke : Stroke, 
    da : DrawingAttributes
)

パラメータ

解説

ms569829.alert_note(ja-jp,VS.90).gifメモ :

可能な場合は必ず、IntPtr を受け入れるオーバーロードではなく、Graphics オブジェクトを受け入れる適切なオーバーロードを使用します。

ペンの幅は、SetViewTransform メソッドをどのように使用するかに基づいて適切に調整されます。具体的には、ペンの幅がビュー変換の行列式の平方根で乗算 (またはスケーリング) されます。

ms569829.alert_note(ja-jp,VS.90).gifメモ :

ペンの幅を明示的に設定していない場合は、既定値の 53 になります。正しい境界ボックスを生成するためには、ペンの幅を行列式の平方根で乗算する必要があります。境界ボックスの高さと幅はそれぞれ、この計算結果値の 1/2 だけ拡大されます。

たとえば、ペンの幅が 53 で行列式の平方根が 50、境界ボックスが (0,0,1000,1000) であるとします。ペンの幅は (53 * 50) / 2 の計算結果に従って、境界ボックスの各方向に対して調整され、右側と下側は 1 ずつ増分されます。この結果、(-1325,-1325, 2326, 2326) の境界ボックスが描画されます。

Renderer オブジェクトは、ビューポートとウィンドウの原点を強制的に 0,0 にします。既存の設定は保存されて復元されますが、Renderer によっては使用されません。スクロールを実行するには、Renderer オブジェクトの GetViewTransform メソッドおよび GetObjectTransform メソッドを使用します。

この例では、InkOverlay オブジェクトに関連付けられた Ink オブジェクトの Strokes コレクション全体が、InkOverlay オブジェクト自身に関連付けられたオブジェクト上にではなく、Panel 上に表示されます。

さらに、もう一方のパネル上に Stroke オブジェクトを表示するときに、変更された DrawingAttributes オブジェクトが使用されます。ストロークの色を反転し、幅を倍にするという変更が適用されます。変更された DrawingAttributes オブジェクトは、次に da パラメータを介して Draw メソッドに渡されます。これは、元のストロークの DrawingAttributes には影響を与えません。

' Access to the Ink.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 allStrokes As Strokes = mInkOverlay.Ink.Strokes
    ' get a graphics object for another panel
    Using g As Graphics = Me.panelForDraw.CreateGraphics()
        ' get a Renderer object. We could have used
        ' mInkOverlay.Renderer, this is another way
        Dim R As Renderer = New Renderer()
        ' traverse the stroke collection
        For Each oneStroke As Stroke In allStrokes
            Dim da As DrawingAttributes = oneStroke.DrawingAttributes.Clone()
            ' invert the stroke color
            Dim cR As Byte = Not da.Color.R
            Dim cG As Byte = Not da.Color.G
            Dim cB As Byte = Not da.Color.B
            da.Color = Color.FromArgb(da.Color.A, cR, cG, cB)
            ' double the stroke width
            da.Width *= 2
            ' draw the stroke
            R.Draw(g, oneStroke, da)
        Next
    End Using
End Using
// Access to the Ink.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 allStrokes = mInkOverlay.Ink.Strokes)
{
    // get a graphics object for another panel
    using (Graphics g = this.panelForDraw.CreateGraphics())
    {
        // get a Renderer object. We could have used
        // mInkOverlay.Renderer, this is another way
        Renderer R = new Renderer();
        // traverse the stroke collection
        foreach (Stroke oneStroke in allStrokes)
        {
            DrawingAttributes da = oneStroke.DrawingAttributes.Clone();
            // invert the stroke color
            byte cR = (byte)~(da.Color.R);
            byte cG = (byte)~(da.Color.G);
            byte cB = (byte)~(da.Color.B);
            da.Color = Color.FromArgb(da.Color.A, cR, cG, cB);
            // double the stroke width
            da.Width *= 2;
            // draw the stroke
            R.Draw(g, oneStroke, da);
        }
    }
}

プラットフォーム

Windows Vista

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

Renderer クラス

Renderer メンバ

Draw オーバーロード

Microsoft.Ink 名前空間

Renderer.SetViewTransform

DrawingAttributes

Strokes

Stroke