diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/TransformProvider2Wrapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/TransformProvider2Wrapper.cs new file mode 100644 index 00000000000..c1c4b597227 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/TransformProvider2Wrapper.cs @@ -0,0 +1,178 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// +// +// +// Description: Transform pattern provider wrapper for WCP +// +// + +using System; +using System.Windows.Threading; +using System.Windows.Media; +using System.Windows.Automation; +using System.Windows.Automation.Provider; +using System.Windows.Automation.Peers; + +namespace MS.Internal.Automation +{ + // Automation/WCP Wrapper class: Implements that UIAutomation I...Provider + // interface, and calls through to a WCP AutomationPeer which implements the corresponding + // I...Provider inteface. Marshalls the call from the RPC thread onto the + // target AutomationPeer's context. + // + // Class has two major parts to it: + // * Implementation of the I...Provider, which uses Dispatcher.Invoke + // to call a private method (lives in second half of the class) via a delegate, + // if necessary, packages any params into an object param. Return type of Invoke + // must be cast from object to appropriate type. + // * private methods - one for each interface entry point - which get called back + // on the right context. These call through to the peer that's actually + // implenting the I...Provider version of the interface. + internal class TransformProvider2Wrapper: TransformProviderWrapper, ITransformProvider2 + { + //------------------------------------------------------ + // + // Constructors + // + //------------------------------------------------------ + + #region Constructors + + private TransformProvider2Wrapper( AutomationPeer peer, ITransformProvider2 iface ) : base(peer, iface) + { + _peer = peer; + _iface = iface; + } + + #endregion Constructors + + + //------------------------------------------------------ + // + // Interface IWindowProvider + // + //------------------------------------------------------ + + #region Interface ITransformProvider2 + + + public void Zoom( double zoomAmount ) + { + ElementUtil.Invoke( _peer, new DispatcherOperationCallback( Zoom ), zoomAmount ); + } + + public void ZoomByUnit( ZoomUnit zoomUnit ) + { + ElementUtil.Invoke( _peer, new DispatcherOperationCallback( ZoomByUnit ), zoomUnit ); + } + + public bool CanZoom + { + get + { + return (bool) ElementUtil.Invoke( _peer, new DispatcherOperationCallback( GetCanZoom ), null ); + } + } + + public double ZoomLevel + { + get + { + return (double) ElementUtil.Invoke( _peer, new DispatcherOperationCallback( GetZoomLevel ), null ); + } + } + + public double ZoomMinimum + { + get + { + return (double) ElementUtil.Invoke( _peer, new DispatcherOperationCallback(GetZoomMinimum ), null ); + } + } + + + public double ZoomMaximum + { + get + { + return (double)ElementUtil.Invoke(_peer, new DispatcherOperationCallback(GetZoomMaximum), null); + } + } + + #endregion Interface ITransformProvider2 + + + //------------------------------------------------------ + // + // Internal Methods + // + //------------------------------------------------------ + + #region Internal Methods + + internal static new object Wrap( AutomationPeer peer, object iface ) + { + return new TransformProvider2Wrapper( peer, (ITransformProvider2) iface ); + } + + #endregion Internal Methods + + //------------------------------------------------------ + // + // Private Methods + // + //------------------------------------------------------ + + #region Private Methods + + private object Zoom( object arg ) + { + _iface.Zoom( (double)arg ); + return null; + } + + private object ZoomByUnit( object arg ) + { + _iface.ZoomByUnit( (ZoomUnit)arg ); + return null; + } + + private object GetCanZoom( object unused ) + { + return _iface.CanZoom; + } + + private object GetZoomLevel( object unused ) + { + return _iface.ZoomLevel; + } + + private object GetZoomMinimum( object unused ) + { + return _iface.ZoomMinimum; + } + + private object GetZoomMaximum(object unused) + { + return _iface.ZoomMaximum; + } + + #endregion Private Methods + + + //------------------------------------------------------ + // + // Private Fields + // + //------------------------------------------------------ + + #region Private Fields + + private AutomationPeer _peer; + private ITransformProvider2 _iface; + + #endregion Private Fields + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/TransformProviderWrapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/TransformProviderWrapper.cs index 2ab80ad29fa..cefdc993815 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/TransformProviderWrapper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Automation/TransformProviderWrapper.cs @@ -37,7 +37,7 @@ internal class TransformProviderWrapper: MarshalByRefObject, ITransformProvider #region Constructors - private TransformProviderWrapper( AutomationPeer peer, ITransformProvider iface ) + private protected TransformProviderWrapper( AutomationPeer peer, ITransformProvider iface ) { _peer = peer; _iface = iface; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj index da1d32be5fa..7ad27fb3c11 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj @@ -158,6 +158,7 @@ + @@ -706,7 +707,7 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs index 5d4ce668f6c..771f399731d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs @@ -56,6 +56,8 @@ public enum PatternInterface VirtualizedItem, /// SynchronizedInput, + /// + Transform2 } /// @@ -2379,6 +2381,7 @@ private static void Initialize() s_patternInfo[TableItemPatternIdentifiers.Pattern.Id] = new PatternInfo(TableItemPatternIdentifiers.Pattern.Id, new WrapObject(TableItemProviderWrapper.Wrap), PatternInterface.TableItem); s_patternInfo[TogglePatternIdentifiers.Pattern.Id] = new PatternInfo(TogglePatternIdentifiers.Pattern.Id, new WrapObject(ToggleProviderWrapper.Wrap), PatternInterface.Toggle); s_patternInfo[TransformPatternIdentifiers.Pattern.Id] = new PatternInfo(TransformPatternIdentifiers.Pattern.Id, new WrapObject(TransformProviderWrapper.Wrap), PatternInterface.Transform); + s_patternInfo[TransformPattern2Identifiers.Pattern.Id] = new PatternInfo(TransformPattern2Identifiers.Pattern.Id, new WrapObject(TransformProvider2Wrapper.Wrap), PatternInterface.Transform2); s_patternInfo[TextPatternIdentifiers.Pattern.Id] = new PatternInfo(TextPatternIdentifiers.Pattern.Id, new WrapObject(TextProviderWrapper.Wrap), PatternInterface.Text); // To avoid the worst situation on legacy systems which may not have new unmanaged core. with this change with old unmanaged core diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore.cs index 65bd40f90d2..beab64227d0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore.cs @@ -2471,6 +2471,7 @@ public enum PatternInterface ItemContainer = 18, VirtualizedItem = 19, SynchronizedInput = 20, + Transform2 = 21 } public partial class UIElement3DAutomationPeer : System.Windows.Automation.Peers.AutomationPeer { diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/Schema.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/Schema.cs index 623ee7f9974..676f9db5373 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/Schema.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/Schema.cs @@ -319,6 +319,7 @@ private static object ConvertToAutomationHeadingLevel(object value) new AutomationPropertyInfo( convertToBool, AutomationElement.IsTextPatternAvailableProperty, typeof(bool), false ), new AutomationPropertyInfo( convertToBool, AutomationElement.IsTogglePatternAvailableProperty, typeof(bool), false ), new AutomationPropertyInfo( convertToBool, AutomationElement.IsTransformPatternAvailableProperty, typeof(bool), false ), + new AutomationPropertyInfo( convertToBool, AutomationElement.IsTransformPattern2AvailableProperty, typeof(bool), false ), new AutomationPropertyInfo( convertToBool, AutomationElement.IsValuePatternAvailableProperty, typeof(bool), false ), new AutomationPropertyInfo( convertToBool, AutomationElement.IsWindowPatternAvailableProperty, typeof(bool), false ), @@ -369,6 +370,11 @@ private static object ConvertToAutomationHeadingLevel(object value) new AutomationPropertyInfo( convertToBool, TransformPattern.CanMoveProperty, typeof(bool), false ), new AutomationPropertyInfo( convertToBool, TransformPattern.CanResizeProperty, typeof(bool), false ), new AutomationPropertyInfo( convertToBool, TransformPattern.CanRotateProperty, typeof(bool), false ), + new AutomationPropertyInfo( convertToBool, TransformPattern2.CanZoomProperty, typeof(bool), false ), + new AutomationPropertyInfo( null, TransformPattern2.ZoomLevelProperty, typeof(double), (double)0 ), + new AutomationPropertyInfo( null, TransformPattern2.ZoomMinimumProperty, typeof(double), (double)0 ), + new AutomationPropertyInfo( null, TransformPattern2.ZoomMaximumProperty, typeof(double), (double)0 ), + }; // Basic properties assumed to be always supported @@ -463,6 +469,13 @@ private static object ConvertToAutomationHeadingLevel(object value) private static readonly AutomationProperty [ ] TransformProperties = { TransformPattern.CanMoveProperty, TransformPattern.CanResizeProperty, TransformPattern.CanRotateProperty}; + + + private static readonly AutomationProperty[] Transform2Properties = { TransformPattern2.CanZoomProperty, + TransformPattern2.ZoomLevelProperty, + TransformPattern2.ZoomMinimumProperty, + TransformPattern2.ZoomMaximumProperty}; + private static readonly AutomationPatternInfo [ ] _patternInfoTable = { new AutomationPatternInfo( InvokePattern.Pattern, null, new WrapObjectClientSide(InvokePattern.Wrap) ), @@ -481,7 +494,8 @@ private static object ConvertToAutomationHeadingLevel(object value) new AutomationPatternInfo( TableItemPattern.Pattern, TableItemProperties, new WrapObjectClientSide(TableItemPattern.Wrap) ), new AutomationPatternInfo( TextPattern.Pattern, null, new WrapObjectClientSide(TextPattern.Wrap) ), new AutomationPatternInfo( TogglePattern.Pattern, ToggleProperties, new WrapObjectClientSide(TogglePattern.Wrap) ), - new AutomationPatternInfo( TransformPattern.Pattern, TransformProperties, new WrapObjectClientSide(TransformPattern.Wrap) ), + new AutomationPatternInfo( TransformPattern.Pattern, TransformProperties, new WrapObjectClientSide(TransformPattern.Wrap) ), + new AutomationPatternInfo( TransformPattern2.Pattern, Transform2Properties, new WrapObjectClientSide(TransformPattern2.Wrap) ), new AutomationPatternInfo( ScrollItemPattern.Pattern, null, new WrapObjectClientSide(ScrollItemPattern.Wrap) ), new AutomationPatternInfo( SynchronizedInputPattern.Pattern, null, new WrapObjectClientSide(SynchronizedInputPattern.Wrap) ), new AutomationPatternInfo( VirtualizedItemPattern.Pattern, null, new WrapObjectClientSide(VirtualizedItemPattern.Wrap)), diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/UiaCoreApi.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/UiaCoreApi.cs index 919db8731b8..3608e535ee0 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/UiaCoreApi.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/UiaCoreApi.cs @@ -809,6 +809,16 @@ internal static void TransformPattern_Rotate(SafePatternHandle hobj, double degr CheckError(RawTransformPattern_Rotate(hobj, degrees)); } + internal static void TransformPattern2_Zoom(SafePatternHandle hobj, double zoomValue) + { + CheckError(RawTransformPattern2_Zoom(hobj, zoomValue)); + } + + internal static void TransformPattern2_ZoomByUnit(SafePatternHandle hobj, ZoomUnit zoomUnit) + { + CheckError(RawTransformPattern2_ZoomByUnit(hobj, zoomUnit)); + } + internal static void ValuePattern_SetValue(SafePatternHandle hobj, string pVal) { CheckError(RawValuePattern_SetValue(hobj, pVal)); @@ -1337,6 +1347,12 @@ private static void CheckError(int hr) [DllImport(DllImport.UIAutomationCore, EntryPoint = "TransformPattern_Rotate", CharSet = CharSet.Unicode)] private static extern int RawTransformPattern_Rotate(SafePatternHandle hobj, double degrees); + [DllImport(DllImport.UIAutomationCore, EntryPoint = "TransformPattern2_Zoom", CharSet = CharSet.Unicode)] + private static extern int RawTransformPattern2_Zoom(SafePatternHandle hobj, double degrees); // TODO: Needs to use Microsoft UI Automation Component Object Model (COM) interfaces instead. + + [DllImport(DllImport.UIAutomationCore, EntryPoint = "TransformPattern2_ZoomByUnit", CharSet = CharSet.Unicode)] + private static extern int RawTransformPattern2_ZoomByUnit(SafePatternHandle hobj, ZoomUnit unit); // TODO: Needs to use Microsoft UI Automation Component Object Model (COM) interfaces instead. + [DllImport(DllImport.UIAutomationCore, EntryPoint = "ValuePattern_SetValue", CharSet = CharSet.Unicode)] private static extern int RawValuePattern_SetValue(SafePatternHandle hobj, [MarshalAs(UnmanagedType.LPWStr)] string pVal); diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/AutomationElement.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/AutomationElement.cs index c0a57525f8f..35d0165bb30 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/AutomationElement.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/AutomationElement.cs @@ -237,6 +237,8 @@ internal static AutomationElement Wrap(SafeNodeHandle hnode) public static readonly AutomationProperty IsTogglePatternAvailableProperty = AutomationElementIdentifiers.IsTogglePatternAvailableProperty; /// Property that indicates whether the TransformPattern is available for this AutomationElement public static readonly AutomationProperty IsTransformPatternAvailableProperty = AutomationElementIdentifiers.IsTransformPatternAvailableProperty; + /// Property that indicates whether the TransformPattern2 is available for this AutomationElement + public static readonly AutomationProperty IsTransformPattern2AvailableProperty = AutomationElementIdentifiers.IsTransformPattern2AvailableProperty; /// Property that indicates whether the ValuePattern is available for this AutomationElement public static readonly AutomationProperty IsValuePatternAvailableProperty = AutomationElementIdentifiers.IsValuePatternAvailableProperty; /// Property that indicates whether the WindowPattern is available for this AutomationElement diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/TransformPattern.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/TransformPattern.cs index 2b7f3c2e93b..51c8cd2dc86 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/TransformPattern.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/TransformPattern.cs @@ -22,7 +22,7 @@ public class TransformPattern: BasePattern #region Constructors - private TransformPattern(AutomationElement el, SafePatternHandle hPattern, bool cached) + private protected TransformPattern(AutomationElement el, SafePatternHandle hPattern, bool cached) : base(el, hPattern) { _hPattern = hPattern; diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/TransformPattern2.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/TransformPattern2.cs new file mode 100644 index 00000000000..78faa76f25b --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/TransformPattern2.cs @@ -0,0 +1,280 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// Description: Client-side wrapper for Transform Pattern + +using MS.Internal.Automation; + +namespace System.Windows.Automation +{ + ///wrapper class for Transform pattern +#if (INTERNAL_COMPILE) + internal class TransformPattern2: TransformPattern +#else + public class TransformPattern2: TransformPattern +#endif + { + //------------------------------------------------------ + // + // Constructors + // + //------------------------------------------------------ + + #region Constructors + + private TransformPattern2(AutomationElement el, SafePatternHandle hPattern, bool cached) + : base(el, hPattern, cached) + { + _hPattern = hPattern; + _cached = cached; + } + + #endregion Constructors + + + //------------------------------------------------------ + // + // Public Constants / Readonly Fields + // + //------------------------------------------------------ + + #region Public Constants and Readonly Fields + + /// Returns the Transform pattern identifier + public static new readonly AutomationPattern Pattern = TransformPattern2Identifiers.Pattern; + + /// Property ID: CanZoom - Indicates whether the control supports zooming of its viewport + public static readonly AutomationProperty CanZoomProperty = TransformPattern2Identifiers.CanZoomProperty; + + public static readonly AutomationProperty ZoomLevelProperty = TransformPattern2Identifiers.ZoomLevelProperty; + + public static readonly AutomationProperty ZoomMaximumProperty = TransformPattern2Identifiers.ZoomMaximumProperty; + + public static readonly AutomationProperty ZoomMinimumProperty = TransformPattern2Identifiers.ZoomMinimumProperty; + + + #endregion Public Constants and Readonly Fields + + + //------------------------------------------------------ + // + // Public Methods + // + //------------------------------------------------------ + + #region Public Methods + + /// + /// Used to adjust an element's current location. The x, and y parameters represent the + /// absolute on-screen position of the top-left corner in pixels, not the delta between the + /// desired location and the window's current location. + /// + /// + /// absolute on-screen position of the top left corner + /// absolute on-screen position of the top left corner + public void Zoom( double zoomValue ) + { + UiaCoreApi.TransformPattern2_Zoom(_hPattern, zoomValue); + } + + /// + /// Used to modify element's on-screen dimensions (affects the + /// BoundingRectangle and BoundingGeometry properties) + /// When called on a split pane, it may have the side-effect of resizing + /// other surrounding panes. + /// + /// The requested width of the window. + /// The requested height of the window. + public void ZoomByUnit( ZoomUnit zoomUnit ) + { + UiaCoreApi.TransformPattern2_ZoomByUnit(_hPattern, zoomUnit); + } + + + #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 new TransformPattern2Information Cached + { + get + { + Misc.ValidateCached(_cached); + return new TransformPattern2Information(_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 new TransformPattern2Information Current + { + get + { + Misc.ValidateCurrent(_hPattern); + return new TransformPattern2Information(_el, false); + } + } + + + #endregion Public Properties + + + //------------------------------------------------------ + // + // Internal Methods + // + //------------------------------------------------------ + + #region Internal Methods + + internal static new object Wrap(AutomationElement el, SafePatternHandle hPattern, bool cached) + { + return new TransformPattern2(el, hPattern, cached); + } + + #endregion Internal Methods + + + //------------------------------------------------------ + // + // Private Fields + // + //------------------------------------------------------ + + #region Private Fields + + private SafePatternHandle _hPattern; + private 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 TransformPattern2Information + { + //------------------------------------------------------ + // + // Constructors + // + //------------------------------------------------------ + + #region Constructors + + internal TransformPattern2Information(AutomationElement el, bool useCache) + { + _el = el; + _useCache = useCache; + } + + #endregion Constructors + + + //------------------------------------------------------ + // + // Public Properties + // + //------------------------------------------------------ + + #region Public Properties + + /// Returns true if the element can be moved otherwise returns false. + public bool CanZoom + { + get + { + return (bool)_el.GetPatternPropertyValue(CanZoomProperty, _useCache); + } + } + + /// Returns true if the element can be resized otherwise returns false. + public double ZoomLevel + { + get + { + return (double)_el.GetPatternPropertyValue(ZoomLevelProperty, _useCache); + } + } + + public double ZoomMinimum + { + get + { + return (double)_el.GetPatternPropertyValue(ZoomMinimumProperty, _useCache); + } + } + + /// Returns true if the element can be rotated otherwise returns false. + public double ZoomMaximum + { + get + { + return (double)_el.GetPatternPropertyValue(ZoomMaximumProperty, _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 + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/UIAutomationClient.csproj b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/UIAutomationClient.csproj index 870f1c0b206..db450c104bc 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/UIAutomationClient.csproj +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/UIAutomationClient.csproj @@ -86,6 +86,7 @@ + diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/ref/UIAutomationClient.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/ref/UIAutomationClient.cs index 0bc1234de9b..96d6e344381 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/ref/UIAutomationClient.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/ref/UIAutomationClient.cs @@ -72,6 +72,7 @@ internal AutomationElement() { } public static readonly System.Windows.Automation.AutomationProperty IsTextPatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsTogglePatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsTransformPatternAvailableProperty; + public static readonly System.Windows.Automation.AutomationProperty IsTransformPattern2AvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsValuePatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsVirtualizedItemPatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsWindowPatternAvailableProperty; @@ -568,6 +569,27 @@ public partial struct TransformPatternInformation public bool CanRotate { get { throw null; } } } } + public partial class TransformPattern2 : TransformPattern + { + internal TransformPattern2() { } + public static readonly System.Windows.Automation.AutomationProperty CanZoomProperty; + public static readonly System.Windows.Automation.AutomationProperty ZoomLevelProperty; + public static readonly System.Windows.Automation.AutomationProperty ZoomMinimumProperty; + public static readonly System.Windows.Automation.AutomationProperty ZoomMaximumProperty; + public void Zoom(double zoomAmount) { } + public void ZoomByUnit(ZoomUnit zoomUnit) { } + public static new readonly System.Windows.Automation.AutomationPattern Pattern; + public new System.Windows.Automation.TransformPattern2.TransformPattern2Information Cached { get { throw null; } } + public new System.Windows.Automation.TransformPattern2.TransformPattern2Information Current { get { throw null; } } + + public partial struct TransformPattern2Information + { + public bool CanZoom { get { throw null; } } + public double ZoomLevel { get { throw null; } } + public double ZoomMinimum { get { throw null; } } + public double ZoomMaximum { get { throw null; } } + } + } public sealed partial class TreeWalker { public static readonly System.Windows.Automation.TreeWalker ContentViewWalker; diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/System/Windows/Automation/Provider/ITransformProvider2.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/System/Windows/Automation/Provider/ITransformProvider2.cs new file mode 100644 index 00000000000..4143c2843bc --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/System/Windows/Automation/Provider/ITransformProvider2.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// Description: Transform pattern provider interface 2 + +using System; +using System.Windows.Automation; +using System.Runtime.InteropServices; + +namespace System.Windows.Automation.Provider +{ + /// + /// Extends the interface to enable Microsoft UI Automation providers to expose API to support the viewport zooming functionality of a control. + /// + [ComVisible(true)] + [Guid("4758742f-7ac2-460c-bc48-09fc09308a93")] +#if (NO_INTERNAL_COMPILE_BUG1080665) + internal interface ITransformProvider2: ITransformProvider +#else + public interface ITransformProvider2 : ITransformProvider +#endif + { + /// + /// Zooms the viewport of the control. + /// + /// + /// The amount to zoom the viewport, specified as a percentage. The provider should zoom the viewport to the nearest supported value. + void Zoom( double zoom ); + + /// + /// Zooms the viewport of the control by the specified logical unit. + /// + /// The logical unit by which to increase or decrease the zoom of the viewport. + void ZoomByUnit( ZoomUnit zoomUnit ); + + /// Gets a value that indicates whether the control supports zooming of its viewport. + /// true if the viewport can be zoomed; otherwise, false. + bool CanZoom + { + [return: MarshalAs(UnmanagedType.Bool)] // Without this, only lower SHORT of BOOL*pRetVal param is updated. + get; + } + + /// Gets the zoom level of the control's viewport. + /// The zoom level, specified as a percentage. The provider should zoom the viewport to the nearest supported value. + double ZoomLevel + { + get; + } + + /// Gets the minimum zoom level of the element. + /// The minimum zoom level, as a percentage. + double ZoomMinimum + { + get; + } + + /// Gets the maximum zoom level of the element. + /// The maximum zoom level, as a percentage. + double ZoomMaximum + { + get; + } + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/UIAutomationProvider.csproj b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/UIAutomationProvider.csproj index 00b71449841..2144d9d4113 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/UIAutomationProvider.csproj +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/UIAutomationProvider.csproj @@ -40,6 +40,7 @@ + diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/ref/UIAutomationProvider.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/ref/UIAutomationProvider.cs index b4501acc1ef..b4786deb7e0 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/ref/UIAutomationProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationProvider/ref/UIAutomationProvider.cs @@ -157,6 +157,15 @@ public partial interface ITransformProvider void Resize(double width, double height); void Rotate(double degrees); } + public partial interface ITransformProvider2 : ITransformProvider + { + bool CanZoom { get; } + double ZoomLevel { get; } + double ZoomMinimum { get; } + double ZoomMaximum { get; } + void Zoom(double zoomAmount); + void ZoomByUnit(ZoomUnit zoomUnit); + } public partial interface IValueProvider { bool IsReadOnly { get; } diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/System/Windows/Automation/AutomationElementIdentifiers.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/System/Windows/Automation/AutomationElementIdentifiers.cs index 2a45341ff35..6110fc03e31 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/System/Windows/Automation/AutomationElementIdentifiers.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/System/Windows/Automation/AutomationElementIdentifiers.cs @@ -177,6 +177,8 @@ public static class AutomationElementIdentifiers public static readonly AutomationProperty IsTogglePatternAvailableProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.IsTogglePatternAvailable, "AutomationElementIdentifiers.IsTogglePatternAvailableProperty"); /// Property that indicates whether the TransformPattern is available for this AutomationElement public static readonly AutomationProperty IsTransformPatternAvailableProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.IsTransformPatternAvailable, "AutomationElementIdentifiers.IsTransformPatternAvailableProperty"); + /// Property that indicates whether the TransformPattern is available for this AutomationElement + public static readonly AutomationProperty IsTransformPattern2AvailableProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.IsTransformPattern2Available, "AutomationElementIdentifiers.IsTransformPattern2AvailableProperty"); /// Property that indicates whether the ValuePattern is available for this AutomationElement public static readonly AutomationProperty IsValuePatternAvailableProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.IsValuePatternAvailable, "AutomationElementIdentifiers.IsValuePatternAvailableProperty"); /// Property that indicates whether the WindowPattern is available for this AutomationElement diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/System/Windows/Automation/TransformPattern2Identifiers.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/System/Windows/Automation/TransformPattern2Identifiers.cs new file mode 100644 index 00000000000..4ae1a766cb7 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/System/Windows/Automation/TransformPattern2Identifiers.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// Description: Automation Identifiers for Transform Pattern + +using MS.Internal.Automation; + +namespace System.Windows.Automation +{ + /// + /// Contains possible values for the ITransformProvider2.ZoomByUnit method, which zooms the viewport of a control by the specified unit. + /// + public enum ZoomUnit + { + /// + /// No increase or decrease in zoom. + /// + NoAmount = 0, + + /// + /// Decrease zoom by a large decrement. + /// + LargeDecrement = 1, + + /// + /// Decrease zoom by a small decrement. + /// + SmallDecrement = 2, + + /// + /// Increase zoom by a large increment. + /// + LargeIncrement = 3, + + /// + /// Increase zoom by a small increment. + /// + SmallIncrement = 4 + }; + + ///wrapper class for Transform2 pattern +#if (INTERNAL_COMPILE) + internal static class TransformPattern2Identifiers +#else + public static class TransformPattern2Identifiers +#endif + { + //------------------------------------------------------ + // + // Public Constants / Readonly Fields + // + //------------------------------------------------------ + + #region Public Constants and Readonly Fields + + /// Returns the Transform pattern identifier + public static readonly AutomationPattern Pattern = AutomationPattern.Register(AutomationIdentifierConstants.Patterns.Transform2, "TransformPattern2Identifiers.Pattern"); + + /// Property ID: CanZoom - This window can be zoom + public static readonly AutomationProperty CanZoomProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.Transform2CanZoom, "TransformPattern2Identifiers.CanZoomProperty"); + + /// Property ID: ZoomLevelProperty - The zoomlevel of the window + public static readonly AutomationProperty ZoomLevelProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.Transform2ZoomLevel, "TransformPattern2Identifiers.ZoomLevelProperty"); + + /// Property ID: ZoomMaximum - This maximum this window can be zoomed + public static readonly AutomationProperty ZoomMaximumProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.Transform2ZoomMaximum, "TransformPattern2Identifiers.ZoomMaximumProperty"); + + /// Property ID: ZoomMinimum - This minimum this window can be zoomed + public static readonly AutomationProperty ZoomMinimumProperty = AutomationProperty.Register(AutomationIdentifierConstants.Properties.Transform2ZoomMinimum, "TransformPattern2Identifiers.ZoomMinimumProperty"); + + + #endregion Public Constants and Readonly Fields + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj index 42827702f21..acf81f68d70 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/UIAutomationTypes.csproj @@ -68,6 +68,7 @@ + diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/ref/UIAutomationTypes.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/ref/UIAutomationTypes.cs index ac901a2489e..8d4ce5c3518 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/ref/UIAutomationTypes.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationTypes/ref/UIAutomationTypes.cs @@ -65,6 +65,7 @@ public static partial class AutomationElementIdentifiers public static readonly System.Windows.Automation.AutomationProperty IsTextPatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsTogglePatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsTransformPatternAvailableProperty; + public static readonly System.Windows.Automation.AutomationProperty IsTransformPattern2AvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsValuePatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsVirtualizedItemPatternAvailableProperty; public static readonly System.Windows.Automation.AutomationProperty IsWindowPatternAvailableProperty; @@ -472,6 +473,22 @@ public static partial class TransformPatternIdentifiers public static readonly System.Windows.Automation.AutomationProperty CanRotateProperty; public static readonly System.Windows.Automation.AutomationPattern Pattern; } + public enum ZoomUnit + { + NoAmount = 0, + LargeDecrement = 1, + SmallDecrement = 2, + LargeIncrement = 3, + SmallIncrement = 4 + }; + public static partial class TransformPattern2Identifiers + { + public static readonly System.Windows.Automation.AutomationProperty CanZoomProperty; + public static readonly System.Windows.Automation.AutomationProperty ZoomLevelProperty; + public static readonly System.Windows.Automation.AutomationProperty ZoomMinimumProperty; + public static readonly System.Windows.Automation.AutomationProperty ZoomMaximumProperty; + public static readonly System.Windows.Automation.AutomationPattern Pattern; + } [System.FlagsAttribute] public enum TreeScope {