TransformPattern.TransformPatternInformation.CanMove Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee wordt een waarde opgehaald die aangeeft of het UI Automation element kan worden verplaatst.
public:
property bool CanMove { bool get(); };
public bool CanMove { get; }
member this.CanMove : bool
Public ReadOnly Property CanMove As Boolean
Waarde van eigenschap
true als het element kan worden verplaatst; anders false.
Voorbeelden
In het volgende voorbeeld wordt een TransformPattern besturingspatroon verkregen uit een AutomationElement en vervolgens gebruikt om de AutomationElement.
///--------------------------------------------------------------------
/// <summary>
/// Obtains a TransformPattern control pattern from
/// an automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A TransformPattern object.
/// </returns>
///--------------------------------------------------------------------
private TransformPattern GetTransformPattern(
AutomationElement targetControl)
{
TransformPattern transformPattern = null;
try
{
transformPattern =
targetControl.GetCurrentPattern(TransformPattern.Pattern)
as TransformPattern;
}
catch (InvalidOperationException)
{
// object doesn't support the TransformPattern control pattern
return null;
}
return transformPattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a TransformPattern control pattern from
''' an automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A TransformPattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetTransformPattern( _
ByVal targetControl As AutomationElement) As TransformPattern
Dim transformPattern As TransformPattern = Nothing
Try
transformPattern = DirectCast( _
targetControl.GetCurrentPattern(transformPattern.Pattern), _
TransformPattern)
Catch exc As InvalidOperationException
' object doesn't support the TransformPattern control pattern
Return Nothing
End Try
Return transformPattern
End Function 'GetTransformPattern
///--------------------------------------------------------------------
/// <summary>
/// Calls the TransformPattern.Move() method for an associated
/// automation element.
/// </summary>
/// <param name="transformPattern">
/// The TransformPattern control pattern obtained from
/// an automation element.
/// </param>
/// <param name="x">
/// The number of screen pixels to move the automation element
/// horizontally.
/// </param>
/// <param name="y">
/// The number of screen pixels to move the automation element
/// vertically.
/// </param>
///--------------------------------------------------------------------
private void MoveElement(
TransformPattern transformPattern, double x, double y)
{
try
{
if (transformPattern.Current.CanMove)
{
transformPattern.Move(x, y);
}
}
catch (InvalidOperationException)
{
// object is not able to perform the requested action
return;
}
}
'''--------------------------------------------------------------------
''' <summary>
''' Calls the TransformPattern.Move() method for an associated
''' automation element.
''' </summary>
''' <param name="transformPattern">
''' The TransformPattern control pattern obtained from
''' an automation element.
''' </param>
''' <param name="x">
''' The number of screen pixels to move the automation element
''' horizontally.
''' </param>
''' <param name="y">
''' The number of screen pixels to move the automation element
''' vertically.
''' </param>
'''--------------------------------------------------------------------
Private Sub MoveElement( _
ByVal transformPattern As TransformPattern, _
ByVal x As Double, ByVal y As Double)
Try
If transformPattern.Current.CanMove Then
transformPattern.Move(x, y)
End If
Catch exc As InvalidOperationException
' object is not able to perform the requested action
Return
End Try
End Sub
Opmerkingen
Een object kan niet worden verplaatst, aangepast of gedraaid, zodat de resulterende schermlocatie volledig buiten de coördinaten van de container valt en niet toegankelijk is voor het toetsenbord of de muis. Wanneer een venster op het hoogste niveau bijvoorbeeld volledig buiten het scherm wordt verplaatst of een onderliggend object buiten de grenzen van de viewport van de container wordt verplaatst. In deze gevallen wordt het object zo dicht mogelijk bij de aangevraagde schermcoördinaten geplaatst, waarbij de coördinaten boven of links worden overschreven om binnen de containergrenzen te vallen.