ElectronNET API: Add platform support attributes

This commit is contained in:
softworkz
2025-11-14 09:44:01 +01:00
parent 8e8d88c48f
commit 0580942a59
11 changed files with 167 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
@@ -259,6 +260,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 => AddEvent(value, GetHashCode());
@@ -316,6 +319,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 => AddEvent(value, GetHashCode());
@@ -327,6 +331,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 => AddEvent(value, GetHashCode());
@@ -481,6 +486,7 @@ namespace ElectronNET.API
/// <summary>
/// Hides all application windows without minimizing them.
/// </summary>
[SupportedOSPlatform("macOS")]
public void Hide()
{
this.CallMethod0();
@@ -489,6 +495,7 @@ namespace ElectronNET.API
/// <summary>
/// Shows application windows after they were hidden. Does not automatically focus them.
/// </summary>
[SupportedOSPlatform("macOS")]
public void Show()
{
this.CallMethod0();
@@ -586,6 +593,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)
{
this.CallMethod1(path);
@@ -594,6 +603,8 @@ namespace ElectronNET.API
/// <summary>
/// Clears the recent documents list.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void ClearRecentDocuments()
{
this.CallMethod0();
@@ -709,6 +720,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 this.RemoveAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken).ConfigureAwait(false);
@@ -722,6 +735,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 this.RemoveAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken).ConfigureAwait(false);
@@ -736,6 +751,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 async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -826,6 +843,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 async Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -846,6 +864,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Jump List settings.</returns>
[SupportedOSPlatform("Windows")]
public async Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -868,6 +887,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)
{
this.CallMethod1(categories);
@@ -950,6 +970,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);
@@ -967,6 +988,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)
{
this.CallMethod3(type, userInfo, webpageUrl);
@@ -976,6 +998,7 @@ namespace ElectronNET.API
/// The type of the currently running activity.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("macOS")]
public async Task<string> GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -985,6 +1008,7 @@ namespace ElectronNET.API
/// <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()
{
this.CallMethod0();
@@ -993,6 +1017,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()
{
this.CallMethod0();
@@ -1002,6 +1027,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)
{
this.CallMethod1(id);
@@ -1016,6 +1042,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 async Task<int> ImportCertificateAsync(ImportCertificateOptions options, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1067,6 +1094,8 @@ 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 async Task<bool> SetBadgeCountAsync(int count, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1086,6 +1115,8 @@ namespace ElectronNET.API
/// The current value displayed in the counter badge.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("macOS")]
public async Task<int> GetBadgeCountAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1101,6 +1132,7 @@ namespace ElectronNET.API
/// Whether the current desktop environment is Unity launcher.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("Linux")]
public async Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1111,6 +1143,8 @@ namespace ElectronNET.API
/// 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("macOS")]
[SupportedOSPlatform("Windows")]
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(CancellationToken cancellationToken = default)
{
return await this.GetLoginItemSettingsAsync(null, cancellationToken).ConfigureAwait(false);
@@ -1122,6 +1156,8 @@ namespace ElectronNET.API
/// </summary>
/// <param name="options"></param>
/// <param name="cancellationToken">The cancellation token.</param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1151,6 +1187,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("macOS")]
[SupportedOSPlatform("Windows")]
public void SetLoginItemSettings(LoginSettings loginSettings)
{
this.CallMethod1(loginSettings);
@@ -1162,6 +1200,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("macOS")]
[SupportedOSPlatform("Windows")]
public async Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1178,6 +1218,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("macOS")]
[SupportedOSPlatform("Windows")]
public void SetAccessibilitySupportEnabled(bool enabled)
{
this.CallMethod1(enabled);

View File

@@ -1,10 +1,11 @@
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
// ReSharper disable InconsistentNaming
@@ -68,6 +69,7 @@ public class BrowserWindow : ApiBase
/// <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 => AddEvent(value, Id);
@@ -187,6 +189,8 @@ public class BrowserWindow : ApiBase
/// <summary>
/// macOS: Emitted once when the window is moved to a new position.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public event Action OnMoved
{
add => AddEvent(value, Id);
@@ -238,6 +242,8 @@ public class BrowserWindow : ApiBase
/// and the APPCOMMAND_ prefix is stripped off.e.g.APPCOMMAND_BROWSER_BACKWARD
/// is emitted as browser-backward.
/// </summary>
[SupportedOSPlatform("Windows")]
[SupportedOSPlatform("Linux")]
public event Action<string> OnAppCommand
{
add => AddEvent(value, Id);
@@ -247,6 +253,7 @@ public class BrowserWindow : ApiBase
/// <summary>
/// Emitted on 3-finger swipe. Possible directions are up, right, down, left.
/// </summary>
[SupportedOSPlatform("macOS")]
public event Action<string> OnSwipe
{
add => AddEvent(value, Id);
@@ -256,6 +263,7 @@ public class BrowserWindow : ApiBase
/// <summary>
/// Emitted when the window opens a sheet.
/// </summary>
[SupportedOSPlatform("macOS")]
public event Action OnSheetBegin
{
add => AddEvent(value, Id);
@@ -265,6 +273,7 @@ public class BrowserWindow : ApiBase
/// <summary>
/// Emitted when the window has closed a sheet.
/// </summary>
[SupportedOSPlatform("macOS")]
public event Action OnSheetEnd
{
add => AddEvent(value, Id);
@@ -274,6 +283,7 @@ public class BrowserWindow : ApiBase
/// <summary>
/// Emitted when the native new tab button is clicked.
/// </summary>
[SupportedOSPlatform("macOS")]
public event Action OnNewWindowForTab
{
add => AddEvent(value, Id);
@@ -432,6 +442,7 @@ public class BrowserWindow : ApiBase
/// <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) => this.CallMethod1(path);
/// <summary>
@@ -442,11 +453,13 @@ public class BrowserWindow : ApiBase
/// 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) => this.CallMethod2(path, displayname);
/// <summary>
/// Closes the currently open Quick Look panel.
/// </summary>
[SupportedOSPlatform("macOS")]
public void CloseFilePreview() => this.CallMethod0();
/// <summary>
@@ -571,6 +584,8 @@ public class BrowserWindow : ApiBase
/// Sets whether the window can be moved by user. On Linux does nothing.
/// </summary>
/// <param name="movable"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void SetMovable(bool movable) => this.CallMethod1(movable);
/// <summary>
@@ -579,12 +594,16 @@ public class BrowserWindow : ApiBase
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public Task<bool> IsMovableAsync() => this.InvokeAsync<bool>();
/// <summary>
/// Sets whether the window can be manually minimized by user. On Linux does nothing.
/// </summary>
/// <param name="minimizable"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void SetMinimizable(bool minimizable) => this.CallMethod1(minimizable);
/// <summary>
@@ -593,12 +612,16 @@ public class BrowserWindow : ApiBase
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public Task<bool> IsMinimizableAsync() => this.InvokeAsync<bool>();
/// <summary>
/// Sets whether the window can be manually maximized by user. On Linux does nothing.
/// </summary>
/// <param name="maximizable"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void SetMaximizable(bool maximizable) => this.CallMethod1(maximizable);
/// <summary>
@@ -607,6 +630,8 @@ public class BrowserWindow : ApiBase
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public Task<bool> IsMaximizableAsync() => this.InvokeAsync<bool>();
/// <summary>
@@ -625,6 +650,8 @@ public class BrowserWindow : ApiBase
/// Sets whether the window can be manually closed by user. On Linux does nothing.
/// </summary>
/// <param name="closable"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void SetClosable(bool closable) => this.CallMethod1(closable);
/// <summary>
@@ -633,6 +660,8 @@ public class BrowserWindow : ApiBase
/// On Linux always returns true.
/// </summary>
/// <returns>On Linux always returns true.</returns>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public Task<bool> IsClosableAsync() => this.InvokeAsync<bool>();
/// <summary>
@@ -743,6 +772,7 @@ public class BrowserWindow : ApiBase
/// but you may want to display them beneath a HTML-rendered toolbar.
/// </summary>
/// <param name="offsetY"></param>
[SupportedOSPlatform("macOS")]
public void SetSheetOffset(float offsetY) => this.CallMethod1(offsetY);
/// <summary>
@@ -752,6 +782,7 @@ public class BrowserWindow : ApiBase
/// </summary>
/// <param name="offsetY"></param>
/// <param name="offsetX"></param>
[SupportedOSPlatform("macOS")]
public void SetSheetOffset(float offsetY, float offsetX) => this.CallMethod2(offsetY, offsetX);
/// <summary>
@@ -764,6 +795,8 @@ public class BrowserWindow : ApiBase
/// Makes the window not show in the taskbar.
/// </summary>
/// <param name="skip"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void SetSkipTaskbar(bool skip) => this.CallMethod1(skip);
/// <summary>
@@ -789,12 +822,14 @@ public class BrowserWindow : ApiBase
/// and the icon of the file will show in windows title bar.
/// </summary>
/// <param name="filename"></param>
[SupportedOSPlatform("macOS")]
public void SetRepresentedFilename(string filename) => this.CallMethod1(filename);
/// <summary>
/// The pathname of the file the window represents.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("macOS")]
public Task<string> GetRepresentedFilenameAsync() => this.InvokeAsync<string>();
/// <summary>
@@ -802,12 +837,14 @@ public class BrowserWindow : ApiBase
/// 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) => this.CallMethod1(edited);
/// <summary>
/// Whether the windows document has been edited.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("macOS")]
public Task<bool> IsDocumentEditedAsync() => this.InvokeAsync<bool>();
/// <summary>
@@ -861,6 +898,8 @@ public class BrowserWindow : ApiBase
/// setting it to null will remove the menu bar.
/// </summary>
/// <param name="menuItems"></param>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public void SetMenu(MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
@@ -878,6 +917,8 @@ public class BrowserWindow : ApiBase
/// <summary>
/// Remove the window's menu bar.
/// </summary>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public void RemoveMenu() => this.CallMethod0();
/// <summary>
@@ -950,6 +991,7 @@ public class BrowserWindow : ApiBase
/// </summary>
/// <param name="thumbarButtons"></param>
/// <returns>Whether the buttons were added successfully.</returns>
[SupportedOSPlatform("Windows")]
public Task<bool> SetThumbarButtonsAsync(ThumbarButton[] thumbarButtons)
{
var tcs = new TaskCompletionSource<bool>();
@@ -977,12 +1019,14 @@ public class BrowserWindow : ApiBase
/// an empty region: {x: 0, y: 0, width: 0, height: 0}.
/// </summary>
/// <param name="rectangle"></param>
[SupportedOSPlatform("Windows")]
public void SetThumbnailClip(Rectangle rectangle) => this.CallMethod1(rectangle);
/// <summary>
/// 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) => this.CallMethod1(tooltip);
/// <summary>
@@ -992,11 +1036,13 @@ public class BrowserWindow : ApiBase
/// 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) => this.CallMethod1(options);
/// <summary>
/// Same as webContents.showDefinitionForSelection().
/// </summary>
[SupportedOSPlatform("macOS")]
public void ShowDefinitionForSelection() => this.CallMethod0();
/// <summary>
@@ -1006,12 +1052,16 @@ public class BrowserWindow : ApiBase
/// If the menu bar is already visible, calling setAutoHideMenuBar(true) wont hide it immediately.
/// </summary>
/// <param name="hide"></param>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public void SetAutoHideMenuBar(bool hide) => this.CallMethod1(hide);
/// <summary>
/// Whether menu bar automatically hides itself.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public Task<bool> IsMenuBarAutoHideAsync() => this.InvokeAsync<bool>();
/// <summary>
@@ -1019,12 +1069,16 @@ public class BrowserWindow : ApiBase
/// users can still bring up the menu bar by pressing the single Alt key.
/// </summary>
/// <param name="visible"></param>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public void SetMenuBarVisibility(bool visible) => this.CallMethod1(visible);
/// <summary>
/// Whether the menu bar is visible.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public Task<bool> IsMenuBarVisibleAsync() => this.InvokeAsync<bool>();
/// <summary>
@@ -1033,6 +1087,8 @@ public class BrowserWindow : ApiBase
/// Note: This API does nothing on Windows.
/// </summary>
/// <param name="visible"></param>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("macOS")]
public void SetVisibleOnAllWorkspaces(bool visible) => this.CallMethod1(visible);
/// <summary>
@@ -1041,6 +1097,8 @@ public class BrowserWindow : ApiBase
/// Note: This API always returns false on Windows.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("macOS")]
public Task<bool> IsVisibleOnAllWorkspacesAsync() => this.InvokeAsync<bool>();
/// <summary>
@@ -1059,12 +1117,16 @@ public class BrowserWindow : ApiBase
/// On Windows it calls SetWindowDisplayAffinity with WDA_MONITOR.
/// </summary>
/// <param name="enable"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void SetContentProtection(bool enable) => this.CallMethod1(enable);
/// <summary>
/// Changes whether the window can be focused.
/// </summary>
/// <param name="focusable"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void SetFocusable(bool focusable) => this.CallMethod1(focusable);
/// <summary>
@@ -1117,6 +1179,7 @@ public class BrowserWindow : ApiBase
/// Controls whether to hide cursor when typing.
/// </summary>
/// <param name="autoHide"></param>
[SupportedOSPlatform("macOS")]
public void SetAutoHideCursor(bool autoHide) => this.CallMethod1(autoHide);
/// <summary>
@@ -1126,6 +1189,7 @@ public class BrowserWindow : ApiBase
/// <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) => this.CallMethod1(type.GetDescription());
/// <summary>
@@ -1144,4 +1208,4 @@ public class BrowserWindow : ApiBase
// This message name does not match the default ApiBase naming convention.
BridgeConnector.Socket.Emit("browserWindow-setBrowserView", Id, browserView.Id);
}
}
}

View File

@@ -1,5 +1,6 @@
using ElectronNET.API.Entities;
using ElectronNET.API.Serialization;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading.Tasks;
@@ -98,6 +99,8 @@ namespace ElectronNET.API
/// be empty strings when the bookmark is unavailable.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public Task<ReadBookmark> ReadBookmarkAsync() => this.InvokeAsync<ReadBookmark>();
/// <summary>
@@ -110,6 +113,8 @@ namespace ElectronNET.API
/// <param name="title"></param>
/// <param name="url"></param>
/// <param name="type"></param>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public void WriteBookmark(string title, string url, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeBookmark", title, url, type);
@@ -121,6 +126,7 @@ namespace ElectronNET.API
/// find pasteboard whenever the application is activated.
/// </summary>
/// <returns></returns>
[SupportedOSPlatform("macOS")]
public Task<string> ReadFindTextAsync() => this.InvokeAsync<string>();
/// <summary>
@@ -128,6 +134,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.Socket.Emit("clipboard-writeFindText", text);

View File

@@ -1,5 +1,6 @@
using ElectronNET.API.Entities;
using System;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading.Tasks;
@@ -186,6 +187,8 @@ namespace ElectronNET.API
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public Task ShowCertificateTrustDialogAsync(CertificateTrustDialogOptions options)
{
return ShowCertificateTrustDialogAsync(null, options);
@@ -199,6 +202,8 @@ namespace ElectronNET.API
/// <param name="browserWindow"></param>
/// <param name="options"></param>
/// <returns></returns>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options)
{
var tcs = new TaskCompletionSource<object>();

View File

@@ -1,16 +1,16 @@
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
using ElectronNET.API.Serialization;
using System.Collections.Generic;
using System.Text.Json;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
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 System;
using System.Runtime.Versioning;
using System.Text.Json.Serialization;
namespace ElectronNET.API.Entities
@@ -43,6 +44,8 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The timeout duration of the notification. Can be 'default' or 'never'.
/// </summary>
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("Windows")]
public string TimeoutType { get; set; }
/// <summary>
@@ -58,6 +61,7 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The urgency level of the notification. Can be 'normal', 'critical', or 'low'.
/// </summary>
[SupportedOSPlatform("Linux")]
public string Urgency { get; set; }
/// <summary>
@@ -127,6 +131,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 +147,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>
@@ -164,4 +170,4 @@ namespace ElectronNET.API.Entities
Body = body;
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
@@ -120,12 +121,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("macOS")]
[SupportedOSPlatform("Windows")]
public Task<bool> ShouldUseHighContrastColorsAsync() => this.InvokeAsync<bool>();
/// <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("macOS")]
[SupportedOSPlatform("Windows")]
public Task<bool> ShouldUseInvertedColorSchemeAsync() => this.InvokeAsync<bool>();
/// <summary>
@@ -138,4 +143,4 @@ namespace ElectronNET.API
remove => RemoveEvent(value, GetHashCode());
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Runtime.Versioning;
// ReSharper disable InconsistentNaming
@@ -15,6 +16,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the system is about to lock the screen.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public event Action OnLockScreen
{
add => AddEvent(value);
@@ -24,6 +27,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the system is about to unlock the screen.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public event Action OnUnLockScreen
{
add => AddEvent(value);
@@ -51,6 +56,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when the system changes to AC power.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public event Action OnAC
{
add => AddEvent(value);
@@ -60,6 +67,8 @@ namespace ElectronNET.API
/// <summary>
/// Emitted when system changes to battery power.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public event Action OnBattery
{
add => AddEvent(value);
@@ -72,6 +81,8 @@ 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 => AddEvent(value);
@@ -104,4 +115,4 @@ namespace ElectronNET.API
}
}
}
}
}

View File

@@ -1,6 +1,7 @@
using ElectronNET.API.Entities;
using System;
using System.Linq;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading.Tasks;
using ElectronNET.API.Serialization;
@@ -108,6 +109,7 @@ namespace ElectronNET.API
/// macOS: The height of the menu bar in pixels.
/// </summary>
/// <returns>The height of the menu bar in pixels.</returns>
[SupportedOSPlatform("macOS")]
public Task<Rectangle> GetMenuBarWorkAreaAsync() => this.InvokeAsync<Rectangle>();
/// <summary>

View File

@@ -1,8 +1,7 @@
using System.Runtime.Versioning;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
using ElectronNET.API.Serialization;
using System.Text.Json;
using System.Threading.Tasks;
namespace ElectronNET.API
{
@@ -133,6 +132,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)
{
var tcs = new TaskCompletionSource<bool>();
@@ -149,6 +149,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)
{
var tcs = new TaskCompletionSource<ShortcutDetails>();

View File

@@ -3,6 +3,7 @@ using ElectronNET.API.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading.Tasks;
using ElectronNET.API.Serialization;
@@ -57,6 +58,8 @@ namespace ElectronNET.API
/// <summary>
/// macOS, Windows: Emitted when the tray icon is right clicked.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public event Action<TrayClickEventArgs, Rectangle> OnRightClick
{
add
@@ -92,6 +95,8 @@ namespace ElectronNET.API
/// <summary>
/// macOS, Windows: Emitted when the tray icon is double clicked.
/// </summary>
[SupportedOSPlatform("macOS")]
[SupportedOSPlatform("Windows")]
public event Action<TrayClickEventArgs, Rectangle> OnDoubleClick
{
add
@@ -127,6 +132,7 @@ namespace ElectronNET.API
/// <summary>
/// Windows: Emitted when the tray balloon shows.
/// </summary>
[SupportedOSPlatform("Windows")]
public event Action OnBalloonShow
{
add => AddEvent(value, GetHashCode());
@@ -136,6 +142,7 @@ namespace ElectronNET.API
/// <summary>
/// Windows: Emitted when the tray balloon is clicked.
/// </summary>
[SupportedOSPlatform("Windows")]
public event Action OnBalloonClick
{
add => AddEvent(value, GetHashCode());
@@ -146,6 +153,7 @@ 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 => AddEvent(value, GetHashCode());
@@ -251,6 +259,7 @@ namespace ElectronNET.API
/// Sets the image associated with this tray icon when pressed on macOS.
/// </summary>
/// <param name="image"></param>
[SupportedOSPlatform("macOS")]
public async Task SetPressedImage(string image)
{
await BridgeConnector.Socket.Emit("tray-setPressedImage", image).ConfigureAwait(false);
@@ -269,6 +278,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 async Task SetTitle(string title)
{
await BridgeConnector.Socket.Emit("tray-setTitle", title).ConfigureAwait(false);
@@ -278,6 +288,7 @@ namespace ElectronNET.API
/// Windows: Displays a tray balloon.
/// </summary>
/// <param name="options"></param>
[SupportedOSPlatform("Windows")]
public async Task DisplayBalloon(DisplayBalloonOptions options)
{
await BridgeConnector.Socket.Emit("tray-displayBalloon", options).ConfigureAwait(false);