TransformPattern.Rotate(Double) Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Obraca kontrolkę.
public:
void Rotate(double degrees);
public void Rotate(double degrees);
member this.Rotate : double -> unit
Public Sub Rotate (degrees As Double)
Parametry
- degrees
- Double
Liczba stopni do rotacji elementu. Liczba dodatnia obraca się zgodnie z ruchem wskazówek zegara; liczba ujemna obraca się w kierunku odwrotnym.
Wyjątki
Właściwość CanRotate ma wartość false.
Przykłady
W poniższym przykładzie TransformPattern wzorzec kontrolki jest uzyskiwany z elementu AutomationElement , a następnie używany do obracania AutomationElementelementu .
///--------------------------------------------------------------------
/// <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
Uwagi
Nie można przenieść, zmienić rozmiaru lub obrócenia obiektu, tak aby jego wynikowa lokalizacja ekranu byłaby całkowicie poza współrzędnymi kontenera i niedostępna dla klawiatury lub myszy. Na przykład gdy okno najwyższego poziomu zostanie przeniesione całkowicie poza ekran lub obiekt podrzędny zostanie przeniesiony poza granice widoku kontenera. W takich przypadkach obiekt jest umieszczany jak najbliżej żądanych współrzędnych ekranu, jak to możliwe, ze współrzędnymi u góry lub lewej przesłonięć, aby mieścić się w granicach kontenera.