藉由使用指定的 DrawingAttributes,計算裝置內容上需要包含要以 Renderer 物件的 Draw 方法繪製而得之 Stroke 物件的 Rectangle (英文)。
命名空間: 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
參數
- stroke
型別:Microsoft.Ink.Stroke
要測量的 Stroke 物件。
- da
型別:Microsoft.Ink.DrawingAttributes
要在計算矩形時使用的 DrawingAttributes,其會覆寫 Stroke 物件的 DrawingAttributes 屬性。
傳回值
型別:System.Drawing.Rectangle
裝置內容上需要包含以 Renderer 物件的 Draw 方法繪製而得之筆劃的 Rectangle (英文)。筆劃必須包含要計算矩形的 X 座標和 Y 座標。否則,方法會傳回空白矩形。
備註
這個方法只有在您將相同的引數同時傳遞至 Measure 和 Draw 方法時才正確。
因為週框方塊受到畫筆寬度的影響,所以要針對 Renderer 物件的檢視轉換適當縮放這個寬度。若要執行這項操作,畫筆寬度會乘以檢視轉換之行列式的平方根。週框方塊的高度和寬度會依這個數目的一半,朝各方向放大,右邊和底部則會加一。
例如,試想畫筆寬度原本為 53,檢視轉換之行列式的平方根為 50,而且週框方塊為 (0, 0, 1000, 1000)。依據週框方塊朝各方向調整的畫筆寬度計算方式為 (53 * 50) / 2,右邊和底部則會加一。這樣會產生週框方塊 (-1325, -1325, 2326, 2326)。
範例
在這個 C# 範例中,當畫筆寬度加倍時,會為 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 範例中,當畫筆寬度加倍時,會為 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