次の方法で共有


Renderer.Measure メソッド (Stroke, DrawingAttributes)

デバイス コンテキストで Rectangle を計算します。このデバイス コンテキストは、指定した DrawingAttributes を使用して、Renderer オブジェクトの Draw メソッドで描画される Stroke オブジェクトを含んでいる必要があります。

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

構文

'宣言
Public Function Measure ( _
    stroke As Stroke, _
    da As DrawingAttributes _
) As Rectangle
'使用
Dim instance As Renderer
Dim stroke As Stroke
Dim da As DrawingAttributes
Dim returnValue As Rectangle

returnValue = instance.Measure(stroke, _
    da)
public Rectangle Measure(
    Stroke stroke,
    DrawingAttributes da
)
public:
Rectangle Measure(
    Stroke^ stroke, 
    DrawingAttributes^ da
)
public Rectangle Measure(
    Stroke stroke,
    DrawingAttributes da
)
public function Measure(
    stroke : Stroke, 
    da : DrawingAttributes
) : Rectangle

パラメータ

戻り値

型 : System.Drawing.Rectangle
デバイス コンテキスト上の Rectangle。このデバイス コンテキストは、Renderer オブジェクトの Draw メソッドで描画されたものを含んでいる必要があります。四角形の計算を行うには、ストロークに x 座標と y 座標が含まれている必要があります。含まれていない場合、メソッドは空の四角形を返します。

解説

このメソッドは、Measure メソッドおよび Draw メソッドの両方に同じ引数を渡す場合にのみ正確です。

境界ボックスはペンの幅の影響を受けるため、Renderer オブジェクトのビュー変換に合わせて、ペンの幅が適切にスケーリングされます。つまり、ペンの幅がビュー変換の行列式の平方根で乗算されてスケーリングされます。境界ボックスの高さと幅は、各方向に対してこの長さの半分ずつ拡大され、右側と下側は 1 ずつ増分されます。

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

この C# の例では、ペンの幅が 2 倍になったときに、Stroke オブジェクト theStroke の外接する四角形を取得します。Renderer オブジェクトは、InkOverlay オブジェクト theInkOverlay から取得されます。

DrawingAttributes drawingAtt = theStroke.DrawingAttributes.Clone();
drawingAtt.Width = drawingAtt.Width * 2;
Rectangle bounds = theInkOverlay.Renderer.Measure(theStroke, drawingAtt);

この Microsoft® Visual Basic® .NET の例では、ペンの幅が 2 倍になったときに、Stroke オブジェクト theStroke の外接する四角形を取得します。Renderer オブジェクトは、InkOverlay オブジェクト theInkOverlay から取得されます。

Dim drawingAtt As DrawingAttributes = theStroke.DrawingAttributes.Clone();
drawingAtt.Width = drawingAtt.Width * 2;
Dim bounds As Rectangle = theInkOverlay.Renderer.Measure(theStroke, drawingAtt);

プラットフォーム

Windows Vista

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

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

Renderer クラス

Renderer メンバ

Measure オーバーロード

Microsoft.Ink 名前空間

Renderer.Draw

Stroke.GetBoundingBox

Strokes.GetBoundingBox

DrawingAttributes