Gets the bounds rules for the shape.
Namespace: Microsoft.VisualStudio.Modeling.Diagrams
Assembly: Microsoft.VisualStudio.Modeling.Sdk.Diagrams (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.dll)
Syntax
'宣言
Public Overridable ReadOnly Property BoundsRules As BoundsRules
'使用
Dim instance As NodeShape
Dim value As BoundsRules
value = instance.BoundsRules
public virtual BoundsRules BoundsRules { get; }
public:
virtual property BoundsRules^ BoundsRules {
BoundsRules^ get ();
}
public function get BoundsRules () : BoundsRules
Property Value
Type: Microsoft.VisualStudio.Modeling.Diagrams.BoundsRules
The bounds rules for the shape.
Examples
public partial class ComponentShape
{
public override BoundsRules BoundsRules
{
get
{
return new ComponentShapeBoundsRule();
}
}
}
public class ComponentShapeBoundsRule : BoundsRules
{
public override RectangleD GetCompliantBounds(ShapeElement shape, RectangleD proposedBounds)
{
try
{
if (IsDeserializing(shape))
return proposedBounds;
ComponentShape componentShape = shape as ComponentShape;
if (componentShape == null) return proposedBounds;
Component component = componentShape.ModelElement as Component;
if (component == null) return proposedBounds;
// Are we moving or resizing?
if (!ApproxEqual(proposedBounds.Height, shape.AbsoluteBoundingBox.Height)
|| !ApproxEqual(proposedBounds.Width, shape.AbsoluteBoundingBox.Width))
{
// resizing
return RestrictResize(component, componentShape, proposedBounds);
}
else
{
return RestrictMovement(component, componentShape, proposedBounds);
}
}
catch (NullReferenceException e)
{
System.Windows.Forms.MessageBox.Show(e.StackTrace);
return proposedBounds;
}
}
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.