From d7e324b7ef1cb7727c74db4cf00bb7a086ccfb45 Mon Sep 17 00:00:00 2001 From: Gerald Versluis Date: Thu, 22 Dec 2022 15:50:49 +0100 Subject: [PATCH 1/2] Update Essentials Screenshot API Docs --- .../IScreenshotResult.xml | 96 --------- .../Microsoft.Maui.Essentials/Screenshot.xml | 56 ------ .../ScreenshotFormat.xml | 52 ----- .../src/Screenshot/Screenshot.shared.cs | 185 ++++++++++++++++-- 4 files changed, 168 insertions(+), 221 deletions(-) delete mode 100644 src/Essentials/docs/Microsoft.Maui.Essentials/IScreenshotResult.xml delete mode 100644 src/Essentials/docs/Microsoft.Maui.Essentials/Screenshot.xml delete mode 100644 src/Essentials/docs/Microsoft.Maui.Essentials/ScreenshotFormat.xml diff --git a/src/Essentials/docs/Microsoft.Maui.Essentials/IScreenshotResult.xml b/src/Essentials/docs/Microsoft.Maui.Essentials/IScreenshotResult.xml deleted file mode 100644 index 897886c5c220..000000000000 --- a/src/Essentials/docs/Microsoft.Maui.Essentials/IScreenshotResult.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - Microsoft.Maui.Essentials - 1.0.0.0 - - - - To be added. - To be added. - - - - - - - Constructor - - Microsoft.Maui.Essentials - 1.0.0.0 - - - - - - - - To be added. - To be added. - To be added. - To be added. - To be added. - - - - - - - Property - - Microsoft.Maui.Essentials - 1.0.0.0 - - - System.Int32 - - - To be added. - To be added. - To be added. - - - - - - - Method - - Microsoft.Maui.Essentials - 1.0.0.0 - - - System.Threading.Tasks.Task<System.IO.Stream> - - - - - - To be added. - To be added. - To be added. - To be added. - - - - - - - Property - - Microsoft.Maui.Essentials - 1.0.0.0 - - - System.Int32 - - - To be added. - To be added. - To be added. - - - - diff --git a/src/Essentials/docs/Microsoft.Maui.Essentials/Screenshot.xml b/src/Essentials/docs/Microsoft.Maui.Essentials/Screenshot.xml deleted file mode 100644 index 41c17e1532cf..000000000000 --- a/src/Essentials/docs/Microsoft.Maui.Essentials/Screenshot.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - Microsoft.Maui.Essentials - 1.0.0.0 - - - System.Object - - - - Take a screenshot depicting the current View. - - - - - - - - Method - - Microsoft.Maui.Essentials - 1.0.0.0 - - - System.Threading.Tasks.Task<Microsoft.Maui.Essentials.IScreenshotResult> - - - - Capture the screen. - Returns the caprured screenshot. - - - - - - - - Property - - Microsoft.Maui.Essentials - 1.0.0.0 - - - System.Boolean - - - Gets a value indicating whether capturing screenshots are supported. - - - - - - diff --git a/src/Essentials/docs/Microsoft.Maui.Essentials/ScreenshotFormat.xml b/src/Essentials/docs/Microsoft.Maui.Essentials/ScreenshotFormat.xml deleted file mode 100644 index 73ccdff852fe..000000000000 --- a/src/Essentials/docs/Microsoft.Maui.Essentials/ScreenshotFormat.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - Microsoft.Maui.Essentials - 1.0.0.0 - - - System.Enum - - - The format to read screenshot images. - - - - - - - - Field - - Microsoft.Maui.Essentials - 1.0.0.0 - - - Microsoft.Maui.Essentials.ScreenshotFormat - - 1 - - Read the screenshot image as a JPEG. - - - - - - - Field - - Microsoft.Maui.Essentials - 1.0.0.0 - - - Microsoft.Maui.Essentials.ScreenshotFormat - - 0 - - Read the screenshot image as a PNG. - - - - diff --git a/src/Essentials/src/Screenshot/Screenshot.shared.cs b/src/Essentials/src/Screenshot/Screenshot.shared.cs index 6ee85f558177..ced628b35633 100644 --- a/src/Essentials/src/Screenshot/Screenshot.shared.cs +++ b/src/Essentials/src/Screenshot/Screenshot.shared.cs @@ -6,56 +6,145 @@ namespace Microsoft.Maui.Media { + /// + /// The Screenshot API lets you take a capture of the current displayed screen of the app. + /// public interface IScreenshot { + /// + /// Gets a value indicating whether capturing screenshots supported on this device. + /// bool IsCaptureSupported { get; } + /// + /// Captures a screenshot of the current screen of the running application. + /// + /// An instance of with information about the captured screenshot. Task CaptureAsync(); } + /// + /// Provides abstractions for the platform screenshot methods when using Screenshot. + /// public interface IPlatformScreenshot : IScreenshot { #if ANDROID + /// + /// Captures a screenshot of the specified activity. + /// + /// The activity to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(Android.App.Activity activity); + + /// + /// Captures a screenshot of the specified view. + /// + /// The view to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(Android.Views.View view); #elif IOS || MACCATALYST + /// + /// Captures a screenshot of the specified window. + /// + /// The window to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(UIKit.UIWindow window); + + /// + /// Captures a screenshot of the specified view. + /// + /// The view to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(UIKit.UIView view); + + /// + /// Captures a screenshot of the specified layer. + /// + /// The layer to capture. + /// Specifies whether to include the child layers or not. + /// An instance of with information about the captured screenshot. Task CaptureAsync(CoreAnimation.CALayer layer, bool skipChildren); #elif WINDOWS + /// + /// Captures a screenshot of the specified window. + /// + /// The window to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(UI.Xaml.Window window); + + /// + /// Captures a screenshot of the specified user-interface element. + /// + /// The user-interface element to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(UI.Xaml.UIElement element); #elif TIZEN + + /// + /// Captures a screenshot of the specified window. + /// + /// The window to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(Tizen.NUI.Window window); + + /// + /// Captures a screenshot of the specified view. + /// + /// The view to capture. + /// An instance of with information about the captured screenshot. Task CaptureAsync(Tizen.NUI.BaseComponents.View view); #endif } - /// + /// + /// A representation of a screenshot, as a result of a screenshot captured by the user. + /// public interface IScreenshotResult { - /// + /// + /// The width of this screenshot in pixels. + /// int Width { get; } - /// + /// + /// The height of this screenshot in pixels. + /// int Height { get; } - /// -#pragma warning disable CS1573 // Parameter has no matching param tag in the XML comment (but other parameters do) + /// + /// Opens a to the corresponding screenshot file on the filesystem. + /// + /// The image format used to read this screenshot. + /// The quality used to read this screenshot. + /// A containing the screenshot file data. Task OpenReadAsync(ScreenshotFormat format = ScreenshotFormat.Png, int quality = 100); -#pragma warning restore CS1573 // Parameter has no matching param tag in the XML comment (but other parameters do) + /// + /// + /// + /// The destination to copy the screenshot file data to. + /// The image format used to copy this screenshot. + /// The quality used to copy this screenshot. + /// A object with the current status of the asynchronous operation. Task CopyToAsync(Stream destination, ScreenshotFormat format = ScreenshotFormat.Png, int quality = 100); } - /// + /// + /// The Screenshot API lets you take a capture of the current displayed screen of the app. + /// public static partial class Screenshot { - /// + /// + /// Gets a value indicating whether capturing screenshots supported on this device. + /// public static bool IsCaptureSupported => Default.IsCaptureSupported; - /// + /// + /// Captures a screenshot of the current screen of the running application. + /// + /// An instance of with information about the captured screenshot. + /// Thrown when is . public static Task CaptureAsync() { if (!IsCaptureSupported) @@ -66,6 +155,9 @@ public static Task CaptureAsync() static IScreenshot? defaultImplementation; + /// + /// Provides the default implementation for static usage of this API. + /// public static IScreenshot Default => defaultImplementation ??= new ScreenshotImplementation(); @@ -73,6 +165,9 @@ internal static void SetDefault(IScreenshot? implementation) => defaultImplementation = implementation; } + /// + /// This class contains static extension methods for use with . + /// public static class ScreenshotExtensions { static IPlatformScreenshot AsPlatform(this IScreenshot screenshot) @@ -84,52 +179,108 @@ static IPlatformScreenshot AsPlatform(this IScreenshot screenshot) } #if ANDROID - + /// + /// Captures a screenshot of the specified activity. + /// + /// The object this method is invoked on. + /// The activity to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, Android.App.Activity activity) => screenshot.AsPlatform().CaptureAsync(activity); + /// + /// Captures a screenshot of the specified view. + /// + /// The object this method is invoked on. + /// The view to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, Android.Views.View view) => screenshot.AsPlatform().CaptureAsync(view); #elif IOS || MACCATALYST - + /// + /// Captures a screenshot of the specified window. + /// + /// The object this method is invoked on. + /// The window to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, UIKit.UIWindow window) => screenshot.AsPlatform().CaptureAsync(window); + /// + /// Captures a screenshot of the specified view. + /// + /// The object this method is invoked on. + /// The view to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, UIKit.UIView view) => screenshot.AsPlatform().CaptureAsync(view); + /// + /// Captures a screenshot of the specified layer. + /// + /// The object this method is invoked on. + /// The layer to capture. + /// Specifies whether to include the child layers or not. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, CoreAnimation.CALayer layer, bool skipChildren) => screenshot.AsPlatform().CaptureAsync(layer, skipChildren); #elif WINDOWS - + /// + /// Captures a screenshot of the specified window. + /// + /// The object this method is invoked on. + /// The window to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, UI.Xaml.Window window) => screenshot.AsPlatform().CaptureAsync(window); + /// + /// Captures a screenshot of the specified user-interface element. + /// + /// The object this method is invoked on. + /// The user-interface element to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, UI.Xaml.UIElement element) => screenshot.AsPlatform().CaptureAsync(element); #elif TIZEN - + /// + /// Captures a screenshot of the specified window. + /// + /// The object this method is invoked on. + /// The window to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, Tizen.NUI.Window window) => screenshot.AsPlatform().CaptureAsync(window); + /// + /// Captures a screenshot of the specified view. + /// + /// The object this method is invoked on. + /// The view to capture. + /// An instance of with information about the captured screenshot. public static Task CaptureAsync(this IScreenshot screenshot, Tizen.NUI.BaseComponents.View view) => screenshot.AsPlatform().CaptureAsync(view); - #endif } - /// + /// + /// The possible formats for reading screenshot images. + /// public enum ScreenshotFormat { - /// + /// Read the screenshot image as a PNG image. Png, - /// + + /// Read the screenshot image as a JPEG image. Jpeg } + /// + /// A representation of a screenshot, as a result of a screenshot captured by the user. + /// partial class ScreenshotResult : IScreenshotResult { public int Width { get; } From eabdf4ca5bb2700277f6fd2df31afa873fbf408a Mon Sep 17 00:00:00 2001 From: Gerald Versluis Date: Fri, 30 Dec 2022 13:27:29 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: E.Z. Hart --- src/Essentials/src/Screenshot/Screenshot.shared.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Essentials/src/Screenshot/Screenshot.shared.cs b/src/Essentials/src/Screenshot/Screenshot.shared.cs index ced628b35633..445d2bf8bc99 100644 --- a/src/Essentials/src/Screenshot/Screenshot.shared.cs +++ b/src/Essentials/src/Screenshot/Screenshot.shared.cs @@ -12,7 +12,7 @@ namespace Microsoft.Maui.Media public interface IScreenshot { /// - /// Gets a value indicating whether capturing screenshots supported on this device. + /// Gets a value indicating whether capturing screenshots is supported on this device. /// bool IsCaptureSupported { get; } @@ -135,7 +135,7 @@ public interface IScreenshotResult public static partial class Screenshot { /// - /// Gets a value indicating whether capturing screenshots supported on this device. + /// Gets a value indicating whether capturing screenshots is supported on this device. /// public static bool IsCaptureSupported => Default.IsCaptureSupported;