using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Shell32 { /// The edge which should be adjacent. [PInvokeData("shobjidl_core.h", MSDNShortId = "NF:shobjidl_core.IApplicationDesignModeSettings2.SetAdjacentDisplayEdges")] [Flags] public enum ADJACENT_DISPLAY_EDGES { /// The widow will not be adjacent to either edge. ADE_NONE = 0, /// the left edge of the window will be adjacent. ADE_LEFT = 0x1, /// The right edge of the window will be adjacent. ADE_RIGHT = 0x2 } /// The desired minimum width of the application design mode window. [PInvokeData("shobjidl_core.h", MSDNShortId = "NF:shobjidl_core.IApplicationDesignModeSettings2.SetApplicationViewMinWidth")] public enum APPLICATION_VIEW_MIN_WIDTH { /// Uses the default minimum width. AVMW_DEFAULT = 0, /// Sets the minimum width at 320 pixels. AVMW_320 = 1, /// Sets the minimum width at 500 pixels. AVMW_500 = 2 } /// /// Defines the set of display orientation modes for a window (app view). Used by /// IApplicationDesignModeSettings2::GetApplicationViewOrientation and IApplicationDesignModeSettings2::SetApplicationViewOrientation. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-application_view_orientation typedef enum // APPLICATION_VIEW_ORIENTATION { AVO_LANDSCAPE, AVO_PORTRAIT } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "NE:shobjidl_core.APPLICATION_VIEW_ORIENTATION")] public enum APPLICATION_VIEW_ORIENTATION { /// The window is in landscape orientation, with the display width greater than the height. AVO_LANDSCAPE = 0, /// The window is in portrait orientation, with the display height greater than the width. AVO_PORTRAIT = (AVO_LANDSCAPE + 1) } /// /// Indicates the current view state of a Windows Store app. Used by IApplicationDesignModeSettings::SetApplicationViewState and IApplicationDesignModeSettings::IsApplicationViewStateSupported. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-application_view_state typedef enum // APPLICATION_VIEW_STATE { AVS_FULLSCREEN_LANDSCAPE, AVS_FILLED, AVS_SNAPPED, AVS_FULLSCREEN_PORTRAIT } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "NE:shobjidl_core.APPLICATION_VIEW_STATE")] public enum APPLICATION_VIEW_STATE { /// The current app's view is full-screen (has no snapped app adjacent to it), and is in landscape orientation. AVS_FULLSCREEN_LANDSCAPE, /// /// The current app's view has been reduced to a partial screen view as the result of another app snapping (being docked at one /// side of the screen in a narrow view). /// AVS_FILLED, /// The current app's view has been snapped (docked at one side of the screen in a narrow view). AVS_SNAPPED, /// The current app's view is full-screen (has no snapped app adjacent to it), and is in portrait orientation. AVS_FULLSCREEN_PORTRAIT, } /// Indicates the input type that generated the spoofed edge gesture. [PInvokeData("shobjidl_core.h", MSDNShortId = "NF:shobjidl_core.IApplicationDesignModeSettings.TriggerEdgeGesture")] public enum EDGE_GESTURE_KIND { /// The edge gesture event was generated by a swipe on a touch-enabled screen. EGK_TOUCH = 0, /// The edge gesture event was generated by the Win+Z key sequence on the keyboard. EGK_KEYBOARD = (EGK_TOUCH + 1), /// The edge gesture event was generated by a right mouse click. EGK_MOUSE = (EGK_KEYBOARD + 1) } /// The native orientation of the display to emulate. [PInvokeData("shobjidl_core.h", MSDNShortId = "NF:shobjidl_core.IApplicationDesignModeSettings2.SetNativeDisplayOrientation")] public enum NATIVE_DISPLAY_ORIENTATION { /// Landscape orientation, with the display width greater than the height. NDO_LANDSCAPE = 0, /// Portrait orientation, with the display height greater than the width. NDO_PORTRAIT = (NDO_LANDSCAPE + 1) } /// /// Enables development tool applications to dynamically spoof system and user states, such as native display resolution, device /// scale factor, and application view state, for the purpose of testing Windows Store apps running in design mode for a wide range /// of form factors without the need for the actual hardware. Also enables testing of changes in normally user-controlled state to /// test Windows Store apps under a variety of scenarios. /// /// /// This interface is acquired by cocreating CLSID_ApplicationDesignModeSettings. /// Users will normally follow a usage pattern similar to the following: /// /// /// /// Call CoCreateInstance with CLSID_ApplicationDesignModeSettings to create the application design mode settings object on a thread /// in the Windows Store app process. /// /// /// /// Call QueryInterface on the application design mode settings object to obtain an IInitializeWithWindow object. /// /// /// /// Call the Initialize method of the IInitializeWithWindow object, passing in the HWND for the proxy core window. This must be done /// before any "set" methods are called and will only succeed once per process. /// /// /// /// /// Call QueryInterface for IApplicationDesignModeSettings and spoof the necessary test state by calling its appropriate /// methods (SetNativeDisplaySize, SetScaleFactor, etc.). These methods will trigger the appropriate Windows Runtime events to fire /// for the Windows Store app. /// /// /// /// /// Call the ComputeApplicationSize method to determine the proper size for the app, based on the currently spoofed state. All /// layout "set" methods must have already been called or this call will fail. The developer tool application is responsible for /// positioning and sizing the app windows, when appropriate. /// /// /// /// When to implement /// Do not implement this interface; the implementation is supplied with Windows. /// When to use /// Use the methods of this interface to test your Windows Store app under various spoofed configurations and scenarios. /// Examples /// This example shows the methods of this interface in use. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iapplicationdesignmodesettings [PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IApplicationDesignModeSettings")] [ComImport, Guid("2A3DEE9A-E31D-46D6-8508-BCC597DB3557"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ApplicationDesignModeSettings))] public interface IApplicationDesignModeSettings { /// /// Sets a spoofed native display size to be used for a Windows Store app running in design mode. /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// SetNativeDisplaySize must be called before calling ComputeApplicationSize. /// /// /// The native size of the display to spoof, as a SIZE structure. The specified size will be normalized to a landscape /// orientation. To spoof orientation, see SetApplicationViewState. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-setnativedisplaysize // HRESULT SetNativeDisplaySize( SIZE nativeDisplaySizePixels ); void SetNativeDisplaySize(SIZE nativeDisplaySizePixels); /// /// Sets a spoofed device scale factor to be used for a Windows Store app running in design mode. /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// SetScaleFactor must be called before calling ComputeApplicationSize. /// /// One of the DEVICE_SCALE_FACTOR enumeration values that indicates the device scale factor to spoof. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-setscalefactor // HRESULT SetScaleFactor( DEVICE_SCALE_FACTOR scaleFactor ); void SetScaleFactor(DEVICE_SCALE_FACTOR scaleFactor); /// /// /// Sets a spoofed application view state (full-screen landscape, full-screen portrait, filled, or snapped) to be used for a /// Windows Store app running in design mode. /// /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// SetApplicationViewState must be called before calling ComputeApplicationSize. /// /// /// One of the APPLICATION_VIEW_STATE enumeration values that indicates the application view state to spoof. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-setapplicationviewstate // HRESULT SetApplicationViewState( APPLICATION_VIEW_STATE viewState ); void SetApplicationViewState(APPLICATION_VIEW_STATE viewState); /// /// Gets the size of the Windows Store app, based on the current set of spoofed settings. /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// In addition, each of these methods must be called before calling ComputeApplicationSize, or the call will fail. /// SetApplicationViewState /// SetNativeDisplaySize /// SetScaleFactor /// /// /// When this method returns successfully, receives a pointer to the size that the Windows Store app should occupy, based on the /// current set of spoofed settings. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-computeapplicationsize // HRESULT ComputeApplicationSize( SIZE *applicationSizePixels ); SIZE ComputeApplicationSize(); /// /// /// Determines whether a particular application view state is supported for specific spoofed display size and scale factor settings. /// /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// /// /// One of the enumeration values that indicates the application view state for which support is being determined. /// /// The native size of the display to spoof. /// One of the enumeration values that indicates the device scale factor to spoof. /// /// When this method returns successfully, receives a pointer to a Boolean value which is set to TRUE if the application /// view state is supported for the given display size and scale factor, and FALSE if it is not. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-isapplicationviewstatesupported // HRESULT IsApplicationViewStateSupported( APPLICATION_VIEW_STATE viewState, SIZE nativeDisplaySizePixels, DEVICE_SCALE_FACTOR // scaleFactor, BOOL *supported ); [return: MarshalAs(UnmanagedType.Bool)] bool IsApplicationViewStateSupported(APPLICATION_VIEW_STATE viewState, SIZE nativeDisplaySizePixels, DEVICE_SCALE_FACTOR scaleFactor); /// /// /// Sends a spoofed edge gesture event to the proxy core window on the caller's thread. This gesture toggles the app's app bar, /// if the app supports one. The caller can specify the type of input that triggered the edge gesture. /// /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// /// /// /// Indicates the EDGE_GESTURE_KIND input type that generated the spoofed edge gesture. If touch ( EGK_TOUCH) is /// specified, both the Starting and Completed edge gesture events are sent. Otherwise, only the Completed /// event is sent. One of the following values: /// /// EGK_TOUCH (0) /// The edge gesture event was generated by a swipe on a touch-enabled screen. /// EGK_KEYBOARD (1) /// The edge gesture event was generated by the Win+Z key sequence on the keyboard. /// EGK_MOUSE (2) /// The edge gesture event was generated by a right mouse click. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-triggeredgegesture // HRESULT TriggerEdgeGesture( EDGE_GESTURE_KIND edgeGestureKind ); void TriggerEdgeGesture(EDGE_GESTURE_KIND edgeGestureKind); } /// /// Enables development tool applications to dynamically control system and user states, such as native display resolution, device /// scale factor, and application view layout, reported to Windows Store apps for the purpose of testing Windows Store apps running /// in design mode for a wide range of form factors without the need for the actual hardware. Also enables testing of changes in /// normally user-controlled state to test Windows Store apps under a variety of scenarios. /// /// /// /// This interface is acquired by cocreating CLSID_ApplicationDesignModeSettings. It is an extension of the original /// IApplicationDesignModeSettings interface. /// /// Examples /// /// In this example, Visual Studio is launching an application in design mode that has overridden the minimum width on a display of /// size 1366x768. It is then enabling a slider control that allows the user to dynamically change the applications width. To do /// this, it needs to use the new SetApplicationViewMinWidth and GetApplicationSizeBoundsAPIs to compute the minimum and maximum /// sizes allowed for this type of application. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iapplicationdesignmodesettings2 [ComImport, Guid("490514E1-675A-4D6E-A58D-E54901B4CA2F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ApplicationDesignModeSettings))] public interface IApplicationDesignModeSettings2 : IApplicationDesignModeSettings { /// /// Sets a spoofed native display size to be used for a Windows Store app running in design mode. /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// SetNativeDisplaySize must be called before calling ComputeApplicationSize. /// /// /// The native size of the display to spoof, as a SIZE structure. The specified size will be normalized to a landscape /// orientation. To spoof orientation, see SetApplicationViewState. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-setnativedisplaysize // HRESULT SetNativeDisplaySize( SIZE nativeDisplaySizePixels ); new void SetNativeDisplaySize(SIZE nativeDisplaySizePixels); /// /// Sets a spoofed device scale factor to be used for a Windows Store app running in design mode. /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// SetScaleFactor must be called before calling ComputeApplicationSize. /// /// One of the DEVICE_SCALE_FACTOR enumeration values that indicates the device scale factor to spoof. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-setscalefactor // HRESULT SetScaleFactor( DEVICE_SCALE_FACTOR scaleFactor ); new void SetScaleFactor(DEVICE_SCALE_FACTOR scaleFactor); /// /// /// Sets a spoofed application view state (full-screen landscape, full-screen portrait, filled, or snapped) to be used for a /// Windows Store app running in design mode. /// /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// SetApplicationViewState must be called before calling ComputeApplicationSize. /// /// /// One of the APPLICATION_VIEW_STATE enumeration values that indicates the application view state to spoof. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-setapplicationviewstate // HRESULT SetApplicationViewState( APPLICATION_VIEW_STATE viewState ); new void SetApplicationViewState(APPLICATION_VIEW_STATE viewState); /// /// Gets the size of the Windows Store app, based on the current set of spoofed settings. /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// In addition, each of these methods must be called before calling ComputeApplicationSize, or the call will fail. /// SetApplicationViewState /// SetNativeDisplaySize /// SetScaleFactor /// /// /// When this method returns successfully, receives a pointer to the size that the Windows Store app should occupy, based on the /// current set of spoofed settings. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-computeapplicationsize // HRESULT ComputeApplicationSize( SIZE *applicationSizePixels ); new SIZE ComputeApplicationSize(); /// /// /// Determines whether a particular application view state is supported for specific spoofed display size and scale factor settings. /// /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// /// /// One of the enumeration values that indicates the application view state for which support is being determined. /// /// The native size of the display to spoof. /// One of the enumeration values that indicates the device scale factor to spoof. /// /// When this method returns successfully, receives a pointer to a Boolean value which is set to TRUE if the application /// view state is supported for the given display size and scale factor, and FALSE if it is not. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-isapplicationviewstatesupported // HRESULT IsApplicationViewStateSupported( APPLICATION_VIEW_STATE viewState, SIZE nativeDisplaySizePixels, DEVICE_SCALE_FACTOR // scaleFactor, BOOL *supported ); [return: MarshalAs(UnmanagedType.Bool)] new bool IsApplicationViewStateSupported(APPLICATION_VIEW_STATE viewState, SIZE nativeDisplaySizePixels, DEVICE_SCALE_FACTOR scaleFactor); /// /// /// Sends a spoofed edge gesture event to the proxy core window on the caller's thread. This gesture toggles the app's app bar, /// if the app supports one. The caller can specify the type of input that triggered the edge gesture. /// /// You must call IInitializeWithWindow::Initialize to set a proxy core window before calling this method. /// /// /// /// Indicates the EDGE_GESTURE_KIND input type that generated the spoofed edge gesture. If touch ( EGK_TOUCH) is /// specified, both the Starting and Completed edge gesture events are sent. Otherwise, only the Completed /// event is sent. One of the following values: /// /// EGK_TOUCH (0) /// The edge gesture event was generated by a swipe on a touch-enabled screen. /// EGK_KEYBOARD (1) /// The edge gesture event was generated by the Win+Z key sequence on the keyboard. /// EGK_MOUSE (2) /// The edge gesture event was generated by a right mouse click. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings-triggeredgegesture // HRESULT TriggerEdgeGesture( EDGE_GESTURE_KIND edgeGestureKind ); new void TriggerEdgeGesture(EDGE_GESTURE_KIND edgeGestureKind); /// Sets the orientation of the emulated display for the design mode window. /// /// Type: NATIVE_DISPLAY_ORIENTATION /// The native orientation of the display to emulate. /// NDO_LANDSCAPE (0) /// Landscape orientation, with the display width greater than the height. /// NDO_PORTRAIT (1) /// Portrait orientation, with the display height greater than the width. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings2-setnativedisplayorientation // HRESULT SetNativeDisplayOrientation( NATIVE_DISPLAY_ORIENTATION nativeDisplayOrientation ); void SetNativeDisplayOrientation(NATIVE_DISPLAY_ORIENTATION nativeDisplayOrientation); /// Sets the window orientation used for the design mode window. /// /// Type: APPLICATION_VIEW_ORIENTATION /// The orientation of the design mode window to use. Either AVO_LANDSCAPE or AVO_PORTRAIT. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings2-setapplicationvieworientation // HRESULT SetApplicationViewOrientation( APPLICATION_VIEW_ORIENTATION viewOrientation ); void SetApplicationViewOrientation(APPLICATION_VIEW_ORIENTATION viewOrientation); /// Sets whether the application window will be adjacent to the edge of the emulated display. /// /// Type: ADJACENT_DISPLAY_EDGES /// The edge which should be adjacent. /// ADE_NONE (0x0) /// The widow will not be adjacent to either edge. /// ADE_LEFT (0x1) /// the left edge of the window will be adjacent. /// ADE_RIGHT (0x2) /// The right edge of the window will be adjacent. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings2-setadjacentdisplayedges // HRESULT SetAdjacentDisplayEdges( ADJACENT_DISPLAY_EDGES adjacentDisplayEdges ); void SetAdjacentDisplayEdges(ADJACENT_DISPLAY_EDGES adjacentDisplayEdges); /// /// This method determines whether or not the application, in design mode, can display information on the Windows 8 lock screen. /// /// /// Type: BOOL /// /// When set to TRUE, the application will display information on the lock screen. When set to FALSE, information /// will not be displayed. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings2-setisonlockscreen // HRESULT SetIsOnLockScreen( BOOL isOnLockScreen ); void SetIsOnLockScreen([MarshalAs(UnmanagedType.Bool)] bool isOnLockScreen); /// Sets the desired minimum width of the application design mode window. /// /// Type: APPLICATION_VIEW_MIN_WIDTH /// The minimum width value. /// AVMW_DEFAULT (0) /// Uses the default minimum width. /// AVMW_320 (1) /// Sets the minimum width at 320 pixels. /// AVMW_500 (2) /// Sets the minimum width at 500 pixels. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings2-setapplicationviewminwidth // HRESULT SetApplicationViewMinWidth( APPLICATION_VIEW_MIN_WIDTH viewMinWidth ); void SetApplicationViewMinWidth(APPLICATION_VIEW_MIN_WIDTH viewMinWidth); /// This methods retrieves the size bounds supported by the application. /// /// Type: SIZE* /// /// When this method returns successfully, receives a pointer to a SIZE structure that defines the minimum possible window size. /// /// /// /// Type: SIZE* /// /// When this method returns successfully, receives a pointer to a SIZE structure that defines the maximum possible window size. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings2-getapplicationsizebounds // HRESULT GetApplicationSizeBounds( SIZE *minApplicationSizePixels, SIZE *maxApplicationSizePixels ); void GetApplicationSizeBounds(out SIZE minApplicationSizePixels, out SIZE maxApplicationSizePixels); /// Gets the orientation of the application design mode window. /// /// Type: SIZE /// The application window size. /// /// /// Type: APPLICATION_VIEW_ORIENTATION* /// When this method returns successfully, receives a pointer to an APPLICATION_VIEW_ORIENTATION structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationdesignmodesettings2-getapplicationvieworientation // HRESULT GetApplicationViewOrientation( SIZE applicationSizePixels, APPLICATION_VIEW_ORIENTATION *viewOrientation ); APPLICATION_VIEW_ORIENTATION GetApplicationViewOrientation(SIZE applicationSizePixels); } /// CLSID_ApplicationDesignModeSettings [PInvokeData("shobjidl.h")] [ComImport, Guid("958a6fb5-dcb2-4faf-aafd-7fb054ad1a3b"), ClassInterface(ClassInterfaceType.None)] public class ApplicationDesignModeSettings { } } }