IRawElementProviderFragmentRoot.ElementProviderFromPoint Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Belirtilen noktadaki bu parçadaki öğesini alır.
public:
System::Windows::Automation::Provider::IRawElementProviderFragment ^ ElementProviderFromPoint(double x, double y);
public System.Windows.Automation.Provider.IRawElementProviderFragment ElementProviderFromPoint (double x, double y);
abstract member ElementProviderFromPoint : double * double -> System.Windows.Automation.Provider.IRawElementProviderFragment
Public Function ElementProviderFromPoint (x As Double, y As Double) As IRawElementProviderFragment
Parametreler
- x
- Double
X koordinatı.
- y
- Double
Y koordinatı.
Döndürülenler
Belirtilen noktadaki alt öğenin sağlayıcısı( varsa) veya nokta bu öğedeyse kök sağlayıcı ancak herhangi bir alt öğede değil. Aksi takdirde null
döndürür.
Örnekler
Aşağıdaki kod örneği, kaydırmayan liste kutusu için bu yöntemin olası bir uygulamasını gösterir. Belirtilen noktadaki liste öğesinin dizini, her öğenin yüksekliği kullanılarak hesaplanır ve bu noktadaki öğe döndürülür. Bu noktada hiçbir öğe yoksa (örneğin, liste kutusunun boş bir alanıysa, yöntem null başvuru ()Nothing
döndürür.
delegate Rectangle MyDelegate(Rectangle clientRect);
/// <summary>
/// Gets the child element that is at the specified point.
/// </summary>
/// <param name="x">Distance from the left of the application window.</param>
/// <param name="y">Distance from the top of the application window.</param>
/// <returns>The provider for the element at that point.</returns>
IRawElementProviderFragment IRawElementProviderFragmentRoot.ElementProviderFromPoint(
double x, double y)
{
// The RectangleToScreen method on the control can't be called directly from
// this thread, so use delegation.
MyDelegate del = new MyDelegate(this.RectangleToScreen);
Rectangle screenRectangle = (Rectangle)this.Invoke(del, new object[] { this.DisplayRectangle });
if (screenRectangle.Contains((int)x, (int)y))
{
int index = (int)(((int)(y - screenRectangle.Y)) / itemHeight);
if (index < myItems.Count)
{
return (IRawElementProviderFragment)myItems[index];
}
else
{
return (IRawElementProviderFragment)this;
}
}
else
{
return null;
}
}
Delegate Function MyDelegate(ByVal clientRect As Rectangle) As Rectangle
''' <summary>
''' Gets the child element that is at the specified point.
''' </summary>
''' <param name="x">Distance from the left of the application window.</param>
''' <param name="y">Distance from the top of the application window.</param>
''' <returns>The provider for the element at that point.</returns>
Function ElementProviderFromPoint(ByVal x As Double, ByVal y As Double) As IRawElementProviderFragment _
Implements IRawElementProviderFragmentRoot.ElementProviderFromPoint
Dim pointX As Integer = CInt(x)
Dim pointY As Integer = CInt(y)
' The RectangleToScreen method on the control can't be called directly from
' this thread, so use delegation.
Dim converterDelegate As MyDelegate = New MyDelegate(AddressOf Me.RectangleToScreen)
Dim screenRectangle As Rectangle = DirectCast(Me.Invoke(converterDelegate, _
New Object() {Me.DisplayRectangle}), Rectangle)
If screenRectangle.Contains(pointX, pointY) Then
Dim index As Integer = CInt((pointY - screenRectangle.Y) \ itemHeight)
If index < myItems.Count Then
Return DirectCast(myItems(index), IRawElementProviderFragment)
Else
Return DirectCast(Me, IRawElementProviderFragment)
End If
Else
Return Nothing
End If
End Function
Açıklamalar
Nokta, bu parça tarafından barındırılan başka bir çerçevedeki bir öğedeyse, yöntemi bu parçayı barındıran öğeyi döndürür.
Döndürülen sağlayıcı, belirtilen noktada fare girişi alacak öğeye karşılık gelir.