RangeValuePattern.RangeValuePatternInformation.SmallChange 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
elements Value 속성에 추가되거나 빼는 UI 자동화 요소에 고유한 작은 변경 값을 가져옵니다.
public:
property double SmallChange { double get(); };
public double SmallChange { get; }
member this.SmallChange : double
Public ReadOnly Property SmallChange As Double
속성 값
UI 자동화 요소에 고유한 작은 변경 값이거나 null
요소가 를 지원하지 SmallChange않는 경우 입니다. 기본값은 0.0입니다.
예제
다음 예제에서는 AutomationElement 지는 RangeValuePattern 컨트롤별 따라 해당 값을 증가 또는 감소를 포함 하는 컨트롤 패턴 SmallChange 값입니다.
SetRangeValue(targetControl[0], rangeValuePattern.Current.SmallChange, 1);
SetRangeValue(targetControl(0), rangeValuePattern.Current.SmallChange, 1)
///--------------------------------------------------------------------
/// <summary>
/// Sets the range value of the control of interest.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <param name="rangeValue">
/// The value (either relative or absolute) to set the control to.
/// </param>
/// <param name="rangeDirection">
/// The value used to specify the direction of adjustment.
/// </param>
///--------------------------------------------------------------------
private void SetRangeValue(
AutomationElement targetControl,
double rangeValue,
double rangeDirection)
{
if (targetControl == null || rangeValue == 0 || rangeDirection == 0)
{
throw new ArgumentException("Argument cannot be null or zero.");
}
RangeValuePattern rangeValuePattern =
GetRangeValuePattern(targetControl);
if (rangeValuePattern.Current.IsReadOnly)
{
throw new InvalidOperationException("Control is read-only.");
}
rangeValue = rangeValue * Math.Sign(rangeDirection);
try
{
if ((rangeValue <= rangeValuePattern.Current.Maximum) ||
(rangeValue >= rangeValuePattern.Current.Minimum))
{
rangeValuePattern.SetValue(rangeValue);
}
}
catch (ArgumentOutOfRangeException)
{
// TO DO: Error handling.
}
catch (ArgumentException)
{
// TO DO: Error handling.
}
}
'''--------------------------------------------------------------------
''' <summary>
''' Sets the range value of the control of interest.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <param name="rangeValue">
''' The value (either relative or absolute) to set the control to.
''' </param>
''' <param name="rangeDirection">
''' The value used to specify the direction of adjustment.
''' </param>
'''--------------------------------------------------------------------
Private Overloads Sub SetRangeValue( _
ByVal targetControl As AutomationElement, _
ByVal rangeValue As Double, ByVal rangeDirection As Double)
If targetControl Is Nothing OrElse _
rangeValue = 0 OrElse rangeDirection = 0 Then
Throw New ArgumentException("Argument cannot be null or zero.")
End If
Dim rangeValuePattern As RangeValuePattern = _
GetRangeValuePattern(targetControl)
If rangeValuePattern.Current.IsReadOnly Then
Throw New InvalidOperationException("Control is read-only.")
End If
rangeValue = rangeValue * Math.Sign(rangeDirection)
Try
If rangeValue <= rangeValuePattern.Current.Maximum OrElse _
rangeValue >= rangeValuePattern.Current.Minimum Then
rangeValuePattern.SetValue(rangeValue)
End If
Catch exc As ArgumentOutOfRangeException
' TO DO: Error handling.
Catch exc As ArgumentException
' TO DO: Error handling.
End Try
End Sub
///--------------------------------------------------------------------
/// <summary>
/// Obtains a RangeValuePattern control pattern from an
/// automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A RangeValuePattern object.
/// </returns>
///--------------------------------------------------------------------
private RangeValuePattern GetRangeValuePattern(
AutomationElement targetControl)
{
RangeValuePattern rangeValuePattern = null;
try
{
rangeValuePattern =
targetControl.GetCurrentPattern(
RangeValuePattern.Pattern)
as RangeValuePattern;
}
// Object doesn't support the
// RangeValuePattern control pattern
catch (InvalidOperationException)
{
return null;
}
return rangeValuePattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a RangeValuePattern control pattern from an
''' automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A RangeValuePattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetRangeValuePattern( _
ByVal targetControl As AutomationElement) As RangeValuePattern
Dim rangeValuePattern As RangeValuePattern = Nothing
Try
rangeValuePattern = DirectCast( _
targetControl.GetCurrentPattern(rangeValuePattern.Pattern), _
RangeValuePattern)
Catch exc As InvalidOperationException
' Object doesn't support the
' RangeValuePattern control pattern
Return Nothing
End Try
Return rangeValuePattern
End Function 'GetRangeValuePattern
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET