ActivityDesigner.Bounds ActivityDesigner.Bounds ActivityDesigner.Bounds ActivityDesigner.Bounds Property


取得 Rectangle,其包含設計工具封入矩形的邏輯座標值。Gets a Rectangle which contains the value for the enclosing rectangle of the designer in logical coordinates.

 property System::Drawing::Rectangle Bounds { System::Drawing::Rectangle get(); };
public System.Drawing.Rectangle Bounds { get; }
member this.Bounds : System.Drawing.Rectangle
Public ReadOnly Property Bounds As Rectangle


Rectangle,它會包圍設計工具。A Rectangle that encloses the designer.


下列程式碼範例將示範如何使用 Bounds 屬性來判斷 ActivityDesigner 上所顯示之圖像 (Glyph) 的新週框 (Bounding Rectangle)。The following code example demonstrates how you can use the Bounds property to determine the new bounding rectangle for a glyph displayed on an ActivityDesigner.

這個程式碼範例是 DesignerGlyphProvider.cs 檔案中<工作流程監視器 SDK>範例的一部分。This code example is part of the Workflow Monitor SDK Sample from the DesignerGlyphProvider.cs file. 如需詳細資訊, 請參閱工作流程監視器For more information, see Workflow Monitor.

public override Rectangle GetBounds(ActivityDesigner designer, bool activated)
    Rectangle imageBounds = Rectangle.Empty;
    Image image = Resources.Executing;
    if (image != null)
        Size glyphSize = WorkflowTheme.CurrentTheme.AmbientTheme.GlyphSize;
        imageBounds.Location = new Point(designer.Bounds.Right - glyphSize.Width / 2, designer.Bounds.Top - glyphSize.Height / 2);
        imageBounds.Size = glyphSize;
    return imageBounds;
Public Overrides Function GetBounds(ByVal designer As System.Workflow.ComponentModel.Design.ActivityDesigner, ByVal activated As Boolean) As System.Drawing.Rectangle
    Dim imageBounds As Rectangle = Rectangle.Empty
    Dim image As Image = AppResources.Executing
    If Not image Is Nothing Then
        Dim glyphSize As Size = WorkflowTheme.CurrentTheme.AmbientTheme.GlyphSize
        imageBounds.Location = New Point(designer.Bounds.Right - glyphSize.Width / 2, designer.Bounds.Top - glyphSize.Height / 2)
        imageBounds.Size = glyphSize
    End If
    Return imageBounds
End Function


您可以使用界限方法傳回的矩形來判斷設計工具包圍的區域和選取區域。You can use the rectangle returned by the bounds method to determine the area enclosed by the designer plus the selection area.