InkOverlay.Draw メソッド
InkOverlay オブジェクト内でインクを再描画する四角形を設定します。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Sub Draw ( _
rDrawRect As Rectangle _
)
'使用
Dim instance As InkOverlay
Dim rDrawRect As Rectangle
instance.Draw(rDrawRect)
public void Draw(
Rectangle rDrawRect
)
public:
void Draw(
Rectangle rDrawRect
)
public void Draw(
Rectangle rDrawRect
)
public function Draw(
rDrawRect : Rectangle
)
パラメータ
- rDrawRect
型 : System.Drawing.Rectangle
ピクセル座標で、インクを再描画する四角形。
解説
rDrawRect パラメータが nullnull 参照 (Visual Basic では Nothing) (Microsoft Visual Basic .NET では Nothing) の場合、ウィンドウ全体が再描画されます。
このメソッドに適した用途は、プログラムにより変更されたストロークの再描画です。Control.Invalidate メソッドを呼び出すこともできますが、この場合は InkOverlay オブジェクトのストロークがすべて再描画されます。さらに、この目的で Renderer.Draw メソッドを呼び出すこともできますが、Renderer オブジェクトは選択されたストロークを描画できません。これは、どのストロークが Selection コレクションに含まれるかを判別できないためです。
メモ : |
---|
描画するためには、AutoRedraw プロパティを true に設定する必要があります。 |
例
この C# の例では、InkOverlay オブジェクト theInkOverlay に関連付けられた Ink オブジェクトに属する Strokes コレクションですべてのストロークの色を変更するメソッドを示します。Stroke オブジェクトの DrawingAttributes プロパティを変更しても、すぐに自動的に表示されるわけではありません。theInkOverlay に関連付けられたコントロールで Invalidate メソッドまたは Refresh メソッドを呼び出すことができますが、呼び出すと theInkOverlay 内のすべての Stroke オブジェクトが再描画されます。パフォーマンスを向上させるには、Strokes コレクションの境界ボックスで Draw メソッドを使用します。これは、境界ボックスをインク空間座標からピクセル座標に変換することを意味しています。
private void ChangeColor(Strokes theStrokes, Color newColor)
{
// Change the color of theStrokes
foreach (Stroke stroke in theStrokes)
{
stroke.DrawingAttributes.Color = newColor;
}
// Convert bounding box to pixel coordinates
Graphics g = CreateGraphics();
Rectangle strokesBounds = theStrokes.GetBoundingBox();
Point topLeft = strokesBounds.Location;
Point bottomRight = strokesBounds.Location + strokesBounds.Size;
theInkOverlay.Renderer.InkSpaceToPixel(g, ref topLeft);
theInkOverlay.Renderer.InkSpaceToPixel(g, ref bottomRight);
g.Dispose()
strokesBounds = new Rectangle(topLeft,
new Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y));
// Redraw the strokes
theInkOverlay.Draw(strokesBounds);
}
この Visual Basic .NET の例では、InkOverlay オブジェクト theInkOverlay に関連付けられた Ink オブジェクトに属する Strokes コレクションですべてのストロークの色を変更するメソッドを示します。Stroke オブジェクトの DrawingAttributes プロパティを変更しても、すぐに自動的に表示されるわけではありません。theInkOverlay に関連付けられたコントロールで Invalidate メソッドまたは Refresh メソッドを呼び出すことができますが、呼び出すと theInkOverlay 内のすべての Stroke オブジェクトが再描画されます。パフォーマンスを向上させるには、Strokes コレクションの境界ボックスで Draw メソッドを使用します。これは、境界ボックスをインク空間座標からピクセル座標に変換することを意味しています。
Private Sub ChangeColor(ByVal theStrokes As Strokes, ByVal newColor As Color)
' Change the color of theStrokes
Dim theStroke As Stroke
For Each theStroke In theStrokes
theStroke.DrawingAttributes.Color = newColor
Next
'Convert bounding box to pixel coordinates
Dim g As Graphics = CreateGraphics()
Dim strokesBounds As Rectangle = theStrokes.GetBoundingBox()
Dim topLeft As Point = strokesBounds.Location
Dim bottomRight As Point = New Point(strokesBounds.Right, strokesBounds.Bottom)
theInkOverlay.Renderer.InkSpaceToPixel(g, topLeft)
theInkOverlay.Renderer.InkSpaceToPixel(g, bottomRight)
g.Dispose()
strokesBounds = New Rectangle(topLeft, _
New Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y))
'Redraw the strokes
theInkOverlay.Draw(strokesBounds)
End Sub
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0