├── Assets ├── plugin.maui.screensecurity_128x128.png └── plugin.maui.screensecurity_template.jpg ├── Plugin.Maui.ScreenSecurity ├── Platforms │ ├── iOS │ │ ├── ThemeStyle.cs │ │ ├── Helpers │ │ │ ├── StringExtensions.cs │ │ │ ├── IOSHelpers.cs │ │ │ └── UIColorExtensions.cs │ │ ├── Protections │ │ │ ├── ScreenRecordingProtectionManager.cs │ │ │ ├── ImageProtectionManager.cs │ │ │ ├── ColorProtectionManager.cs │ │ │ ├── ScreenshotProtectionManager.cs │ │ │ └── BlurProtectionManager.cs │ │ └── ScreenSecurity.ios.cs │ ├── Android │ │ ├── Helpers │ │ │ └── AndroidHelpers.cs │ │ └── ScreenSecurity.android.cs │ └── Windows │ │ ├── NativeMethods.cs │ │ └── ScreenSecurity.windows.cs ├── Handlers │ ├── ScreenCaptureEventHandler.cs │ └── ErrorsHandler.cs ├── ScreenSecurity.cs ├── ScreenSecurity.net.cs ├── ScreenProtectionOptions.cs ├── MauiAppBuilderExtensions.cs ├── IScreenSecurity.cs └── Plugin.Maui.ScreenSecurity.csproj ├── samples ├── ScreenSecurityBlazorSample │ ├── wwwroot │ │ ├── favicon.png │ │ ├── index.html │ │ └── css │ │ │ └── app.css │ ├── Properties │ │ └── launchSettings.json │ ├── Resources │ │ ├── Fonts │ │ │ └── OpenSans-Regular.ttf │ │ ├── AppIcon │ │ │ ├── appicon.svg │ │ │ └── appiconfg.svg │ │ ├── Raw │ │ │ └── AboutAssets.txt │ │ ├── Splash │ │ │ └── splash.svg │ │ └── Images │ │ │ └── dotnet_bot.svg │ ├── Platforms │ │ ├── Android │ │ │ ├── Resources │ │ │ │ └── values │ │ │ │ │ └── colors.xml │ │ │ ├── MainApplication.cs │ │ │ ├── MainActivity.cs │ │ │ └── AndroidManifest.xml │ │ ├── iOS │ │ │ ├── AppDelegate.cs │ │ │ ├── Program.cs │ │ │ └── Info.plist │ │ └── Windows │ │ │ ├── App.xaml │ │ │ ├── app.manifest │ │ │ ├── App.xaml.cs │ │ │ └── Package.appxmanifest │ ├── Components │ │ ├── Routes.razor │ │ ├── Layout │ │ │ ├── MainLayout.razor │ │ │ ├── NavMenu.razor │ │ │ ├── MainLayout.razor.css │ │ │ └── NavMenu.razor.css │ │ ├── _Imports.razor │ │ └── Pages │ │ │ ├── ProtectedPage.razor │ │ │ ├── UnprotectedPage.razor │ │ │ └── Home.razor │ ├── App.xaml.cs │ ├── MainPage.xaml.cs │ ├── MainPage.xaml │ ├── MauiProgram.cs │ ├── App.xaml │ └── ScreenSecurityBlazorSample.csproj └── ScreenSecuritySample │ ├── Resources │ ├── Images │ │ ├── protection_bg.png │ │ └── dotnet_bot.svg │ ├── Fonts │ │ ├── OpenSans-Regular.ttf │ │ └── OpenSans-Semibold.ttf │ ├── AppIcon │ │ ├── appicon.svg │ │ └── appiconfg.svg │ ├── Raw │ │ └── AboutAssets.txt │ ├── Splash │ │ └── splash.svg │ └── Styles │ │ ├── Colors.xaml │ │ └── Styles.xaml │ ├── Properties │ └── launchSettings.json │ ├── Platforms │ ├── Android │ │ ├── Resources │ │ │ └── values │ │ │ │ └── colors.xml │ │ ├── MainApplication.cs │ │ ├── MainActivity.cs │ │ └── AndroidManifest.xml │ ├── iOS │ │ ├── AppDelegate.cs │ │ ├── Program.cs │ │ └── Info.plist │ └── Windows │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── app.manifest │ │ └── Package.appxmanifest │ ├── App.xaml.cs │ ├── AppShell.xaml.cs │ ├── AppShell.xaml │ ├── App.xaml │ ├── MauiProgram.cs │ ├── Views │ ├── SecondPage.xaml │ ├── SecondPage.xaml.cs │ ├── MainPage.xaml │ └── MainPage.xaml.cs │ └── ScreenSecuritySample.csproj ├── LICENSE ├── Plugin.Maui.ScreenSecurity.sln ├── CHANGELOG.md ├── README.md └── .gitignore /Assets/plugin.maui.screensecurity_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabriBertani/Plugin.Maui.ScreenSecurity/HEAD/Assets/plugin.maui.screensecurity_128x128.png -------------------------------------------------------------------------------- /Assets/plugin.maui.screensecurity_template.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabriBertani/Plugin.Maui.ScreenSecurity/HEAD/Assets/plugin.maui.screensecurity_template.jpg -------------------------------------------------------------------------------- /Plugin.Maui.ScreenSecurity/Platforms/iOS/ThemeStyle.cs: -------------------------------------------------------------------------------- 1 | namespace Plugin.Maui.ScreenSecurity.Platforms.iOS; 2 | 3 | internal enum ThemeStyle 4 | { 5 | Light, 6 | Dark 7 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabriBertani/Plugin.Maui.ScreenSecurity/HEAD/samples/ScreenSecurityBlazorSample/wwwroot/favicon.png -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Resources/Images/protection_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabriBertani/Plugin.Maui.ScreenSecurity/HEAD/samples/ScreenSecuritySample/Resources/Images/protection_bg.png -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabriBertani/Plugin.Maui.ScreenSecurity/HEAD/samples/ScreenSecuritySample/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabriBertani/Plugin.Maui.ScreenSecurity/HEAD/samples/ScreenSecuritySample/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabriBertani/Plugin.Maui.ScreenSecurity/HEAD/samples/ScreenSecurityBlazorSample/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace ScreenSecuritySample; 4 | 5 | [Register(nameof(AppDelegate))] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace ScreenSecurityBlazorSample; 4 | 5 | [Register(nameof(AppDelegate))] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Components/Routes.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | @Body 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ScreenSecuritySample; 2 | 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | } 9 | 10 | protected override Window CreateWindow(IActivationState activationState) 11 | { 12 | return new Window(new AppShell()); 13 | } 14 | } -------------------------------------------------------------------------------- /Plugin.Maui.ScreenSecurity/Handlers/ScreenCaptureEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Plugin.Maui.ScreenSecurity.Handlers; 2 | 3 | internal static class ScreenCaptureEventHandler 4 | { 5 | internal static event EventHandler? ScreenCaptured; 6 | 7 | internal static void RaiseScreenCaptured() 8 | { 9 | ScreenCaptured?.Invoke(null, EventArgs.Empty); 10 | } 11 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace ScreenSecuritySample; 5 | 6 | [Application] 7 | public class MainApplication(IntPtr handle, JniHandleOwnership ownership) : MauiApplication(handle, ownership) 8 | { 9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 10 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ScreenSecurityBlazorSample 2 | { 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | } 9 | 10 | protected override Window CreateWindow(IActivationState? activationState) 11 | { 12 | return new Window(new MainPage()); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace ScreenSecurityBlazorSample; 5 | 6 | [Application] 7 | public class MainApplication(IntPtr handle, 8 | JniHandleOwnership ownership) : MauiApplication(handle, ownership) 9 | { 10 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 11 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.JSInterop 8 | @using ScreenSecurityBlazorSample 9 | @using ScreenSecurityBlazorSample.Components 10 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | using ScreenSecuritySample.Views; 2 | 3 | namespace ScreenSecuritySample; 4 | 5 | public partial class AppShell : Shell 6 | { 7 | public AppShell() 8 | { 9 | InitializeComponent(); 10 | 11 | RegisterRoutes(); 12 | } 13 | 14 | private static void RegisterRoutes() 15 | { 16 | Routing.RegisterRoute("unprotected_page", typeof(SecondPage)); 17 | } 18 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Components/Pages/ProtectedPage.razor: -------------------------------------------------------------------------------- 1 | @page "/protected_page" 2 | 3 | @using Plugin.Maui.ScreenSecurity; 4 | 5 |

Protected page

6 | 7 |

This page is protected against content exposure.

8 | 9 | @code { 10 | protected override void OnInitialized() 11 | { 12 | ScreenSecurity.Default?.ActivateScreenSecurityProtection(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Components/Pages/UnprotectedPage.razor: -------------------------------------------------------------------------------- 1 | @page "/unprotected_page" 2 | 3 | @using Plugin.Maui.ScreenSecurity; 4 | 5 |

Unprotected Page

6 | 7 |

This page is NOT protected against content exposure.

8 | 9 | @code { 10 | protected override void OnInitialized() 11 | { 12 | ScreenSecurity.Default?.DeactivateScreenSecurityProtection(); 13 | } 14 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace ScreenSecuritySample; 4 | 5 | public class Program 6 | { 7 | // This is the main entry point of the application. 8 | static void Main(string[] args) 9 | { 10 | // if you want to use a different Application Delegate class from "AppDelegate" 11 | // you can specify it here. 12 | UIApplication.Main(args, null, typeof(AppDelegate)); 13 | } 14 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace ScreenSecurityBlazorSample; 4 | 5 | public class Program 6 | { 7 | // This is the main entry point of the application. 8 | static void Main(string[] args) 9 | { 10 | // if you want to use a different Application Delegate class from "AppDelegate" 11 | // you can specify it here. 12 | UIApplication.Main(args, null, typeof(AppDelegate)); 13 | } 14 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | 4 | namespace ScreenSecurityBlazorSample; 5 | 6 | [Activity( 7 | Theme = "@style/Maui.SplashTheme", 8 | MainLauncher = true, 9 | Exported = true, 10 | ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 11 | public class MainActivity : MauiAppCompatActivity 12 | { 13 | } -------------------------------------------------------------------------------- /Plugin.Maui.ScreenSecurity/ScreenSecurity.cs: -------------------------------------------------------------------------------- 1 | namespace Plugin.Maui.ScreenSecurity; 2 | 3 | public static class ScreenSecurity 4 | { 5 | /// 6 | /// Provides the default implementation for static usage of this API. 7 | /// 8 | private static IScreenSecurity? _defaultImplementation; 9 | 10 | public static IScreenSecurity Default => _defaultImplementation ??= new ScreenSecurityImplementation(); 11 | 12 | internal static void SetDefault(IScreenSecurity? implementation) => _defaultImplementation = implementation; 13 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using System.Diagnostics; 4 | 5 | namespace ScreenSecuritySample; 6 | 7 | [Activity( 8 | Theme = "@style/Maui.SplashTheme", 9 | MainLauncher = true, 10 | Exported = true, 11 | ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 12 | public class MainActivity : MauiAppCompatActivity 13 | { 14 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using Plugin.Maui.ScreenSecurity; 2 | 3 | namespace ScreenSecurityBlazorSample 4 | { 5 | public partial class MainPage : ContentPage 6 | { 7 | public MainPage() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | // Uncomment this to enable screen protection on the entire app. 13 | // Note: If you open the Unprotected Page, protection will be disabled. 14 | //protected override void OnAppearing() 15 | //{ 16 | // base.OnAppearing(); 17 | 18 | // ScreenSecurity.Default?.ActivateScreenSecurityProtection(); 19 | //} 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Plugin.Maui.ScreenSecurity/Platforms/iOS/Helpers/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace Plugin.Maui.ScreenSecurity.Platforms.iOS; 4 | 5 | internal static partial class StringExtensions 6 | { 7 | internal static bool IsHexColor(this string hexColor) => ValidHexColorRegex().IsMatch(hexColor); 8 | 9 | internal static bool IsValidImage(this string image) => ValidImageRegex().IsMatch(image); 10 | 11 | [GeneratedRegex("([^\\s]+(\\.(?i)(jpe?g|png|gif|bmp|svg))$)", RegexOptions.None)] 12 | private static partial Regex ValidImageRegex(); 13 | 14 | [GeneratedRegex("^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6})$")] 15 | private static partial Regex ValidHexColorRegex(); 16 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with you package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with your package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // To learn more about WinUI, the WinUI project structure, 2 | // and more about our project templates, see: http://aka.ms/winui-project-info. 3 | 4 | namespace ScreenSecuritySample.WinUI; 5 | 6 | /// 7 | /// Provides application-specific behavior to supplement the default Application class. 8 | /// 9 | public partial class App : MauiWinUIApplication 10 | { 11 | /// 12 | /// Initializes the singleton application object. This is the first line of authored code 13 | /// executed, and as such is the logical equivalent of main() or WinMain(). 14 | /// 15 | public App() 16 | { 17 | this.InitializeComponent(); 18 | } 19 | 20 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 21 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using Plugin.Maui.ScreenSecurity; 2 | using ScreenSecuritySample.Views; 3 | 4 | namespace ScreenSecuritySample; 5 | 6 | public static class MauiProgram 7 | { 8 | public static MauiApp CreateMauiApp() 9 | { 10 | var builder = MauiApp.CreateBuilder(); 11 | builder 12 | .UseMauiApp() 13 | .ConfigureFonts(fonts => 14 | { 15 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 16 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 17 | }) 18 | .UseScreenSecurity(); 19 | 20 | // Register Main Page 21 | builder.Services.AddScoped(); 22 | builder.Services.AddScoped(); 23 | 24 | return builder.Build(); 25 | } 26 | } -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Plugin.Maui.ScreenSecurity; 3 | 4 | namespace ScreenSecurityBlazorSample 5 | { 6 | public static class MauiProgram 7 | { 8 | public static MauiApp CreateMauiApp() 9 | { 10 | var builder = MauiApp.CreateBuilder(); 11 | builder 12 | .UseMauiApp() 13 | .ConfigureFonts(fonts => 14 | { 15 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 16 | }) 17 | .UseScreenSecurity(); 18 | 19 | builder.Services.AddMauiBlazorWebView(); 20 | 21 | #if DEBUG 22 | builder.Services.AddBlazorWebViewDeveloperTools(); 23 | builder.Logging.AddDebug(); 24 | #endif 25 | 26 | return builder.Build(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Plugin.Maui.ScreenSecurity/Platforms/Android/Helpers/AndroidHelpers.cs: -------------------------------------------------------------------------------- 1 | using Android.OS; 2 | using Java.Lang; 3 | using Java.Util.Concurrent; 4 | using Plugin.Maui.ScreenSecurity.Handlers; 5 | using static Android.App.Activity; 6 | using Object = Java.Lang.Object; 7 | 8 | namespace Plugin.Maui.ScreenSecurity.Platforms.Android; 9 | 10 | internal class CustomScreenCaptureCallback : Object, IScreenCaptureCallback 11 | { 12 | public void OnScreenCaptured() 13 | { 14 | ScreenCaptureEventHandler.RaiseScreenCaptured(); 15 | } 16 | } 17 | 18 | internal class MainThreadExecutor : Object, IExecutor 19 | { 20 | private readonly Handler _handler = new(Looper.MainLooper ?? throw new InvalidOperationException("MainLooper is null")); 21 | 22 | public void Execute(IRunnable? command) 23 | { 24 | if (command is not null) 25 | _handler.Post(command); 26 | } 27 | } -------------------------------------------------------------------------------- /Plugin.Maui.ScreenSecurity/Handlers/ErrorsHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.ExceptionServices; 2 | 3 | namespace Plugin.Maui.ScreenSecurity.Handlers; 4 | 5 | internal static class ErrorsHandler 6 | { 7 | internal static void HandleException(string methodName, bool throwErrors, Exception ex) 8 | { 9 | System.Diagnostics.Trace.WriteLine($"{methodName} failed with Exception message: {ex.Message}"); 10 | System.Diagnostics.Trace.WriteLine($"Exception Stacktrace: {ex.StackTrace}"); 11 | if (ex.InnerException is not null) 12 | System.Diagnostics.Trace.WriteLine($"With InnerException: {ex.InnerException}"); 13 | 14 | if (throwErrors) 15 | { 16 | ExceptionDispatchInfo.Capture(ex).Throw(); 17 | 18 | // Keep an explicit return so the compiler knows this code path doesn't continue. 19 | return; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | 3 | // To learn more about WinUI, the WinUI project structure, 4 | // and more about our project templates, see: http://aka.ms/winui-project-info. 5 | 6 | namespace ScreenSecurityBlazorSample.WinUI 7 | { 8 | /// 9 | /// Provides application-specific behavior to supplement the default Application class. 10 | /// 11 | public partial class App : MauiWinUIApplication 12 | { 13 | /// 14 | /// Initializes the singleton application object. This is the first line of authored code 15 | /// executed, and as such is the logical equivalent of main() or WinMain(). 16 | /// 17 | public App() 18 | { 19 | this.InitializeComponent(); 20 | } 21 | 22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Plugin.Maui.ScreenSecurity/ScreenSecurity.net.cs: -------------------------------------------------------------------------------- 1 | namespace Plugin.Maui.ScreenSecurity; 2 | 3 | internal partial class ScreenSecurityImplementation : IScreenSecurity 4 | { 5 | public void ActivateScreenSecurityProtection() 6 | { 7 | throw new NotImplementedException(); 8 | } 9 | 10 | public void ActivateScreenSecurityProtection(bool blurScreenProtection, bool preventScreenshot, bool preventScreenRecording) 11 | { 12 | throw new NotImplementedException(); 13 | } 14 | 15 | public void ActivateScreenSecurityProtection(ScreenProtectionOptions screenProtectionOptions) 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | 20 | public void DeactivateScreenSecurityProtection() 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | 25 | public bool IsProtectionEnabled { get; private set; } 26 | 27 | public bool ThrowErrors { get; set; } 28 | 29 | public event EventHandler? ScreenCaptured; 30 | } -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ScreenSecurityBlazorSample 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 |
Loading...
19 | 20 |
21 | An unhandled error has occurred. 22 | Reload 23 | 🗙 24 |
25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Fabricio Bertani 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | arm64 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | XSAppIconAssets 30 | Assets.xcassets/appicon.appiconset 31 | MinimumOSVersion 32 | 15.0 33 | 34 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | #512bdf 10 | White 11 | 12 | 16 | 17 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/ScreenSecurityBlazorSample/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 28 | -------------------------------------------------------------------------------- /samples/ScreenSecuritySample/Views/SecondPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 13 |