diff --git a/src/ElectronNET.API/API/App.cs b/src/ElectronNET.API/API/App.cs index 088ed84a..81b64c89 100644 --- a/src/ElectronNET.API/API/App.cs +++ b/src/ElectronNET.API/API/App.cs @@ -7,7 +7,9 @@ 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 { @@ -39,7 +41,7 @@ public event Action WindowAllClosed } }); - BridgeConnector.Socket.Emit("register-app-window-all-closed-event", GetHashCode()); + BridgeConnector.Socket.Emit("register-app-window-all-closed", GetHashCode()); } _windowAllClosed += value; } @@ -111,7 +113,7 @@ public event Func BeforeQuit } }); - BridgeConnector.Socket.Emit("register-app-before-quit-event", GetHashCode()); + BridgeConnector.Socket.Emit("register-app-before-quit", GetHashCode()); } _beforeQuit += value; } @@ -162,7 +164,7 @@ public event Func WillQuit } }); - BridgeConnector.Socket.Emit("register-app-will-quit-event", GetHashCode()); + BridgeConnector.Socket.Emit("register-app-will-quit", GetHashCode()); } _willQuit += value; } @@ -197,7 +199,7 @@ public event Func Quitting } }); - BridgeConnector.Socket.Emit("register-app-will-quit-event", GetHashCode() + "quitting"); + BridgeConnector.Socket.Emit("register-app-will-quit", GetHashCode() + "quitting"); } _quitting += value; } @@ -217,26 +219,8 @@ public event Func Quitting /// 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.AddEvent("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 @@ public event Action BrowserWindowBlur /// 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.AddEvent("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 @@ public event Action BrowserWindowFocus /// 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.AddEvent("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 @@ public event Action BrowserWindowCreated /// 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.AddEvent("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 @@ public event Action WebContentsCreated /// when Chrome's accessibility support is enabled, otherwise. public event Action 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.AddEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value, (args) => (bool)args); + remove => ApiEventManager.RemoveEvent("app-accessibility-support-changed", GetHashCode(), _accessibilitySupportChanged, value); } private event Action _accessibilitySupportChanged; @@ -408,26 +320,8 @@ internal set /// public event Action 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.AddEvent("app-open-file", GetHashCode(), _openFile, value, (args) => args.ToString()); + remove => ApiEventManager.RemoveEvent("app-open-file", GetHashCode(), _openFile, value); } private event Action _openFile; @@ -439,26 +333,8 @@ public event Action OpenFile /// public event Action 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.AddEvent("app-open-url", GetHashCode(), _openUrl, value, (args) => args.ToString()); + remove => ApiEventManager.RemoveEvent("app-open-url", GetHashCode(), _openUrl, value); } private event Action _openUrl; diff --git a/src/ElectronNET.API/API/AutoUpdater.cs b/src/ElectronNET.API/API/AutoUpdater.cs index da1001fa..b06a5ab9 100644 --- a/src/ElectronNET.API/API/AutoUpdater.cs +++ b/src/ElectronNET.API/API/AutoUpdater.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using ElectronNET.Common; +// ReSharper disable InconsistentNaming namespace ElectronNET.API { @@ -286,26 +288,8 @@ public Dictionary RequestHeaders /// public event Action OnError { - add - { - if (_error == null) - { - BridgeConnector.Socket.On("autoUpdater-error" + GetHashCode(), (message) => - { - _error(message.ToString()); - }); - - BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode()); - } - _error += value; - } - remove - { - _error -= value; - - if (_error == null) - BridgeConnector.Socket.Off("autoUpdater-error" + GetHashCode()); - } + add => ApiEventManager.AddEvent("autoUpdater-error", GetHashCode(), _error, value, (args) => args.ToString()); + remove => ApiEventManager.RemoveEvent("autoUpdater-error", GetHashCode(), _error, value); } private event Action _error; @@ -315,26 +299,8 @@ public event Action OnError /// public event Action OnCheckingForUpdate { - add - { - if (_checkingForUpdate == null) - { - BridgeConnector.Socket.On("autoUpdater-checking-for-update" + GetHashCode(), () => - { - _checkingForUpdate(); - }); - - BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode()); - } - _checkingForUpdate += value; - } - remove - { - _checkingForUpdate -= value; - - if (_checkingForUpdate == null) - BridgeConnector.Socket.Off("autoUpdater-checking-for-update" + GetHashCode()); - } + add => ApiEventManager.AddEvent("autoUpdater-checking-for-update", GetHashCode(), _checkingForUpdate, value); + remove => ApiEventManager.RemoveEvent("autoUpdater-checking-for-update", GetHashCode(), _checkingForUpdate, value); } private event Action _checkingForUpdate; @@ -345,26 +311,8 @@ public event Action OnCheckingForUpdate /// public event Action OnUpdateAvailable { - add - { - if (_updateAvailable == null) - { - BridgeConnector.Socket.On("autoUpdater-update-available" + GetHashCode(), (updateInfo) => - { - _updateAvailable(JObject.Parse(updateInfo.ToString()).ToObject()); - }); - - BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode()); - } - _updateAvailable += value; - } - remove - { - _updateAvailable -= value; - - if (_updateAvailable == null) - BridgeConnector.Socket.Off("autoUpdater-update-available" + GetHashCode()); - } + add => ApiEventManager.AddEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject()); + remove => ApiEventManager.RemoveEvent("autoUpdater-update-available", GetHashCode(), _updateAvailable, value); } private event Action _updateAvailable; @@ -374,26 +322,8 @@ public event Action OnUpdateAvailable /// public event Action OnUpdateNotAvailable { - add - { - if (_updateNotAvailable == null) - { - BridgeConnector.Socket.On("autoUpdater-update-not-available" + GetHashCode(), (updateInfo) => - { - _updateNotAvailable(JObject.Parse(updateInfo.ToString()).ToObject()); - }); - - BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode()); - } - _updateNotAvailable += value; - } - remove - { - _updateNotAvailable -= value; - - if (_updateNotAvailable == null) - BridgeConnector.Socket.Off("autoUpdater-update-not-available" + GetHashCode()); - } + add => ApiEventManager.AddEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value, (args) => JObject.Parse(args.ToString()).ToObject()); + remove => ApiEventManager.RemoveEvent("autoUpdater-update-not-available", GetHashCode(), _updateNotAvailable, value); } private event Action _updateNotAvailable; @@ -403,26 +333,8 @@ public event Action OnUpdateNotAvailable /// public event Action OnDownloadProgress { - add - { - if (_downloadProgress == null) - { - BridgeConnector.Socket.On("autoUpdater-download-progress" + GetHashCode(), (progressInfo) => - { - _downloadProgress(JObject.Parse(progressInfo.ToString()).ToObject()); - }); - - BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode()); - } - _downloadProgress += value; - } - remove - { - _downloadProgress -= value; - - if (_downloadProgress == null) - BridgeConnector.Socket.Off("autoUpdater-download-progress" + GetHashCode()); - } + add => ApiEventManager.AddEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value, (args) => JObject.Parse(args.ToString()).ToObject()); + remove => ApiEventManager.RemoveEvent("autoUpdater-download-progress", GetHashCode(), _downloadProgress, value); } private event Action _downloadProgress; @@ -432,26 +344,8 @@ public event Action OnDownloadProgress /// public event Action OnUpdateDownloaded { - add - { - if (_updateDownloaded == null) - { - BridgeConnector.Socket.On("autoUpdater-update-downloaded" + GetHashCode(), (updateInfo) => - { - _updateDownloaded(JObject.Parse(updateInfo.ToString()).ToObject()); - }); - - BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode()); - } - _updateDownloaded += value; - } - remove - { - _updateDownloaded -= value; - - if (_updateDownloaded == null) - BridgeConnector.Socket.Off("autoUpdater-update-downloaded" + GetHashCode()); - } + add => ApiEventManager.AddEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value, (args) => JObject.Parse(args.ToString()).ToObject()); + remove => ApiEventManager.RemoveEvent("autoUpdater-update-downloaded", GetHashCode(), _updateDownloaded, value); } private event Action _updateDownloaded; diff --git a/src/ElectronNET.API/API/BrowserWindow.cs b/src/ElectronNET.API/API/BrowserWindow.cs index 2fd04a45..25a0b792 100644 --- a/src/ElectronNET.API/API/BrowserWindow.cs +++ b/src/ElectronNET.API/API/BrowserWindow.cs @@ -8,6 +8,8 @@ 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 /// 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 event Action OnReadyToShow /// public event Action 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 _pageTitleUpdated; @@ -92,28 +54,8 @@ public event Action OnPageTitleUpdated /// 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 event Action OnClose /// 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 event Action OnClosed /// 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 event Action OnSessionEnd /// 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 event Action OnUnresponsive /// 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 event Action OnResponsive /// 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 event Action OnBlur /// 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 event Action OnFocus /// 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 event Action OnShow /// 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 event Action OnHide /// 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 event Action OnMaximize /// 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 event Action OnUnmaximize /// 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 event Action OnMinimize /// 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 event Action OnRestore /// 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 event Action OnResize /// 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 event Action OnMove /// 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 event Action OnMoved /// 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 event Action OnEnterFullScreen /// 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 event Action OnLeaveFullScreen /// 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 event Action OnEnterHtmlFullScreen /// 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 event Action OnLeaveHtmlFullScreen /// public event Action 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 _appCommand; @@ -753,28 +295,8 @@ public event Action OnAppCommand /// public event Action 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 _swipe; @@ -784,28 +306,8 @@ public event Action OnSwipe /// 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 event Action OnSheetBegin /// 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 event Action OnSheetEnd /// 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; diff --git a/src/ElectronNET.API/API/NativeTheme.cs b/src/ElectronNET.API/API/NativeTheme.cs index 037a97a6..2dfd2103 100644 --- a/src/ElectronNET.API/API/NativeTheme.cs +++ b/src/ElectronNET.API/API/NativeTheme.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using ElectronNET.API.Entities; using ElectronNET.API.Extensions; +using ElectronNET.Common; namespace ElectronNET.API { @@ -183,28 +184,8 @@ public Task ShouldUseInvertedColorSchemeAsync() /// public event Action Updated { - add - { - if (_updated == null) - { - BridgeConnector.Socket.On("nativeTheme-updated" + GetHashCode(), () => - { - _updated(); - }); - - BridgeConnector.Socket.Emit("register-nativeTheme-updated-event", GetHashCode()); - } - _updated += value; - } - remove - { - _updated -= value; - - if (_updated == null) - { - BridgeConnector.Socket.Off("nativeTheme-updated" + GetHashCode()); - } - } + add => ApiEventManager.AddEvent("nativeTheme-updated", GetHashCode(), _updated, value); + remove => ApiEventManager.RemoveEvent("nativeTheme-updated", GetHashCode(), _updated, value); } private event Action _updated; diff --git a/src/ElectronNET.API/API/PowerMonitor.cs b/src/ElectronNET.API/API/PowerMonitor.cs index 03e68748..a42e5acd 100644 --- a/src/ElectronNET.API/API/PowerMonitor.cs +++ b/src/ElectronNET.API/API/PowerMonitor.cs @@ -1,5 +1,7 @@ using System; using System.Threading.Tasks; +using ElectronNET.Common; +// ReSharper disable InconsistentNaming namespace ElectronNET.API { @@ -13,26 +15,8 @@ public sealed class PowerMonitor /// public event Action OnLockScreen { - add - { - if (_lockScreen == null) - { - BridgeConnector.Socket.On("pm-lock-screen" , () => - { - _lockScreen(); - }); - - BridgeConnector.Socket.Emit("register-pm-lock-screen"); - } - _lockScreen += value; - } - remove - { - _lockScreen -= value; - - if (_lockScreen == null) - BridgeConnector.Socket.Off("pm-lock-screen"); - } + add => ApiEventManager.AddEvent("pm-lock-screen", string.Empty, _lockScreen, value); + remove => ApiEventManager.RemoveEvent("pm-lock-screen", string.Empty, _lockScreen, value); } private event Action _lockScreen; @@ -42,26 +26,8 @@ public event Action OnLockScreen /// public event Action OnUnLockScreen { - add - { - if (_unlockScreen == null) - { - BridgeConnector.Socket.On("pm-unlock-screen", () => - { - _unlockScreen(); - }); - - BridgeConnector.Socket.Emit("register-pm-unlock-screen"); - } - _unlockScreen += value; - } - remove - { - _unlockScreen -= value; - - if (_unlockScreen == null) - BridgeConnector.Socket.Off("pm-unlock-screen"); - } + add => ApiEventManager.AddEvent("pm-unlock-screen", string.Empty, _unlockScreen, value); + remove => ApiEventManager.RemoveEvent("pm-unlock-screen", string.Empty, _unlockScreen, value); } private event Action _unlockScreen; @@ -71,26 +37,8 @@ public event Action OnUnLockScreen /// public event Action OnSuspend { - add - { - if (_suspend == null) - { - BridgeConnector.Socket.On("pm-suspend", () => - { - _suspend(); - }); - - BridgeConnector.Socket.Emit("register-pm-suspend"); - } - _suspend += value; - } - remove - { - _suspend -= value; - - if (_suspend == null) - BridgeConnector.Socket.Off("pm-suspend"); - } + add => ApiEventManager.AddEvent("pm-suspend", string.Empty, _suspend, value); + remove => ApiEventManager.RemoveEvent("pm-suspend", string.Empty, _suspend, value); } private event Action _suspend; @@ -100,26 +48,8 @@ public event Action OnSuspend /// public event Action OnResume { - add - { - if (_resume == null) - { - BridgeConnector.Socket.On("pm-resume", () => - { - _resume(); - }); - - BridgeConnector.Socket.Emit("register-pm-resume"); - } - _resume += value; - } - remove - { - _resume -= value; - - if (_resume == null) - BridgeConnector.Socket.Off("pm-resume"); - } + add => ApiEventManager.AddEvent("pm-resume", string.Empty, _resume, value); + remove => ApiEventManager.RemoveEvent("pm-resume", string.Empty, _resume, value); } private event Action _resume; @@ -129,26 +59,8 @@ public event Action OnResume /// public event Action OnAC { - add - { - if (_onAC == null) - { - BridgeConnector.Socket.On("pm-on-ac", () => - { - _onAC(); - }); - - BridgeConnector.Socket.Emit("register-pm-on-ac"); - } - _onAC += value; - } - remove - { - _onAC -= value; - - if (_onAC == null) - BridgeConnector.Socket.Off("pm-on-ac"); - } + add => ApiEventManager.AddEvent("pm-on-ac", string.Empty, _onAC, value); + remove => ApiEventManager.RemoveEvent("pm-on-ac", string.Empty, _onAC, value); } private event Action _onAC; @@ -158,31 +70,12 @@ public event Action OnAC /// public event Action OnBattery { - add - { - if (_onBattery == null) - { - BridgeConnector.Socket.On("pm-on-battery", () => - { - _onBattery(); - }); - - BridgeConnector.Socket.Emit("register-pm-on-battery"); - } - _onBattery += value; - } - remove - { - _onBattery -= value; - - if (_onBattery == null) - BridgeConnector.Socket.Off("pm-on-battery"); - } + add => ApiEventManager.AddEvent("pm-on-battery", string.Empty, _onBattery, value); + remove => ApiEventManager.RemoveEvent("pm-on-battery", string.Empty, _onBattery, value); } private event Action _onBattery; - - + /// /// Emitted when the system is about to reboot or shut down. If the event handler /// invokes `e.preventDefault()`, Electron will attempt to delay system shutdown in @@ -191,26 +84,8 @@ public event Action OnBattery /// public event Action OnShutdown { - add - { - if (_shutdown == null) - { - BridgeConnector.Socket.On("pm-shutdown", () => - { - _shutdown(); - }); - - BridgeConnector.Socket.Emit("register-pm-shutdown"); - } - _shutdown += value; - } - remove - { - _shutdown -= value; - - if (_shutdown == null) - BridgeConnector.Socket.Off("pm-on-shutdown"); - } + add => ApiEventManager.AddEvent("pm-shutdown", string.Empty, _shutdown, value); + remove => ApiEventManager.RemoveEvent("pm-shutdown", string.Empty, _shutdown, value); } private event Action _shutdown; diff --git a/src/ElectronNET.API/API/Screen.cs b/src/ElectronNET.API/API/Screen.cs index 31cecb5f..8f4ee0c1 100644 --- a/src/ElectronNET.API/API/Screen.cs +++ b/src/ElectronNET.API/API/Screen.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json.Serialization; using System; using System.Threading.Tasks; +using ElectronNET.Common; namespace ElectronNET.API { @@ -17,26 +18,8 @@ public sealed class Screen /// public event Action OnDisplayAdded { - add - { - if (_onDisplayAdded == null) - { - BridgeConnector.Socket.On("screen-display-added-event" + GetHashCode(), (display) => - { - _onDisplayAdded(((JObject)display).ToObject()); - }); - - BridgeConnector.Socket.Emit("register-screen-display-added", GetHashCode()); - } - _onDisplayAdded += value; - } - remove - { - _onDisplayAdded -= value; - - if (_onDisplayAdded == null) - BridgeConnector.Socket.Off("screen-display-added-event" + GetHashCode()); - } + add => ApiEventManager.AddEvent("screen-display-added", GetHashCode(), _onDisplayAdded, value, (args) => ((JObject)args).ToObject()); + remove => ApiEventManager.RemoveEvent("screen-display-added", GetHashCode(), _onDisplayAdded, value); } private event Action _onDisplayAdded; @@ -46,26 +29,8 @@ public event Action OnDisplayAdded /// public event Action OnDisplayRemoved { - add - { - if (_onDisplayRemoved == null) - { - BridgeConnector.Socket.On("screen-display-removed-event" + GetHashCode(), (display) => - { - _onDisplayRemoved(((JObject)display).ToObject()); - }); - - BridgeConnector.Socket.Emit("register-screen-display-removed", GetHashCode()); - } - _onDisplayRemoved += value; - } - remove - { - _onDisplayRemoved -= value; - - if (_onDisplayRemoved == null) - BridgeConnector.Socket.Off("screen-display-removed-event" + GetHashCode()); - } + add => ApiEventManager.AddEvent("screen-display-removed", GetHashCode(), _onDisplayRemoved, value, (args) => ((JObject)args).ToObject()); + remove => ApiEventManager.RemoveEvent("screen-display-removed", GetHashCode(), _onDisplayRemoved, value); } private event Action _onDisplayRemoved; @@ -77,29 +42,8 @@ public event Action OnDisplayRemoved /// public event Action OnDisplayMetricsChanged { - add - { - if (_onDisplayMetricsChanged == null) - { - BridgeConnector.Socket.On("screen-display-metrics-changed-event" + GetHashCode(), (args) => - { - var display = ((JArray)args).First.ToObject(); - var metrics = ((JArray)args).Last.ToObject(); - - _onDisplayMetricsChanged(display, metrics); - }); - - BridgeConnector.Socket.Emit("register-screen-display-metrics-changed", GetHashCode()); - } - _onDisplayMetricsChanged += value; - } - remove - { - _onDisplayMetricsChanged -= value; - - if (_onDisplayMetricsChanged == null) - BridgeConnector.Socket.Off("screen-display-metrics-changed-event" + GetHashCode()); - } + add => ApiEventManager.AddScreenEvent("screen-display-metrics-changed", GetHashCode(), _onDisplayMetricsChanged, value); + remove => ApiEventManager.RemoveScreenEvent("screen-display-metrics-changed", GetHashCode(), _onDisplayMetricsChanged, value); } private event Action _onDisplayMetricsChanged; diff --git a/src/ElectronNET.API/API/Tray.cs b/src/ElectronNET.API/API/Tray.cs index 906a58c7..f4d353d1 100644 --- a/src/ElectronNET.API/API/Tray.cs +++ b/src/ElectronNET.API/API/Tray.cs @@ -6,6 +6,8 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using ElectronNET.Common; +// ReSharper disable InconsistentNaming namespace ElectronNET.API { @@ -19,29 +21,8 @@ public sealed class Tray /// public event Action OnClick { - add - { - if (_click == null) - { - BridgeConnector.Socket.On("tray-click-event" + GetHashCode(), (result) => - { - var args = ((JArray)result).ToObject(); - var trayClickEventArgs = ((JObject)args[0]).ToObject(); - var bounds = ((JObject)args[1]).ToObject(); - _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 _click; @@ -51,29 +32,8 @@ public event Action OnClick /// public event Action OnRightClick { - add - { - if (_rightClick == null) - { - BridgeConnector.Socket.On("tray-right-click-event" + GetHashCode(), (result) => - { - var args = ((JArray)result).ToObject(); - var trayClickEventArgs = ((JObject)args[0]).ToObject(); - var bounds = ((JObject)args[1]).ToObject(); - _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 _rightClick; @@ -83,29 +43,8 @@ public event Action OnRightClick /// public event Action OnDoubleClick { - add - { - if (_doubleClick == null) - { - BridgeConnector.Socket.On("tray-double-click-event" + GetHashCode(), (result) => - { - var args = ((JArray)result).ToObject(); - var trayClickEventArgs = ((JObject)args[0]).ToObject(); - var bounds = ((JObject)args[1]).ToObject(); - _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 _doubleClick; @@ -115,26 +54,8 @@ public event Action OnDoubleClick /// 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 @@ public event Action OnBalloonShow /// 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 @@ public event Action OnBalloonClick /// 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; diff --git a/src/ElectronNET.API/API/WebContents.cs b/src/ElectronNET.API/API/WebContents.cs index daa75fac..deaef8c4 100644 --- a/src/ElectronNET.API/API/WebContents.cs +++ b/src/ElectronNET.API/API/WebContents.cs @@ -4,6 +4,8 @@ using Newtonsoft.Json.Serialization; using System; using System.Threading.Tasks; +using ElectronNET.Common; +// ReSharper disable InconsistentNaming namespace ElectronNET.API; @@ -30,26 +32,8 @@ public class WebContents /// public event Action OnCrashed { - add - { - if (_crashed == null) - { - BridgeConnector.Socket.On("webContents-crashed" + Id, (killed) => - { - _crashed((bool)killed); - }); - - BridgeConnector.Socket.Emit("register-webContents-crashed", Id); - } - _crashed += value; - } - remove - { - _crashed -= value; - - if (_crashed == null) - BridgeConnector.Socket.Off("webContents-crashed" + Id); - } + add => ApiEventManager.AddEvent("webContents-crashed", Id, _crashed, value, (args) => (bool)args); + remove => ApiEventManager.RemoveEvent("webContents-crashed", Id, _crashed, value); } private event Action _crashed; @@ -60,26 +44,8 @@ public event Action OnCrashed /// public event Action OnDidFinishLoad { - add - { - if (_didFinishLoad == null) - { - BridgeConnector.Socket.On("webContents-didFinishLoad" + Id, () => - { - _didFinishLoad(); - }); - - BridgeConnector.Socket.Emit("register-webContents-didFinishLoad", Id); - } - _didFinishLoad += value; - } - remove - { - _didFinishLoad -= value; - - if (_didFinishLoad == null) - BridgeConnector.Socket.Off("webContents-didFinishLoad" + Id); - } + add => ApiEventManager.AddEvent("webContents-didFinishLoad", Id, _didFinishLoad, value); + remove => ApiEventManager.RemoveEvent("webContents-didFinishLoad", Id, _didFinishLoad, value); } private event Action _didFinishLoad; @@ -89,26 +55,8 @@ public event Action OnDidFinishLoad /// public event Action OnDidStartNavigation { - add - { - if (_didStartNavigation == null) - { - BridgeConnector.Socket.On("webContents-didStartNavigation" + Id, (url) => - { - _didStartNavigation(url); - }); - - BridgeConnector.Socket.Emit("register-webContents-didStartNavigation", Id); - } - _didStartNavigation += value; - } - remove - { - _didStartNavigation -= value; - - if (_didStartNavigation == null) - BridgeConnector.Socket.Off("webContents-didStartNavigation" + Id); - } + add => ApiEventManager.AddEvent("webContents-didStartNavigation", Id, _didStartNavigation, value); + remove => ApiEventManager.RemoveEvent("webContents-didStartNavigation", Id, _didStartNavigation, value); } private event Action _didStartNavigation; @@ -119,26 +67,8 @@ public event Action OnDidStartNavigation /// public event Action OnDidNavigate { - add - { - if (_didNavigate == null) - { - BridgeConnector.Socket.On("webContents-didNavigate" + Id, (data) => - { - _didNavigate(data); - }); - - BridgeConnector.Socket.Emit("register-webContents-didNavigate", Id); - } - _didNavigate += value; - } - remove - { - _didNavigate -= value; - - if (_didNavigate == null) - BridgeConnector.Socket.Off("webContents-didNavigate" + Id); - } + add => ApiEventManager.AddEvent("webContents-didNavigate", Id, _didNavigate, value); + remove => ApiEventManager.RemoveEvent("webContents-didNavigate", Id, _didNavigate, value); } private event Action _didNavigate; @@ -149,26 +79,8 @@ public event Action OnDidNavigate /// public event Action OnWillRedirect { - add - { - if (_willRedirect == null) - { - BridgeConnector.Socket.On("webContents-willRedirect" + Id, (url) => - { - _willRedirect(url); - }); - - BridgeConnector.Socket.Emit("register-webContents-willRedirect", Id); - } - _willRedirect += value; - } - remove - { - _willRedirect -= value; - - if (_willRedirect == null) - BridgeConnector.Socket.Off("webContents-willRedirect" + Id); - } + add => ApiEventManager.AddEvent("webContents-willRedirect", Id, _willRedirect, value); + remove => ApiEventManager.RemoveEvent("webContents-willRedirect", Id, _willRedirect, value); } private event Action _willRedirect; @@ -178,56 +90,19 @@ public event Action OnWillRedirect /// public event Action OnDidRedirectNavigation { - add - { - if (_didRedirectNavigation == null) - { - BridgeConnector.Socket.On("webContents-didRedirectNavigation" + Id, (url) => - { - _didRedirectNavigation(url?.ToString()); - }); - - BridgeConnector.Socket.Emit("register-webContents-didRedirectNavigation", Id); - } - _didRedirectNavigation += value; - } - remove - { - _didRedirectNavigation -= value; - - if (_didRedirectNavigation == null) - BridgeConnector.Socket.Off("webContents-didRedirectNavigation" + Id); - } + add => ApiEventManager.AddEvent("webContents-didRedirectNavigation", Id, _didRedirectNavigation, value); + remove => ApiEventManager.RemoveEvent("webContents-didRedirectNavigation", Id, _didRedirectNavigation, value); } private event Action _didRedirectNavigation; - /// /// This event is like OnDidFinishLoad but emitted when the load failed. /// public event Action OnDidFailLoad { - add - { - if (_didFailLoad == null) - { - BridgeConnector.Socket.On("webContents-willRedirect" + Id, (data) => - { - _didFailLoad(((JObject) data).ToObject()); - }); - - BridgeConnector.Socket.Emit("register-webContents-willRedirect", Id); - } - _didFailLoad += value; - } - remove - { - _didFailLoad -= value; - - if (_didFailLoad == null) - BridgeConnector.Socket.Off("webContents-willRedirect" + Id); - } + add => ApiEventManager.AddEvent("webContents-didFailLoad", Id, _didFailLoad, value, (args) => ((JObject)args).ToObject()); + remove => ApiEventManager.RemoveEvent("webContents-didFailLoad", Id, _didFailLoad, value); } private event Action _didFailLoad; @@ -237,27 +112,8 @@ public event Action OnDidFailLoad /// public event Action InputEvent { - add - { - if (_inputEvent == null) - { - BridgeConnector.Socket.On("webContents-input-event" + Id, (eventArgs) => - { - var inputEvent = ((JObject)eventArgs).ToObject(); - _inputEvent(inputEvent); - }); - - BridgeConnector.Socket.Emit("register-webContents-input-event", Id); - } - _inputEvent += value; - } - remove - { - _inputEvent -= value; - - if (_inputEvent == null) - BridgeConnector.Socket.Off("webContents-input-event" + Id); - } + add => ApiEventManager.AddEvent("webContents-input-event", Id, _inputEvent, value, (args) => ((JObject)args).ToObject()); + remove => ApiEventManager.RemoveEvent("webContents-input-event", Id, _inputEvent, value); } private event Action _inputEvent; @@ -267,26 +123,8 @@ public event Action InputEvent /// public event Action OnDomReady { - add - { - if (_domReady == null) - { - BridgeConnector.Socket.On("webContents-domReady" + Id, () => - { - _domReady(); - }); - - BridgeConnector.Socket.Emit("register-webContents-domReady", Id); - } - _domReady += value; - } - remove - { - _domReady -= value; - - if (_domReady == null) - BridgeConnector.Socket.Off("webContents-domReady" + Id); - } + add => ApiEventManager.AddEvent("webContents-domReady", Id, _domReady, value); + remove => ApiEventManager.RemoveEvent("webContents-domReady", Id, _domReady, value); } private event Action _domReady; diff --git a/src/ElectronNET.API/API/WindowManager.cs b/src/ElectronNET.API/API/WindowManager.cs index f5e714d4..771f55df 100644 --- a/src/ElectronNET.API/API/WindowManager.cs +++ b/src/ElectronNET.API/API/WindowManager.cs @@ -51,7 +51,7 @@ public bool IsQuitOnWindowAllClosed get => _isQuitOnWindowAllClosed; set { - BridgeConnector.Socket.Emit("quit-app-window-all-closed-event", value); + BridgeConnector.Socket.Emit("quit-app-window-all-closed", value); _isQuitOnWindowAllClosed = value; } } diff --git a/src/ElectronNET.API/Common/ApiEventManager.cs b/src/ElectronNET.API/Common/ApiEventManager.cs new file mode 100644 index 00000000..4aed5c1e --- /dev/null +++ b/src/ElectronNET.API/Common/ApiEventManager.cs @@ -0,0 +1,99 @@ +using System; +using ElectronNET.API; +using ElectronNET.API.Entities; +using Newtonsoft.Json.Linq; + +namespace ElectronNET.Common; + +internal static class ApiEventManager +{ + internal static void AddEvent(string eventName, object id, Action callback, Action value, string suffix = "") + { + if (callback == null) + { + BridgeConnector.Socket.On(eventName + id, () => { callback(); }); + BridgeConnector.Socket.Emit($"register-{eventName}{suffix}", id); + } + callback += value; + } + + internal static void RemoveEvent(string eventName, object id, Action callback, Action value) + { + callback -= value; + if (callback == null) BridgeConnector.Socket.Off(eventName + id); + } + + internal static void AddEvent(string eventName, object id, Action callback, Action value, Func converter, string suffix = "") + { + if (callback == null) + { + BridgeConnector.Socket.On(eventName + id, (args) => + { + var converted = converter.Invoke(args); + callback(converted); + }); + BridgeConnector.Socket.Emit($"register-{eventName}{suffix}", id); + } + callback += value; + } + + internal static void AddEvent(string eventName, object id, Action callback, Action value) + { + if (callback == null) + { + BridgeConnector.Socket.On(eventName + id, (args) => callback(args)); + BridgeConnector.Socket.Emit($"register-{eventName}", id); + } + callback += value; + } + + internal static void RemoveEvent(string eventName, object id, Action callback, Action value) + { + callback -= value; + if (callback == null) BridgeConnector.Socket.Off(eventName + id); + } + + internal static void AddTrayEvent(string eventName, object id, Action callback, Action value) + { + if (callback == null) + { + BridgeConnector.Socket.On(eventName + id, (result) => + { + var args = ((JArray)result).ToObject(); + var trayClickEventArgs = ((JObject)args[0]).ToObject(); + var bounds = ((JObject)args[1]).ToObject(); + callback(trayClickEventArgs, bounds); + }); + BridgeConnector.Socket.Emit($"register-{eventName}", id); + callback += value; + } + } + + internal static void RemoveTrayEvent(string eventName, object id, Action callback, Action value) + { + callback -= value; + if (callback == null) BridgeConnector.Socket.Off(eventName + id); + } + + internal static void AddScreenEvent(string eventName, object id, Action callback, Action value) + { + if (callback == null) + { + BridgeConnector.Socket.On(eventName + id, (args) => + { + var display = ((JArray)args).First.ToObject(); + var metrics = ((JArray)args).Last.ToObject(); + callback(display, metrics); + }); + BridgeConnector.Socket.Emit($"register-{eventName}", id); + callback += value; + } + } + + internal static void RemoveScreenEvent(string eventName, object id, Action callback, Action value) + { + callback -= value; + if (callback == null) BridgeConnector.Socket.Off(eventName + id); + } + +} \ No newline at end of file diff --git a/src/ElectronNET.Host/api/app.js b/src/ElectronNET.Host/api/app.js index 783b204a..af52917c 100644 --- a/src/ElectronNET.Host/api/app.js +++ b/src/ElectronNET.Host/api/app.js @@ -18,45 +18,45 @@ module.exports = (socket, app) => { electronSocket.emit('app-window-all-closed' + appWindowAllClosedEventId); } }); - socket.on('quit-app-window-all-closed-event', (quit) => { + socket.on('quit-app-window-all-closed', (quit) => { isQuitWindowAllClosed = quit; }); - socket.on('register-app-window-all-closed-event', (id) => { + socket.on('register-app-window-all-closed', (id) => { appWindowAllClosedEventId = id; }); - socket.on('register-app-before-quit-event', (id) => { + socket.on('register-app-before-quit', (id) => { app.on('before-quit', (event) => { event.preventDefault(); electronSocket.emit('app-before-quit' + id); }); }); - socket.on('register-app-will-quit-event', (id) => { + socket.on('register-app-will-quit', (id) => { app.on('will-quit', (event) => { event.preventDefault(); electronSocket.emit('app-will-quit' + id); }); }); - socket.on('register-app-browser-window-blur-event', (id) => { + socket.on('register-app-browser-window-blur', (id) => { app.on('browser-window-blur', () => { electronSocket.emit('app-browser-window-blur' + id); }); }); - socket.on('register-app-browser-window-focus-event', (id) => { + socket.on('register-app-browser-window-focus', (id) => { app.on('browser-window-focus', () => { electronSocket.emit('app-browser-window-focus' + id); }); }); - socket.on('register-app-browser-window-created-event', (id) => { + socket.on('register-app-browser-window-created', (id) => { app.on('browser-window-created', () => { electronSocket.emit('app-browser-window-created' + id); }); }); - socket.on('register-app-web-contents-created-event', (id) => { + socket.on('register-app-web-contents-created', (id) => { app.on('web-contents-created', () => { electronSocket.emit('app-web-contents-created' + id); }); }); - socket.on('register-app-accessibility-support-changed-event', (id) => { + socket.on('register-app-accessibility-support-changed', (id) => { app.on('accessibility-support-changed', (event, accessibilitySupportEnabled) => { electronSocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled); }); diff --git a/src/ElectronNET.Host/api/app.ts b/src/ElectronNET.Host/api/app.ts index 69cb8d96..d93c41d6 100644 --- a/src/ElectronNET.Host/api/app.ts +++ b/src/ElectronNET.Host/api/app.ts @@ -21,15 +21,15 @@ export = (socket: Socket, app: Electron.App) => { } }); - socket.on('quit-app-window-all-closed-event', (quit) => { + socket.on('quit-app-window-all-closed', (quit) => { isQuitWindowAllClosed = quit; }); - socket.on('register-app-window-all-closed-event', (id) => { + socket.on('register-app-window-all-closed', (id) => { appWindowAllClosedEventId = id; }); - socket.on('register-app-before-quit-event', (id) => { + socket.on('register-app-before-quit', (id) => { app.on('before-quit', (event) => { event.preventDefault(); @@ -37,7 +37,7 @@ export = (socket: Socket, app: Electron.App) => { }); }); - socket.on('register-app-will-quit-event', (id) => { + socket.on('register-app-will-quit', (id) => { app.on('will-quit', (event) => { event.preventDefault(); @@ -45,31 +45,31 @@ export = (socket: Socket, app: Electron.App) => { }); }); - socket.on('register-app-browser-window-blur-event', (id) => { + socket.on('register-app-browser-window-blur', (id) => { app.on('browser-window-blur', () => { electronSocket.emit('app-browser-window-blur' + id); }); }); - socket.on('register-app-browser-window-focus-event', (id) => { + socket.on('register-app-browser-window-focus', (id) => { app.on('browser-window-focus', () => { electronSocket.emit('app-browser-window-focus' + id); }); }); - socket.on('register-app-browser-window-created-event', (id) => { + socket.on('register-app-browser-window-created', (id) => { app.on('browser-window-created', () => { electronSocket.emit('app-browser-window-created' + id); }); }); - socket.on('register-app-web-contents-created-event', (id) => { + socket.on('register-app-web-contents-created', (id) => { app.on('web-contents-created', () => { electronSocket.emit('app-web-contents-created' + id); }); }); - socket.on('register-app-accessibility-support-changed-event', (id) => { + socket.on('register-app-accessibility-support-changed', (id) => { app.on('accessibility-support-changed', (event, accessibilitySupportEnabled) => { electronSocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled); }); diff --git a/src/ElectronNET.Host/api/autoUpdater.js b/src/ElectronNET.Host/api/autoUpdater.js index 3ba69caa..9dcc72f1 100644 --- a/src/ElectronNET.Host/api/autoUpdater.js +++ b/src/ElectronNET.Host/api/autoUpdater.js @@ -3,32 +3,32 @@ const electron_updater_1 = require("electron-updater"); let electronSocket; module.exports = (socket) => { electronSocket = socket; - socket.on('register-autoUpdater-error-event', (id) => { + socket.on('register-autoUpdater-error', (id) => { electron_updater_1.autoUpdater.on('error', (error) => { electronSocket.emit('autoUpdater-error' + id, error.message); }); }); - socket.on('register-autoUpdater-checking-for-update-event', (id) => { + socket.on('register-autoUpdater-checking-for-update', (id) => { electron_updater_1.autoUpdater.on('checking-for-update', () => { electronSocket.emit('autoUpdater-checking-for-update' + id); }); }); - socket.on('register-autoUpdater-update-available-event', (id) => { + socket.on('register-autoUpdater-update-available', (id) => { electron_updater_1.autoUpdater.on('update-available', (updateInfo) => { electronSocket.emit('autoUpdater-update-available' + id, updateInfo); }); }); - socket.on('register-autoUpdater-update-not-available-event', (id) => { + socket.on('register-autoUpdater-update-not-available', (id) => { electron_updater_1.autoUpdater.on('update-not-available', (updateInfo) => { electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo); }); }); - socket.on('register-autoUpdater-download-progress-event', (id) => { + socket.on('register-autoUpdater-download-progress', (id) => { electron_updater_1.autoUpdater.on('download-progress', (progressInfo) => { electronSocket.emit('autoUpdater-download-progress' + id, progressInfo); }); }); - socket.on('register-autoUpdater-update-downloaded-event', (id) => { + socket.on('register-autoUpdater-update-downloaded', (id) => { electron_updater_1.autoUpdater.on('update-downloaded', (updateInfo) => { electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo); }); diff --git a/src/ElectronNET.Host/api/autoUpdater.ts b/src/ElectronNET.Host/api/autoUpdater.ts index f72c5d18..14ddfc83 100644 --- a/src/ElectronNET.Host/api/autoUpdater.ts +++ b/src/ElectronNET.Host/api/autoUpdater.ts @@ -5,37 +5,37 @@ let electronSocket; export = (socket: Socket) => { electronSocket = socket; - socket.on('register-autoUpdater-error-event', (id) => { + socket.on('register-autoUpdater-error', (id) => { autoUpdater.on('error', (error) => { electronSocket.emit('autoUpdater-error' + id, error.message); }); }); - socket.on('register-autoUpdater-checking-for-update-event', (id) => { + socket.on('register-autoUpdater-checking-for-update', (id) => { autoUpdater.on('checking-for-update', () => { electronSocket.emit('autoUpdater-checking-for-update' + id); }); }); - socket.on('register-autoUpdater-update-available-event', (id) => { + socket.on('register-autoUpdater-update-available', (id) => { autoUpdater.on('update-available', (updateInfo) => { electronSocket.emit('autoUpdater-update-available' + id, updateInfo); }); }); - socket.on('register-autoUpdater-update-not-available-event', (id) => { + socket.on('register-autoUpdater-update-not-available', (id) => { autoUpdater.on('update-not-available', (updateInfo) => { electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo); }); }); - socket.on('register-autoUpdater-download-progress-event', (id) => { + socket.on('register-autoUpdater-download-progress', (id) => { autoUpdater.on('download-progress', (progressInfo) => { electronSocket.emit('autoUpdater-download-progress' + id, progressInfo); }); }); - socket.on('register-autoUpdater-update-downloaded-event', (id) => { + socket.on('register-autoUpdater-update-downloaded', (id) => { autoUpdater.on('update-downloaded', (updateInfo) => { electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo); }); diff --git a/src/ElectronNET.Host/api/nativeTheme.js b/src/ElectronNET.Host/api/nativeTheme.js index b971f6bb..0864a4e5 100644 --- a/src/ElectronNET.Host/api/nativeTheme.js +++ b/src/ElectronNET.Host/api/nativeTheme.js @@ -22,7 +22,7 @@ module.exports = (socket) => { socket.on('nativeTheme-themeSource', (themeSource) => { electron_1.nativeTheme.themeSource = themeSource; }); - socket.on('register-nativeTheme-updated-event', (id) => { + socket.on('register-nativeTheme-updated', (id) => { electron_1.nativeTheme.on('updated', () => { electronSocket.emit('nativeTheme-updated' + id); }); diff --git a/src/ElectronNET.Host/api/nativeTheme.ts b/src/ElectronNET.Host/api/nativeTheme.ts index 16d22cdc..333fbc90 100644 --- a/src/ElectronNET.Host/api/nativeTheme.ts +++ b/src/ElectronNET.Host/api/nativeTheme.ts @@ -33,7 +33,7 @@ export = (socket: Socket) => { nativeTheme.themeSource = themeSource; }); - socket.on('register-nativeTheme-updated-event', (id) => { + socket.on('register-nativeTheme-updated', (id) => { nativeTheme.on('updated', () => { electronSocket.emit('nativeTheme-updated' + id); }); diff --git a/src/ElectronNET.Host/api/screen.js b/src/ElectronNET.Host/api/screen.js index cfd025a3..f1525a79 100644 --- a/src/ElectronNET.Host/api/screen.js +++ b/src/ElectronNET.Host/api/screen.js @@ -5,17 +5,17 @@ module.exports = (socket) => { electronSocket = socket; socket.on('register-screen-display-added', (id) => { electron_1.screen.on('display-added', (event, display) => { - electronSocket.emit('screen-display-added-event' + id, display); + electronSocket.emit('screen-display-added' + id, display); }); }); socket.on('register-screen-display-removed', (id) => { electron_1.screen.on('display-removed', (event, display) => { - electronSocket.emit('screen-display-removed-event' + id, display); + electronSocket.emit('screen-display-removed' + id, display); }); }); socket.on('register-screen-display-metrics-changed', (id) => { electron_1.screen.on('display-metrics-changed', (event, display, changedMetrics) => { - electronSocket.emit('screen-display-metrics-changed-event' + id, [display, changedMetrics]); + electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]); }); }); socket.on('screen-getCursorScreenPoint', () => { diff --git a/src/ElectronNET.Host/api/screen.js.map b/src/ElectronNET.Host/api/screen.js.map index 1514a5e9..a395faf5 100644 --- a/src/ElectronNET.Host/api/screen.js.map +++ b/src/ElectronNET.Host/api/screen.js.map @@ -1 +1 @@ -{"version":3,"file":"screen.js","sourceRoot":"","sources":["screen.ts"],"names":[],"mappings":";AACA,uCAAkC;AAClC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,CAAC,EAAE,EAAE,EAAE;QAC9C,iBAAM,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC1C,cAAc,CAAC,IAAI,CAAC,4BAA4B,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,iCAAiC,EAAE,CAAC,EAAE,EAAE,EAA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AC,KAAK,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,iBAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACrD,cAAc,CAAC,IAAI,CAAC,wCAAwC,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,SAAS,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,iBAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACrD,cAAc,CAAC,IAAI,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"} \ No newline at end of file diff --git a/src/ElectronNET.Host/api/screen.ts b/src/ElectronNET.Host/api/screen.ts index 7f505b54..1f8795f0 100644 --- a/src/ElectronNET.Host/api/screen.ts +++ b/src/ElectronNET.Host/api/screen.ts @@ -7,19 +7,19 @@ export = (socket: Socket) => { socket.on('register-screen-display-added', (id) => { screen.on('display-added', (event, display) => { - electronSocket.emit('screen-display-added-event' + id, display); + electronSocket.emit('screen-display-added' + id, display); }); }); socket.on('register-screen-display-removed', (id) => { screen.on('display-removed', (event, display) => { - electronSocket.emit('screen-display-removed-event' + id, display); + electronSocket.emit('screen-display-removed' + id, display); }); }); socket.on('register-screen-display-metrics-changed', (id) => { screen.on('display-metrics-changed', (event, display, changedMetrics) => { - electronSocket.emit('screen-display-metrics-changed-event' + id, [display, changedMetrics]); + electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]); }); }); diff --git a/src/ElectronNET.Host/api/tray.js b/src/ElectronNET.Host/api/tray.js index 98fb740c..103acfbf 100644 --- a/src/ElectronNET.Host/api/tray.js +++ b/src/ElectronNET.Host/api/tray.js @@ -7,42 +7,42 @@ module.exports = (socket) => { socket.on('register-tray-click', (id) => { if (tray.value) { tray.value.on('click', (event, bounds) => { - electronSocket.emit('tray-click-event' + id, [event.__proto__, bounds]); + electronSocket.emit('tray-click' + id, [event.__proto__, bounds]); }); } }); socket.on('register-tray-right-click', (id) => { if (tray.value) { tray.value.on('right-click', (event, bounds) => { - electronSocket.emit('tray-right-click-event' + id, [event.__proto__, bounds]); + electronSocket.emit('tray-right-click' + id, [event.__proto__, bounds]); }); } }); socket.on('register-tray-double-click', (id) => { if (tray.value) { tray.value.on('double-click', (event, bounds) => { - electronSocket.emit('tray-double-click-event' + id, [event.__proto__, bounds]); + electronSocket.emit('tray-double-click' + id, [event.__proto__, bounds]); }); } }); socket.on('register-tray-balloon-show', (id) => { if (tray.value) { tray.value.on('balloon-show', () => { - electronSocket.emit('tray-balloon-show-event' + id); + electronSocket.emit('tray-balloon-show' + id); }); } }); socket.on('register-tray-balloon-click', (id) => { if (tray.value) { tray.value.on('balloon-click', () => { - electronSocket.emit('tray-balloon-click-event' + id); + electronSocket.emit('tray-balloon-click' + id); }); } }); socket.on('register-tray-balloon-closed', (id) => { if (tray.value) { tray.value.on('balloon-closed', () => { - electronSocket.emit('tray-balloon-closed-event' + id); + electronSocket.emit('tray-balloon-closed' + id); }); } }); diff --git a/src/ElectronNET.Host/api/tray.js.map b/src/ElectronNET.Host/api/tray.js.map index 8328f0d7..8d6584ba 100644 --- a/src/ElectronNET.Host/api/tray.js.map +++ b/src/ElectronNET.Host/api/tray.js.map @@ -1 +1 @@ -{"version":3,"file":"tray.js","sourceRoot":"","sources":["tray.ts"],"names":[],"mappings":";AACA,uCAAmD;AACnD,IAAI,IAAI,GAA6B,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3F,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,CAAC,EAAE,EAAE,EAAE;QACpC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;Y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AC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChD,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC5D,CAAC;YAED,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBAC1B,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC"} \ No newline at end of file diff --git a/src/ElectronNET.Host/api/tray.ts b/src/ElectronNET.Host/api/tray.ts index 55a0f12e..1481f9a6 100644 --- a/src/ElectronNET.Host/api/tray.ts +++ b/src/ElectronNET.Host/api/tray.ts @@ -8,7 +8,7 @@ export = (socket: Socket) => { socket.on('register-tray-click', (id) => { if (tray.value) { tray.value.on('click', (event, bounds) => { - electronSocket.emit('tray-click-event' + id, [(event).__proto__, bounds]); + electronSocket.emit('tray-click' + id, [(event).__proto__, bounds]); }); } }); @@ -16,7 +16,7 @@ export = (socket: Socket) => { socket.on('register-tray-right-click', (id) => { if (tray.value) { tray.value.on('right-click', (event, bounds) => { - electronSocket.emit('tray-right-click-event' + id, [(event).__proto__, bounds]); + electronSocket.emit('tray-right-click' + id, [(event).__proto__, bounds]); }); } }); @@ -24,7 +24,7 @@ export = (socket: Socket) => { socket.on('register-tray-double-click', (id) => { if (tray.value) { tray.value.on('double-click', (event, bounds) => { - electronSocket.emit('tray-double-click-event' + id, [(event).__proto__, bounds]); + electronSocket.emit('tray-double-click' + id, [(event).__proto__, bounds]); }); } }); @@ -32,7 +32,7 @@ export = (socket: Socket) => { socket.on('register-tray-balloon-show', (id) => { if (tray.value) { tray.value.on('balloon-show', () => { - electronSocket.emit('tray-balloon-show-event' + id); + electronSocket.emit('tray-balloon-show' + id); }); } }); @@ -40,7 +40,7 @@ export = (socket: Socket) => { socket.on('register-tray-balloon-click', (id) => { if (tray.value) { tray.value.on('balloon-click', () => { - electronSocket.emit('tray-balloon-click-event' + id); + electronSocket.emit('tray-balloon-click' + id); }); } }); @@ -48,7 +48,7 @@ export = (socket: Socket) => { socket.on('register-tray-balloon-closed', (id) => { if (tray.value) { tray.value.on('balloon-closed', () => { - electronSocket.emit('tray-balloon-closed-event' + id); + electronSocket.emit('tray-balloon-closed' + id); }); } }); diff --git a/src/ElectronNET.Host/main.js b/src/ElectronNET.Host/main.js index 3c980760..0ea7c602 100644 --- a/src/ElectronNET.Host/main.js +++ b/src/ElectronNET.Host/main.js @@ -328,7 +328,7 @@ function startSocketApiBridge(port) { if (nativeTheme === undefined) nativeTheme = require('./api/nativeTheme')(socket); if (dock === undefined) dock = require('./api/dock')(socket); - socket.on('register-app-open-file-event', (id) => { + socket.on('register-app-open-file', (id) => { global['electronsocket'] = socket; app.on('open-file', (event, file) => { @@ -342,7 +342,7 @@ function startSocketApiBridge(port) { } }); - socket.on('register-app-open-url-event', (id) => { + socket.on('register-app-open-url', (id) => { global['electronsocket'] = socket; app.on('open-url', (event, url) => {