Strokes.GetBoundingBox 方法

通过使用默认 BoundingBoxMode 标志确定边界,返回包含 Stroke 对象的边框 Rectangle

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Function GetBoundingBox As Rectangle
用法
Dim instance As Strokes
Dim returnValue As Rectangle

returnValue = instance.GetBoundingBox()
public Rectangle GetBoundingBox()
public:
Rectangle GetBoundingBox()
public Rectangle GetBoundingBox()
public function GetBoundingBox() : Rectangle

返回值

类型:System.Drawing.Rectangle
返回定义 Strokes 集合边界框的边框 Rectangle

备注

边框 Rectangle 采用墨迹空间 坐标。

边框 Rectangle 对应于显示 Strokes 集合时将要失效或重绘的显示部分。

如果边界框受到笔宽度的影响,则此宽度根据 Renderer 对象的视图变换进行相应缩放。为此,笔宽度将乘以视图变换的行列式的平方根。

备注

如果没有显式设置笔宽度,则笔宽度的默认值为 53。只有将笔宽度乘以行列式的平方根才能得到正确的边界框。边界框的高度和宽度在每个方向上扩展该数量的一半。例如,如果笔宽度为 53,行列式的平方根为 50,边界框为 (0, 0, 1000, 1000)。根据笔宽度,边界框在每个方向上的调整计算方法为 (53 * 50) / 2,右侧和下方增加一个单位。这样,将呈现出边界框 (-1325, -1325, 2326, 2326)。

备注

此方法返回的边框 RectangleStrokes 集合边界框的副本。修改此方法返回的 Rectangle 不影响原始 Strokes 集合的边界框。

示例

在此示例中,InkOverlay 对象的 Strokes 集合裁剪至 Strokes 集合的右半边。首先,通过调用 GetBoundingBox 方法获得 Strokes 集合的边框。然后,创建裁剪了右半部分的新边框并传递给 Clip 方法。

' Access to the 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
    ' Determine the bounding box for the Strokes collection.
    Dim bounds As Rectangle = allStrokes.GetBoundingBox()
    'Create rectangle for Clip method.
    Dim halfRectangle As Rectangle = _
            New Rectangle(bounds.Left, bounds.Top, bounds.Width / 2, bounds.Height)
    ' Clip the Strokes collection.
    allStrokes.Clip(halfRectangle)
End Using
// Access to the 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)
{
    // Determine the bounding box for the Strokes collection.
    Rectangle bounds = allStrokes.GetBoundingBox();
    //Create rectangle for Clip method.
    Rectangle halfRectangle = 
        new Rectangle(bounds.Left, bounds.Top, bounds.Width / 2, bounds.Height);
    // Clip the Strokes collection.
    allStrokes.Clip(halfRectangle);
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Strokes 类

Strokes 成员

GetBoundingBox 重载

Microsoft.Ink 命名空间

Stroke.GetBoundingBox

BoundingBoxMode