TransformPattern.TransformPatternInformation.CanRotate Property

Gets a value that specifies whether the UI Automation element can be rotated.

Namespace:  System.Windows.Automation
Assembly:  UIAutomationClient (in UIAutomationClient.dll)

public bool CanRotate { get; }

Property Value

Type: System.Boolean
true if the element can be rotated; otherwise false.

An object cannot be moved, resized, or rotated such that its resulting screen location would be completely outside the coordinates of its container and inaccessible to keyboard or mouse. For example, when a top-level window is moved completely off-screen or a child object is moved outside the boundaries of the container's viewport. In these cases the object is placed as close to the requested screen coordinates as possible with the top or left coordinates overridden to be within the container boundaries.

In the following example, a TransformPattern control pattern is obtained from an AutomationElement and subsequently used to rotate the 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> 
/// Calls the TransformPattern.Rotate() method for an associated  
/// automation element. 
/// </summary> 
/// <param name="transformPattern">
/// The TransformPattern control pattern obtained from 
/// an automation element. 
/// </param> 
/// <param name="degrees">
/// The amount of degrees to rotate the automation element. 
/// </param> 
///-------------------------------------------------------------------- 
private void RotateElement(
    TransformPattern transformPattern, double degrees)
{
    try
    {
        if (transformPattern.Current.CanRotate)
        {
            transformPattern.Rotate(degrees);
        }
    }
    catch (InvalidOperationException)
    {
        // object is not able to perform the requested action 
        return;
    }
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft