Condividi tramite


GeometryHitTestParameters Classe

Definizione

Specifica un oggetto Geometry come parametro da usare per l'hit testing di una struttura ad albero visuale.

public ref class GeometryHitTestParameters : System::Windows::Media::HitTestParameters
public class GeometryHitTestParameters : System.Windows.Media.HitTestParameters
type GeometryHitTestParameters = class
    inherit HitTestParameters
Public Class GeometryHitTestParameters
Inherits HitTestParameters
Ereditarietà
GeometryHitTestParameters

Esempio

Nell'esempio seguente viene illustrato come configurare un hit test usando GeometryHitTestParameters per il HitTest metodo . Il Point valore passato al OnMouseDown metodo viene usato per creare un Geometry oggetto per espandere l'intervallo dell'hit test.

// Respond to the mouse button down event by setting up a hit test results callback.
private void OnMouseDown(object sender, MouseButtonEventArgs e)
{
    // Retrieve the coordinate of the mouse position.
    Point pt = e.GetPosition((UIElement)sender);

    // Expand the hit test area by creating a geometry centered on the hit test point.
    EllipseGeometry expandedHitTestArea = new EllipseGeometry(pt, 10.0, 10.0);

    // Clear the contents of the list used for hit test results.
    hitResultsList.Clear();

    // Set up a callback to receive the hit test result enumeration.
    VisualTreeHelper.HitTest(myControl, null,
        new HitTestResultCallback(MyHitTestResultCallback),
        new GeometryHitTestParameters(expandedHitTestArea));

    // Perform actions on the hit test results list.
    if (hitResultsList.Count > 0)
    {
        ProcessHitTestResultsList();
    }
}
' Respond to the mouse button down event by setting up a hit test results callback.
Private Overloads Sub OnMouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    ' Retrieve the coordinate of the mouse position.
    Dim pt As Point = e.GetPosition(CType(sender, UIElement))

    ' Expand the hit test area by creating a geometry centered on the hit test point.
    Dim expandedHitTestArea As New EllipseGeometry(pt, 10.0, 10.0)

    ' Clear the contents of the list used for hit test results.
    hitResultsList.Clear()

    ' Set up a callback to receive the hit test result enumeration.
    VisualTreeHelper.HitTest(myControl, Nothing, New HitTestResultCallback(AddressOf MyHitTestResultCallback), New GeometryHitTestParameters(expandedHitTestArea))

    ' Perform actions on the hit test results list.
    If hitResultsList.Count > 0 Then
        ProcessHitTestResultsList()
    End If
End Sub

La IntersectionDetail proprietà di GeometryHitTestResult fornisce informazioni sui risultati di un hit test che usa come Geometry parametro di hit test. La figura seguente mostra la relazione tra la geometria di hit test (il cerchio blu) e l'oggetto di destinazione (quadrato rosso).

Diagramma dell'intersezioneDetail usata nel Intersezione tra la geometria di hit test e l'oggetto di destinazione

Commenti

Con la GeometryHitTestParameters classe è possibile usare un Geometry valore per l'hit testing per determinare se qualsiasi oggetto visivo si interseca con il Geometry valore .

È anche possibile eseguire il hit test con un Point valore creando un PointHitTestParameters oggetto .

Annotazioni

Windows Presentation Foundation (WPF) hit testing considera solo l'area riempita di una geometria durante un hit test. Se si crea un punto Geometry, l'hit test non interseca nulla perché un punto non ha alcuna area.

Costruttori

Nome Descrizione
GeometryHitTestParameters(Geometry)

Inizializza una nuova istanza della GeometryHitTestParameters classe utilizzando l'oggetto specificato Geometry.

Proprietà

Nome Descrizione
HitGeometry

Ottiene l'oggetto Geometry che definisce la geometria di hit test per questa GeometryHitTestParameters istanza.

Metodi

Nome Descrizione
Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Si applica a