TransformPattern.Rotate(Double) メソッド

定義

コントロールを回転します。

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

パラメーター

degrees
Double

要素を回転する角度の数値。 正の値は時計回りの回転、負の値は反時計回りの回転を表します。

例外

CanRotate プロパティが false です。

次の例では、コントロール パターンが 1 つからAutomationElement取得され、TransformPatternその後、回転に使用されます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

注釈

オブジェクトを移動、サイズ変更、または回転することはできません。これにより、結果として得られる画面の位置がコンテナーの座標の外にあり、キーボードやマウスにアクセスできなくなります。 たとえば、最上位のウィンドウが画面から完全に移動された場合や、子オブジェクトがコンテナーのビューポートの境界の外に移動された場合などです。 このような場合、オブジェクトは要求された画面座標の近くに可能な限り配置され、上部または左の座標はコンテナーの境界内にオーバーライドされます。

適用対象