Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / UIAutomationClient / System / Windows / Automation / ScrollPattern.cs / 1305600 / ScrollPattern.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Client-side wrapper for Scroll Pattern
//
// History:
// 06/23/2003 : BrendanM Ported to WCP
//
//---------------------------------------------------------------------------
using System;
using System.Windows.Automation.Provider;
using MS.Internal.Automation;
namespace System.Windows.Automation
{
///
/// Represents UI elements that are expressing a value
///
#if (INTERNAL_COMPILE)
internal class ScrollPattern: BasePattern
#else
public class ScrollPattern: BasePattern
#endif
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
private ScrollPattern(AutomationElement el, SafePatternHandle hPattern, bool cached)
: base(el, hPattern)
{
_hPattern = hPattern;
_cached = cached;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Constants / Readonly Fields
//
//-----------------------------------------------------
#region Public Constants and Readonly Fields
/// Value used by SetSCrollPercent to indicate that no scrolling should take place in the specified direction
public const double NoScroll = -1.0;
/// Scroll pattern
public static readonly AutomationPattern Pattern = ScrollPatternIdentifiers.Pattern;
/// Property ID: HorizontalScrollPercent - Current horizontal scroll position
public static readonly AutomationProperty HorizontalScrollPercentProperty = ScrollPatternIdentifiers.HorizontalScrollPercentProperty;
/// Property ID: HorizontalViewSize - Minimum possible horizontal scroll position
public static readonly AutomationProperty HorizontalViewSizeProperty = ScrollPatternIdentifiers.HorizontalViewSizeProperty;
/// Property ID: VerticalScrollPercent - Current vertical scroll position
public static readonly AutomationProperty VerticalScrollPercentProperty = ScrollPatternIdentifiers.VerticalScrollPercentProperty;
/// Property ID: VerticalViewSize
public static readonly AutomationProperty VerticalViewSizeProperty = ScrollPatternIdentifiers.VerticalViewSizeProperty;
/// Property ID: HorizontallyScrollable
public static readonly AutomationProperty HorizontallyScrollableProperty = ScrollPatternIdentifiers.HorizontallyScrollableProperty;
/// Property ID: VerticallyScrollable
public static readonly AutomationProperty VerticallyScrollableProperty = ScrollPatternIdentifiers.VerticallyScrollableProperty;
#endregion Public Constants and Readonly Fields
//------------------------------------------------------
//
// Public Methods
//
//------------------------------------------------------
#region Public Methods
/// Request to set the current horizontal and Vertical scroll position
/// by percent (0-100). Passing in the value of "-1" will indicate that
/// scrolling in that direction should be ignored.
/// The ability to call this method and simultaneously scroll horizontally and
/// vertically provides simple panning support.
/// Amount to scroll by horizontally
/// Amount to scroll by vertically
///
///
/// This API does not work inside the secure execution environment.
///
///
public void SetScrollPercent( double horizontalPercent, double verticalPercent )
{
UiaCoreApi.ScrollPattern_SetScrollPercent(_hPattern, horizontalPercent, verticalPercent);
}
/// Request to scroll horizontally and vertically by the specified amount.
/// The ability to call this method and simultaneously scroll horizontally
/// and vertically provides simple panning support. If only horizontal or vertical percent
/// needs to be changed the constant SetScrollPercentUnchanged can be used for
/// either parameter and that axis wil be unchanged.
///
/// amount to scroll by horizontally
/// amount to scroll by vertically
///
///
/// This API does not work inside the secure execution environment.
///
///
public void Scroll( ScrollAmount horizontalAmount, ScrollAmount verticalAmount )
{
UiaCoreApi.ScrollPattern_Scroll(_hPattern, horizontalAmount, verticalAmount);
}
///
/// Request to scroll horizontally by the specified amount
///
/// Amount to scroll by
///
///
/// This API does not work inside the secure execution environment.
///
///
public void ScrollHorizontal( ScrollAmount amount )
{
UiaCoreApi.ScrollPattern_Scroll(_hPattern, amount, ScrollAmount.NoAmount);
}
///
/// Request to scroll vertically by the specified amount
///
/// Amount to scroll by
///
///
/// This API does not work inside the secure execution environment.
///
///
public void ScrollVertical( ScrollAmount amount )
{
UiaCoreApi.ScrollPattern_Scroll(_hPattern, ScrollAmount.NoAmount, amount);
}
#endregion Public Methods
//-----------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
#region Public Properties
///
/// This member allows access to previously requested
/// cached properties for this element. The returned object
/// has accessors for each property defined for this pattern.
///
///
/// Cached property values must have been previously requested
/// using a CacheRequest. If you try to access a cached
/// property that was not previously requested, an InvalidOperation
/// Exception will be thrown.
///
/// To get the value of a property at the current point in time,
/// access the property via the Current accessor instead of
/// Cached.
///
public ScrollPatternInformation Cached
{
get
{
Misc.ValidateCached(_cached);
return new ScrollPatternInformation(_el, true);
}
}
///
/// This member allows access to current property values
/// for this element. The returned object has accessors for
/// each property defined for this pattern.
///
///
/// This pattern must be from an AutomationElement with a
/// Full reference in order to get current values. If the
/// AutomationElement was obtained using AutomationElementMode.None,
/// then it contains only cached data, and attempting to get
/// the current value of any property will throw an InvalidOperationException.
///
/// To get the cached value of a property that was previously
/// specified using a CacheRequest, access the property via the
/// Cached accessor instead of Current.
///
public ScrollPatternInformation Current
{
get
{
Misc.ValidateCurrent(_hPattern);
return new ScrollPatternInformation(_el, false);
}
}
#endregion Public Properties
//-----------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
#region Internal Methods
static internal object Wrap(AutomationElement el, SafePatternHandle hPattern, bool cached)
{
return new ScrollPattern(el, hPattern, cached);
}
#endregion Internal Methods
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
SafePatternHandle _hPattern;
bool _cached;
#endregion Private Fields
//-----------------------------------------------------
//
// Nested Classes
//
//------------------------------------------------------
#region Nested Classes
///
/// This class provides access to either Cached or Current
/// properties on a pattern via the pattern's .Cached or
/// .Current accessors.
///
public struct ScrollPatternInformation
{
//------------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
internal ScrollPatternInformation(AutomationElement el, bool useCache)
{
_el = el;
_useCache = useCache;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// Get the current horizontal scroll position
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double HorizontalScrollPercent
{
get
{
return (double)_el.GetPatternPropertyValue(HorizontalScrollPercentProperty, _useCache);
}
}
///
/// Get the current vertical scroll position
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double VerticalScrollPercent
{
get
{
return (double)_el.GetPatternPropertyValue(VerticalScrollPercentProperty, _useCache);
}
}
///
/// Equal to the horizontal percentage of the entire control that is currently viewable.
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double HorizontalViewSize
{
get
{
return (double)_el.GetPatternPropertyValue(HorizontalViewSizeProperty, _useCache);
}
}
///
/// Equal to the horizontal percentage of the entire control that is currently viewable.
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double VerticalViewSize
{
get
{
return (double)_el.GetPatternPropertyValue(VerticalViewSizeProperty, _useCache);
}
}
///
/// True if control can scroll horizontally
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public bool HorizontallyScrollable
{
get
{
return (bool)_el.GetPatternPropertyValue(HorizontallyScrollableProperty, _useCache);
}
}
///
/// True if control can scroll vertically
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public bool VerticallyScrollable
{
get
{
return (bool)_el.GetPatternPropertyValue(VerticallyScrollableProperty, _useCache);
}
}
#endregion Public Properties
//-----------------------------------------------------
//
// Private Fields
//
//-----------------------------------------------------
#region Private Fields
private AutomationElement _el; // AutomationElement that contains the cache or live reference
private bool _useCache; // true to use cache, false to use live reference to get current values
#endregion Private Fields
}
#endregion Nested Classes
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Client-side wrapper for Scroll Pattern
//
// History:
// 06/23/2003 : BrendanM Ported to WCP
//
//---------------------------------------------------------------------------
using System;
using System.Windows.Automation.Provider;
using MS.Internal.Automation;
namespace System.Windows.Automation
{
///
/// Represents UI elements that are expressing a value
///
#if (INTERNAL_COMPILE)
internal class ScrollPattern: BasePattern
#else
public class ScrollPattern: BasePattern
#endif
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
private ScrollPattern(AutomationElement el, SafePatternHandle hPattern, bool cached)
: base(el, hPattern)
{
_hPattern = hPattern;
_cached = cached;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Constants / Readonly Fields
//
//-----------------------------------------------------
#region Public Constants and Readonly Fields
/// Value used by SetSCrollPercent to indicate that no scrolling should take place in the specified direction
public const double NoScroll = -1.0;
/// Scroll pattern
public static readonly AutomationPattern Pattern = ScrollPatternIdentifiers.Pattern;
/// Property ID: HorizontalScrollPercent - Current horizontal scroll position
public static readonly AutomationProperty HorizontalScrollPercentProperty = ScrollPatternIdentifiers.HorizontalScrollPercentProperty;
/// Property ID: HorizontalViewSize - Minimum possible horizontal scroll position
public static readonly AutomationProperty HorizontalViewSizeProperty = ScrollPatternIdentifiers.HorizontalViewSizeProperty;
/// Property ID: VerticalScrollPercent - Current vertical scroll position
public static readonly AutomationProperty VerticalScrollPercentProperty = ScrollPatternIdentifiers.VerticalScrollPercentProperty;
/// Property ID: VerticalViewSize
public static readonly AutomationProperty VerticalViewSizeProperty = ScrollPatternIdentifiers.VerticalViewSizeProperty;
/// Property ID: HorizontallyScrollable
public static readonly AutomationProperty HorizontallyScrollableProperty = ScrollPatternIdentifiers.HorizontallyScrollableProperty;
/// Property ID: VerticallyScrollable
public static readonly AutomationProperty VerticallyScrollableProperty = ScrollPatternIdentifiers.VerticallyScrollableProperty;
#endregion Public Constants and Readonly Fields
//------------------------------------------------------
//
// Public Methods
//
//------------------------------------------------------
#region Public Methods
/// Request to set the current horizontal and Vertical scroll position
/// by percent (0-100). Passing in the value of "-1" will indicate that
/// scrolling in that direction should be ignored.
/// The ability to call this method and simultaneously scroll horizontally and
/// vertically provides simple panning support.
/// Amount to scroll by horizontally
/// Amount to scroll by vertically
///
///
/// This API does not work inside the secure execution environment.
///
///
public void SetScrollPercent( double horizontalPercent, double verticalPercent )
{
UiaCoreApi.ScrollPattern_SetScrollPercent(_hPattern, horizontalPercent, verticalPercent);
}
/// Request to scroll horizontally and vertically by the specified amount.
/// The ability to call this method and simultaneously scroll horizontally
/// and vertically provides simple panning support. If only horizontal or vertical percent
/// needs to be changed the constant SetScrollPercentUnchanged can be used for
/// either parameter and that axis wil be unchanged.
///
/// amount to scroll by horizontally
/// amount to scroll by vertically
///
///
/// This API does not work inside the secure execution environment.
///
///
public void Scroll( ScrollAmount horizontalAmount, ScrollAmount verticalAmount )
{
UiaCoreApi.ScrollPattern_Scroll(_hPattern, horizontalAmount, verticalAmount);
}
///
/// Request to scroll horizontally by the specified amount
///
/// Amount to scroll by
///
///
/// This API does not work inside the secure execution environment.
///
///
public void ScrollHorizontal( ScrollAmount amount )
{
UiaCoreApi.ScrollPattern_Scroll(_hPattern, amount, ScrollAmount.NoAmount);
}
///
/// Request to scroll vertically by the specified amount
///
/// Amount to scroll by
///
///
/// This API does not work inside the secure execution environment.
///
///
public void ScrollVertical( ScrollAmount amount )
{
UiaCoreApi.ScrollPattern_Scroll(_hPattern, ScrollAmount.NoAmount, amount);
}
#endregion Public Methods
//-----------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
#region Public Properties
///
/// This member allows access to previously requested
/// cached properties for this element. The returned object
/// has accessors for each property defined for this pattern.
///
///
/// Cached property values must have been previously requested
/// using a CacheRequest. If you try to access a cached
/// property that was not previously requested, an InvalidOperation
/// Exception will be thrown.
///
/// To get the value of a property at the current point in time,
/// access the property via the Current accessor instead of
/// Cached.
///
public ScrollPatternInformation Cached
{
get
{
Misc.ValidateCached(_cached);
return new ScrollPatternInformation(_el, true);
}
}
///
/// This member allows access to current property values
/// for this element. The returned object has accessors for
/// each property defined for this pattern.
///
///
/// This pattern must be from an AutomationElement with a
/// Full reference in order to get current values. If the
/// AutomationElement was obtained using AutomationElementMode.None,
/// then it contains only cached data, and attempting to get
/// the current value of any property will throw an InvalidOperationException.
///
/// To get the cached value of a property that was previously
/// specified using a CacheRequest, access the property via the
/// Cached accessor instead of Current.
///
public ScrollPatternInformation Current
{
get
{
Misc.ValidateCurrent(_hPattern);
return new ScrollPatternInformation(_el, false);
}
}
#endregion Public Properties
//-----------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
#region Internal Methods
static internal object Wrap(AutomationElement el, SafePatternHandle hPattern, bool cached)
{
return new ScrollPattern(el, hPattern, cached);
}
#endregion Internal Methods
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
SafePatternHandle _hPattern;
bool _cached;
#endregion Private Fields
//-----------------------------------------------------
//
// Nested Classes
//
//------------------------------------------------------
#region Nested Classes
///
/// This class provides access to either Cached or Current
/// properties on a pattern via the pattern's .Cached or
/// .Current accessors.
///
public struct ScrollPatternInformation
{
//------------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
internal ScrollPatternInformation(AutomationElement el, bool useCache)
{
_el = el;
_useCache = useCache;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// Get the current horizontal scroll position
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double HorizontalScrollPercent
{
get
{
return (double)_el.GetPatternPropertyValue(HorizontalScrollPercentProperty, _useCache);
}
}
///
/// Get the current vertical scroll position
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double VerticalScrollPercent
{
get
{
return (double)_el.GetPatternPropertyValue(VerticalScrollPercentProperty, _useCache);
}
}
///
/// Equal to the horizontal percentage of the entire control that is currently viewable.
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double HorizontalViewSize
{
get
{
return (double)_el.GetPatternPropertyValue(HorizontalViewSizeProperty, _useCache);
}
}
///
/// Equal to the horizontal percentage of the entire control that is currently viewable.
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public double VerticalViewSize
{
get
{
return (double)_el.GetPatternPropertyValue(VerticalViewSizeProperty, _useCache);
}
}
///
/// True if control can scroll horizontally
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public bool HorizontallyScrollable
{
get
{
return (bool)_el.GetPatternPropertyValue(HorizontallyScrollableProperty, _useCache);
}
}
///
/// True if control can scroll vertically
///
///
///
/// This API does not work inside the secure execution environment.
///
///
public bool VerticallyScrollable
{
get
{
return (bool)_el.GetPatternPropertyValue(VerticallyScrollableProperty, _useCache);
}
}
#endregion Public Properties
//-----------------------------------------------------
//
// Private Fields
//
//-----------------------------------------------------
#region Private Fields
private AutomationElement _el; // AutomationElement that contains the cache or live reference
private bool _useCache; // true to use cache, false to use live reference to get current values
#endregion Private Fields
}
#endregion Nested Classes
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ping.cs
- ObjectDataSourceView.cs
- XsltLibrary.cs
- XmlUTF8TextReader.cs
- TextRunTypographyProperties.cs
- CheckableControlBaseAdapter.cs
- Itemizer.cs
- Domain.cs
- ConditionalExpression.cs
- ErrorWebPart.cs
- StorageModelBuildProvider.cs
- ExpressionConverter.cs
- ToolStripCollectionEditor.cs
- CodeNamespaceImportCollection.cs
- ActivityFunc.cs
- Rijndael.cs
- SafeReversePInvokeHandle.cs
- ObjectSecurity.cs
- MediaPlayerState.cs
- ZoomPercentageConverter.cs
- TailPinnedEventArgs.cs
- DataObjectEventArgs.cs
- regiisutil.cs
- SafeHandles.cs
- AsmxEndpointPickerExtension.cs
- DataGridViewCellFormattingEventArgs.cs
- ModifiableIteratorCollection.cs
- ResourceDisplayNameAttribute.cs
- TouchFrameEventArgs.cs
- XmlHelper.cs
- KerberosSecurityTokenParameters.cs
- RangeValuePattern.cs
- WebExceptionStatus.cs
- TableProvider.cs
- GenericArgumentsUpdater.cs
- PartBasedPackageProperties.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- RadioButtonBaseAdapter.cs
- DiscoveryInnerClientAdhoc11.cs
- XmlSchemaComplexContentExtension.cs
- Invariant.cs
- Renderer.cs
- JoinGraph.cs
- ScrollViewerAutomationPeer.cs
- CheckBoxAutomationPeer.cs
- Tokenizer.cs
- _HeaderInfo.cs
- ToolStripItemEventArgs.cs
- Registry.cs
- WebPartVerbsEventArgs.cs
- VersionedStreamOwner.cs
- ActivityFunc.cs
- DynamicQueryableWrapper.cs
- SQLDecimalStorage.cs
- SecUtil.cs
- WebPartPersonalization.cs
- LineServicesRun.cs
- TraceContextEventArgs.cs
- FormViewCommandEventArgs.cs
- HealthMonitoringSectionHelper.cs
- WebServiceClientProxyGenerator.cs
- BatchWriter.cs
- httpserverutility.cs
- VBIdentifierName.cs
- ContextMenuStrip.cs
- MemoryRecordBuffer.cs
- ConnectionPointConverter.cs
- FontWeights.cs
- FrameworkPropertyMetadata.cs
- XmlDocumentType.cs
- Aggregates.cs
- DesignerFrame.cs
- ViewPort3D.cs
- TriggerBase.cs
- TargetConverter.cs
- EntitySqlException.cs
- Types.cs
- CodeObjectCreateExpression.cs
- Parameter.cs
- TextTreeFixupNode.cs
- EntityUtil.cs
- FormViewDeleteEventArgs.cs
- ComponentResourceManager.cs
- NumberSubstitution.cs
- FileSecurity.cs
- TemplateColumn.cs
- NamespaceQuery.cs
- XmlToDatasetMap.cs
- PropertyDescriptorComparer.cs
- X509Extension.cs
- AnnotationResourceChangedEventArgs.cs
- PromptStyle.cs
- SettingsBase.cs
- LineSegment.cs
- BitmapEffectOutputConnector.cs
- DeclaredTypeValidatorAttribute.cs
- PerformanceCounterCategory.cs
- MultitargetingHelpers.cs
- RemoveStoryboard.cs
- GeometryDrawing.cs