From 224bc1ef659ab27103884d300e64c8fc14f736fa Mon Sep 17 00:00:00 2001 From: rafael-aero Date: Thu, 26 Aug 2021 14:22:54 +0200 Subject: [PATCH] Add supported OS platform annotations --- ElectronNET.API/App.cs | 59 ++++++++++ ElectronNET.API/BrowserWindow.cs | 107 ++++++++++++++++-- ElectronNET.API/Clipboard.cs | 7 ++ ElectronNET.API/Dialog.cs | 5 + ElectronNET.API/Dock.cs | 2 + ElectronNET.API/Electron.cs | 2 + .../Entities/NotificationAction.cs | 1 + .../Entities/NotificationOptions.cs | 13 +++ ElectronNET.API/Entities/OpenDialogOptions.cs | 2 + .../Entities/OpenDialogProperty.cs | 53 ++++++++- .../Entities/OpenExternalOptions.cs | 3 + ElectronNET.API/Entities/SaveDialogOptions.cs | 13 +++ ElectronNET.API/NativeTheme.cs | 5 + ElectronNET.API/PowerMonitor.cs | 16 +++ ElectronNET.API/Shell.cs | 4 + ElectronNET.API/Tray.cs | 15 +++ 16 files changed, 294 insertions(+), 13 deletions(-) diff --git a/ElectronNET.API/App.cs b/ElectronNET.API/App.cs index 274786c..80b3d41 100644 --- a/ElectronNET.API/App.cs +++ b/ElectronNET.API/App.cs @@ -7,6 +7,11 @@ using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using ElectronNET.API.Extensions; +using System.Runtime.Versioning; + +//TODO: Implement app.showEmojiPanel and app.isEmojiPanelSupported: https://www.electronjs.org/docs/api/app#appshowemojipanel-macos-windows +//TODO: Implement app.moveToApplicationsFolder: https://www.electronjs.org/docs/api/app#appmovetoapplicationsfolderoptions-macos +//TODO: Implement apprunningUnderRosettaTranslation: https://www.electronjs.org/docs/api/app#apprunningunderrosettatranslation-macos-readonly namespace ElectronNET.API { @@ -337,6 +342,8 @@ namespace ElectronNET.API /// screen readers, are enabled or disabled. See https://www.chromium.org/developers/design-documents/accessibility for more details. /// /// when Chrome's accessibility support is enabled, otherwise. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public event Action AccessibilitySupportChanged { add @@ -411,6 +418,7 @@ namespace ElectronNET.API /// /// On Windows, you have to parse the arguments using App.CommandLine to get the filepath. /// + [SupportedOSPlatform("macos")] public event Action OpenFile { add @@ -442,6 +450,7 @@ namespace ElectronNET.API /// Emitted when a MacOS user wants to open a URL with the application. Your application's Info.plist file must /// define the URL scheme within the CFBundleURLTypes key, and set NSPrincipalClass to AtomApplication. /// + [SupportedOSPlatform("macos")] public event Action OpenUrl { add @@ -599,6 +608,7 @@ namespace ElectronNET.API /// /// You should seek to use the option as sparingly as possible. /// + [SupportedOSPlatform("macos")] public void Focus(FocusOptions focusOptions) { BridgeConnector.Emit("appFocus", JObject.FromObject(focusOptions, _jsonSerializer)); @@ -607,6 +617,7 @@ namespace ElectronNET.API /// /// Hides all application windows without minimizing them. /// + [SupportedOSPlatform("macos")] public void Hide() { BridgeConnector.Emit("appHide"); @@ -615,6 +626,7 @@ namespace ElectronNET.API /// /// Shows application windows after they were hidden. Does not automatically focus them. /// + [SupportedOSPlatform("macos")] public void Show() { BridgeConnector.Emit("appShow"); @@ -688,6 +700,8 @@ namespace ElectronNET.API /// list from the task bar, and on macOS you can visit it from dock menu. /// /// Path to add. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public void AddRecentDocument(string path) { BridgeConnector.Emit("appAddRecentDocument", path); @@ -696,6 +710,8 @@ namespace ElectronNET.API /// /// Clears the recent documents list. /// + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public void ClearRecentDocuments() { BridgeConnector.Emit("appClearRecentDocuments"); @@ -726,6 +742,8 @@ namespace ElectronNET.API /// call this method with electron as the parameter. /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public async Task SetAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default) { return await SetAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken); @@ -757,6 +775,8 @@ namespace ElectronNET.API /// The path to the Electron executable. Defaults to process.execPath /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public async Task SetAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default) { return await SetAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken); @@ -789,6 +809,8 @@ namespace ElectronNET.API /// Arguments passed to the executable. Defaults to an empty array. /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public Task SetAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appSetAsDefaultProtocolClient", "appSetAsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args); /// @@ -798,6 +820,8 @@ namespace ElectronNET.API /// The name of your protocol, without ://. /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public async Task RemoveAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default) { return await RemoveAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken); @@ -811,6 +835,8 @@ namespace ElectronNET.API /// Defaults to process.execPath. /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public async Task RemoveAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default) { return await RemoveAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken); @@ -825,6 +851,8 @@ namespace ElectronNET.API /// Defaults to an empty array. /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public Task RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appRemoveAsDefaultProtocolClient", "appRemoveAsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args); @@ -841,6 +869,8 @@ namespace ElectronNET.API /// The name of your protocol, without ://. /// The cancellation token. /// Whether the current executable is the default handler for a protocol (aka URI scheme). + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public async Task IsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default) { return await IsDefaultProtocolClientAsync(protocol, null, null, cancellationToken); @@ -860,6 +890,8 @@ namespace ElectronNET.API /// Defaults to process.execPath. /// The cancellation token. /// Whether the current executable is the default handler for a protocol (aka URI scheme). + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public async Task IsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default) { return await IsDefaultProtocolClientAsync(protocol, path, null, cancellationToken); @@ -880,6 +912,8 @@ namespace ElectronNET.API /// Defaults to an empty array. /// The cancellation token. /// Whether the current executable is the default handler for a protocol (aka URI scheme). + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public Task IsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appIsDefaultProtocolClient", "appIsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args); @@ -891,6 +925,7 @@ namespace ElectronNET.API /// Array of objects. /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("windows")] public Task SetUserTasksAsync(UserTask[] userTasks, CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appSetUserTasks", "appSetUserTasksCompleted", cancellationToken, JArray.FromObject(userTasks, _jsonSerializer)); /// @@ -898,6 +933,7 @@ namespace ElectronNET.API /// /// The cancellation token. /// Jump List settings. + [SupportedOSPlatform("windows")] public Task GetJumpListSettingsAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appGetJumpListSettings", "appGetJumpListSettingsCompleted", cancellationToken); /// @@ -916,6 +952,7 @@ namespace ElectronNET.API /// omitted from the Jump List. The list of removed items can be obtained using . /// /// Array of objects. + [SupportedOSPlatform("windows")] public void SetJumpList(JumpListCategory[] categories) { BridgeConnector.Emit("appSetJumpList", JArray.FromObject(categories, _jsonSerializer)); @@ -991,6 +1028,7 @@ namespace ElectronNET.API /// /// Uniquely identifies the activity. Maps to NSUserActivity.activityType. /// App-specific state to store for use by another device. + [SupportedOSPlatform("macos")] public void SetUserActivity(string type, object userInfo) { SetUserActivity(type, userInfo, null); @@ -1008,6 +1046,7 @@ namespace ElectronNET.API /// /// The webpage to load in a browser if no suitable app is installed on the resuming device. The scheme must be http or https. /// + [SupportedOSPlatform("macos")] public void SetUserActivity(string type, object userInfo, string webpageUrl) { BridgeConnector.Emit("appSetUserActivity", type, userInfo, webpageUrl); @@ -1017,12 +1056,14 @@ namespace ElectronNET.API /// The type of the currently running activity. /// /// The cancellation token. + [SupportedOSPlatform("macos")] public Task GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appGetCurrentActivityType", "appGetCurrentActivityTypeCompleted", cancellationToken); /// /// Invalidates the current Handoff user activity. /// + [SupportedOSPlatform("macos")] public void InvalidateCurrentActivity() { BridgeConnector.Emit("appInvalidateCurrentActivity"); @@ -1031,6 +1072,7 @@ namespace ElectronNET.API /// /// Marks the current Handoff user activity as inactive without invalidating it. /// + [SupportedOSPlatform("macos")] public void ResignCurrentActivity() { BridgeConnector.Emit("appResignCurrentActivity"); @@ -1040,6 +1082,7 @@ namespace ElectronNET.API /// Changes the Application User Model ID to id. /// /// Model Id. + [SupportedOSPlatform("windows")] public void SetAppUserModelId(string id) { BridgeConnector.Emit("appSetAppUserModelId", id); @@ -1054,6 +1097,7 @@ namespace ElectronNET.API /// /// The cancellation token. /// Result of import. Value of 0 indicates success. + [SupportedOSPlatform("linux")] public Task ImportCertificateAsync(ImportCertificateOptions options, CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appImportCertificate", "appImportCertificateCompleted", cancellationToken, JObject.FromObject(options, _jsonSerializer)); /// @@ -1084,12 +1128,16 @@ namespace ElectronNET.API /// Counter badge. /// The cancellation token. /// Whether the call succeeded. + [SupportedOSPlatform("linux")] + [SupportedOSPlatform("macos")] public Task SetBadgeCountAsync(int count, CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appSetBadgeCount", "appSetBadgeCountCompleted", cancellationToken, count); /// /// The current value displayed in the counter badge. /// /// The cancellation token. + [SupportedOSPlatform("linux")] + [SupportedOSPlatform("macos")] public Task GetBadgeCountAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appGetBadgeCount", "appGetBadgeCountCompleted", cancellationToken); /// @@ -1101,12 +1149,15 @@ namespace ElectronNET.API /// Whether the current desktop environment is Unity launcher. /// /// The cancellation token. + [SupportedOSPlatform("linux")] public Task IsUnityRunningAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appIsUnityRunning", "appIsUnityRunningCompleted", cancellationToken); /// /// If you provided path and args options to then you need to pass the same /// arguments here for to be set correctly. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public async Task GetLoginItemSettingsAsync(CancellationToken cancellationToken = default) { return await GetLoginItemSettingsAsync(null, cancellationToken); @@ -1118,6 +1169,8 @@ namespace ElectronNET.API /// /// /// The cancellation token. + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task GetLoginItemSettingsAsync(LoginItemSettingsOptions options, CancellationToken cancellationToken = default) => options is null ? BridgeConnector.OnResult("appGetLoginItemSettings", "appGetLoginItemSettingsCompleted", cancellationToken) : BridgeConnector.OnResult("appGetLoginItemSettings", "appGetLoginItemSettingsCompleted", cancellationToken, JObject.FromObject(options, _jsonSerializer)); @@ -1128,6 +1181,8 @@ namespace ElectronNET.API /// you'll want to set the launch path to Update.exe, and pass arguments that specify your application name. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetLoginItemSettings(LoginSettings loginSettings) { BridgeConnector.Emit("appSetLoginItemSettings", JObject.FromObject(loginSettings, _jsonSerializer)); @@ -1139,6 +1194,8 @@ namespace ElectronNET.API /// See Chromium's accessibility docs for more details. /// /// if Chrome’s accessibility support is enabled, otherwise. + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult("appIsAccessibilitySupportEnabled", "appIsAccessibilitySupportEnabledCompleted", cancellationToken); @@ -1152,6 +1209,8 @@ namespace ElectronNET.API /// Note: Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default. /// /// Enable or disable accessibility tree rendering. + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetAccessibilitySupportEnabled(bool enabled) { BridgeConnector.Emit("appSetAboutPanelOptions", enabled); diff --git a/ElectronNET.API/BrowserWindow.cs b/ElectronNET.API/BrowserWindow.cs index 0b8222c..9a15ddb 100644 --- a/ElectronNET.API/BrowserWindow.cs +++ b/ElectronNET.API/BrowserWindow.cs @@ -7,8 +7,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Threading.Tasks; +//TODO: Add setTrafficLightPosition and getTrafficLightPosition: https://www.electronjs.org/docs/api/browser-window#winsettrafficlightpositionposition-macos + namespace ElectronNET.API { /// @@ -146,6 +149,7 @@ namespace ElectronNET.API /// /// Emitted when window session is going to end due to force shutdown or machine restart or session log off. /// + [SupportedOSPlatform("windows")] public event Action OnSessionEnd { add @@ -465,6 +469,8 @@ namespace ElectronNET.API /// /// Emitted when the window is being resized. /// + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public event Action OnResize { add @@ -496,6 +502,8 @@ namespace ElectronNET.API /// /// Note: On macOS this event is just an alias of moved. /// + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public event Action OnMove { add @@ -523,8 +531,10 @@ namespace ElectronNET.API private event Action _move; /// - /// macOS: Emitted once when the window is moved to a new position. + /// Emitted once when the window is moved to a new position. /// + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public event Action OnMoved { add @@ -676,6 +686,8 @@ namespace ElectronNET.API /// and the APPCOMMAND_ prefix is stripped off.e.g.APPCOMMAND_BROWSER_BACKWARD /// is emitted as browser-backward. /// + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public event Action OnAppCommand { add @@ -705,6 +717,7 @@ namespace ElectronNET.API /// /// Emitted when scroll wheel event phase has begun. /// + [SupportedOSPlatform("macos")] public event Action OnScrollTouchBegin { add @@ -734,6 +747,7 @@ namespace ElectronNET.API /// /// Emitted when scroll wheel event phase has ended. /// + [SupportedOSPlatform("macos")] public event Action OnScrollTouchEnd { add @@ -763,6 +777,7 @@ namespace ElectronNET.API /// /// Emitted when scroll wheel event phase filed upon reaching the edge of element. /// + [SupportedOSPlatform("macos")] public event Action OnScrollTouchEdge { add @@ -792,6 +807,7 @@ namespace ElectronNET.API /// /// Emitted on 3-finger swipe. Possible directions are up, right, down, left. /// + [SupportedOSPlatform("macos")] public event Action OnSwipe { add @@ -821,6 +837,7 @@ namespace ElectronNET.API /// /// Emitted when the window opens a sheet. /// + [SupportedOSPlatform("macos")] public event Action OnSheetBegin { add @@ -850,6 +867,7 @@ namespace ElectronNET.API /// /// Emitted when the window has closed a sheet. /// + [SupportedOSPlatform("macos")] public event Action OnSheetEnd { add @@ -879,6 +897,7 @@ namespace ElectronNET.API /// /// Emitted when the native new tab button is clicked. /// + [SupportedOSPlatform("macos")] public event Action OnNewWindowForTab { add @@ -1080,17 +1099,41 @@ namespace ElectronNET.API /// /// The aspect ratio to maintain for some portion of the content view. /// The extra size not to be included while maintaining the aspect ratio. + public void SetAspectRatio(int aspectRatio) + { + BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, new Size() { Height = 0, Width = 0 }); + } + + /// + /// This will make a window maintain an aspect ratio. The extra size allows a developer to have space, + /// specified in pixels, not included within the aspect ratio calculations. This API already takes into + /// account the difference between a window’s size and its content size. + /// + /// Consider a normal window with an HD video player and associated controls.Perhaps there are 15 pixels + /// of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below + /// the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within + /// the player itself we would call this function with arguments of 16/9 and[40, 50]. The second argument + /// doesn’t care where the extra width and height are within the content view–only that they exist. Just + /// sum any extra width and height areas you have within the overall content view. + /// + /// The aspect ratio to maintain for some portion of the content view. + /// The extra size not to be included while maintaining the aspect ratio. + [SupportedOSPlatform("macos")] public void SetAspectRatio(int aspectRatio, Size extraSize) { BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, extraSize); } + + + /// /// Uses Quick Look to preview a file at a given path. /// /// The absolute path to the file to preview with QuickLook. This is important as /// Quick Look uses the file name and file extension on the path to determine the content type of the /// file to open. + [SupportedOSPlatform("macos")] public void PreviewFile(string path) { BridgeConnector.Emit("browserWindowPreviewFile", Id, path); @@ -1104,6 +1147,7 @@ namespace ElectronNET.API /// file to open. /// The name of the file to display on the Quick Look modal view. This is /// purely visual and does not affect the content type of the file. Defaults to path. + [SupportedOSPlatform("macos")] public void PreviewFile(string path, string displayname) { BridgeConnector.Emit("browserWindowPreviewFile", Id, path, displayname); @@ -1112,6 +1156,7 @@ namespace ElectronNET.API /// /// Closes the currently open Quick Look panel. /// + [SupportedOSPlatform("macos")] public void CloseFilePreview() { BridgeConnector.Emit("browserWindowCloseFilePreview", Id); @@ -1131,6 +1176,7 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("macos")] public void SetBounds(Rectangle bounds, bool animate) { BridgeConnector.Emit("browserWindowSetBounds", Id, bounds, animate); @@ -1159,6 +1205,7 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("macos")] public void SetContentBounds(Rectangle bounds, bool animate) { BridgeConnector.Emit("browserWindowSetContentBounds", Id, bounds, animate); @@ -1189,6 +1236,7 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("macos")] public void SetSize(int width, int height, bool animate) { BridgeConnector.Emit("browserWindowSetSize", Id, width, height, animate); @@ -1219,6 +1267,7 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("macos")] public void SetContentSize(int width, int height, bool animate) { BridgeConnector.Emit("browserWindowSetContentSize", Id, width, height, animate); @@ -1293,6 +1342,8 @@ namespace ElectronNET.API /// Sets whether the window can be moved by user. On Linux does nothing. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetMovable(bool movable) { BridgeConnector.Emit("browserWindowSetMovable", Id, movable); @@ -1300,10 +1351,10 @@ namespace ElectronNET.API /// /// Whether the window can be moved by user. - /// - /// On Linux always returns true. /// /// On Linux always returns true. + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task IsMovableAsync() { return BridgeConnector.OnResult("browserWindowIsMovable", "browserWindow-isMovable-completed" + Id, Id); @@ -1313,6 +1364,8 @@ namespace ElectronNET.API /// Sets whether the window can be manually minimized by user. On Linux does nothing. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetMinimizable(bool minimizable) { BridgeConnector.Emit("browserWindowSetMinimizable", Id, minimizable); @@ -1320,10 +1373,10 @@ namespace ElectronNET.API /// /// Whether the window can be manually minimized by user. - /// - /// On Linux always returns true. /// /// On Linux always returns true. + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task IsMinimizableAsync() { return BridgeConnector.OnResult("browserWindowIsMinimizable", "browserWindow-isMinimizable-completed" + Id, Id); @@ -1333,6 +1386,8 @@ namespace ElectronNET.API /// Sets whether the window can be manually maximized by user. On Linux does nothing. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetMaximizable(bool maximizable) { BridgeConnector.Emit("browserWindowSetMaximizable", Id, maximizable); @@ -1340,10 +1395,10 @@ namespace ElectronNET.API /// /// Whether the window can be manually maximized by user. - /// - /// On Linux always returns true. /// /// On Linux always returns true. + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task IsMaximizableAsync() { return BridgeConnector.OnResult("browserWindowIsMaximizable", "browserWindow-isMaximizable-completed" + Id, Id); @@ -1371,6 +1426,8 @@ namespace ElectronNET.API /// Sets whether the window can be manually closed by user. On Linux does nothing. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetClosable(bool closable) { BridgeConnector.Emit("browserWindowSetClosable", Id, closable); @@ -1378,10 +1435,10 @@ namespace ElectronNET.API /// /// Whether the window can be manually closed by user. - /// - /// On Linux always returns true. /// /// On Linux always returns true. + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task IsClosableAsync() { return BridgeConnector.OnResult("browserWindowIsClosable", "browserWindow-isClosable-completed" + Id, Id); @@ -1407,6 +1464,8 @@ namespace ElectronNET.API /// Values include normal, floating, torn-off-menu, modal-panel, main-menu, /// status, pop-up-menu and screen-saver. The default is floating. /// See the macOS docs + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetAlwaysOnTop(bool flag, OnTopLevel level) { BridgeConnector.Emit("browserWindowSetAlwaysOnTop", Id, flag, level.GetDescription()); @@ -1423,6 +1482,7 @@ namespace ElectronNET.API /// See the macOS docs /// The number of layers higher to set this window relative to the given level. /// The default is 0. Note that Apple discourages setting levels higher than 1 above screen-saver. + [SupportedOSPlatform("macos")] public void SetAlwaysOnTop(bool flag, OnTopLevel level, int relativeLevel) { BridgeConnector.Emit("browserWindowSetAlwaysOnTop", Id, flag, level.GetDescription(), relativeLevel); @@ -1468,6 +1528,7 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("macos")] public void SetPosition(int x, int y, bool animate) { // Workaround Windows 10 / Electron Bug @@ -1482,7 +1543,7 @@ namespace ElectronNET.API private bool isWindows10() { - return RuntimeInformation.OSDescription.Contains("Windows 10"); + return OperatingSystem.IsWindowsVersionAtLeast(10); } /// @@ -1520,6 +1581,7 @@ namespace ElectronNET.API /// but you may want to display them beneath a HTML-rendered toolbar. /// /// + [SupportedOSPlatform("macos")] public void SetSheetOffset(float offsetY) { BridgeConnector.Emit("browserWindowSetSheetOffset", Id, offsetY); @@ -1532,6 +1594,7 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("macos")] public void SetSheetOffset(float offsetY, float offsetX) { BridgeConnector.Emit("browserWindowSetSheetOffset", Id, offsetY, offsetX); @@ -1587,6 +1650,7 @@ namespace ElectronNET.API /// and the icon of the file will show in window’s title bar. /// /// + [SupportedOSPlatform("macos")] public void SetRepresentedFilename(string filename) { BridgeConnector.Emit("browserWindowSetRepresentedFilename", Id, filename); @@ -1596,6 +1660,7 @@ namespace ElectronNET.API /// The pathname of the file the window represents. /// /// + [SupportedOSPlatform("macos")] public Task GetRepresentedFilenameAsync() { return BridgeConnector.OnResult("browserWindowGetRepresentedFilename", "browserWindow-getRepresentedFilename-completed" + Id, Id); @@ -1606,6 +1671,7 @@ namespace ElectronNET.API /// and the icon in title bar will become gray when set to true. /// /// + [SupportedOSPlatform("macos")] public void SetDocumentEdited(bool edited) { BridgeConnector.Emit("browserWindowSetDocumentEdited", Id, edited); @@ -1615,6 +1681,7 @@ namespace ElectronNET.API /// Whether the window’s document has been edited. /// /// + [SupportedOSPlatform("macos")] public Task IsDocumentEditedAsync() { return BridgeConnector.OnResult("browserWindowIsDocumentEdited", "browserWindow-isDocumentEdited-completed" + Id, Id); @@ -1679,6 +1746,8 @@ namespace ElectronNET.API /// setting it to null will remove the menu bar. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("linux")] public void SetMenu(MenuItem[] menuItems) { menuItems.AddMenuItemsId(); @@ -1696,6 +1765,8 @@ namespace ElectronNET.API /// /// Remove the window's menu bar. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("linux")] public void RemoveMenu() { BridgeConnector.Emit("browserWindowRemoveMenu", Id); @@ -1729,6 +1800,7 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("windows")] public void SetProgressBar(double progress, ProgressBarOptions progressBarOptions) { BridgeConnector.Emit("browserWindowSetProgressBar", Id, progress, progressBarOptions); @@ -1776,6 +1848,7 @@ namespace ElectronNET.API /// /// /// Whether the buttons were added successfully. + [SupportedOSPlatform("windows")] public Task SetThumbarButtonsAsync(ThumbarButton[] thumbarButtons) { var taskCompletionSource = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); @@ -1808,6 +1881,7 @@ namespace ElectronNET.API /// an empty region: {x: 0, y: 0, width: 0, height: 0}. /// /// + [SupportedOSPlatform("windows")] public void SetThumbnailClip(Rectangle rectangle) { BridgeConnector.Emit("browserWindowSetThumbnailClip", Id, rectangle); @@ -1817,6 +1891,7 @@ namespace ElectronNET.API /// Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar. /// /// + [SupportedOSPlatform("windows")] public void SetThumbnailToolTip(string tooltip) { BridgeConnector.Emit("browserWindowSetThumbnailToolTip", Id, tooltip); @@ -1829,6 +1904,7 @@ namespace ElectronNET.API /// If one of those properties is not set, then neither will be used. /// /// + [SupportedOSPlatform("windows")] public void SetAppDetails(AppDetailsOptions options) { BridgeConnector.Emit("browserWindowSetAppDetails", Id, options); @@ -1837,6 +1913,7 @@ namespace ElectronNET.API /// /// Same as webContents.showDefinitionForSelection(). /// + [SupportedOSPlatform("macos")] public void ShowDefinitionForSelection() { BridgeConnector.Emit("browserWindowShowDefinitionForSelection", Id); @@ -1868,6 +1945,8 @@ namespace ElectronNET.API /// users can still bring up the menu bar by pressing the single Alt key. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("linux")] public void SetMenuBarVisibility(bool visible) { BridgeConnector.Emit("browserWindowSetMenuBarVisibility", Id, visible); @@ -1877,6 +1956,8 @@ namespace ElectronNET.API /// Whether the menu bar is visible. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("linux")] public Task IsMenuBarVisibleAsync() { return BridgeConnector.OnResult("browserWindowIsMenuBarVisible", "browserWindow-isMenuBarVisible-completed" + Id, Id); @@ -1923,6 +2004,8 @@ namespace ElectronNET.API /// On Windows it calls SetWindowDisplayAffinity with WDA_MONITOR. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetContentProtection(bool enable) { BridgeConnector.Emit("browserWindowSetContentProtection", Id, enable); @@ -1932,6 +2015,8 @@ namespace ElectronNET.API /// Changes whether the window can be focused. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void SetFocusable(bool focusable) { BridgeConnector.Emit("browserWindowSetFocusable", Id, focusable); @@ -1971,6 +2056,7 @@ namespace ElectronNET.API /// Controls whether to hide cursor when typing. /// /// + [SupportedOSPlatform("macos")] public void SetAutoHideCursor(bool autoHide) { BridgeConnector.Emit("browserWindowSetAutoHideCursor", Id, autoHide); @@ -1983,6 +2069,7 @@ namespace ElectronNET.API /// Can be appearance-based, light, dark, titlebar, selection, /// menu, popover, sidebar, medium-light or ultra-dark. /// See the macOS documentation for more details. + [SupportedOSPlatform("macos")] public void SetVibrancy(Vibrancy type) { BridgeConnector.Emit("browserWindowSetVibrancy", Id, type.GetDescription()); diff --git a/ElectronNET.API/Clipboard.cs b/ElectronNET.API/Clipboard.cs index b757bb0..f9e0fb4 100644 --- a/ElectronNET.API/Clipboard.cs +++ b/ElectronNET.API/Clipboard.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; +using System.Runtime.Versioning; using System.Threading.Tasks; namespace ElectronNET.API @@ -93,6 +94,8 @@ namespace ElectronNET.API /// be empty strings when the bookmark is unavailable. /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task ReadBookmarkAsync() => BridgeConnector.OnResult("clipboard-readBookmark", "clipboard-readBookmark-Completed"); /// @@ -105,6 +108,8 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public void WriteBookmark(string title, string url, string type = "") { BridgeConnector.Emit("clipboard-writeBookmark", title, url, type); @@ -116,6 +121,7 @@ namespace ElectronNET.API /// find pasteboard whenever the application is activated. /// /// + [SupportedOSPlatform("macos")] public Task ReadFindTextAsync() => BridgeConnector.OnResult("clipboard-readFindText", "clipboard-readFindText-Completed"); /// @@ -123,6 +129,7 @@ namespace ElectronNET.API /// synchronous IPC when called from the renderer process. /// /// + [SupportedOSPlatform("macos")] public void WriteFindText(string text) { BridgeConnector.Emit("clipboard-writeFindText", text); diff --git a/ElectronNET.API/Dialog.cs b/ElectronNET.API/Dialog.cs index a8ecb82..6011e1d 100644 --- a/ElectronNET.API/Dialog.cs +++ b/ElectronNET.API/Dialog.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; +using System.Runtime.Versioning; using System.Threading.Tasks; using System.Web; @@ -191,6 +192,8 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task ShowCertificateTrustDialogAsync(CertificateTrustDialogOptions options) { return ShowCertificateTrustDialogAsync(null, options); @@ -204,6 +207,8 @@ namespace ElectronNET.API /// /// /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options) { var taskCompletionSource = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); diff --git a/ElectronNET.API/Dock.cs b/ElectronNET.API/Dock.cs index 9c00b2d..791cb3f 100644 --- a/ElectronNET.API/Dock.cs +++ b/ElectronNET.API/Dock.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using ElectronNET.API.Entities; @@ -12,6 +13,7 @@ namespace ElectronNET.API /// /// Control your app in the macOS dock. /// + [SupportedOSPlatform("macos")] public sealed class Dock { private static Dock _dock; diff --git a/ElectronNET.API/Electron.cs b/ElectronNET.API/Electron.cs index 8570b74..1dab7d9 100644 --- a/ElectronNET.API/Electron.cs +++ b/ElectronNET.API/Electron.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using System.Runtime.Versioning; namespace ElectronNET.API { @@ -102,6 +103,7 @@ namespace ElectronNET.API /// /// Control your app in the macOS dock. /// + [SupportedOSPlatform("macos")] public static Dock Dock { get { return Dock.Instance; } } } } \ No newline at end of file diff --git a/ElectronNET.API/Entities/NotificationAction.cs b/ElectronNET.API/Entities/NotificationAction.cs index c7194cd..0477561 100644 --- a/ElectronNET.API/Entities/NotificationAction.cs +++ b/ElectronNET.API/Entities/NotificationAction.cs @@ -3,6 +3,7 @@ /// /// /// + [SupportedOSPlatform("macos")] public class NotificationAction { /// diff --git a/ElectronNET.API/Entities/NotificationOptions.cs b/ElectronNET.API/Entities/NotificationOptions.cs index d191379..5347822 100644 --- a/ElectronNET.API/Entities/NotificationOptions.cs +++ b/ElectronNET.API/Entities/NotificationOptions.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using System; +using System.Runtime.Versioning; namespace ElectronNET.API.Entities { @@ -17,6 +18,8 @@ namespace ElectronNET.API.Entities /// /// A subtitle for the notification, which will be displayed below the title. /// + [SupportedOSPlatform("macos")] + public string SubTitle { get; set; } /// @@ -38,38 +41,46 @@ namespace ElectronNET.API.Entities /// /// Whether or not to add an inline reply option to the notification. /// + [SupportedOSPlatform("macos")] public bool HasReply { get; set; } /// /// The timeout duration of the notification. Can be 'default' or 'never'. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("linux")] public string TimeoutType { get; set; } /// /// The placeholder to write in the inline reply input field. /// + [SupportedOSPlatform("macos")] public string ReplyPlaceholder { get; set; } /// /// The name of the sound file to play when the notification is shown. /// + [SupportedOSPlatform("macos")] public string Sound { get; set; } /// /// The urgency level of the notification. Can be 'normal', 'critical', or 'low'. /// + [SupportedOSPlatform("linux")] public string Urgency { get; set; } /// /// Actions to add to the notification. Please read the available actions and /// limitations in the NotificationAction documentation. /// + [SupportedOSPlatform("macos")] public NotificationAction Actions { get; set; } /// /// A custom title for the close button of an alert. An empty string will cause the /// default localized text to be used. /// + [SupportedOSPlatform("macos")] public string CloseButtonText { get; set; } /// @@ -127,6 +138,7 @@ namespace ElectronNET.API.Entities /// The string the user entered into the inline reply field /// [JsonIgnore] + [SupportedOSPlatform("macos")] public Action OnReply { get; set; } /// @@ -142,6 +154,7 @@ namespace ElectronNET.API.Entities /// macOS only - The index of the action that was activated /// [JsonIgnore] + [SupportedOSPlatform("macos")] public Action OnAction { get; set; } /// diff --git a/ElectronNET.API/Entities/OpenDialogOptions.cs b/ElectronNET.API/Entities/OpenDialogOptions.cs index 3f18dff..76b58a8 100644 --- a/ElectronNET.API/Entities/OpenDialogOptions.cs +++ b/ElectronNET.API/Entities/OpenDialogOptions.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using System.Runtime.Versioning; namespace ElectronNET.API.Entities { @@ -39,6 +40,7 @@ namespace ElectronNET.API.Entities /// /// Message to display above input boxes. /// + [SupportedOSPlatform("macos")] public string Message { get; set; } /// diff --git a/ElectronNET.API/Entities/OpenDialogProperty.cs b/ElectronNET.API/Entities/OpenDialogProperty.cs index 44a16b1..ec47dad 100644 --- a/ElectronNET.API/Entities/OpenDialogProperty.cs +++ b/ElectronNET.API/Entities/OpenDialogProperty.cs @@ -1,4 +1,6 @@ -namespace ElectronNET.API.Entities +using System.Runtime.Versioning; + +namespace ElectronNET.API.Entities { /// /// @@ -28,21 +30,66 @@ /// /// The create directory /// + [SupportedOSPlatform("macos")] createDirectory, /// /// The prompt to create /// + [SupportedOSPlatform("windows")] promptToCreate, /// /// The no resolve aliases /// + [SupportedOSPlatform("macos")] noResolveAliases, /// - /// The treat package as directory + /// Treat packages, such as .app folders, as a directory instead of a file. /// - treatPackageAsDirectory + [SupportedOSPlatform("macos")] + treatPackageAsDirectory, + + /// + /// Don't add the item being opened to recent documents list + /// + [SupportedOSPlatform("windows")] + dontAddToRecent + } + + /// + /// + /// + public enum SaveDialogProperty + { + /// + /// The show hidden files + /// + showHiddenFiles, + + /// + /// The create directory + /// + [SupportedOSPlatform("macos")] + createDirectory, + + /// + /// Treat packages, such as .app folders, as a directory instead of a file. + /// + [SupportedOSPlatform("macos")] + treatPackageAsDirectory, + + /// + /// Sets whether the user will be presented a confirmation dialog if the user types a file name that already exists. + /// + [SupportedOSPlatform("linux")] + showOverwriteConfirmation, + + /// + /// Don't add the item being opened to recent documents list + /// + [SupportedOSPlatform("windows")] + dontAddToRecent } } \ No newline at end of file diff --git a/ElectronNET.API/Entities/OpenExternalOptions.cs b/ElectronNET.API/Entities/OpenExternalOptions.cs index dba51ca..d913593 100644 --- a/ElectronNET.API/Entities/OpenExternalOptions.cs +++ b/ElectronNET.API/Entities/OpenExternalOptions.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using System.Runtime.Versioning; namespace ElectronNET.API.Entities { @@ -12,11 +13,13 @@ namespace ElectronNET.API.Entities /// to bring the opened application to the foreground. The default is . /// [DefaultValue(true)] + [SupportedOSPlatform("macos")] public bool Activate { get; set; } = true; /// /// The working directory. /// + [SupportedOSPlatform("windows")] public string WorkingDirectory { get; set; } } } \ No newline at end of file diff --git a/ElectronNET.API/Entities/SaveDialogOptions.cs b/ElectronNET.API/Entities/SaveDialogOptions.cs index 16811d7..2e7ed4e 100644 --- a/ElectronNET.API/Entities/SaveDialogOptions.cs +++ b/ElectronNET.API/Entities/SaveDialogOptions.cs @@ -1,4 +1,7 @@ using ElectronNET.API.Entities; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.Runtime.Versioning; namespace ElectronNET.API { @@ -46,16 +49,26 @@ namespace ElectronNET.API /// /// Message to display above text fields. /// + [SupportedOSPlatform("macos")] public string Message { get; set; } /// /// Custom label for the text displayed in front of the filename text field. /// + [SupportedOSPlatform("macos")] public string NameFieldLabel { get; set; } /// /// Show the tags input box, defaults to true. /// + [SupportedOSPlatform("macos")] public bool ShowsTagField { get; set; } + + /// + /// Contains which features the dialog should use. The following values are supported: + /// 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory' + /// + [JsonProperty("properties", ItemConverterType = typeof(StringEnumConverter))] + public SaveDialogProperty[] Properties { get; set; } } } \ No newline at end of file diff --git a/ElectronNET.API/NativeTheme.cs b/ElectronNET.API/NativeTheme.cs index 12bce45..235d349 100644 --- a/ElectronNET.API/NativeTheme.cs +++ b/ElectronNET.API/NativeTheme.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.Versioning; using System.Threading.Tasks; using ElectronNET.API.Entities; using ElectronNET.API.Extensions; @@ -114,12 +115,16 @@ namespace ElectronNET.API /// A for if the OS / Chromium currently has high-contrast mode enabled or is /// being instructed to show a high-contrast UI. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task ShouldUseHighContrastColorsAsync() => BridgeConnector.OnResult("nativeTheme-shouldUseHighContrastColors", "nativeTheme-shouldUseHighContrastColors-completed"); /// /// A for if the OS / Chromium currently has an inverted color scheme or is /// being instructed to use an inverted color scheme. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public Task ShouldUseInvertedColorSchemeAsync() => BridgeConnector.OnResult("nativeTheme-shouldUseInvertedColorScheme", "nativeTheme-shouldUseInvertedColorScheme-completed"); /// diff --git a/ElectronNET.API/PowerMonitor.cs b/ElectronNET.API/PowerMonitor.cs index 8a7ab80..c92bff9 100644 --- a/ElectronNET.API/PowerMonitor.cs +++ b/ElectronNET.API/PowerMonitor.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.Versioning; using System.Threading.Tasks; namespace ElectronNET.API @@ -11,6 +12,8 @@ namespace ElectronNET.API /// /// Emitted when the system is about to lock the screen. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnLockScreen { add @@ -40,6 +43,8 @@ namespace ElectronNET.API /// /// Emitted when the system is about to unlock the screen. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnUnLockScreen { add @@ -69,6 +74,8 @@ namespace ElectronNET.API /// /// Emitted when the system is suspending. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnSuspend { add @@ -98,6 +105,8 @@ namespace ElectronNET.API /// /// Emitted when system is resuming. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnResume { add @@ -127,6 +136,8 @@ namespace ElectronNET.API /// /// Emitted when the system changes to AC power. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnAC { add @@ -156,6 +167,8 @@ namespace ElectronNET.API /// /// Emitted when system changes to battery power. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnBattery { add @@ -189,6 +202,9 @@ namespace ElectronNET.API /// order for the app to exit cleanly.If `e.preventDefault()` is called, the app /// should exit as soon as possible by calling something like `app.quit()`. /// + [SupportedOSPlatform("linux")] + [SupportedOSPlatform("macos")] + public event Action OnShutdown { add diff --git a/ElectronNET.API/Shell.cs b/ElectronNET.API/Shell.cs index 5bf82c4..929daac 100644 --- a/ElectronNET.API/Shell.cs +++ b/ElectronNET.API/Shell.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using System.Threading.Tasks; using ElectronNET.API.Extensions; +using System.Runtime.Versioning; namespace ElectronNET.API { @@ -93,6 +94,7 @@ namespace ElectronNET.API /// Max 2081 characters on windows. /// Controls the behavior of OpenExternal. /// The error message corresponding to the failure if a failure occurred, otherwise . + public Task OpenExternalAsync(string url, OpenExternalOptions options) { var taskCompletionSource = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); @@ -141,6 +143,7 @@ namespace ElectronNET.API /// Default is /// Structure of a shortcut. /// Whether the shortcut was created successfully. + [SupportedOSPlatform("windows")] public Task WriteShortcutLinkAsync(string shortcutPath, ShortcutLinkOperation operation, ShortcutDetails options) { return BridgeConnector.OnResult("shell-writeShortcutLink", "shell-writeShortcutLinkCompleted", shortcutPath, operation.GetDescription(), options); @@ -152,6 +155,7 @@ namespace ElectronNET.API /// /// The path tot the shortcut. /// of the shortcut. + [SupportedOSPlatform("windows")] public Task ReadShortcutLinkAsync(string shortcutPath) { return BridgeConnector.OnResult("shell-readShortcutLink", "shell-readShortcutLinkCompleted", shortcutPath); diff --git a/ElectronNET.API/Tray.cs b/ElectronNET.API/Tray.cs index c37f5fe..c1b6cbb 100644 --- a/ElectronNET.API/Tray.cs +++ b/ElectronNET.API/Tray.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; +using System.Runtime.Versioning; using System.Threading.Tasks; namespace ElectronNET.API @@ -12,6 +13,9 @@ namespace ElectronNET.API /// /// Add icons and context menus to the system's notification area. /// + + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("windows")] public sealed class Tray { /// @@ -46,6 +50,8 @@ namespace ElectronNET.API /// /// macOS, Windows: Emitted when the tray icon is right clicked. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnRightClick { add @@ -75,6 +81,8 @@ namespace ElectronNET.API /// /// macOS, Windows: Emitted when the tray icon is double clicked. /// + [SupportedOSPlatform("windows")] + [SupportedOSPlatform("macos")] public event Action OnDoubleClick { add @@ -104,6 +112,7 @@ namespace ElectronNET.API /// /// Windows: Emitted when the tray balloon shows. /// + [SupportedOSPlatform("windows")] public event Action OnBalloonShow { add @@ -133,6 +142,7 @@ namespace ElectronNET.API /// /// Windows: Emitted when the tray balloon is clicked. /// + [SupportedOSPlatform("windows")] public event Action OnBalloonClick { add @@ -163,6 +173,8 @@ namespace ElectronNET.API /// Windows: Emitted when the tray balloon is closed /// because of timeout or user manually closes it. /// + + [SupportedOSPlatform("windows")] public event Action OnBalloonClosed { add @@ -285,6 +297,7 @@ namespace ElectronNET.API /// Sets the image associated with this tray icon when pressed on macOS. /// /// + [SupportedOSPlatform("macos")] public void SetPressedImage(string image) { BridgeConnector.Emit("tray-setPressedImage", image); @@ -303,6 +316,7 @@ namespace ElectronNET.API /// macOS: Sets the title displayed aside of the tray icon in the status bar. /// /// + [SupportedOSPlatform("macos")] public void SetTitle(string title) { BridgeConnector.Emit("tray-setTitle", title); @@ -312,6 +326,7 @@ namespace ElectronNET.API /// Windows: Displays a tray balloon. /// /// + [SupportedOSPlatform("windows")] public void DisplayBalloon(DisplayBalloonOptions options) { BridgeConnector.Emit("tray-displayBalloon", options);