Stroke.GetBoundingBox 方法
返回定义 Stroke 对象的边界框的边框 Rectangle。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Function GetBoundingBox As Rectangle
用法
Dim instance As Stroke
Dim returnValue As Rectangle
returnValue = instance.GetBoundingBox()
public Rectangle GetBoundingBox()
public:
Rectangle GetBoundingBox()
public Rectangle GetBoundingBox()
public function GetBoundingBox() : Rectangle
返回值
备注
边框 Rectangle 采用墨迹空间 坐标。
边框 Rectangle 对应于显示 Stroke 对象时要无效或重绘的显示部分。
如果边界框受到笔宽度的影响,则此宽度根据 Renderer 对象的视图变换进行相应缩放。为此,笔宽度将乘以视图变换的行列式的平方根。
备注
如果未显式设置笔宽度,则默认值为 53。只有将笔宽度乘以行列式的平方根才能得到正确的边界框。边界框的高度和宽度在每个方向上扩展该数量的一半。例如,如果笔宽度为 53,行列式的平方根为 50,边界框为 (0, 0, 1000, 1000)。根据笔宽度,边界框在每个方向上的调整计算方法为 (53 * 50) / 2,右侧和下方增加一个单位。这样,将呈现出边界框 (-1325, -1325, 2326, 2326)。
示例
在此示例中,修改 InkOverlay 的所有选定 Stroke 对象。首先,调用 GetBoundingBox 方法来确定所选 Stroke 的边框。然后,将得到的边框修改为其原始宽度的一半。然后,调用 Clip 方法来裁剪 Stroke 的右半部分。
For Each S As Stroke In mInkOverlay.Selection
Dim sBounds As Rectangle = S.GetBoundingBox()
' decrease width by half
sBounds.Width -= sBounds.Width / 2
' clip the stroke
S.Clip(sBounds)
Next
foreach (Stroke S in mInkOverlay.Selection)
{
Rectangle sBounds = S.GetBoundingBox();
// decrease width by half
sBounds.Width -= sBounds.Width / 2;
// clip the stroke
S.Clip(sBounds);
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0