TransformPattern.Rotate(Double) Metodo

Definizione

Ruota il controllo.

public:
 void Rotate(double degrees);
public void Rotate (double degrees);
member this.Rotate : double -> unit
Public Sub Rotate (degrees As Double)

Parametri

degrees
Double

Numero di gradi di rotazione dell'elemento. Un numero positivo ruota in senso orario. Un numero negativo ruota in senso antiorario.

Eccezioni

La proprietà CanRotate è false.

Esempio

Nell'esempio seguente viene ottenuto un TransformPattern modello di controllo da un AutomationElement oggetto e successivamente usato per ruotare l'oggetto 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.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;
    }
}
'''--------------------------------------------------------------------
''' <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 Sub RotateElement( _
ByVal transformPattern As TransformPattern, ByVal degrees As Double)
    Try
        If transformPattern.Current.CanRotate Then
            transformPattern.Rotate(degrees)
        End If
    Catch
        ' object is not able to perform the requested action
        Return
    End Try

End Sub

Commenti

Non è possibile spostare, ridimensionare o ruotare un oggetto in modo che la relativa posizione dello schermo risultante sia completamente esterna alle coordinate del contenitore e non accessibile alla tastiera o al mouse. Ad esempio, quando una finestra di primo livello viene spostata completamente fuori schermo o un oggetto figlio viene spostato all'esterno dei limiti del riquadro di visualizzazione del contenitore. In questi casi, l'oggetto viene posizionato più vicino alle coordinate dello schermo richieste il più possibile con le coordinate superiore o sinistra sostituite per essere all'interno dei limiti del contenitore.

Si applica a