mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-12 21:25:06 +00:00
refactoring dotnet events
This commit is contained in:
@@ -7,7 +7,9 @@ using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Extensions;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
using ElectronNET.Common;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -217,26 +219,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action BrowserWindowBlur
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_browserWindowBlur == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("app-browser-window-blur" + GetHashCode(), () =>
|
||||
{
|
||||
_browserWindowBlur();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-app-browser-window-blur-event", GetHashCode());
|
||||
}
|
||||
_browserWindowBlur += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_browserWindowBlur -= value;
|
||||
|
||||
if (_browserWindowBlur == null)
|
||||
BridgeConnector.Socket.Off("app-browser-window-blur" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEventWithSuffix("app-browser-window-blur", GetHashCode(), _browserWindowBlur, value);
|
||||
remove => ApiEventManager.RemoveEvent("app-browser-window-blur", GetHashCode(), _browserWindowBlur, value);
|
||||
}
|
||||
|
||||
private event Action _browserWindowBlur;
|
||||
@@ -246,26 +230,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action BrowserWindowFocus
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_browserWindowFocus == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("app-browser-window-focus" + GetHashCode(), () =>
|
||||
{
|
||||
_browserWindowFocus();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-app-browser-window-focus-event", GetHashCode());
|
||||
}
|
||||
_browserWindowFocus += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_browserWindowFocus -= value;
|
||||
|
||||
if (_browserWindowFocus == null)
|
||||
BridgeConnector.Socket.Off("app-browser-window-focus" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEventWithSuffix("app-browser-window-focus", GetHashCode(), _browserWindowFocus, value);
|
||||
remove => ApiEventManager.RemoveEvent("app-browser-window-focus", GetHashCode(), _browserWindowFocus, value);
|
||||
}
|
||||
|
||||
private event Action _browserWindowFocus;
|
||||
@@ -275,26 +241,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action BrowserWindowCreated
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_browserWindowCreated == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("app-browser-window-created" + GetHashCode(), () =>
|
||||
{
|
||||
_browserWindowCreated();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-app-browser-window-created-event", GetHashCode());
|
||||
}
|
||||
_browserWindowCreated += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_browserWindowCreated -= value;
|
||||
|
||||
if (_browserWindowCreated == null)
|
||||
BridgeConnector.Socket.Off("app-browser-window-created" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEventWithSuffix("app-browser-window-created", GetHashCode(), _browserWindowCreated, value);
|
||||
remove => ApiEventManager.RemoveEvent("app-browser-window-created", GetHashCode(), _browserWindowCreated, value);
|
||||
}
|
||||
|
||||
private event Action _browserWindowCreated;
|
||||
@@ -304,26 +252,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action WebContentsCreated
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_webContentsCreated == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("app-web-contents-created" + GetHashCode(), () =>
|
||||
{
|
||||
_webContentsCreated();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-app-web-contents-created-event", GetHashCode());
|
||||
}
|
||||
_webContentsCreated += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_webContentsCreated -= value;
|
||||
|
||||
if (_webContentsCreated == null)
|
||||
BridgeConnector.Socket.Off("app-web-contents-created" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEventWithSuffix("app-web-contents-created", GetHashCode(), _webContentsCreated, value);
|
||||
remove => ApiEventManager.RemoveEvent("app-web-contents-created", GetHashCode(), _webContentsCreated, value);
|
||||
}
|
||||
|
||||
private event Action _webContentsCreated;
|
||||
@@ -335,26 +265,8 @@ namespace ElectronNET.API
|
||||
/// <returns><see langword="true"/> when Chrome's accessibility support is enabled, <see langword="false"/> otherwise.</returns>
|
||||
public event Action<bool> AccessibilitySupportChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_accessibilitySupportChanged == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("app-accessibility-support-changed" + GetHashCode(), (state) =>
|
||||
{
|
||||
_accessibilitySupportChanged((bool)state);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-app-accessibility-support-changed-event", GetHashCode());
|
||||
}
|
||||
_accessibilitySupportChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_accessibilitySupportChanged -= value;
|
||||
|
||||
if (_accessibilitySupportChanged == null)
|
||||
BridgeConnector.Socket.Off("app-accessibility-support-changed" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEventWithSuffix("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value, (args) => (bool)args);
|
||||
remove => ApiEventManager.RemoveEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value);
|
||||
}
|
||||
|
||||
private event Action<bool> _accessibilitySupportChanged;
|
||||
@@ -408,26 +320,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<string> OpenFile
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_openFile == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("app-open-file" + GetHashCode(), (file) =>
|
||||
{
|
||||
_openFile(file.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-app-open-file-event", GetHashCode());
|
||||
}
|
||||
_openFile += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_openFile -= value;
|
||||
|
||||
if (_openFile == null)
|
||||
BridgeConnector.Socket.Off("app-open-file" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEventWithSuffix("app-open-file", GetHashCode(), _openFile, value, (args) => args.ToString());
|
||||
remove => ApiEventManager.RemoveEvent("app-open-file", GetHashCode(), _openFile, value);
|
||||
}
|
||||
|
||||
private event Action<string> _openFile;
|
||||
@@ -439,26 +333,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<string> OpenUrl
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_openUrl == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("app-open-url" + GetHashCode(), (url) =>
|
||||
{
|
||||
_openUrl(url.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-app-open-url-event", GetHashCode());
|
||||
}
|
||||
_openUrl += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_openUrl -= value;
|
||||
|
||||
if (_openUrl == null)
|
||||
BridgeConnector.Socket.Off("app-open-url" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEventWithSuffix("app-open-url", GetHashCode(), _openUrl, value, (args) => args.ToString());
|
||||
remove => ApiEventManager.RemoveEvent("app-open-url", GetHashCode(), _openUrl, value);
|
||||
}
|
||||
|
||||
private event Action<string> _openUrl;
|
||||
|
||||
@@ -8,6 +8,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.Common;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ElectronNET.API;
|
||||
|
||||
@@ -30,28 +32,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnReadyToShow
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_readyToShow == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-ready-to-show" + Id, () =>
|
||||
{
|
||||
_readyToShow();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-ready-to-show", Id);
|
||||
}
|
||||
_readyToShow += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_readyToShow -= value;
|
||||
|
||||
if (_readyToShow == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-ready-to-show" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-ready-to-show", Id, _readyToShow, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-ready-to-show", Id, _readyToShow, value);
|
||||
}
|
||||
|
||||
private event Action _readyToShow;
|
||||
@@ -61,28 +43,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action<string> OnPageTitleUpdated
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_pageTitleUpdated == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-page-title-updated" + Id, (title) =>
|
||||
{
|
||||
_pageTitleUpdated(title.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-page-title-updated", Id);
|
||||
}
|
||||
_pageTitleUpdated += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_pageTitleUpdated -= value;
|
||||
|
||||
if (_pageTitleUpdated == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-page-title-updated" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-page-title-updated", Id, _pageTitleUpdated, value, (args) => args.ToString());
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-page-title-updated", Id, _pageTitleUpdated, value);
|
||||
}
|
||||
|
||||
private event Action<string> _pageTitleUpdated;
|
||||
@@ -92,28 +54,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnClose
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_close == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-close" + Id, () =>
|
||||
{
|
||||
_close();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-close", Id);
|
||||
}
|
||||
_close += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_close -= value;
|
||||
|
||||
if (_close == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-close" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-close", Id, _close, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-close", Id, _close, value);
|
||||
}
|
||||
|
||||
private event Action _close;
|
||||
@@ -125,28 +67,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnClosed
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_closed == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-closed" + Id, () =>
|
||||
{
|
||||
_closed();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-closed", Id);
|
||||
}
|
||||
_closed += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_closed -= value;
|
||||
|
||||
if (_closed == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-closed" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-closed", Id, _closed, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-closed", Id, _closed, value);
|
||||
}
|
||||
|
||||
private event Action _closed;
|
||||
@@ -156,28 +78,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnSessionEnd
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_sessionEnd == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-session-end" + Id, () =>
|
||||
{
|
||||
_sessionEnd();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-session-end", Id);
|
||||
}
|
||||
_sessionEnd += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_sessionEnd -= value;
|
||||
|
||||
if (_sessionEnd == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-session-end" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-session-end", Id, _sessionEnd, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-session-end", Id, _sessionEnd, value);
|
||||
}
|
||||
|
||||
private event Action _sessionEnd;
|
||||
@@ -187,28 +89,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnUnresponsive
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_unresponsive == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-unresponsive" + Id, () =>
|
||||
{
|
||||
_unresponsive();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-unresponsive", Id);
|
||||
}
|
||||
_unresponsive += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_unresponsive -= value;
|
||||
|
||||
if (_unresponsive == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-unresponsive" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-unresponsive", Id, _unresponsive, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-unresponsive", Id, _unresponsive, value);
|
||||
}
|
||||
|
||||
private event Action _unresponsive;
|
||||
@@ -218,28 +100,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnResponsive
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_responsive == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-responsive" + Id, () =>
|
||||
{
|
||||
_responsive();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-responsive", Id);
|
||||
}
|
||||
_responsive += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_responsive -= value;
|
||||
|
||||
if (_responsive == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-responsive" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-responsive", Id, _responsive, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-responsive", Id, _responsive, value);
|
||||
}
|
||||
|
||||
private event Action _responsive;
|
||||
@@ -249,28 +111,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnBlur
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_blur == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-blur" + Id, () =>
|
||||
{
|
||||
_blur();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-blur", Id);
|
||||
}
|
||||
_blur += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_blur -= value;
|
||||
|
||||
if (_blur == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-blur" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-blur", Id, _blur, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-blur", Id, _blur, value);
|
||||
}
|
||||
|
||||
private event Action _blur;
|
||||
@@ -280,28 +122,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnFocus
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_focus == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-focus" + Id, () =>
|
||||
{
|
||||
_focus();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-focus", Id);
|
||||
}
|
||||
_focus += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_focus -= value;
|
||||
|
||||
if (_focus == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-focus" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-focus", Id, _focus, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-focus", Id, _focus, value);
|
||||
}
|
||||
|
||||
private event Action _focus;
|
||||
@@ -311,28 +133,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnShow
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_show == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-show" + Id, () =>
|
||||
{
|
||||
_show();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-show", Id);
|
||||
}
|
||||
_show += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_show -= value;
|
||||
|
||||
if (_show == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-show" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-show", Id, _show, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-show", Id, _show, value);
|
||||
}
|
||||
|
||||
private event Action _show;
|
||||
@@ -342,28 +144,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnHide
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_hide == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-hide" + Id, () =>
|
||||
{
|
||||
_hide();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-hide", Id);
|
||||
}
|
||||
_hide += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_hide -= value;
|
||||
|
||||
if (_hide == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-hide" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-hide", Id, _hide, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-hide", Id, _hide, value);
|
||||
}
|
||||
|
||||
private event Action _hide;
|
||||
@@ -373,28 +155,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnMaximize
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_maximize == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-maximize" + Id, () =>
|
||||
{
|
||||
_maximize();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-maximize", Id);
|
||||
}
|
||||
_maximize += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_maximize -= value;
|
||||
|
||||
if (_maximize == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-maximize" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-maximize", Id, _maximize, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-maximize", Id, _maximize, value);
|
||||
}
|
||||
|
||||
private event Action _maximize;
|
||||
@@ -404,28 +166,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnUnmaximize
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_unmaximize == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-unmaximize" + Id, () =>
|
||||
{
|
||||
_unmaximize();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-unmaximize", Id);
|
||||
}
|
||||
_unmaximize += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_unmaximize -= value;
|
||||
|
||||
if (_unmaximize == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-unmaximize" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-unmaximize", Id, _unmaximize, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-unmaximize", Id, _unmaximize, value);
|
||||
}
|
||||
|
||||
private event Action _unmaximize;
|
||||
@@ -435,28 +177,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnMinimize
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_minimize == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-minimize" + Id, () =>
|
||||
{
|
||||
_minimize();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-minimize", Id);
|
||||
}
|
||||
_minimize += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_minimize -= value;
|
||||
|
||||
if (_minimize == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-minimize" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-minimize", Id, _minimize, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-minimize", Id, _minimize, value);
|
||||
}
|
||||
|
||||
private event Action _minimize;
|
||||
@@ -466,28 +188,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnRestore
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_restore == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-restore" + Id, () =>
|
||||
{
|
||||
_restore();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-restore", Id);
|
||||
}
|
||||
_restore += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_restore -= value;
|
||||
|
||||
if (_restore == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-restore" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-restore", Id, _restore, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-restore", Id, _restore, value);
|
||||
}
|
||||
|
||||
private event Action _restore;
|
||||
@@ -497,28 +199,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnResize
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_resize == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-resize" + Id, () =>
|
||||
{
|
||||
_resize();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-resize", Id);
|
||||
}
|
||||
_resize += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_resize -= value;
|
||||
|
||||
if (_resize == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-resize" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-resize", Id, _resize, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-resize", Id, _resize, value);
|
||||
}
|
||||
|
||||
private event Action _resize;
|
||||
@@ -530,28 +212,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnMove
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_move == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-move" + Id, () =>
|
||||
{
|
||||
_move();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-move", Id);
|
||||
}
|
||||
_move += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_move -= value;
|
||||
|
||||
if (_move == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-move" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-move", Id, _move, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-move", Id, _move, value);
|
||||
}
|
||||
|
||||
private event Action _move;
|
||||
@@ -561,28 +223,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnMoved
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_moved == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-moved" + Id, () =>
|
||||
{
|
||||
_moved();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-moved", Id);
|
||||
}
|
||||
_moved += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_moved -= value;
|
||||
|
||||
if (_moved == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-moved" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-moved", Id, _moved, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-moved", Id, _moved, value);
|
||||
}
|
||||
|
||||
private event Action _moved;
|
||||
@@ -592,28 +234,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnEnterFullScreen
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_enterFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-enter-full-screen" + Id, () =>
|
||||
{
|
||||
_enterFullScreen();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-enter-full-screen", Id);
|
||||
}
|
||||
_enterFullScreen += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_enterFullScreen -= value;
|
||||
|
||||
if (_enterFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-enter-full-screen" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-enter-full-screen", Id, _enterFullScreen, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-enter-full-screen", Id, _enterFullScreen, value);
|
||||
}
|
||||
|
||||
private event Action _enterFullScreen;
|
||||
@@ -623,28 +245,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnLeaveFullScreen
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_leaveFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-leave-full-screen" + Id, () =>
|
||||
{
|
||||
_leaveFullScreen();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-leave-full-screen", Id);
|
||||
}
|
||||
_leaveFullScreen += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_leaveFullScreen -= value;
|
||||
|
||||
if (_leaveFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-leave-full-screen" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-leave-full-screen", Id, _leaveFullScreen, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-leave-full-screen", Id, _leaveFullScreen, value);
|
||||
}
|
||||
|
||||
private event Action _leaveFullScreen;
|
||||
@@ -654,28 +256,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnEnterHtmlFullScreen
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_enterHtmlFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-enter-html-full-screen" + Id, () =>
|
||||
{
|
||||
_enterHtmlFullScreen();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-enter-html-full-screen", Id);
|
||||
}
|
||||
_enterHtmlFullScreen += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_enterHtmlFullScreen -= value;
|
||||
|
||||
if (_enterHtmlFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-enter-html-full-screen" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-enter-html-full-screen", Id, _enterHtmlFullScreen, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-enter-html-full-screen", Id, _enterHtmlFullScreen, value);
|
||||
}
|
||||
|
||||
private event Action _enterHtmlFullScreen;
|
||||
@@ -685,28 +267,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnLeaveHtmlFullScreen
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_leaveHtmlFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-leave-html-full-screen" + Id, () =>
|
||||
{
|
||||
_leaveHtmlFullScreen();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-leave-html-full-screen", Id);
|
||||
}
|
||||
_leaveHtmlFullScreen += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_leaveHtmlFullScreen -= value;
|
||||
|
||||
if (_leaveHtmlFullScreen == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-leave-html-full-screen" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-leave-html-full-screen", Id, _leaveHtmlFullScreen, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-leave-html-full-screen", Id, _leaveHtmlFullScreen, value);
|
||||
}
|
||||
|
||||
private event Action _leaveHtmlFullScreen;
|
||||
@@ -722,28 +284,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action<string> OnAppCommand
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_appCommand == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-app-command" + Id, (command) =>
|
||||
{
|
||||
_appCommand(command.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-app-command", Id);
|
||||
}
|
||||
_appCommand += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_appCommand -= value;
|
||||
|
||||
if (_appCommand == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-app-command" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-app-command", Id, _appCommand, value, (args) => args.ToString());
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-app-command", Id, _appCommand, value);
|
||||
}
|
||||
|
||||
private event Action<string> _appCommand;
|
||||
@@ -753,28 +295,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action<string> OnSwipe
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_swipe == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-swipe" + Id, (direction) =>
|
||||
{
|
||||
_swipe(direction.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-swipe", Id);
|
||||
}
|
||||
_swipe += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_swipe -= value;
|
||||
|
||||
if (_swipe == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-swipe" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-swipe", Id, _swipe, value, (args) => args.ToString());
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-swipe", Id, _swipe, value);
|
||||
}
|
||||
|
||||
private event Action<string> _swipe;
|
||||
@@ -784,28 +306,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnSheetBegin
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_sheetBegin == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-sheet-begin" + Id, () =>
|
||||
{
|
||||
_sheetBegin();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-sheet-begin", Id);
|
||||
}
|
||||
_sheetBegin += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_sheetBegin -= value;
|
||||
|
||||
if (_sheetBegin == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-sheet-begin" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-sheet-begin", Id, _sheetBegin, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-sheet-begin", Id, _sheetBegin, value);
|
||||
}
|
||||
|
||||
private event Action _sheetBegin;
|
||||
@@ -815,28 +317,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnSheetEnd
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_sheetEnd == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-sheet-end" + Id, () =>
|
||||
{
|
||||
_sheetEnd();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-sheet-end", Id);
|
||||
}
|
||||
_sheetEnd += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_sheetEnd -= value;
|
||||
|
||||
if (_sheetEnd == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-sheet-end" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-sheet-end", Id, _sheetEnd, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-sheet-end", Id, _sheetEnd, value);
|
||||
}
|
||||
|
||||
private event Action _sheetEnd;
|
||||
@@ -846,28 +328,8 @@ public class BrowserWindow
|
||||
/// </summary>
|
||||
public event Action OnNewWindowForTab
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_newWindowForTab == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("browserWindow-new-window-for-tab" + Id, () =>
|
||||
{
|
||||
_newWindowForTab();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-browserWindow-new-window-for-tab", Id);
|
||||
}
|
||||
_newWindowForTab += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_newWindowForTab -= value;
|
||||
|
||||
if (_newWindowForTab == null)
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserWindow-new-window-for-tab" + Id);
|
||||
}
|
||||
}
|
||||
add => ApiEventManager.AddEvent("browserWindow-new-window-for-tab", Id, _newWindowForTab, value);
|
||||
remove => ApiEventManager.RemoveEvent("browserWindow-new-window-for-tab", Id, _newWindowForTab, value);
|
||||
}
|
||||
|
||||
private event Action _newWindowForTab;
|
||||
|
||||
@@ -6,6 +6,8 @@ using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.Common;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -19,29 +21,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<TrayClickEventArgs, Rectangle> OnClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_click == null)
|
||||
{
|
||||
BridgeConnector.Socket.On<dynamic>("tray-click-event" + GetHashCode(), (result) =>
|
||||
{
|
||||
var args = ((JArray)result).ToObject<object[]>();
|
||||
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
|
||||
var bounds = ((JObject)args[1]).ToObject<Rectangle>();
|
||||
_click(trayClickEventArgs, bounds);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-click", GetHashCode());
|
||||
}
|
||||
_click += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_click -= value;
|
||||
|
||||
if (_click == null)
|
||||
BridgeConnector.Socket.Off("tray-click-event" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddTrayEvent("tray-click", GetHashCode(), _click, value);
|
||||
remove => ApiEventManager.RemoveTrayEvent("tray-click", GetHashCode(), _click, value);
|
||||
}
|
||||
|
||||
private event Action<TrayClickEventArgs, Rectangle> _click;
|
||||
@@ -51,29 +32,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<TrayClickEventArgs, Rectangle> OnRightClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_rightClick == null)
|
||||
{
|
||||
BridgeConnector.Socket.On<dynamic>("tray-right-click-event" + GetHashCode(), (result) =>
|
||||
{
|
||||
var args = ((JArray)result).ToObject<object[]>();
|
||||
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
|
||||
var bounds = ((JObject)args[1]).ToObject<Rectangle>();
|
||||
_rightClick(trayClickEventArgs, bounds);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-right-click", GetHashCode());
|
||||
}
|
||||
_rightClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_rightClick -= value;
|
||||
|
||||
if (_rightClick == null)
|
||||
BridgeConnector.Socket.Off("tray-right-click-event" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddTrayEvent("tray-right-click", GetHashCode(), _rightClick, value);
|
||||
remove => ApiEventManager.RemoveTrayEvent("tray-right-click", GetHashCode(), _rightClick, value);
|
||||
}
|
||||
|
||||
private event Action<TrayClickEventArgs, Rectangle> _rightClick;
|
||||
@@ -83,29 +43,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<TrayClickEventArgs, Rectangle> OnDoubleClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_doubleClick == null)
|
||||
{
|
||||
BridgeConnector.Socket.On<dynamic>("tray-double-click-event" + GetHashCode(), (result) =>
|
||||
{
|
||||
var args = ((JArray)result).ToObject<object[]>();
|
||||
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
|
||||
var bounds = ((JObject)args[1]).ToObject<Rectangle>();
|
||||
_doubleClick(trayClickEventArgs, bounds);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-double-click", GetHashCode());
|
||||
}
|
||||
_doubleClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_doubleClick -= value;
|
||||
|
||||
if (_doubleClick == null)
|
||||
BridgeConnector.Socket.Off("tray-double-click-event" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddTrayEvent("tray-double-click", GetHashCode(), _doubleClick, value);
|
||||
remove => ApiEventManager.RemoveTrayEvent("tray-double-click", GetHashCode(), _doubleClick, value);
|
||||
}
|
||||
|
||||
private event Action<TrayClickEventArgs, Rectangle> _doubleClick;
|
||||
@@ -115,26 +54,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action OnBalloonShow
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_balloonShow == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-balloon-show-event" + GetHashCode(), () =>
|
||||
{
|
||||
_balloonShow();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-balloon-show", GetHashCode());
|
||||
}
|
||||
_balloonShow += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_balloonShow -= value;
|
||||
|
||||
if (_balloonShow == null)
|
||||
BridgeConnector.Socket.Off("tray-balloon-show-event" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEvent("tray-balloon-show", GetHashCode(), _balloonShow, value);
|
||||
remove => ApiEventManager.RemoveEvent("tray-balloon-show", GetHashCode(), _balloonShow, value);
|
||||
}
|
||||
|
||||
private event Action _balloonShow;
|
||||
@@ -144,26 +65,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action OnBalloonClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_balloonClick == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-balloon-click-event" + GetHashCode(), () =>
|
||||
{
|
||||
_balloonClick();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-balloon-click", GetHashCode());
|
||||
}
|
||||
_balloonClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_balloonClick -= value;
|
||||
|
||||
if (_balloonClick == null)
|
||||
BridgeConnector.Socket.Off("tray-balloon-click-event" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEvent("tray-balloon-click", GetHashCode(), _balloonClick, value);
|
||||
remove => ApiEventManager.RemoveEvent("tray-balloon-click", GetHashCode(), _balloonClick, value);
|
||||
}
|
||||
|
||||
private event Action _balloonClick;
|
||||
@@ -174,26 +77,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action OnBalloonClosed
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_balloonClosed == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-balloon-closed-event" + GetHashCode(), () =>
|
||||
{
|
||||
_balloonClosed();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-balloon-closed", GetHashCode());
|
||||
}
|
||||
_balloonClosed += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_balloonClosed -= value;
|
||||
|
||||
if (_balloonClosed == null)
|
||||
BridgeConnector.Socket.Off("tray-balloon-closed-event" + GetHashCode());
|
||||
}
|
||||
add => ApiEventManager.AddEvent("tray-balloon-closed", GetHashCode(), _balloonClosed, value);
|
||||
remove => ApiEventManager.RemoveEvent("tray-balloon-closed", GetHashCode(), _balloonClosed, value);
|
||||
}
|
||||
|
||||
private event Action _balloonClosed;
|
||||
|
||||
Reference in New Issue
Block a user