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

@@ -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);