Add supported OS platform annotations

This commit is contained in:
rafael-aero
2021-08-26 14:22:54 +02:00
parent 7ad6803671
commit 224bc1ef65
16 changed files with 294 additions and 13 deletions

View File

@@ -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.
/// </summary>
/// <returns><see langword="true"/> when Chrome's accessibility support is enabled, <see langword="false"/> otherwise.</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public event Action<bool> AccessibilitySupportChanged
{
add
@@ -411,6 +418,7 @@ namespace ElectronNET.API
/// <para/>
/// On Windows, you have to parse the arguments using App.CommandLine to get the filepath.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action<string> 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.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action<string> OpenUrl
{
add
@@ -599,6 +608,7 @@ namespace ElectronNET.API
/// <para/>
/// You should seek to use the <see cref="FocusOptions.Steal"/> option as sparingly as possible.
/// </summary>
[SupportedOSPlatform("macos")]
public void Focus(FocusOptions focusOptions)
{
BridgeConnector.Emit("appFocus", JObject.FromObject(focusOptions, _jsonSerializer));
@@ -607,6 +617,7 @@ namespace ElectronNET.API
/// <summary>
/// Hides all application windows without minimizing them.
/// </summary>
[SupportedOSPlatform("macos")]
public void Hide()
{
BridgeConnector.Emit("appHide");
@@ -615,6 +626,7 @@ namespace ElectronNET.API
/// <summary>
/// Shows application windows after they were hidden. Does not automatically focus them.
/// </summary>
[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.
/// </summary>
/// <param name="path">Path to add.</param>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public void AddRecentDocument(string path)
{
BridgeConnector.Emit("appAddRecentDocument", path);
@@ -696,6 +710,8 @@ namespace ElectronNET.API
/// <summary>
/// Clears the recent documents list.
/// </summary>
[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.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public async Task<bool> SetAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
{
return await SetAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken);
@@ -757,6 +775,8 @@ namespace ElectronNET.API
/// <param name="path">The path to the Electron executable. Defaults to process.execPath</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public async Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
{
return await SetAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken);
@@ -789,6 +809,8 @@ namespace ElectronNET.API
/// <param name="args">Arguments passed to the executable. Defaults to an empty array.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appSetAsDefaultProtocolClient", "appSetAsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args);
/// <summary>
@@ -798,6 +820,8 @@ namespace ElectronNET.API
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
{
return await RemoveAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken);
@@ -811,6 +835,8 @@ namespace ElectronNET.API
/// <param name="path">Defaults to process.execPath.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
{
return await RemoveAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken);
@@ -825,6 +851,8 @@ namespace ElectronNET.API
/// <param name="args">Defaults to an empty array.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appRemoveAsDefaultProtocolClient", "appRemoveAsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args);
@@ -841,6 +869,8 @@ namespace ElectronNET.API
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the current executable is the default handler for a protocol (aka URI scheme).</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public async Task<bool> IsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
{
return await IsDefaultProtocolClientAsync(protocol, null, null, cancellationToken);
@@ -860,6 +890,8 @@ namespace ElectronNET.API
/// <param name="path">Defaults to process.execPath.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the current executable is the default handler for a protocol (aka URI scheme).</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public async Task<bool> IsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
{
return await IsDefaultProtocolClientAsync(protocol, path, null, cancellationToken);
@@ -880,6 +912,8 @@ namespace ElectronNET.API
/// <param name="args">Defaults to an empty array.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the current executable is the default handler for a protocol (aka URI scheme).</returns>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public Task<bool> IsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appIsDefaultProtocolClient", "appIsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args);
@@ -891,6 +925,7 @@ namespace ElectronNET.API
/// <param name="userTasks">Array of <see cref="UserTask"/> objects.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("windows")]
public Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appSetUserTasks", "appSetUserTasksCompleted", cancellationToken, JArray.FromObject(userTasks, _jsonSerializer));
/// <summary>
@@ -898,6 +933,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Jump List settings.</returns>
[SupportedOSPlatform("windows")]
public Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<JumpListSettings>("appGetJumpListSettings", "appGetJumpListSettingsCompleted", cancellationToken);
/// <summary>
@@ -916,6 +952,7 @@ namespace ElectronNET.API
/// omitted from the Jump List. The list of removed items can be obtained using <see cref="GetJumpListSettingsAsync"/>.
/// </summary>
/// <param name="categories">Array of <see cref="JumpListCategory"/> objects.</param>
[SupportedOSPlatform("windows")]
public void SetJumpList(JumpListCategory[] categories)
{
BridgeConnector.Emit("appSetJumpList", JArray.FromObject(categories, _jsonSerializer));
@@ -991,6 +1028,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="type">Uniquely identifies the activity. Maps to <see href="https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType">NSUserActivity.activityType</see>.</param>
/// <param name="userInfo">App-specific state to store for use by another device.</param>
[SupportedOSPlatform("macos")]
public void SetUserActivity(string type, object userInfo)
{
SetUserActivity(type, userInfo, null);
@@ -1008,6 +1046,7 @@ namespace ElectronNET.API
/// <param name="webpageUrl">
/// The webpage to load in a browser if no suitable app is installed on the resuming device. The scheme must be http or https.
/// </param>
[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.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("macos")]
public Task<string> GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<string>("appGetCurrentActivityType", "appGetCurrentActivityTypeCompleted", cancellationToken);
/// <summary>
/// Invalidates the current <see href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html">Handoff</see> user activity.
/// </summary>
[SupportedOSPlatform("macos")]
public void InvalidateCurrentActivity()
{
BridgeConnector.Emit("appInvalidateCurrentActivity");
@@ -1031,6 +1072,7 @@ namespace ElectronNET.API
/// <summary>
/// Marks the current <see href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html">Handoff</see> user activity as inactive without invalidating it.
/// </summary>
[SupportedOSPlatform("macos")]
public void ResignCurrentActivity()
{
BridgeConnector.Emit("appResignCurrentActivity");
@@ -1040,6 +1082,7 @@ namespace ElectronNET.API
/// Changes the <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx">Application User Model ID</see> to id.
/// </summary>
/// <param name="id">Model Id.</param>
[SupportedOSPlatform("windows")]
public void SetAppUserModelId(string id)
{
BridgeConnector.Emit("appSetAppUserModelId", id);
@@ -1054,6 +1097,7 @@ namespace ElectronNET.API
/// <param name="options"></param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Result of import. Value of 0 indicates success.</returns>
[SupportedOSPlatform("linux")]
public Task<int> ImportCertificateAsync(ImportCertificateOptions options, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<int>("appImportCertificate", "appImportCertificateCompleted", cancellationToken, JObject.FromObject(options, _jsonSerializer));
/// <summary>
@@ -1084,12 +1128,16 @@ namespace ElectronNET.API
/// <param name="count">Counter badge.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the call succeeded.</returns>
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
public Task<bool> SetBadgeCountAsync(int count, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appSetBadgeCount", "appSetBadgeCountCompleted", cancellationToken, count);
/// <summary>
/// The current value displayed in the counter badge.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
public Task<int> GetBadgeCountAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<int>("appGetBadgeCount", "appGetBadgeCountCompleted", cancellationToken);
/// <summary>
@@ -1101,12 +1149,15 @@ namespace ElectronNET.API
/// Whether the current desktop environment is Unity launcher.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("linux")]
public Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appIsUnityRunning", "appIsUnityRunningCompleted", cancellationToken);
/// <summary>
/// If you provided path and args options to <see cref="SetLoginItemSettings"/> then you need to pass the same
/// arguments here for <see cref="LoginItemSettings.OpenAtLogin"/> to be set correctly.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(CancellationToken cancellationToken = default)
{
return await GetLoginItemSettingsAsync(null, cancellationToken);
@@ -1118,6 +1169,8 @@ namespace ElectronNET.API
/// </summary>
/// <param name="options"></param>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options, CancellationToken cancellationToken = default) =>
options is null ? BridgeConnector.OnResult<LoginItemSettings>("appGetLoginItemSettings", "appGetLoginItemSettingsCompleted", cancellationToken)
: BridgeConnector.OnResult<LoginItemSettings>("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.
/// </summary>
/// <param name="loginSettings"></param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public void SetLoginItemSettings(LoginSettings loginSettings)
{
BridgeConnector.Emit("appSetLoginItemSettings", JObject.FromObject(loginSettings, _jsonSerializer));
@@ -1139,6 +1194,8 @@ namespace ElectronNET.API
/// See <see href="chromium.org/developers/design-documents/accessibility">Chromium's accessibility docs</see> for more details.
/// </summary>
/// <returns><see langword="true"/> if Chromes accessibility support is enabled, <see langword="false"/> otherwise.</returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("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.
/// </summary>
/// <param name="enabled">Enable or disable <see href="https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree">accessibility tree</see> rendering.</param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public void SetAccessibilitySupportEnabled(bool enabled)
{
BridgeConnector.Emit("appSetAboutPanelOptions", enabled);

View File

@@ -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
{
/// <summary>
@@ -146,6 +149,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when window session is going to end due to force shutdown or machine restart or session log off.
/// </summary>
[SupportedOSPlatform("windows")]
public event Action OnSessionEnd
{
add
@@ -465,6 +469,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the window is being resized.
/// </summary>
[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.
/// </summary>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public event Action OnMove
{
add
@@ -523,8 +531,10 @@ namespace ElectronNET.API
private event Action _move;
/// <summary>
/// macOS: Emitted once when the window is moved to a new position.
/// Emitted once when the window is moved to a new position.
/// </summary>
[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.
/// </summary>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public event Action<string> OnAppCommand
{
add
@@ -705,6 +717,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when scroll wheel event phase has begun.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action OnScrollTouchBegin
{
add
@@ -734,6 +747,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when scroll wheel event phase has ended.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action OnScrollTouchEnd
{
add
@@ -763,6 +777,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when scroll wheel event phase filed upon reaching the edge of element.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action OnScrollTouchEdge
{
add
@@ -792,6 +807,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted on 3-finger swipe. Possible directions are up, right, down, left.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action<string> OnSwipe
{
add
@@ -821,6 +837,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the window opens a sheet.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action OnSheetBegin
{
add
@@ -850,6 +867,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the window has closed a sheet.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action OnSheetEnd
{
add
@@ -879,6 +897,7 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the native new tab button is clicked.
/// </summary>
[SupportedOSPlatform("macos")]
public event Action OnNewWindowForTab
{
add
@@ -1080,17 +1099,41 @@ namespace ElectronNET.API
/// </summary>
/// <param name="aspectRatio">The aspect ratio to maintain for some portion of the content view.</param>
/// <param name="extraSize">The extra size not to be included while maintaining the aspect ratio.</param>
public void SetAspectRatio(int aspectRatio)
{
BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, new Size() { Height = 0, Width = 0 });
}
/// <summary>
/// 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 windows 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
/// doesnt care where the extra width and height are within the content viewonly that they exist. Just
/// sum any extra width and height areas you have within the overall content view.
/// </summary>
/// <param name="aspectRatio">The aspect ratio to maintain for some portion of the content view.</param>
/// <param name="extraSize">The extra size not to be included while maintaining the aspect ratio.</param>
[SupportedOSPlatform("macos")]
public void SetAspectRatio(int aspectRatio, Size extraSize)
{
BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, extraSize);
}
/// <summary>
/// Uses Quick Look to preview a file at a given path.
/// </summary>
/// <param name="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.</param>
[SupportedOSPlatform("macos")]
public void PreviewFile(string path)
{
BridgeConnector.Emit("browserWindowPreviewFile", Id, path);
@@ -1104,6 +1147,7 @@ namespace ElectronNET.API
/// file to open.</param>
/// <param name="displayname">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.</param>
[SupportedOSPlatform("macos")]
public void PreviewFile(string path, string displayname)
{
BridgeConnector.Emit("browserWindowPreviewFile", Id, path, displayname);
@@ -1112,6 +1156,7 @@ namespace ElectronNET.API
/// <summary>
/// Closes the currently open Quick Look panel.
/// </summary>
[SupportedOSPlatform("macos")]
public void CloseFilePreview()
{
BridgeConnector.Emit("browserWindowCloseFilePreview", Id);
@@ -1131,6 +1176,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="bounds"></param>
/// <param name="animate"></param>
[SupportedOSPlatform("macos")]
public void SetBounds(Rectangle bounds, bool animate)
{
BridgeConnector.Emit("browserWindowSetBounds", Id, bounds, animate);
@@ -1159,6 +1205,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="bounds"></param>
/// <param name="animate"></param>
[SupportedOSPlatform("macos")]
public void SetContentBounds(Rectangle bounds, bool animate)
{
BridgeConnector.Emit("browserWindowSetContentBounds", Id, bounds, animate);
@@ -1189,6 +1236,7 @@ namespace ElectronNET.API
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="animate"></param>
[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
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="animate"></param>
[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.
/// </summary>
/// <param name="movable"></param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public void SetMovable(bool movable)
{
BridgeConnector.Emit("browserWindowSetMovable", Id, movable);
@@ -1300,10 +1351,10 @@ namespace ElectronNET.API
/// <summary>
/// Whether the window can be moved by user.
///
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<bool> IsMovableAsync()
{
return BridgeConnector.OnResult<bool>("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.
/// </summary>
/// <param name="minimizable"></param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public void SetMinimizable(bool minimizable)
{
BridgeConnector.Emit("browserWindowSetMinimizable", Id, minimizable);
@@ -1320,10 +1373,10 @@ namespace ElectronNET.API
/// <summary>
/// Whether the window can be manually minimized by user.
///
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<bool> IsMinimizableAsync()
{
return BridgeConnector.OnResult<bool>("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.
/// </summary>
/// <param name="maximizable"></param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public void SetMaximizable(bool maximizable)
{
BridgeConnector.Emit("browserWindowSetMaximizable", Id, maximizable);
@@ -1340,10 +1395,10 @@ namespace ElectronNET.API
/// <summary>
/// Whether the window can be manually maximized by user.
///
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<bool> IsMaximizableAsync()
{
return BridgeConnector.OnResult<bool>("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.
/// </summary>
/// <param name="closable"></param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public void SetClosable(bool closable)
{
BridgeConnector.Emit("browserWindowSetClosable", Id, closable);
@@ -1378,10 +1435,10 @@ namespace ElectronNET.API
/// <summary>
/// Whether the window can be manually closed by user.
///
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<bool> IsClosableAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsClosable", "browserWindow-isClosable-completed" + Id, Id);
@@ -1407,6 +1464,8 @@ namespace ElectronNET.API
/// <param name="level">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</param>
[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</param>
/// <param name="relativeLevel">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.</param>
[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
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="animate"></param>
[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);
}
/// <summary>
@@ -1520,6 +1581,7 @@ namespace ElectronNET.API
/// but you may want to display them beneath a HTML-rendered toolbar.
/// </summary>
/// <param name="offsetY"></param>
[SupportedOSPlatform("macos")]
public void SetSheetOffset(float offsetY)
{
BridgeConnector.Emit("browserWindowSetSheetOffset", Id, offsetY);
@@ -1532,6 +1594,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="offsetY"></param>
/// <param name="offsetX"></param>
[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 windows title bar.
/// </summary>
/// <param name="filename"></param>
[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.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("macos")]
public Task<string> GetRepresentedFilenameAsync()
{
return BridgeConnector.OnResult<string>("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.
/// </summary>
/// <param name="edited"></param>
[SupportedOSPlatform("macos")]
public void SetDocumentEdited(bool edited)
{
BridgeConnector.Emit("browserWindowSetDocumentEdited", Id, edited);
@@ -1615,6 +1681,7 @@ namespace ElectronNET.API
/// Whether the windows document has been edited.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("macos")]
public Task<bool> IsDocumentEditedAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsDocumentEdited", "browserWindow-isDocumentEdited-completed" + Id, Id);
@@ -1679,6 +1746,8 @@ namespace ElectronNET.API
/// setting it to null will remove the menu bar.
/// </summary>
/// <param name="menuItems"></param>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
public void SetMenu(MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
@@ -1696,6 +1765,8 @@ namespace ElectronNET.API
/// <summary>
/// Remove the window's menu bar.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
public void RemoveMenu()
{
BridgeConnector.Emit("browserWindowRemoveMenu", Id);
@@ -1729,6 +1800,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="progress"></param>
/// <param name="progressBarOptions"></param>
[SupportedOSPlatform("windows")]
public void SetProgressBar(double progress, ProgressBarOptions progressBarOptions)
{
BridgeConnector.Emit("browserWindowSetProgressBar", Id, progress, progressBarOptions);
@@ -1776,6 +1848,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="thumbarButtons"></param>
/// <returns>Whether the buttons were added successfully.</returns>
[SupportedOSPlatform("windows")]
public Task<bool> SetThumbarButtonsAsync(ThumbarButton[] thumbarButtons)
{
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
@@ -1808,6 +1881,7 @@ namespace ElectronNET.API
/// an empty region: {x: 0, y: 0, width: 0, height: 0}.
/// </summary>
/// <param name="rectangle"></param>
[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.
/// </summary>
/// <param name="tooltip"></param>
[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.
/// </summary>
/// <param name="options"></param>
[SupportedOSPlatform("windows")]
public void SetAppDetails(AppDetailsOptions options)
{
BridgeConnector.Emit("browserWindowSetAppDetails", Id, options);
@@ -1837,6 +1913,7 @@ namespace ElectronNET.API
/// <summary>
/// Same as webContents.showDefinitionForSelection().
/// </summary>
[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.
/// </summary>
/// <param name="visible"></param>
[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.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
public Task<bool> IsMenuBarVisibleAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarVisible", "browserWindow-isMenuBarVisible-completed" + Id, Id);
@@ -1923,6 +2004,8 @@ namespace ElectronNET.API
/// On Windows it calls SetWindowDisplayAffinity with WDA_MONITOR.
/// </summary>
/// <param name="enable"></param>
[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.
/// </summary>
/// <param name="focusable"></param>
[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.
/// </summary>
/// <param name="autoHide"></param>
[SupportedOSPlatform("macos")]
public void SetAutoHideCursor(bool autoHide)
{
BridgeConnector.Emit("browserWindowSetAutoHideCursor", Id, autoHide);
@@ -1983,6 +2069,7 @@ namespace ElectronNET.API
/// <param name="type">Can be appearance-based, light, dark, titlebar, selection,
/// menu, popover, sidebar, medium-light or ultra-dark.
/// See the macOS documentation for more details.</param>
[SupportedOSPlatform("macos")]
public void SetVibrancy(Vibrancy type)
{
BridgeConnector.Emit("browserWindowSetVibrancy", Id, type.GetDescription());

View File

@@ -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.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<ReadBookmark> ReadBookmarkAsync() => BridgeConnector.OnResult<ReadBookmark>("clipboard-readBookmark", "clipboard-readBookmark-Completed");
/// <summary>
@@ -105,6 +108,8 @@ namespace ElectronNET.API
/// <param name="title"></param>
/// <param name="url"></param>
/// <param name="type"></param>
[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.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("macos")]
public Task<string> ReadFindTextAsync() => BridgeConnector.OnResult<string>("clipboard-readFindText", "clipboard-readFindText-Completed");
/// <summary>
@@ -123,6 +129,7 @@ namespace ElectronNET.API
/// synchronous IPC when called from the renderer process.
/// </summary>
/// <param name="text"></param>
[SupportedOSPlatform("macos")]
public void WriteFindText(string text)
{
BridgeConnector.Emit("clipboard-writeFindText", text);

View File

@@ -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
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task ShowCertificateTrustDialogAsync(CertificateTrustDialogOptions options)
{
return ShowCertificateTrustDialogAsync(null, options);
@@ -204,6 +207,8 @@ namespace ElectronNET.API
/// <param name="browserWindow"></param>
/// <param name="options"></param>
/// <returns></returns>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options)
{
var taskCompletionSource = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);

View File

@@ -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
/// <summary>
/// Control your app in the macOS dock.
/// </summary>
[SupportedOSPlatform("macos")]
public sealed class Dock
{
private static Dock _dock;

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using System.Runtime.Versioning;
namespace ElectronNET.API
{
@@ -102,6 +103,7 @@ namespace ElectronNET.API
/// <summary>
/// Control your app in the macOS dock.
/// </summary>
[SupportedOSPlatform("macos")]
public static Dock Dock { get { return Dock.Instance; } }
}
}

View File

@@ -3,6 +3,7 @@
/// <summary>
///
/// </summary>
[SupportedOSPlatform("macos")]
public class NotificationAction
{
/// <summary>

View File

@@ -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
/// <summary>
/// A subtitle for the notification, which will be displayed below the title.
/// </summary>
[SupportedOSPlatform("macos")]
public string SubTitle { get; set; }
/// <summary>
@@ -38,38 +41,46 @@ namespace ElectronNET.API.Entities
/// <summary>
/// Whether or not to add an inline reply option to the notification.
/// </summary>
[SupportedOSPlatform("macos")]
public bool HasReply { get; set; }
/// <summary>
/// The timeout duration of the notification. Can be 'default' or 'never'.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
public string TimeoutType { get; set; }
/// <summary>
/// The placeholder to write in the inline reply input field.
/// </summary>
[SupportedOSPlatform("macos")]
public string ReplyPlaceholder { get; set; }
/// <summary>
/// The name of the sound file to play when the notification is shown.
/// </summary>
[SupportedOSPlatform("macos")]
public string Sound { get; set; }
/// <summary>
/// The urgency level of the notification. Can be 'normal', 'critical', or 'low'.
/// </summary>
[SupportedOSPlatform("linux")]
public string Urgency { get; set; }
/// <summary>
/// Actions to add to the notification. Please read the available actions and
/// limitations in the NotificationAction documentation.
/// </summary>
[SupportedOSPlatform("macos")]
public NotificationAction Actions { get; set; }
/// <summary>
/// A custom title for the close button of an alert. An empty string will cause the
/// default localized text to be used.
/// </summary>
[SupportedOSPlatform("macos")]
public string CloseButtonText { get; set; }
/// <summary>
@@ -127,6 +138,7 @@ namespace ElectronNET.API.Entities
/// The string the user entered into the inline reply field
/// </summary>
[JsonIgnore]
[SupportedOSPlatform("macos")]
public Action<string> OnReply { get; set; }
/// <summary>
@@ -142,6 +154,7 @@ namespace ElectronNET.API.Entities
/// macOS only - The index of the action that was activated
/// </summary>
[JsonIgnore]
[SupportedOSPlatform("macos")]
public Action<string> OnAction { get; set; }
/// <summary>

View File

@@ -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
/// <summary>
/// Message to display above input boxes.
/// </summary>
[SupportedOSPlatform("macos")]
public string Message { get; set; }
/// <summary>

View File

@@ -1,4 +1,6 @@
namespace ElectronNET.API.Entities
using System.Runtime.Versioning;
namespace ElectronNET.API.Entities
{
/// <summary>
///
@@ -28,21 +30,66 @@
/// <summary>
/// The create directory
/// </summary>
[SupportedOSPlatform("macos")]
createDirectory,
/// <summary>
/// The prompt to create
/// </summary>
[SupportedOSPlatform("windows")]
promptToCreate,
/// <summary>
/// The no resolve aliases
/// </summary>
[SupportedOSPlatform("macos")]
noResolveAliases,
/// <summary>
/// The treat package as directory
/// Treat packages, such as .app folders, as a directory instead of a file.
/// </summary>
treatPackageAsDirectory
[SupportedOSPlatform("macos")]
treatPackageAsDirectory,
/// <summary>
/// Don't add the item being opened to recent documents list
/// </summary>
[SupportedOSPlatform("windows")]
dontAddToRecent
}
/// <summary>
///
/// </summary>
public enum SaveDialogProperty
{
/// <summary>
/// The show hidden files
/// </summary>
showHiddenFiles,
/// <summary>
/// The create directory
/// </summary>
[SupportedOSPlatform("macos")]
createDirectory,
/// <summary>
/// Treat packages, such as .app folders, as a directory instead of a file.
/// </summary>
[SupportedOSPlatform("macos")]
treatPackageAsDirectory,
/// <summary>
/// Sets whether the user will be presented a confirmation dialog if the user types a file name that already exists.
/// </summary>
[SupportedOSPlatform("linux")]
showOverwriteConfirmation,
/// <summary>
/// Don't add the item being opened to recent documents list
/// </summary>
[SupportedOSPlatform("windows")]
dontAddToRecent
}
}

View File

@@ -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
/// <see langword="true"/> to bring the opened application to the foreground. The default is <see langword="true"/>.
/// </summary>
[DefaultValue(true)]
[SupportedOSPlatform("macos")]
public bool Activate { get; set; } = true;
/// <summary>
/// The working directory.
/// </summary>
[SupportedOSPlatform("windows")]
public string WorkingDirectory { get; set; }
}
}

View File

@@ -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
/// <summary>
/// Message to display above text fields.
/// </summary>
[SupportedOSPlatform("macos")]
public string Message { get; set; }
/// <summary>
/// Custom label for the text displayed in front of the filename text field.
/// </summary>
[SupportedOSPlatform("macos")]
public string NameFieldLabel { get; set; }
/// <summary>
/// Show the tags input box, defaults to true.
/// </summary>
[SupportedOSPlatform("macos")]
public bool ShowsTagField { get; set; }
/// <summary>
/// Contains which features the dialog should use. The following values are supported:
/// 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'
/// </summary>
[JsonProperty("properties", ItemConverterType = typeof(StringEnumConverter))]
public SaveDialogProperty[] Properties { get; set; }
}
}

View File

@@ -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 <see cref="bool"/> for if the OS / Chromium currently has high-contrast mode enabled or is
/// being instructed to show a high-contrast UI.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<bool> ShouldUseHighContrastColorsAsync() => BridgeConnector.OnResult<bool>("nativeTheme-shouldUseHighContrastColors", "nativeTheme-shouldUseHighContrastColors-completed");
/// <summary>
/// A <see cref="bool"/> for if the OS / Chromium currently has an inverted color scheme or is
/// being instructed to use an inverted color scheme.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public Task<bool> ShouldUseInvertedColorSchemeAsync() => BridgeConnector.OnResult<bool>("nativeTheme-shouldUseInvertedColorScheme", "nativeTheme-shouldUseInvertedColorScheme-completed");
/// <summary>

View File

@@ -1,4 +1,5 @@
using System;
using System.Runtime.Versioning;
using System.Threading.Tasks;
namespace ElectronNET.API
@@ -11,6 +12,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the system is about to lock the screen.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public event Action OnLockScreen
{
add
@@ -40,6 +43,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the system is about to unlock the screen.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public event Action OnUnLockScreen
{
add
@@ -69,6 +74,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the system is suspending.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public event Action OnSuspend
{
add
@@ -98,6 +105,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when system is resuming.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public event Action OnResume
{
add
@@ -127,6 +136,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the system changes to AC power.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public event Action OnAC
{
add
@@ -156,6 +167,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when system changes to battery power.
/// </summary>
[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()`.
/// </summary>
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
public event Action OnShutdown
{
add

View File

@@ -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
/// <param name="url">Max 2081 characters on windows.</param>
/// <param name="options">Controls the behavior of OpenExternal.</param>
/// <returns>The error message corresponding to the failure if a failure occurred, otherwise <see cref="string.Empty"/>.</returns>
public Task<string> OpenExternalAsync(string url, OpenExternalOptions options)
{
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
@@ -141,6 +143,7 @@ namespace ElectronNET.API
/// <param name="operation">Default is <see cref="ShortcutLinkOperation.Create"/></param>
/// <param name="options">Structure of a shortcut.</param>
/// <returns>Whether the shortcut was created successfully.</returns>
[SupportedOSPlatform("windows")]
public Task<bool> WriteShortcutLinkAsync(string shortcutPath, ShortcutLinkOperation operation, ShortcutDetails options)
{
return BridgeConnector.OnResult<bool>("shell-writeShortcutLink", "shell-writeShortcutLinkCompleted", shortcutPath, operation.GetDescription(), options);
@@ -152,6 +155,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="shortcutPath">The path tot the shortcut.</param>
/// <returns><see cref="ShortcutDetails"/> of the shortcut.</returns>
[SupportedOSPlatform("windows")]
public Task<ShortcutDetails> ReadShortcutLinkAsync(string shortcutPath)
{
return BridgeConnector.OnResult<ShortcutDetails>("shell-readShortcutLink", "shell-readShortcutLinkCompleted", shortcutPath);

View File

@@ -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
/// <summary>
/// Add icons and context menus to the system's notification area.
/// </summary>
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public sealed class Tray
{
/// <summary>
@@ -46,6 +50,8 @@ namespace ElectronNET.API
/// <summary>
/// macOS, Windows: Emitted when the tray icon is right clicked.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public event Action<TrayClickEventArgs, Rectangle> OnRightClick
{
add
@@ -75,6 +81,8 @@ namespace ElectronNET.API
/// <summary>
/// macOS, Windows: Emitted when the tray icon is double clicked.
/// </summary>
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public event Action<TrayClickEventArgs, Rectangle> OnDoubleClick
{
add
@@ -104,6 +112,7 @@ namespace ElectronNET.API
/// <summary>
/// Windows: Emitted when the tray balloon shows.
/// </summary>
[SupportedOSPlatform("windows")]
public event Action OnBalloonShow
{
add
@@ -133,6 +142,7 @@ namespace ElectronNET.API
/// <summary>
/// Windows: Emitted when the tray balloon is clicked.
/// </summary>
[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.
/// </summary>
[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.
/// </summary>
/// <param name="image"></param>
[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.
/// </summary>
/// <param name="title"></param>
[SupportedOSPlatform("macos")]
public void SetTitle(string title)
{
BridgeConnector.Emit("tray-setTitle", title);
@@ -312,6 +326,7 @@ namespace ElectronNET.API
/// Windows: Displays a tray balloon.
/// </summary>
/// <param name="options"></param>
[SupportedOSPlatform("windows")]
public void DisplayBalloon(DisplayBalloonOptions options)
{
BridgeConnector.Emit("tray-displayBalloon", options);