mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-21 22:45:20 +00:00
Merge branch 'master' of https://github.com/theolivenbaum/Electron.NET
This commit is contained in:
@@ -153,7 +153,7 @@ namespace ElectronNET.API
|
||||
|
||||
public static async Task<T> OnResult<T>(string triggerEvent, string completedEvent, params object[] args)
|
||||
{
|
||||
string eventKey = triggerEvent;
|
||||
string eventKey = completedEvent;
|
||||
|
||||
if (args is object && args.Length > 0) // If there are arguments passed, we generate a unique event key with the arguments
|
||||
// this allow us to wait for previous events first before registering new ones
|
||||
@@ -166,7 +166,7 @@ namespace ElectronNET.API
|
||||
eventKey = $"{eventKey}-{(uint)hash.ToHashCode()}";
|
||||
}
|
||||
|
||||
if (EventTasks<T>.TryGetOrAdd(triggerEvent, eventKey, out var taskCompletionSource, out var waitThisFirstAndThenTryAgain))
|
||||
if (EventTasks<T>.TryGetOrAdd(completedEvent, eventKey, out var taskCompletionSource, out var waitThisFirstAndThenTryAgain))
|
||||
{
|
||||
if (waitThisFirstAndThenTryAgain is object)
|
||||
{
|
||||
@@ -192,7 +192,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
Off(completedEvent);
|
||||
taskCompletionSource.SetResult(result);
|
||||
EventTasks<T>.DoneWith(triggerEvent, eventKey, taskCompletionSource);
|
||||
EventTasks<T>.DoneWith(completedEvent, eventKey, taskCompletionSource);
|
||||
});
|
||||
|
||||
Emit(triggerEvent, args);
|
||||
@@ -205,21 +205,56 @@ namespace ElectronNET.API
|
||||
|
||||
public static async Task<T> OnResult<T>(string triggerEvent, string completedEvent, CancellationToken cancellationToken, params object[] args)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
string eventKey = completedEvent;
|
||||
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
if (args is object && args.Length > 0) // If there are arguments passed, we generate a unique event key with the arguments
|
||||
// this allow us to wait for previous events first before registering new ones
|
||||
{
|
||||
|
||||
On<T>(completedEvent, (result) =>
|
||||
var hash = new HashCode();
|
||||
foreach (var obj in args)
|
||||
{
|
||||
Off(completedEvent);
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
Emit(triggerEvent, args);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
hash.Add(obj);
|
||||
}
|
||||
eventKey = $"{eventKey}-{(uint)hash.ToHashCode()}";
|
||||
}
|
||||
|
||||
if (EventTasks<T>.TryGetOrAdd(completedEvent, eventKey, out var taskCompletionSource, out var waitThisFirstAndThenTryAgain))
|
||||
{
|
||||
if (waitThisFirstAndThenTryAgain is object)
|
||||
{
|
||||
//There was a pending call with different parameters, so we need to wait that first and then call here again
|
||||
try
|
||||
{
|
||||
await Task.Run(() => waitThisFirstAndThenTryAgain, cancellationToken);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Ignore any exceptions here so we can set a new event below
|
||||
//The exception will also be visible to the original first caller due to taskCompletionSource.Task
|
||||
}
|
||||
|
||||
//Try again to set the event
|
||||
return await OnResult<T>(triggerEvent, completedEvent, cancellationToken, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
//A new TaskCompletionSource was added, so we need to register the completed event here
|
||||
|
||||
On<T>(completedEvent, (result) =>
|
||||
{
|
||||
Off(completedEvent);
|
||||
taskCompletionSource.SetResult(result);
|
||||
EventTasks<T>.DoneWith(completedEvent, eventKey, taskCompletionSource);
|
||||
});
|
||||
|
||||
Emit(triggerEvent, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
private static SocketIO Socket
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ElectronNET.API
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
public Task<Rectangle> GetBoundsAsync() => BridgeConnector.OnResult<Rectangle>("browserView-getBounds", "browserView-getBounds-reply", Id);
|
||||
public Task<Rectangle> GetBoundsAsync() => BridgeConnector.OnResult<Rectangle>("browserView-getBounds", "browserView-getBounds-reply" + Id, Id);
|
||||
|
||||
public void SetBounds(Rectangle value)
|
||||
{
|
||||
|
||||
@@ -949,13 +949,13 @@ namespace ElectronNET.API
|
||||
/// Whether the window is focused.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFocusedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsFocused", "browserWindow-isFocused-completed", Id);
|
||||
public Task<bool> IsFocusedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsFocused", "browserWindow-isFocused-completed" + Id, Id);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the window is destroyed.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDestroyedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsDestroyed", "browserWindow-isDestroyed-completed", Id);
|
||||
public Task<bool> IsDestroyedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsDestroyed", "browserWindow-isDestroyed-completed" + Id, Id);
|
||||
|
||||
/// <summary>
|
||||
/// Shows and gives focus to the window.
|
||||
@@ -987,7 +987,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsVisibleAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisible", "browserWindow-isVisible-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisible", "browserWindow-isVisible-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -996,7 +996,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsModalAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsModal", "browserWindow-isModal-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsModal", "browserWindow-isModal-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1021,7 +1021,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMaximizedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximized", "browserWindow-isMaximized-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximized", "browserWindow-isMaximized-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1046,7 +1046,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMinimizedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimized", "browserWindow-isMinimized-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimized", "browserWindow-isMinimized-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1063,7 +1063,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFullScreenAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreen", "browserWindow-isFullScreen-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreen", "browserWindow-isFullScreen-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1142,7 +1142,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<Rectangle> GetBoundsAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetBounds", "browserWindow-getBounds-completed", Id);
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetBounds", "browserWindow-getBounds-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1170,7 +1170,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<Rectangle> GetContentBoundsAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetContentBounds", "browserWindow-getContentBounds-completed", Id);
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetContentBounds", "browserWindow-getContentBounds-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1200,7 +1200,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetSize", "browserWindow-getSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetSize", "browserWindow-getSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1230,7 +1230,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetContentSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetContentSize", "browserWindow-getContentSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetContentSize", "browserWindow-getContentSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1249,7 +1249,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetMinimumSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMinimumSize", "browserWindow-getMinimumSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMinimumSize", "browserWindow-getMinimumSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1268,7 +1268,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetMaximumSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMaximumSize", "browserWindow-getMaximumSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMaximumSize", "browserWindow-getMaximumSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1286,7 +1286,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsResizableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsResizable", "browserWindow-isResizable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsResizable", "browserWindow-isResizable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1306,7 +1306,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMovableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMovable", "browserWindow-isMovable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMovable", "browserWindow-isMovable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1326,7 +1326,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMinimizableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimizable", "browserWindow-isMinimizable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimizable", "browserWindow-isMinimizable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1346,7 +1346,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMaximizableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximizable", "browserWindow-isMaximizable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximizable", "browserWindow-isMaximizable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1364,7 +1364,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFullScreenableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreenable", "browserWindow-isFullScreenable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreenable", "browserWindow-isFullScreenable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1384,7 +1384,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsClosableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsClosable", "browserWindow-isClosable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsClosable", "browserWindow-isClosable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1434,7 +1434,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsAlwaysOnTopAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsAlwaysOnTop", "browserWindow-isAlwaysOnTop-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsAlwaysOnTop", "browserWindow-isAlwaysOnTop-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1491,7 +1491,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetPositionAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetPosition", "browserWindow-getPosition-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetPosition", "browserWindow-getPosition-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1511,7 +1511,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<string> GetTitleAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetTitle", "browserWindow-getTitle-completed", Id);
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetTitle", "browserWindow-getTitle-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1570,7 +1570,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsKioskAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsKiosk", "browserWindow-isKiosk-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsKiosk", "browserWindow-isKiosk-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1579,7 +1579,7 @@ namespace ElectronNET.API
|
||||
/// <returns>string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.</returns>
|
||||
public Task<string> GetNativeWindowHandle()
|
||||
{
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetNativeWindowHandle", "browserWindow-getNativeWindowHandle-completed", Id);
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetNativeWindowHandle", "browserWindow-getNativeWindowHandle-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1598,7 +1598,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<string> GetRepresentedFilenameAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetRepresentedFilename", "browserWindow-getRepresentedFilename-completed", Id);
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetRepresentedFilename", "browserWindow-getRepresentedFilename-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1617,7 +1617,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDocumentEditedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsDocumentEdited", "browserWindow-isDocumentEdited-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsDocumentEdited", "browserWindow-isDocumentEdited-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1751,7 +1751,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> HasShadowAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowHasShadow", "browserWindow-hasShadow-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowHasShadow", "browserWindow-hasShadow-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1780,9 +1780,9 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("browserWindowSetThumbarButtons-completed", (success) =>
|
||||
BridgeConnector.On<bool>("browserWindowSetThumbarButtons-completed" + Id, (success) =>
|
||||
{
|
||||
BridgeConnector.Off("browserWindowSetThumbarButtons-completed");
|
||||
BridgeConnector.Off("browserWindowSetThumbarButtons-completed" + Id);
|
||||
|
||||
taskCompletionSource.SetResult(success);
|
||||
});
|
||||
@@ -1860,7 +1860,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMenuBarAutoHideAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarAutoHide", "browserWindow-isMenuBarAutoHide-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarAutoHide", "browserWindow-isMenuBarAutoHide-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1879,7 +1879,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMenuBarVisibleAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarVisible", "browserWindow-isMenuBarVisible-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarVisible", "browserWindow-isMenuBarVisible-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1901,7 +1901,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsVisibleOnAllWorkspacesAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisibleOnAllWorkspaces", "browserWindow-isVisibleOnAllWorkspaces-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisibleOnAllWorkspaces", "browserWindow-isVisibleOnAllWorkspaces-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1953,7 +1953,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public async Task<BrowserWindow> GetParentWindowAsync()
|
||||
{
|
||||
var windowID = await BridgeConnector.OnResult<int>("browserWindowGetParentWindow", "browserWindow-getParentWindow-completed", Id);
|
||||
var windowID = await BridgeConnector.OnResult<int>("browserWindowGetParentWindow", "browserWindow-getParentWindow-completed" + Id, Id);
|
||||
return Electron.WindowManager.BrowserWindows.Where(w => w.Id == windowID).Single();
|
||||
}
|
||||
|
||||
@@ -1963,7 +1963,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public async Task<List<BrowserWindow>> GetChildWindowsAsync()
|
||||
{
|
||||
var windowIDs = new HashSet<int>(await BridgeConnector.OnResult<int[]>("browserWindowGetChildWindows", "browserWindow-getChildWindows-completed", Id));
|
||||
var windowIDs = new HashSet<int>(await BridgeConnector.OnResult<int[]>("browserWindowGetChildWindows", "browserWindow-getChildWindows-completed" + Id, Id));
|
||||
return Electron.WindowManager.BrowserWindows.Where(w => windowIDs.Contains(w.Id)).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace ElectronNET.API
|
||||
/// <returns>printers</returns>
|
||||
public Task<PrinterInfo[]> GetPrintersAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<PrinterInfo[]>("webContents-getPrinters", "webContents-getPrinters-completed", Id);
|
||||
return BridgeConnector.OnResult<PrinterInfo[]>("webContents-getPrinters", "webContents-getPrinters-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,8 +121,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns>success</returns>
|
||||
public Task<bool> PrintAsync(PrintOptions options = null) => options is null ? BridgeConnector.OnResult<bool>("webContents-print", "webContents-print-completed", Id, "")
|
||||
: BridgeConnector.OnResult<bool>("webContents-print", "webContents-print-completed", Id, options);
|
||||
public Task<bool> PrintAsync(PrintOptions options = null) => options is null ? BridgeConnector.OnResult<bool>("webContents-print", "webContents-print-completed" + Id, Id, "")
|
||||
: BridgeConnector.OnResult<bool>("webContents-print", "webContents-print-completed" + Id, Id, options);
|
||||
|
||||
/// <summary>
|
||||
/// Prints window's web page as PDF with Chromium's preview printing custom
|
||||
@@ -133,8 +133,8 @@ namespace ElectronNET.API
|
||||
/// <param name="path"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns>success</returns>
|
||||
public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null) => options is null ? BridgeConnector.OnResult<bool>("webContents-printToPDF", "webContents-printToPDF-completed", Id, "", path)
|
||||
: BridgeConnector.OnResult<bool>("webContents-printToPDF", "webContents-printToPDF-completed", Id, options, path);
|
||||
public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null) => options is null ? BridgeConnector.OnResult<bool>("webContents-printToPDF", "webContents-printToPDF-completed" + Id, Id, "", path)
|
||||
: BridgeConnector.OnResult<bool>("webContents-printToPDF", "webContents-printToPDF-completed" + Id, Id, options, path);
|
||||
|
||||
/// <summary>
|
||||
/// Is used to get the Url of the loaded page.
|
||||
|
||||
@@ -24,7 +24,7 @@ const browserViewApi = (socket) => {
|
||||
});
|
||||
socket.on('browserView-getBounds', (id) => {
|
||||
const bounds = getBrowserViewById(id).getBounds();
|
||||
electronSocket.emit('browserView-getBounds-reply', bounds);
|
||||
electronSocket.emit('browserView-getBounds-reply' + id, bounds);
|
||||
});
|
||||
socket.on('browserView-setBounds', (id, bounds) => {
|
||||
getBrowserViewById(id).setBounds(bounds);
|
||||
|
||||
@@ -31,7 +31,7 @@ const browserViewApi = (socket: Socket) => {
|
||||
socket.on('browserView-getBounds', (id) => {
|
||||
const bounds = getBrowserViewById(id).getBounds();
|
||||
|
||||
electronSocket.emit('browserView-getBounds-reply', bounds);
|
||||
electronSocket.emit('browserView-getBounds-reply' + id, bounds);
|
||||
});
|
||||
|
||||
socket.on('browserView-setBounds', (id, bounds) => {
|
||||
|
||||
@@ -272,15 +272,15 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowIsFocused', (id) => {
|
||||
const isFocused = getWindowById(id)?.isFocused() ?? null;
|
||||
electronSocket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
electronSocket.emit('browserWindow-isFocused-completed' + id, isFocused);
|
||||
});
|
||||
socket.on('browserWindowIsDestroyed', (id) => {
|
||||
const w = getWindowById(id);
|
||||
if (w) {
|
||||
const isDestroyed = w.isDestroyed();
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, isDestroyed);
|
||||
} else {
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', true);
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, true);
|
||||
}
|
||||
});
|
||||
socket.on('browserWindowShow', (id) => {
|
||||
@@ -294,11 +294,11 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowIsVisible', (id) => {
|
||||
const isVisible = getWindowById(id)?.isVisible() ?? null;
|
||||
electronSocket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
electronSocket.emit('browserWindow-isVisible-completed' + id, isVisible);
|
||||
});
|
||||
socket.on('browserWindowIsModal', (id) => {
|
||||
const isModal = getWindowById(id)?.isModal() ?? null;
|
||||
electronSocket.emit('browserWindow-isModal-completed', isModal);
|
||||
electronSocket.emit('browserWindow-isModal-completed' + id, isModal);
|
||||
});
|
||||
socket.on('browserWindowMaximize', (id) => {
|
||||
getWindowById(id)?.maximize();
|
||||
@@ -308,7 +308,7 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowIsMaximized', (id) => {
|
||||
const isMaximized = getWindowById(id)?.isMaximized() ?? null;
|
||||
electronSocket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
electronSocket.emit('browserWindow-isMaximized-completed' + id, isMaximized);
|
||||
});
|
||||
socket.on('browserWindowMinimize', (id) => {
|
||||
getWindowById(id)?.minimize();
|
||||
@@ -318,14 +318,14 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowIsMinimized', (id) => {
|
||||
const isMinimized = getWindowById(id)?.isMinimized() ?? null;
|
||||
electronSocket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
electronSocket.emit('browserWindow-isMinimized-completed' + id, isMinimized);
|
||||
});
|
||||
socket.on('browserWindowSetFullScreen', (id, fullscreen) => {
|
||||
getWindowById(id)?.setFullScreen(fullscreen);
|
||||
});
|
||||
socket.on('browserWindowIsFullScreen', (id) => {
|
||||
const isFullScreen = getWindowById(id)?.isFullScreen() ?? null;
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed' + id, isFullScreen);
|
||||
});
|
||||
socket.on('browserWindowSetAspectRatio', (id, aspectRatio, extraSize) => {
|
||||
getWindowById(id)?.setAspectRatio(aspectRatio, extraSize);
|
||||
@@ -341,91 +341,91 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowGetBounds', (id) => {
|
||||
const rectangle = getWindowById(id)?.getBounds() ?? null;
|
||||
electronSocket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getBounds-completed' + id, rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetContentBounds', (id, bounds, animate) => {
|
||||
getWindowById(id)?.setContentBounds(bounds, animate);
|
||||
});
|
||||
socket.on('browserWindowGetContentBounds', (id) => {
|
||||
const rectangle = getWindowById(id)?.getContentBounds() ?? null;
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed' + id, rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetSize', (id, width, height, animate) => {
|
||||
getWindowById(id)?.setSize(width, height, animate);
|
||||
});
|
||||
socket.on('browserWindowGetSize', (id) => {
|
||||
const size = getWindowById(id)?.getSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetContentSize', (id, width, height, animate) => {
|
||||
getWindowById(id)?.setContentSize(width, height, animate);
|
||||
});
|
||||
socket.on('browserWindowGetContentSize', (id) => {
|
||||
const size = getWindowById(id)?.getContentSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getContentSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getContentSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetMinimumSize', (id, width, height) => {
|
||||
getWindowById(id)?.setMinimumSize(width, height);
|
||||
});
|
||||
socket.on('browserWindowGetMinimumSize', (id) => {
|
||||
const size = getWindowById(id)?.getMinimumSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetMaximumSize', (id, width, height) => {
|
||||
getWindowById(id)?.setMaximumSize(width, height);
|
||||
});
|
||||
socket.on('browserWindowGetMaximumSize', (id) => {
|
||||
const size = getWindowById(id)?.getMaximumSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetResizable', (id, resizable) => {
|
||||
getWindowById(id)?.setResizable(resizable);
|
||||
});
|
||||
socket.on('browserWindowIsResizable', (id) => {
|
||||
const resizable = getWindowById(id)?.isResizable() ?? null;
|
||||
electronSocket.emit('browserWindow-isResizable-completed', resizable);
|
||||
electronSocket.emit('browserWindow-isResizable-completed' + id, resizable);
|
||||
});
|
||||
socket.on('browserWindowSetMovable', (id, movable) => {
|
||||
getWindowById(id)?.setMovable(movable);
|
||||
});
|
||||
socket.on('browserWindowIsMovable', (id) => {
|
||||
const movable = getWindowById(id)?.isMovable() ?? null;
|
||||
electronSocket.emit('browserWindow-isMovable-completed', movable);
|
||||
electronSocket.emit('browserWindow-isMovable-completed' + id, movable);
|
||||
});
|
||||
socket.on('browserWindowSetMinimizable', (id, minimizable) => {
|
||||
getWindowById(id)?.setMinimizable(minimizable);
|
||||
});
|
||||
socket.on('browserWindowIsMinimizable', (id) => {
|
||||
const minimizable = getWindowById(id)?.isMinimizable() ?? null;
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed' + id, minimizable);
|
||||
});
|
||||
socket.on('browserWindowSetMaximizable', (id, maximizable) => {
|
||||
getWindowById(id)?.setMaximizable(maximizable);
|
||||
});
|
||||
socket.on('browserWindowIsMaximizable', (id) => {
|
||||
const maximizable = getWindowById(id)?.isMaximizable() ?? null;
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed' + id, maximizable);
|
||||
});
|
||||
socket.on('browserWindowSetFullScreenable', (id, fullscreenable) => {
|
||||
getWindowById(id)?.setFullScreenable(fullscreenable);
|
||||
});
|
||||
socket.on('browserWindowIsFullScreenable', (id) => {
|
||||
const fullscreenable = getWindowById(id)?.isFullScreenable() ?? null;
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed' + id, fullscreenable);
|
||||
});
|
||||
socket.on('browserWindowSetClosable', (id, closable) => {
|
||||
getWindowById(id)?.setClosable(closable);
|
||||
});
|
||||
socket.on('browserWindowIsClosable', (id) => {
|
||||
const closable = getWindowById(id)?.isClosable() ?? null;
|
||||
electronSocket.emit('browserWindow-isClosable-completed', closable);
|
||||
electronSocket.emit('browserWindow-isClosable-completed' + id, closable);
|
||||
});
|
||||
socket.on('browserWindowSetAlwaysOnTop', (id, flag, level, relativeLevel) => {
|
||||
getWindowById(id)?.setAlwaysOnTop(flag, level, relativeLevel);
|
||||
});
|
||||
socket.on('browserWindowIsAlwaysOnTop', (id) => {
|
||||
const isAlwaysOnTop = getWindowById(id)?.isAlwaysOnTop() ?? null;
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed' + id, isAlwaysOnTop);
|
||||
});
|
||||
socket.on('browserWindowCenter', (id) => {
|
||||
getWindowById(id)?.center();
|
||||
@@ -435,14 +435,14 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowGetPosition', (id) => {
|
||||
const position = getWindowById(id)?.getPosition() ?? null;
|
||||
electronSocket.emit('browserWindow-getPosition-completed', position);
|
||||
electronSocket.emit('browserWindow-getPosition-completed' + id, position);
|
||||
});
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id)?.setTitle(title);
|
||||
});
|
||||
socket.on('browserWindowGetTitle', (id) => {
|
||||
const title = getWindowById(id)?.getTitle() ?? null;
|
||||
electronSocket.emit('browserWindow-getTitle-completed', title);
|
||||
electronSocket.emit('browserWindow-getTitle-completed' + id, title);
|
||||
});
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id)?.setTitle(title);
|
||||
@@ -466,25 +466,25 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowIsKiosk', (id) => {
|
||||
const isKiosk = getWindowById(id)?.isKiosk() ?? null;
|
||||
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
electronSocket.emit('browserWindow-isKiosk-completed' + id, isKiosk);
|
||||
});
|
||||
socket.on('browserWindowGetNativeWindowHandle', (id) => {
|
||||
const nativeWindowHandle = getWindowById(id)?.getNativeWindowHandle()?.readInt32LE(0)?.toString(16) ?? null;
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed' + id, nativeWindowHandle);
|
||||
});
|
||||
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
|
||||
getWindowById(id)?.setRepresentedFilename(filename);
|
||||
});
|
||||
socket.on('browserWindowGetRepresentedFilename', (id) => {
|
||||
const pathname = getWindowById(id)?.getRepresentedFilename() ?? null;
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed' + id, pathname);
|
||||
});
|
||||
socket.on('browserWindowSetDocumentEdited', (id, edited) => {
|
||||
getWindowById(id)?.setDocumentEdited(edited);
|
||||
});
|
||||
socket.on('browserWindowIsDocumentEdited', (id) => {
|
||||
const edited = getWindowById(id)?.isDocumentEdited() ?? null;
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed' + id, edited);
|
||||
});
|
||||
socket.on('browserWindowFocusOnWebView', (id) => {
|
||||
getWindowById(id)?.focusOnWebView();
|
||||
@@ -532,7 +532,7 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowHasShadow', (id) => {
|
||||
const hasShadow = getWindowById(id)?.hasShadow() ?? null;
|
||||
electronSocket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
electronSocket.emit('browserWindow-hasShadow-completed' + id, hasShadow);
|
||||
});
|
||||
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons) => {
|
||||
thumbarButtons.forEach(thumbarButton => {
|
||||
@@ -543,7 +543,7 @@ module.exports = (socket, app) => {
|
||||
};
|
||||
});
|
||||
const success = getWindowById(id)?.setThumbarButtons(thumbarButtons) ?? null;
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed' + id, success);
|
||||
});
|
||||
socket.on('browserWindowSetThumbnailClip', (id, rectangle) => {
|
||||
getWindowById(id)?.setThumbnailClip(rectangle);
|
||||
@@ -562,21 +562,21 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowIsMenuBarAutoHide', (id) => {
|
||||
const isMenuBarAutoHide = getWindowById(id)?.isMenuBarAutoHide() ?? null;
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed' + id, isMenuBarAutoHide);
|
||||
});
|
||||
socket.on('browserWindowSetMenuBarVisibility', (id, visible) => {
|
||||
getWindowById(id)?.setMenuBarVisibility(visible);
|
||||
});
|
||||
socket.on('browserWindowIsMenuBarVisible', (id) => {
|
||||
const isMenuBarVisible = getWindowById(id)?.isMenuBarVisible() ?? null;
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed' + id, isMenuBarVisible);
|
||||
});
|
||||
socket.on('browserWindowSetVisibleOnAllWorkspaces', (id, visible) => {
|
||||
getWindowById(id)?.setVisibleOnAllWorkspaces(visible);
|
||||
});
|
||||
socket.on('browserWindowIsVisibleOnAllWorkspaces', (id) => {
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id)?.isVisibleOnAllWorkspaces() ?? null;
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed' + id, isVisibleOnAllWorkspaces);
|
||||
});
|
||||
socket.on('browserWindowSetIgnoreMouseEvents', (id, ignore) => {
|
||||
getWindowById(id)?.setIgnoreMouseEvents(ignore);
|
||||
@@ -593,7 +593,7 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
socket.on('browserWindowGetParentWindow', (id) => {
|
||||
const browserWindow = getWindowById(id)?.getParentWindow() ?? null;
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed' + id, browserWindow.id);
|
||||
});
|
||||
socket.on('browserWindowGetChildWindows', (id) => {
|
||||
const browserWindows = getWindowById(id)?.getChildWindows() ?? null;
|
||||
@@ -601,7 +601,7 @@ module.exports = (socket, app) => {
|
||||
browserWindows.forEach(x => {
|
||||
ids.push(x.id);
|
||||
});
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed' + id, ids);
|
||||
});
|
||||
socket.on('browserWindowSetAutoHideCursor', (id, autoHide) => {
|
||||
getWindowById(id)?.setAutoHideCursor(autoHide);
|
||||
|
||||
@@ -311,16 +311,16 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsFocused', (id) => {
|
||||
const isFocused = getWindowById(id)?.isFocused() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
electronSocket.emit('browserWindow-isFocused-completed' + id, isFocused);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsDestroyed', (id) => {
|
||||
const w = getWindowById(id);
|
||||
if (w) {
|
||||
const isDestroyed = w.isDestroyed();
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, isDestroyed);
|
||||
} else {
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', true);
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -339,13 +339,13 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsVisible', (id) => {
|
||||
const isVisible = getWindowById(id)?.isVisible() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
electronSocket.emit('browserWindow-isVisible-completed' + id, isVisible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsModal', (id) => {
|
||||
const isModal = getWindowById(id)?.isModal() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isModal-completed', isModal);
|
||||
electronSocket.emit('browserWindow-isModal-completed' + id, isModal);
|
||||
});
|
||||
|
||||
socket.on('browserWindowMaximize', (id) => {
|
||||
@@ -359,7 +359,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMaximized', (id) => {
|
||||
const isMaximized = getWindowById(id)?.isMaximized() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
electronSocket.emit('browserWindow-isMaximized-completed' + id, isMaximized);
|
||||
});
|
||||
|
||||
socket.on('browserWindowMinimize', (id) => {
|
||||
@@ -373,7 +373,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMinimized', (id) => {
|
||||
const isMinimized = getWindowById(id)?.isMinimized() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
electronSocket.emit('browserWindow-isMinimized-completed' + id, isMinimized);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetFullScreen', (id, fullscreen) => {
|
||||
@@ -383,7 +383,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsFullScreen', (id) => {
|
||||
const isFullScreen = getWindowById(id)?.isFullScreen() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed' + id, isFullScreen);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAspectRatio', (id, aspectRatio, extraSize) => {
|
||||
@@ -405,7 +405,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetBounds', (id) => {
|
||||
const rectangle = getWindowById(id)?.getBounds() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getBounds-completed' + id, rectangle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetContentBounds', (id, bounds, animate) => {
|
||||
@@ -415,7 +415,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetContentBounds', (id) => {
|
||||
const rectangle = getWindowById(id)?.getContentBounds() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed' + id, rectangle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetSize', (id, width, height, animate) => {
|
||||
@@ -425,7 +425,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetSize', (id) => {
|
||||
const size = getWindowById(id)?.getSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetContentSize', (id, width, height, animate) => {
|
||||
@@ -435,7 +435,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetContentSize', (id) => {
|
||||
const size = getWindowById(id)?.getContentSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getContentSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getContentSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMinimumSize', (id, width, height) => {
|
||||
@@ -445,7 +445,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetMinimumSize', (id) => {
|
||||
const size = getWindowById(id)?.getMinimumSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMaximumSize', (id, width, height) => {
|
||||
@@ -455,7 +455,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetMaximumSize', (id) => {
|
||||
const size = getWindowById(id)?.getMaximumSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetResizable', (id, resizable) => {
|
||||
@@ -465,7 +465,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsResizable', (id) => {
|
||||
const resizable = getWindowById(id)?.isResizable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isResizable-completed', resizable);
|
||||
electronSocket.emit('browserWindow-isResizable-completed' + id, resizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMovable', (id, movable) => {
|
||||
@@ -475,7 +475,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMovable', (id) => {
|
||||
const movable = getWindowById(id)?.isMovable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMovable-completed', movable);
|
||||
electronSocket.emit('browserWindow-isMovable-completed' + id, movable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMinimizable', (id, minimizable) => {
|
||||
@@ -485,7 +485,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMinimizable', (id) => {
|
||||
const minimizable = getWindowById(id)?.isMinimizable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed' + id, minimizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMaximizable', (id, maximizable) => {
|
||||
@@ -495,7 +495,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMaximizable', (id) => {
|
||||
const maximizable = getWindowById(id)?.isMaximizable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed' + id, maximizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetFullScreenable', (id, fullscreenable) => {
|
||||
@@ -505,7 +505,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsFullScreenable', (id) => {
|
||||
const fullscreenable = getWindowById(id)?.isFullScreenable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed' + id, fullscreenable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetClosable', (id, closable) => {
|
||||
@@ -515,7 +515,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsClosable', (id) => {
|
||||
const closable = getWindowById(id)?.isClosable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isClosable-completed', closable);
|
||||
electronSocket.emit('browserWindow-isClosable-completed' + id, closable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAlwaysOnTop', (id, flag, level, relativeLevel) => {
|
||||
@@ -525,7 +525,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsAlwaysOnTop', (id) => {
|
||||
const isAlwaysOnTop = getWindowById(id)?.isAlwaysOnTop() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed' + id, isAlwaysOnTop);
|
||||
});
|
||||
|
||||
socket.on('browserWindowCenter', (id) => {
|
||||
@@ -539,7 +539,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetPosition', (id) => {
|
||||
const position = getWindowById(id)?.getPosition() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getPosition-completed', position);
|
||||
electronSocket.emit('browserWindow-getPosition-completed' + id, position);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
@@ -549,7 +549,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetTitle', (id) => {
|
||||
const title = getWindowById(id)?.getTitle() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getTitle-completed', title);
|
||||
electronSocket.emit('browserWindow-getTitle-completed' + id, title);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
@@ -579,12 +579,12 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsKiosk', (id) => {
|
||||
const isKiosk = getWindowById(id)?.isKiosk() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
electronSocket.emit('browserWindow-isKiosk-completed' + id, isKiosk);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetNativeWindowHandle', (id) => {
|
||||
const nativeWindowHandle = getWindowById(id)?.getNativeWindowHandle()?.readInt32LE(0)?.toString(16) ?? null;
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed' + id, nativeWindowHandle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
|
||||
@@ -594,7 +594,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetRepresentedFilename', (id) => {
|
||||
const pathname = getWindowById(id)?.getRepresentedFilename() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed' + id, pathname);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetDocumentEdited', (id, edited) => {
|
||||
@@ -604,7 +604,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsDocumentEdited', (id) => {
|
||||
const edited = getWindowById(id)?.isDocumentEdited() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed' + id, edited);
|
||||
});
|
||||
|
||||
socket.on('browserWindowFocusOnWebView', (id) => {
|
||||
@@ -668,7 +668,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowHasShadow', (id) => {
|
||||
const hasShadow = getWindowById(id)?.hasShadow() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
electronSocket.emit('browserWindow-hasShadow-completed' + id, hasShadow);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons: Electron.ThumbarButton[]) => {
|
||||
@@ -681,7 +681,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
});
|
||||
|
||||
const success = getWindowById(id)?.setThumbarButtons(thumbarButtons) ?? null;
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed' + id, success);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetThumbnailClip', (id, rectangle) => {
|
||||
@@ -707,7 +707,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMenuBarAutoHide', (id) => {
|
||||
const isMenuBarAutoHide = getWindowById(id)?.isMenuBarAutoHide() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed' + id, isMenuBarAutoHide);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMenuBarVisibility', (id, visible) => {
|
||||
@@ -717,7 +717,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMenuBarVisible', (id) => {
|
||||
const isMenuBarVisible = getWindowById(id)?.isMenuBarVisible() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed' + id, isMenuBarVisible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetVisibleOnAllWorkspaces', (id, visible) => {
|
||||
@@ -727,7 +727,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsVisibleOnAllWorkspaces', (id) => {
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id)?.isVisibleOnAllWorkspaces() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed' + id, isVisibleOnAllWorkspaces);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetIgnoreMouseEvents', (id, ignore) => {
|
||||
@@ -751,7 +751,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetParentWindow', (id) => {
|
||||
const browserWindow = getWindowById(id)?.getParentWindow() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed' + id, browserWindow.id);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetChildWindows', (id) => {
|
||||
@@ -763,7 +763,7 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
ids.push(x.id);
|
||||
});
|
||||
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed' + id, ids);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAutoHideCursor', (id, autoHide) => {
|
||||
|
||||
@@ -29,20 +29,20 @@ module.exports = (socket) => {
|
||||
});
|
||||
socket.on('webContents-getPrinters', async (id) => {
|
||||
const printers = await getWindowById(id).webContents.getPrinters();
|
||||
electronSocket.emit('webContents-getPrinters-completed', printers);
|
||||
electronSocket.emit('webContents-getPrinters-completed' + Id, printers);
|
||||
});
|
||||
socket.on('webContents-print', async (id, options = {}) => {
|
||||
await getWindowById(id).webContents.print(options);
|
||||
electronSocket.emit('webContents-print-completed', true);
|
||||
electronSocket.emit('webContents-print-completed' + Id, true);
|
||||
});
|
||||
socket.on('webContents-printToPDF', async (id, options = {}, path) => {
|
||||
const buffer = await getWindowById(id).webContents.printToPDF(options);
|
||||
fs.writeFile(path, buffer, (error) => {
|
||||
if (error) {
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, false);
|
||||
}
|
||||
else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -201,7 +201,7 @@ module.exports = (socket) => {
|
||||
Object.keys(extensionsList).forEach(key => {
|
||||
chromeExtensionInfo.push(extensionsList[key]);
|
||||
});
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed', chromeExtensionInfo);
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed' + Id, chromeExtensionInfo);
|
||||
});
|
||||
socket.on('webContents-session-removeExtension', (id, name) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
@@ -210,7 +210,7 @@ module.exports = (socket) => {
|
||||
socket.on('webContents-session-loadExtension', async (id, path, allowFileAccess = false) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
|
||||
electronSocket.emit('webContents-session-loadExtension-completed', extension);
|
||||
electronSocket.emit('webContents-session-loadExtension-completed' + Id, extension);
|
||||
});
|
||||
function getWindowById(id) {
|
||||
if (id >= 1000) {
|
||||
|
||||
@@ -34,12 +34,12 @@ export = (socket: Socket) => {
|
||||
|
||||
socket.on('webContents-getPrinters', async (id) => {
|
||||
const printers = await getWindowById(id).webContents.getPrinters();
|
||||
electronSocket.emit('webContents-getPrinters-completed', printers);
|
||||
electronSocket.emit('webContents-getPrinters-completed' + Id, printers);
|
||||
});
|
||||
|
||||
socket.on('webContents-print', async (id, options = {}) => {
|
||||
await getWindowById(id).webContents.print(options);
|
||||
electronSocket.emit('webContents-print-completed', true);
|
||||
electronSocket.emit('webContents-print-completed' + Id, true);
|
||||
});
|
||||
|
||||
socket.on('webContents-printToPDF', async (id, options = {}, path) => {
|
||||
@@ -47,9 +47,9 @@ export = (socket: Socket) => {
|
||||
|
||||
fs.writeFile(path, buffer, (error) => {
|
||||
if (error) {
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, false);
|
||||
} else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -253,7 +253,7 @@ export = (socket: Socket) => {
|
||||
chromeExtensionInfo.push(extensionsList[key]);
|
||||
});
|
||||
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed', chromeExtensionInfo);
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed' + Id, chromeExtensionInfo);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-removeExtension', (id, name) => {
|
||||
@@ -265,7 +265,7 @@ export = (socket: Socket) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
|
||||
|
||||
electronSocket.emit('webContents-session-loadExtension-completed', extension);
|
||||
electronSocket.emit('webContents-session-loadExtension-completed' + Id, extension);
|
||||
});
|
||||
|
||||
function getWindowById(id: number): Electron.BrowserWindow | Electron.BrowserView {
|
||||
|
||||
Reference in New Issue
Block a user