Merge branch 'develop'

This commit is contained in:
Florian Rappl
2025-10-31 17:52:49 +01:00
350 changed files with 22446 additions and 5830 deletions

View File

@@ -70,7 +70,7 @@ namespace ElectronNET.API
{
BridgeConnector.Socket.On("app-before-quit" + GetHashCode(), async () =>
{
await _beforeQuit(new QuitEventArgs());
await this._beforeQuit(new QuitEventArgs()).ConfigureAwait(false);
if (_preventQuit)
{
@@ -84,7 +84,7 @@ namespace ElectronNET.API
}
else if (_willQuit != null)
{
await _willQuit(new QuitEventArgs());
await this._willQuit(new QuitEventArgs()).ConfigureAwait(false);
if (_preventQuit)
{
@@ -98,14 +98,14 @@ namespace ElectronNET.API
}
else
{
await _quitting();
await this._quitting().ConfigureAwait(false);
Exit();
}
}
}
else if (_quitting != null)
{
await _quitting();
await this._quitting().ConfigureAwait(false);
Exit();
}
}
@@ -142,7 +142,7 @@ namespace ElectronNET.API
{
BridgeConnector.Socket.On("app-will-quit" + GetHashCode(), async () =>
{
await _willQuit(new QuitEventArgs());
await this._willQuit(new QuitEventArgs()).ConfigureAwait(false);
if (_preventQuit)
{
@@ -156,7 +156,7 @@ namespace ElectronNET.API
}
else
{
await _quitting();
await this._quitting().ConfigureAwait(false);
Exit();
}
}
@@ -192,7 +192,7 @@ namespace ElectronNET.API
{
if(_willQuit == null)
{
await _quitting();
await this._quitting().ConfigureAwait(false);
Exit();
}
});
@@ -567,6 +567,11 @@ namespace ElectronNET.API
BridgeConnector.Socket.Emit("appExit", exitCode);
}
public void DisposeSocket()
{
BridgeConnector.Socket.DisposeSocket();
}
/// <summary>
/// Relaunches the app when current instance exits. By default the new instance will use the same working directory
/// and command line arguments with current instance.
@@ -816,7 +821,7 @@ namespace ElectronNET.API
/// <returns>Whether the call succeeded.</returns>
public async Task<bool> SetAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
{
return await SetAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken);
return await this.SetAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -847,7 +852,7 @@ namespace ElectronNET.API
/// <returns>Whether the call succeeded.</returns>
public async Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
{
return await SetAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken);
return await this.SetAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -906,7 +911,7 @@ namespace ElectronNET.API
/// <returns>Whether the call succeeded.</returns>
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
{
return await RemoveAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken);
return await this.RemoveAsDefaultProtocolClientAsync(protocol, null, null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -919,7 +924,7 @@ namespace ElectronNET.API
/// <returns>Whether the call succeeded.</returns>
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
{
return await RemoveAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken);
return await this.RemoveAsDefaultProtocolClientAsync(protocol, path, null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -966,7 +971,7 @@ namespace ElectronNET.API
/// <returns>Whether the current executable is the default handler for a protocol (aka URI scheme).</returns>
public async Task<bool> IsDefaultProtocolClientAsync(string protocol, CancellationToken cancellationToken = default)
{
return await IsDefaultProtocolClientAsync(protocol, null, null, cancellationToken);
return await this.IsDefaultProtocolClientAsync(protocol, null, null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -985,7 +990,7 @@ namespace ElectronNET.API
/// <returns>Whether the current executable is the default handler for a protocol (aka URI scheme).</returns>
public async Task<bool> IsDefaultProtocolClientAsync(string protocol, string path, CancellationToken cancellationToken = default)
{
return await IsDefaultProtocolClientAsync(protocol, path, null, cancellationToken);
return await this.IsDefaultProtocolClientAsync(protocol, path, null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -1437,7 +1442,7 @@ namespace ElectronNET.API
/// </summary>
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(CancellationToken cancellationToken = default)
{
return await GetLoginItemSettingsAsync(null, cancellationToken);
return await this.GetLoginItemSettingsAsync(null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -1624,7 +1629,7 @@ namespace ElectronNET.API
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public async Task On(string eventName, Action<object> action)
=> await Events.Instance.On(ModuleName, eventName, action);
=> await Events.Instance.On(ModuleName, eventName, action).ConfigureAwait(false);
/// <summary>
/// Subscribe to an unmapped event on the <see cref="App"/> module once.
/// </summary>
@@ -1638,6 +1643,6 @@ namespace ElectronNET.API
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public async Task Once(string eventName, Action<object> action)
=> await Events.Instance.Once(ModuleName, eventName, action);
=> await Events.Instance.Once(ModuleName, eventName, action).ConfigureAwait(false);
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace ElectronNET.API
{
/// <summary>
/// Query and modify a session's cookies.
/// </summary>
public class Cookies
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; private set; }
internal Cookies(int id)
{
Id = id;
}
/// <summary>
/// Emitted when a cookie is changed because it was added, edited, removed, or expired.
/// </summary>
public event Action<Cookie, CookieChangedCause, bool> OnChanged
{
add
{
if (_changed == null)
{
BridgeConnector.Socket.On("webContents-session-cookies-changed" + Id, (args) =>
{
Cookie cookie = ((JArray)args)[0].ToObject<Cookie>();
CookieChangedCause cause = ((JArray)args)[1].ToObject<CookieChangedCause>();
bool removed = ((JArray)args)[2].ToObject<bool>();
_changed(cookie, cause, removed);
});
BridgeConnector.Socket.Emit("register-webContents-session-cookies-changed", Id);
}
_changed += value;
}
remove
{
_changed -= value;
if (_changed == null)
BridgeConnector.Socket.Off("webContents-session-cookies-changed" + Id);
}
}
private event Action<Cookie, CookieChangedCause, bool> _changed;
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
}

View File

@@ -103,7 +103,7 @@ namespace ElectronNET.API
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
public async Task<MessageBoxResult> ShowMessageBoxAsync(string message)
{
return await ShowMessageBoxAsync(null, new MessageBoxOptions(message));
return await this.ShowMessageBoxAsync(null, new MessageBoxOptions(message)).ConfigureAwait(false);
}
/// <summary>
@@ -117,7 +117,7 @@ namespace ElectronNET.API
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
public async Task<MessageBoxResult> ShowMessageBoxAsync(MessageBoxOptions messageBoxOptions)
{
return await ShowMessageBoxAsync(null, messageBoxOptions);
return await this.ShowMessageBoxAsync(null, messageBoxOptions).ConfigureAwait(false);
}
/// <summary>
@@ -130,7 +130,7 @@ namespace ElectronNET.API
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
public async Task<MessageBoxResult> ShowMessageBoxAsync(BrowserWindow browserWindow, string message)
{
return await ShowMessageBoxAsync(browserWindow, new MessageBoxOptions(message));
return await this.ShowMessageBoxAsync(browserWindow, new MessageBoxOptions(message)).ConfigureAwait(false);
}
/// <summary>

View File

@@ -1,10 +1,11 @@
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using ElectronNET.API.Converter;
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
using ElectronNET.Converter;
/// <summary>
///
/// </summary>

View File

@@ -20,5 +20,14 @@
/// The y.
/// </value>
public int Y { get; set; }
/// <summary>
/// Convert this <see cref="Point"/> to <see cref="System.Drawing.Point"/>.
/// </summary>
/// <param name="point">The point.</param>
public static implicit operator System.Drawing.Point(Point point)
{
return new System.Drawing.Point(point.X, point.Y);
}
}
}

View File

@@ -36,5 +36,14 @@
/// The height.
/// </value>
public int Height { get; set; }
/// <summary>
/// Convert this <see cref="Rectangle"/> to <see cref="System.Drawing.Rectangle"/>.
/// </summary>
/// <param name="rectangle">The rectangle.</param>
public static implicit operator System.Drawing.Rectangle(Rectangle rectangle)
{
return new System.Drawing.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
}
}
}

View File

@@ -20,5 +20,14 @@
/// The height.
/// </value>
public int Height { get; set; }
/// <summary>
/// Convert this <see cref="Size"/> to <see cref="System.Drawing.Size"/>.
/// </summary>
/// <param name="size">The size.</param>
public static implicit operator System.Drawing.Size(Size size)
{
return new System.Drawing.Size(size.Width, size.Height);
}
}
}

Some files were not shown because too many files have changed in this diff Show More