TransformPattern.Rotate(Double) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
旋转控件。
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。
示例
在下面的示例中,从一个TransformPatternAutomationElement控件模式获取,随后用于旋转该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
注解
无法移动、调整对象大小或旋转对象,以便其生成的屏幕位置完全超出其容器的坐标,并且无法访问键盘或鼠标。 例如,当顶级窗口完全移出屏幕外或子对象在容器视区边界之外移动时。 在这些情况下,对象尽可能接近所请求的屏幕坐标,并覆盖顶部或左侧坐标,以位于容器边界内。