ShapeElement.DoHitTest Method (PointD, DiagramHitTestInfo, Boolean)
Returns true if the specified point is within the shape.
Namespace: Microsoft.VisualStudio.Modeling.Diagrams
Assembly: Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0.dll)
Syntax
'宣告
Public Overridable Function DoHitTest ( _
point As PointD, _
hitTestInfo As DiagramHitTestInfo, _
includeTolerance As Boolean _
) As Boolean
public virtual bool DoHitTest(
PointD point,
DiagramHitTestInfo hitTestInfo,
bool includeTolerance
)
public:
virtual bool DoHitTest(
PointD point,
DiagramHitTestInfo^ hitTestInfo,
bool includeTolerance
)
abstract DoHitTest :
point:PointD *
hitTestInfo:DiagramHitTestInfo *
includeTolerance:bool -> bool
override DoHitTest :
point:PointD *
hitTestInfo:DiagramHitTestInfo *
includeTolerance:bool -> bool
public function DoHitTest(
point : PointD,
hitTestInfo : DiagramHitTestInfo,
includeTolerance : boolean
) : boolean
Parameters
- point
Type: Microsoft.VisualStudio.Modeling.Diagrams.PointD
A point on the diagram, relative to the parent shape.
- hitTestInfo
Type: Microsoft.VisualStudio.Modeling.Diagrams.DiagramHitTestInfo
The object that will receive the results of the hit test, showing which child shape or field was hit.
- includeTolerance
Type: System.Boolean
true to include the boundary area around the shape when the hit test is performed; otherwise, false.
Return Value
Type: System.Boolean
true if the shape was hit; otherwise, false.
Remarks
If the method returns true, the hitTestInfo indicates the DiagramItem that was actually hit, which might be a child of the shape.
Instead of calling this directly from a command, consider overriding OnClick() or OnDoubleClick(), in which the HitTestInfo is included in the event argument.
Examples
public override global::System.Windows.Forms.Cursor GetCursor(global::System.Windows.Forms.Cursor currentCursor, DslDiagrams::DiagramClientView diagramClientView, DslDiagrams::PointD mousePosition)
{
if (this.MouseDownHitShape == null && currentCursor != global::System.Windows.Forms.Cursors.No)
{
DslDiagrams::DiagramHitTestInfo hitTestInfo = new DslDiagrams::DiagramHitTestInfo(diagramClientView);
this.Diagram.DoHitTest(mousePosition, hitTestInfo);
DslDiagrams::ShapeElement shape = hitTestInfo.HitDiagramItem.Shape;
}
return base.GetCursor(currentCursor, diagramClientView, mousePosition);
}
.NET Framework Security
- 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.