次の方法で共有


Renderer.Draw メソッド (IntPtr, Strokes)

ハンドルが渡されるデバイス コンテキストに Strokes コレクションを描画します。

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

構文

'宣言
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name := "FullTrust")> _
<UIPermissionAttribute(SecurityAction.Demand, Window := UIPermissionWindow.SafeTopLevelWindows)> _
<SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode := True)> _
Public Sub Draw ( _
    hdc As IntPtr, _
    strokes As Strokes _
)
'使用
Dim instance As Renderer
Dim hdc As IntPtr
Dim strokes As Strokes

instance.Draw(hdc, strokes)
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
[UIPermissionAttribute(SecurityAction.Demand, Window = UIPermissionWindow.SafeTopLevelWindows)]
[SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true)]
public void Draw(
    IntPtr hdc,
    Strokes strokes
)
[PermissionSetAttribute(SecurityAction::InheritanceDemand, Name = L"FullTrust")]
[UIPermissionAttribute(SecurityAction::Demand, Window = UIPermissionWindow::SafeTopLevelWindows)]
[SecurityPermissionAttribute(SecurityAction::Demand, UnmanagedCode = true)]
public:
void Draw(
    IntPtr hdc, 
    Strokes^ strokes
)
/** @attribute PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust") */
/** @attribute UIPermissionAttribute(SecurityAction.Demand, Window = UIPermissionWindow.SafeTopLevelWindows) */
/** @attribute SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true) */
public void Draw(
    IntPtr hdc,
    Strokes strokes
)
public function Draw(
    hdc : IntPtr, 
    strokes : Strokes
)

パラメータ

  • hdc
    型 : System.IntPtr
    描画するデバイス コンテキストのハンドル。

解説

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

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

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

ms569821.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 メソッドを使用します。

ms569821.alert_security(ja-jp,VS.90).gifセキュリティに関するメモ :

部分信頼で使用している場合、このメソッドには InkCollector により必要とされるアクセス許可に加えて、SecurityPermissionFlag.UnmanagedCode アクセス許可が必要です。セキュリティの問題と部分信頼の詳細については、「Security and Trust」を参照してください。

この例では、InkOverlay オブジェクトに関連付けられた Ink オブジェクトの Strokes コレクション全体が、InkOverlay オブジェクト自身に関連付けられたオブジェクト上にではなく、Panel 上に表示されます。これは、Draw メソッドを呼び出し、hdc パラメータに InkOverlay オブジェクトに関連付けられているものとは異なるデバイス コンテキスト ハンドルを渡すことによって実現されます。

' 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()
        ' get the handle to the device context
        Dim hdc As IntPtr = g.GetHdc()
        ' draw the strokes
        R.Draw(hdc, allStrokes)
        ' release the handle to the device context
        g.ReleaseHdc(hdc)
    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();
        // get the handle to the device context
        IntPtr hdc = g.GetHdc();
        // draw the strokes
        R.Draw(hdc, allStrokes);
        // release the handle to the device context
        g.ReleaseHdc();
    }
}

プラットフォーム

Windows Vista

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

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

Renderer クラス

Renderer メンバ

Draw オーバーロード

Microsoft.Ink 名前空間

Renderer.SetViewTransform

DrawingAttributes

Strokes

Stroke