共用方式為


BoundsRules 類別

限制可以放置圖形,它可以要如何調整大小的規則。

繼承階層架構

System.Object
  Microsoft.VisualStudio.Modeling.Diagrams.BoundsRules
    Microsoft.VisualStudio.Modeling.Diagrams.AvoidCornerRule
    Microsoft.VisualStudio.Modeling.Diagrams.DefaultBoundsRules
    Microsoft.VisualStudio.Modeling.Diagrams.KeepInParentRule
    Microsoft.VisualStudio.Modeling.Diagrams.NoBoundsRules
    Microsoft.VisualStudio.Modeling.Diagrams.PortMovementRule
    Microsoft.VisualStudio.Modeling.Diagrams.SnapToGridRule
    Microsoft.VisualStudio.Modeling.Diagrams.SnapToPerimeterFollowingRotationRule

命名空間:  Microsoft.VisualStudio.Modeling.Diagrams
組件:  Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0 (在 Microsoft.VisualStudio.Modeling.Sdk.Diagrams.11.0.dll 中)

語法

'宣告
<SerializableAttribute> _
Public MustInherit Class BoundsRules
[SerializableAttribute]
public abstract class BoundsRules

BoundsRules 型別會公開下列成員。

建構函式

  名稱 說明
受保護的方法 BoundsRules

回頁首

方法

  名稱 說明
公用方法 Equals 判斷指定的物件是否等於目前物件。 (繼承自 Object)。
受保護的方法 Finalize 允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。 (繼承自 Object)。
公用方法 GetCompliantBounds 調整建議的大小和位置,以使其符合此繫結規則。當使用者移動滑鼠時,請重複呼叫。幽靈車圖形為使用者顯示相容的界限。
公用方法 GetHashCode 做為特定型別的雜湊函式。 (繼承自 Object)。
公用方法 GetType 取得目前執行個體的 Type。 (繼承自 Object)。
受保護的方法 MemberwiseClone 建立目前 Object 的淺層複本 (Shallow Copy)。 (繼承自 Object)。
公用方法 ToString 傳回表示目前物件的字串。 (繼承自 Object)。

回頁首

備註

A 範圍規則是一種類別定義的大小和位置的圖形上的限制。GetCompliantBounds就會重複呼叫時使用者拖曳圖形角落或側邊的圖形。

如需詳細資訊,請參閱 BoundsRules 限制圖案位置和大小

範例

下列範例會限制為帶有子橫條的水平或垂直的固定大小的矩形圖形。當使用者拖曳角落或側邊時,大綱會翻轉之間允許的兩種組態的高度和寬度。

請注意位置和大小可以被限制是否您想要的。

範圍規則是一種類別,並在圖形中建立執行個體:

using Microsoft.VisualStudio.Modeling.Diagrams; ...
public partial class BarShape
{
  /// <summary>
  /// Rule invoked when the user is resizing a shape.
  /// </summary>
  public override BoundsRules BoundsRules
  { get { return new BarBoundsRule(); } }
}
/// <summary>
/// Rule invoked when the user is changing a shape's outline.
/// Provides real-time mouse rubber-band feedback, so must work fast.
/// </summary>
public class BarBoundsRule: BoundsRules
{ 
  public override RectangleD GetCompliantBounds 
     (ShapeElement shape, RectangleD proposedBounds)
  {
    double thickness = 0.1;
    if (proposedBounds.Height > proposedBounds.Width)
    {
      // There is a minimum width for a shape; the width
      // will actually be set to the lesser of 
      // thickness and that minimum.
      return new RectangleD(proposedBounds.Location, 
            new SizeD(thickness, proposedBounds.Height));
    }
    else
    {
      // There is a minimum height for a shape; the 
      // height will actually be set to the lesser of 
      // thickness and that minimum.
      return new RectangleD(proposedBounds.Location, 
         new SizeD(proposedBounds.Width, thickness));
} } }

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。不保證任何執行個體成員是安全執行緒。

請參閱

參考

Microsoft.VisualStudio.Modeling.Diagrams 命名空間

其他資源

BoundsRules 限制圖案位置和大小