diff --git a/ElectronNET.API/App.cs b/ElectronNET.API/App.cs
index c08bb91..e4849ad 100644
--- a/ElectronNET.API/App.cs
+++ b/ElectronNET.API/App.cs
@@ -2,45 +2,1363 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
-using Quobject.SocketIoClientDotNet.Client;
using System;
+using System.Threading.Tasks;
namespace ElectronNET.API
{
- public static class App
+ public sealed class App
{
- private static Socket _socket;
- private static JsonSerializer _jsonSerializer;
-
- public static IpcMain IpcMain { get; private set; }
-
- public static void OpenWindow(int width, int height, bool show)
+ ///
+ /// Emitted when all windows have been closed.
+ ///
+ /// If you do not subscribe to this event and all windows are closed,
+ /// the default behavior is to quit the app; however, if you subscribe,
+ /// you control whether the app quits or not.If the user pressed Cmd + Q,
+ /// or the developer called app.quit(), Electron will first try to close
+ /// all the windows and then emit the will-quit event, and in this case the
+ /// window-all-closed event would not be emitted.
+ ///
+ public event Action WindowAllClosed
{
- _jsonSerializer = new JsonSerializer()
+ add
{
- ContractResolver = new CamelCasePropertyNamesContractResolver()
- };
+ if (_windowAllClosed == null)
+ {
+ BridgeConnector.Socket.On("app-window-all-closed", () =>
+ {
+ _windowAllClosed();
+ });
- _socket = IO.Socket("http://localhost:" + BridgeSettings.SocketPort);
- _socket.On(Socket.EVENT_CONNECT, () =>
+ BridgeConnector.Socket.Emit("register-app-window-all-closed-event");
+ }
+ _windowAllClosed += value;
+ }
+ remove
{
- Console.WriteLine("Verbunden!");
+ _windowAllClosed -= value;
+ }
+ }
- var browserWindowOptions = new BrowserWindowOptions() {
- Height = height,
- Width = width,
- Show = show
- };
+ private event Action _windowAllClosed;
- _socket.Emit("createBrowserWindow", JObject.FromObject(browserWindowOptions, _jsonSerializer));
+ ///
+ /// Emitted before the application starts closing its windows.
+ ///
+ /// Note: If application quit was initiated by autoUpdater.quitAndInstall() then before-quit is emitted after
+ /// emitting close event on all windows and closing them.
+ ///
+ public event Action BeforeQuit
+ {
+ add
+ {
+ if (_beforeQuit == null)
+ {
+ BridgeConnector.Socket.On("app-before-quit", () =>
+ {
+ _beforeQuit();
+ });
+
+ BridgeConnector.Socket.Emit("register-app-before-quit-event");
+ }
+ _beforeQuit += value;
+ }
+ remove
+ {
+ _beforeQuit -= value;
+ }
+ }
+
+ private event Action _beforeQuit;
+
+ ///
+ /// Emitted when all windows have been closed and the application will quit.
+ ///
+ /// See the description of the window-all-closed event for the differences between the will-quit and
+ /// window-all-closed events.
+ ///
+ public event Action WillQuit
+ {
+ add
+ {
+ if (_willQuit == null)
+ {
+ BridgeConnector.Socket.On("app-will-quit", () =>
+ {
+ _willQuit();
+ });
+
+ BridgeConnector.Socket.Emit("register-app-will-quit-event");
+ }
+ _willQuit += value;
+ }
+ remove
+ {
+ _willQuit -= value;
+ }
+ }
+
+ private event Action _willQuit;
+
+ ///
+ /// Emitted when the application is quitting.
+ ///
+ public event Action Quitting
+ {
+ add
+ {
+ if (_quitting == null)
+ {
+ BridgeConnector.Socket.On("app-quit", () =>
+ {
+ _quitting();
+ });
+
+ BridgeConnector.Socket.Emit("register-app-quit-event");
+ }
+ _quitting += value;
+ }
+ remove
+ {
+ _quitting -= value;
+ }
+ }
+
+ private event Action _quitting;
+
+ ///
+ /// Emitted when a BrowserWindow gets blurred.
+ ///
+ public event Action BrowserWindowBlur
+ {
+ add
+ {
+ if (_browserWindowBlur == null)
+ {
+ BridgeConnector.Socket.On("app-browser-window-blur", () =>
+ {
+ _browserWindowBlur();
+ });
+
+ BridgeConnector.Socket.Emit("register-app-browser-window-blur-event");
+ }
+ _browserWindowBlur += value;
+ }
+ remove
+ {
+ _browserWindowBlur -= value;
+ }
+ }
+
+ private event Action _browserWindowBlur;
+
+ ///
+ /// Emitted when a BrowserWindow gets focused.
+ ///
+ public event Action BrowserWindowFocus
+ {
+ add
+ {
+ if (_browserWindowFocus == null)
+ {
+ BridgeConnector.Socket.On("app-browser-window-focus", () =>
+ {
+ _browserWindowFocus();
+ });
+
+ BridgeConnector.Socket.Emit("register-app-browser-window-focus-event");
+ }
+ _browserWindowFocus += value;
+ }
+ remove
+ {
+ _browserWindowFocus -= value;
+ }
+ }
+
+ private event Action _browserWindowFocus;
+
+ ///
+ /// Emitted when a new BrowserWindow is created.
+ ///
+ public event Action BrowserWindowCreated
+ {
+ add
+ {
+ if (_browserWindowCreated == null)
+ {
+ BridgeConnector.Socket.On("app-browser-window-created", () =>
+ {
+ _browserWindowCreated();
+ });
+
+ BridgeConnector.Socket.Emit("register-app-browser-window-created-event");
+ }
+ _browserWindowCreated += value;
+ }
+ remove
+ {
+ _browserWindowCreated -= value;
+ }
+ }
+
+ private event Action _browserWindowCreated;
+
+ ///
+ /// Emitted when a new webContents is created.
+ ///
+ public event Action WebContentsCreated
+ {
+ add
+ {
+ if (_webContentsCreated == null)
+ {
+ BridgeConnector.Socket.On("app-web-contents-created", () =>
+ {
+ _webContentsCreated();
+ });
+
+ BridgeConnector.Socket.Emit("register-app-web-contents-created-event");
+ }
+ _webContentsCreated += value;
+ }
+ remove
+ {
+ _webContentsCreated -= value;
+ }
+ }
+
+ private event Action _webContentsCreated;
+
+ ///
+ /// Emitted when Chrome’s accessibility support changes.
+ /// This event fires when assistive technologies, such as screen readers, are enabled or disabled.
+ /// See https://www.chromium.org/developers/design-documents/accessibility for more details.
+ ///
+ public event Action AccessibilitySupportChanged
+ {
+ add
+ {
+ if (_accessibilitySupportChanged == null)
+ {
+ BridgeConnector.Socket.On("app-accessibility-support-changed", (state) =>
+ {
+ _accessibilitySupportChanged((bool)state);
+ });
+
+ BridgeConnector.Socket.Emit("register-app-accessibility-support-changed-event");
+ }
+ _accessibilitySupportChanged += value;
+ }
+ remove
+ {
+ _accessibilitySupportChanged -= value;
+ }
+ }
+
+ private event Action _accessibilitySupportChanged;
+
+ internal App() { }
+
+ internal static App Instance
+ {
+ get
+ {
+ if (_app == null)
+ {
+ _app = new App();
+ }
+
+ return _app;
+ }
+ }
+
+ private static App _app;
+
+ private JsonSerializer _jsonSerializer = new JsonSerializer()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver()
+ };
+
+ ///
+ /// Try to close all windows. The before-quit event will be emitted first. If all
+ /// windows are successfully closed, the will-quit event will be emitted and by
+ /// default the application will terminate. This method guarantees that all
+ /// beforeunload and unload event handlers are correctly executed. It is possible
+ /// that a window cancels the quitting by returning false in the beforeunload event
+ /// handler.
+ ///
+ public void Quit()
+ {
+ BridgeConnector.Socket.Emit("appQuit");
+ }
+
+ ///
+ /// All windows will be closed immediately without asking user and
+ /// the before-quit and will-quit events will not be emitted.
+ ///
+ /// Exits immediately with exitCode. exitCode defaults to 0.
+ public void Exit(int exitCode = 0)
+ {
+ BridgeConnector.Socket.Emit("appExit", exitCode);
+ }
+
+ ///
+ /// Relaunches the app when current instance exits. By default the new instance will
+ /// use the same working directory and command line arguments with current instance.
+ /// When args is specified, the args will be passed as command line arguments
+ /// instead. When execPath is specified, the execPath will be executed for relaunch
+ /// instead of current app. Note that this method does not quit the app when
+ /// executed, you have to call app.quit or app.exit after calling app.relaunch to
+ /// make the app restart. When app.relaunch is called for multiple times, multiple
+ /// instances will be started after current instance exited.
+ ///
+ public void Relaunch()
+ {
+ BridgeConnector.Socket.Emit("appRelaunch");
+ }
+
+ ///
+ /// Relaunches the app when current instance exits. By default the new instance will
+ /// use the same working directory and command line arguments with current instance.
+ /// When args is specified, the args will be passed as command line arguments
+ /// instead. When execPath is specified, the execPath will be executed for relaunch
+ /// instead of current app. Note that this method does not quit the app when
+ /// executed, you have to call app.quit or app.exit after calling app.relaunch to
+ /// make the app restart. When app.relaunch is called for multiple times, multiple
+ /// instances will be started after current instance exited.
+ ///
+ ///
+ public void Relaunch(RelaunchOptions relaunchOptions)
+ {
+ BridgeConnector.Socket.Emit("appRelaunch", JObject.FromObject(relaunchOptions, _jsonSerializer));
+ }
+
+ ///
+ /// On Linux, focuses on the first visible window. On macOS, makes the application
+ /// the active app.On Windows, focuses on the application's first window.
+ ///
+ public void Focus()
+ {
+ BridgeConnector.Socket.Emit("appFocus");
+ }
+
+ ///
+ /// Hides all application windows without minimizing them.
+ ///
+ public void Hide()
+ {
+ BridgeConnector.Socket.Emit("appHide");
+ }
+
+ ///
+ /// Shows application windows after they were hidden. Does not automatically focus them.
+ ///
+ public void Show()
+ {
+ BridgeConnector.Socket.Emit("appShow");
+ }
+
+ ///
+ /// The current application directory.
+ ///
+ ///
+ public async Task GetAppPathAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetAppPathCompleted", (path) =>
+ {
+ BridgeConnector.Socket.Off("appGetAppPathCompleted");
+ taskCompletionSource.SetResult(path.ToString());
});
- IpcMain = new IpcMain(_socket);
+ BridgeConnector.Socket.Emit("appGetAppPath");
+
+ return await taskCompletionSource.Task;
}
- public static void CreateNotification(NotificationOptions notificationOptions)
+ ///
+ /// You can request the following paths by the name.
+ ///
+ ///
+ /// A path to a special directory or file associated with name.
+ public async Task GetPathAsync(PathName pathName)
{
- _socket.Emit("createNotification", JObject.FromObject(notificationOptions, _jsonSerializer));
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetPathCompleted", (path) =>
+ {
+ BridgeConnector.Socket.Off("appGetPathCompleted");
+
+ taskCompletionSource.SetResult(path.ToString());
+ });
+
+ BridgeConnector.Socket.Emit("appGetPath", pathName.ToString());
+
+ return await taskCompletionSource.Task;
}
+
+ // TODO: Fertig coden
+ ///
+ /// Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
+ /// and macOS, icons depend on the application associated with file mime type.
+ ///
+ ///
+ ///
+ //public async static Task GetFileIconAsync(string filePath)
+ //{
+ // var taskCompletionSource = new TaskCompletionSource();
+
+ // BridgeConnector.Socket.On("appGetFileIconCompleted", (results) =>
+ // {
+ // BridgeConnector.Socket.Off("appGetFileIconCompleted");
+
+ // byte[] test = ((JArray)results).Last.ToObject();
+
+
+ // //object[] result = results as object[];
+ // //NativeImage nativeImage = (NativeImage)result[1];
+ // //taskCompletionSource.SetResult(nativeImage);
+ // });
+ // BridgeConnector.Socket.Emit("appGetFileIcon", filePath);
+
+ // return await taskCompletionSource.Task;
+ //}
+
+ // TODO: Fertig coden
+
+ ///
+ /// Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
+ /// and macOS, icons depend on the application associated with file mime type.
+ ///
+ ///
+ ///
+ ///
+ //public async static Task GetFileIconAsync(string filePath, FileIconOptions fileIconOptions)
+ //{
+ // var taskCompletionSource = new TaskCompletionSource();
+
+ // BridgeConnector.Socket.On("appGetFileIconCompleted", (results) =>
+ // {
+ // BridgeConnector.Socket.Off("appGetFileIconCompleted");
+
+ // object[] result = results as object[];
+ // NativeImage nativeImage = (NativeImage)result[1];
+ // taskCompletionSource.SetResult(nativeImage);
+ // });
+ // BridgeConnector.Socket.Emit("appGetFileIcon", filePath, JObject.FromObject(fileIconOptions, _jsonSerializer));
+
+ // return await taskCompletionSource.Task;
+ //}
+
+ ///
+ /// Overrides the path to a special directory or file associated with name. If the
+ /// path specifies a directory that does not exist, the directory will be created by
+ /// this method.On failure an Error is thrown.You can only override paths of a
+ /// name defined in app.getPath. By default, web pages' cookies and caches will be
+ /// stored under the userData directory.If you want to change this location, you
+ /// have to override the userData path before the ready event of the app module is emitted.
+ ///
+ ///
+ ///
+ public void SetPath(string name, string path)
+ {
+ BridgeConnector.Socket.Emit("appSetPath", name, path);
+ }
+
+ ///
+ /// The version of the loaded application.
+ /// If no version is found in the application’s package.json file,
+ /// the version of the current bundle or executable is returned.
+ ///
+ ///
+ public async Task GetVersionAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetVersionCompleted", (version) =>
+ {
+ BridgeConnector.Socket.Off("appGetVersionCompleted");
+ taskCompletionSource.SetResult(version.ToString());
+ });
+
+ BridgeConnector.Socket.Emit("appGetVersion");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Usually the name field of package.json is a short lowercased name, according to
+ /// the npm modules spec. You should usually also specify a productName field, which
+ /// is your application's full capitalized name, and which will be preferred over
+ /// name by Electron.
+ ///
+ /// The current application’s name, which is the name in the application’s package.json file.
+ public async Task GetNameAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetNameCompleted", (name) =>
+ {
+ BridgeConnector.Socket.Off("appGetNameCompleted");
+ taskCompletionSource.SetResult(name.ToString());
+ });
+
+ BridgeConnector.Socket.Emit("appGetName");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Overrides the current application's name.
+ ///
+ /// Application's name
+ public void SetName(string name)
+ {
+ BridgeConnector.Socket.Emit("appSetName", name);
+ }
+
+ ///
+ /// The current application locale.
+ /// Note: When distributing your packaged app, you have to also ship the locales
+ /// folder.Note: On Windows you have to call it after the ready events gets emitted.
+ ///
+ ///
+ public async Task GetLocaleAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetLocaleCompleted", (locale) =>
+ {
+ BridgeConnector.Socket.Off("appGetLocaleCompleted");
+ taskCompletionSource.SetResult(locale.ToString());
+ });
+
+ BridgeConnector.Socket.Emit("appGetLocale");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Adds path to the recent documents list. This list is managed by the OS. On
+ /// Windows you can visit the list from the task bar, and on macOS you can visit it
+ /// from dock menu.
+ ///
+ ///
+ public void AddRecentDocument(string path)
+ {
+ BridgeConnector.Socket.Emit("appAddRecentDocument", path);
+ }
+
+ ///
+ /// Clears the recent documents list.
+ ///
+ public void ClearRecentDocuments()
+ {
+ BridgeConnector.Socket.Emit("appClearRecentDocuments");
+ }
+
+ ///
+ /// This method sets the current executable as the default handler for a protocol
+ /// (aka URI scheme). It allows you to integrate your app deeper into the operating
+ /// system.Once registered, all links with your-protocol:// will be opened with the
+ /// current executable. The whole link, including protocol, will be passed to your
+ /// application as a parameter. On Windows you can provide optional parameters path,
+ /// the path to your executable, and args, an array of arguments to be passed to
+ /// your executable when it launches.Note: On macOS, you can only register
+ /// protocols that have been added to your app's info.plist, which can not be
+ /// modified at runtime.You can however change the file with a simple text editor
+ /// or script during build time. Please refer to Apple's documentation for details.
+ /// The API uses the Windows Registry and LSSetDefaultHandlerForURLScheme
+ /// internally.
+ ///
+ /// The name of your protocol, without ://.
+ /// If you want your app to handle electron:// links,
+ /// call this method with electron as the parameter.
+ /// Whether the call succeeded.
+ public async Task SetAsDefaultProtocolClientAsync(string protocol)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appSetAsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appSetAsDefaultProtocolClient", protocol);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method sets the current executable as the default handler for a protocol
+ /// (aka URI scheme). It allows you to integrate your app deeper into the operating
+ /// system.Once registered, all links with your-protocol:// will be opened with the
+ /// current executable. The whole link, including protocol, will be passed to your
+ /// application as a parameter. On Windows you can provide optional parameters path,
+ /// the path to your executable, and args, an array of arguments to be passed to
+ /// your executable when it launches.Note: On macOS, you can only register
+ /// protocols that have been added to your app's info.plist, which can not be
+ /// modified at runtime.You can however change the file with a simple text editor
+ /// or script during build time. Please refer to Apple's documentation for details.
+ /// The API uses the Windows Registry and LSSetDefaultHandlerForURLScheme
+ /// internally.
+ ///
+ /// The name of your protocol, without ://.
+ /// If you want your app to handle electron:// links,
+ /// call this method with electron as the parameter.
+ /// Defaults to process.execPath
+ /// Whether the call succeeded.
+ public async Task SetAsDefaultProtocolClientAsync(string protocol, string path)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appSetAsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appSetAsDefaultProtocolClient", protocol, path);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method sets the current executable as the default handler for a protocol
+ /// (aka URI scheme). It allows you to integrate your app deeper into the operating
+ /// system.Once registered, all links with your-protocol:// will be opened with the
+ /// current executable. The whole link, including protocol, will be passed to your
+ /// application as a parameter. On Windows you can provide optional parameters path,
+ /// the path to your executable, and args, an array of arguments to be passed to
+ /// your executable when it launches.Note: On macOS, you can only register
+ /// protocols that have been added to your app's info.plist, which can not be
+ /// modified at runtime.You can however change the file with a simple text editor
+ /// or script during build time. Please refer to Apple's documentation for details.
+ /// The API uses the Windows Registry and LSSetDefaultHandlerForURLScheme
+ /// internally.
+ ///
+ /// The name of your protocol, without ://.
+ /// If you want your app to handle electron:// links,
+ /// call this method with electron as the parameter.
+ /// Defaults to process.execPath
+ /// Defaults to an empty array
+ /// Whether the call succeeded.
+ public async Task SetAsDefaultProtocolClientAsync(string protocol, string path, string[] args)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appSetAsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appSetAsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appSetAsDefaultProtocolClient", protocol, path, args);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method checks if the current executable as the default handler for a
+ /// protocol(aka URI scheme). If so, it will remove the app as the default handler.
+ ///
+ /// The name of your protocol, without ://.
+ /// Whether the call succeeded.
+ public async Task RemoveAsDefaultProtocolClientAsync(string protocol)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appRemoveAsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appRemoveAsDefaultProtocolClient", protocol);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method checks if the current executable as the default handler for a
+ /// protocol(aka URI scheme). If so, it will remove the app as the default handler.
+ ///
+ /// The name of your protocol, without ://.
+ /// Defaults to process.execPath.
+ /// Whether the call succeeded.
+ public async Task RemoveAsDefaultProtocolClientAsync(string protocol, string path)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appRemoveAsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appRemoveAsDefaultProtocolClient", protocol, path);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method checks if the current executable as the default handler for a
+ /// protocol(aka URI scheme). If so, it will remove the app as the default handler.
+ ///
+ /// The name of your protocol, without ://.
+ /// Defaults to process.execPath.
+ /// Defaults to an empty array.
+ /// Whether the call succeeded.
+ public async Task RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appRemoveAsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appRemoveAsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appRemoveAsDefaultProtocolClient", protocol, path, args);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method checks if the current executable is the default handler for a
+ /// protocol(aka URI scheme). If so, it will return true. Otherwise, it will return
+ /// false. Note: On macOS, you can use this method to check if the app has been
+ /// registered as the default protocol handler for a protocol.You can also verify
+ /// this by checking ~/Library/Preferences/com.apple.LaunchServices.plist on the
+ /// macOS machine.Please refer to Apple's documentation for details. The API uses
+ /// the Windows Registry and LSCopyDefaultHandlerForURLScheme internally.
+ ///
+ /// The name of your protocol, without ://.
+ /// Returns Boolean
+ public async Task IsDefaultProtocolClientAsync(string protocol)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appIsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appIsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appIsDefaultProtocolClient", protocol);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method checks if the current executable is the default handler for a
+ /// protocol(aka URI scheme). If so, it will return true. Otherwise, it will return
+ /// false. Note: On macOS, you can use this method to check if the app has been
+ /// registered as the default protocol handler for a protocol.You can also verify
+ /// this by checking ~/Library/Preferences/com.apple.LaunchServices.plist on the
+ /// macOS machine.Please refer to Apple's documentation for details. The API uses
+ /// the Windows Registry and LSCopyDefaultHandlerForURLScheme internally.
+ ///
+ /// The name of your protocol, without ://.
+ /// Defaults to process.execPath.
+ /// Returns Boolean
+ public async Task IsDefaultProtocolClientAsync(string protocol, string path)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appIsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appIsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appIsDefaultProtocolClient", protocol, path);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// This method checks if the current executable is the default handler for a
+ /// protocol(aka URI scheme). If so, it will return true. Otherwise, it will return
+ /// false. Note: On macOS, you can use this method to check if the app has been
+ /// registered as the default protocol handler for a protocol.You can also verify
+ /// this by checking ~/Library/Preferences/com.apple.LaunchServices.plist on the
+ /// macOS machine.Please refer to Apple's documentation for details. The API uses
+ /// the Windows Registry and LSCopyDefaultHandlerForURLScheme internally.
+ ///
+ /// The name of your protocol, without ://.
+ /// Defaults to process.execPath.
+ /// Defaults to an empty array.
+ /// Returns Boolean
+ public async Task IsDefaultProtocolClientAsync(string protocol, string path, string[] args)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appIsDefaultProtocolClientCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appIsDefaultProtocolClientCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appIsDefaultProtocolClient", protocol, path, args);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Adds tasks to the Tasks category of the JumpList on Windows. tasks is an array
+ /// of Task objects.Note: If you'd like to customize the Jump List even more use
+ /// app.setJumpList(categories) instead.
+ ///
+ /// Array of Task objects.
+ /// Whether the call succeeded.
+ public async Task SetUserTasksAsync(UserTask[] userTasks)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appSetUserTasksCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appSetUserTasksCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appSetUserTasks", JObject.FromObject(userTasks, _jsonSerializer));
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Jump List settings for the application.
+ ///
+ ///
+ public async Task GetJumpListSettingsAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetJumpListSettingsCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appGetJumpListSettingsCompleted");
+ taskCompletionSource.SetResult(JObject.Parse(success.ToString()).ToObject());
+ });
+
+ BridgeConnector.Socket.Emit("appGetJumpListSettings");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets or removes a custom Jump List for the application, and returns one of the
+ /// following strings: If categories is null the previously set custom Jump List(if
+ /// any) will be replaced by the standard Jump List for the app(managed by
+ /// Windows). Note: If a JumpListCategory object has neither the type nor the name
+ /// property set then its type is assumed to be tasks.If the name property is set
+ /// but the type property is omitted then the type is assumed to be custom. Note:
+ /// Users can remove items from custom categories, and Windows will not allow a
+ /// removed item to be added back into a custom category until after the next
+ /// successful call to app.setJumpList(categories). Any attempt to re-add a removed
+ /// item to a custom category earlier than that will result in the entire custom
+ /// category being omitted from the Jump List. The list of removed items can be
+ /// obtained using app.getJumpListSettings().
+ ///
+ ///
+ public void SetJumpList(JumpListCategory[] jumpListCategories)
+ {
+ BridgeConnector.Socket.Emit("appSetJumpList", JObject.FromObject(jumpListCategories, _jsonSerializer));
+ }
+
+ ///
+ /// This method makes your application a Single Instance Application - instead of
+ /// allowing multiple instances of your app to run, this will ensure that only a
+ /// single instance of your app is running, and other instances signal this instance
+ /// and exit.callback will be called by the first instance with callback(argv,
+ /// workingDirectory) when a second instance has been executed.argv is an Array of
+ /// the second instance's command line arguments, and workingDirectory is its
+ /// current working directory.Usually applications respond to this by making their
+ /// primary window focused and non-minimized.The callback is guaranteed to be
+ /// executed after the ready event of app gets emitted.This method returns false if
+ /// your process is the primary instance of the application and your app should
+ /// continue loading.And returns true if your process has sent its parameters to
+ /// another instance, and you should immediately quit.On macOS the system enforces
+ /// single instance automatically when users try to open a second instance of your
+ /// app in Finder, and the open-file and open-url events will be emitted for that.
+ /// However when users start your app in command line the system's single instance
+ /// mechanism will be bypassed and you have to use this method to ensure single
+ /// instance.
+ ///
+ /// Lambda with an array of the second instance’s command line arguments.
+ /// The second parameter is the working directory path.
+ /// This method returns false if your process is the primary instance of
+ /// the application and your app should continue loading. And returns true if your
+ /// process has sent its parameters to another instance, and you should immediately quit.
+ public async Task MakeSingleInstanceAsync(Action newInstanceOpened)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appMakeSingleInstanceCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appMakeSingleInstanceCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Off("newInstanceOpened");
+ BridgeConnector.Socket.On("newInstanceOpened", (result) =>
+ {
+ JArray results = (JArray)result;
+ string[] args = results.First.ToObject();
+ string workdirectory = results.Last.ToObject();
+
+ newInstanceOpened(args, workdirectory);
+ });
+
+ BridgeConnector.Socket.Emit("appMakeSingleInstance");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Releases all locks that were created by makeSingleInstance. This will allow
+ /// multiple instances of the application to once again run side by side.
+ ///
+ public void ReleaseSingleInstance()
+ {
+ BridgeConnector.Socket.Emit("appReleaseSingleInstance");
+ }
+
+ ///
+ /// Creates an NSUserActivity and sets it as the current activity. The activity is
+ /// eligible for Handoff to another device afterward.
+ ///
+ /// Uniquely identifies the activity. Maps to NSUserActivity.activityType.
+ /// App-specific state to store for use by another device.
+ public void SetUserActivity(string type, object userInfo)
+ {
+ BridgeConnector.Socket.Emit("appSetUserActivity", type, userInfo);
+ }
+
+ ///
+ /// Creates an NSUserActivity and sets it as the current activity. The activity is
+ /// eligible for Handoff to another device afterward.
+ ///
+ /// Uniquely identifies the activity. Maps to NSUserActivity.activityType.
+ /// App-specific state to store for use by another device.
+ /// The webpage to load in a browser if no suitable app is installed on the resuming device. The scheme must be http or https.
+ public void SetUserActivity(string type, object userInfo, string webpageURL)
+ {
+ BridgeConnector.Socket.Emit("appSetUserActivity", type, userInfo, webpageURL);
+ }
+
+ ///
+ /// The type of the currently running activity.
+ ///
+ ///
+ public async Task GetCurrentActivityTypeAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetCurrentActivityTypeCompleted", (activityType) =>
+ {
+ BridgeConnector.Socket.Off("appGetCurrentActivityTypeCompleted");
+ taskCompletionSource.SetResult(activityType.ToString());
+ });
+
+ BridgeConnector.Socket.Emit("appGetCurrentActivityType");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Changes the Application User Model ID to id.
+ ///
+ ///
+ public void SetAppUserModelId(string id)
+ {
+ BridgeConnector.Socket.Emit("appSetAppUserModelId", id);
+ }
+
+ ///
+ /// Imports the certificate in pkcs12 format into the platform certificate store.
+ /// callback is called with the result of import operation, a value of 0 indicates
+ /// success while any other value indicates failure according to chromium net_error_list.
+ ///
+ ///
+ /// Result of import. Value of 0 indicates success.
+ public async Task ImportCertificateAsync(ImportCertificateOptions options)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appImportCertificateCompleted", (result) =>
+ {
+ BridgeConnector.Socket.Off("appImportCertificateCompleted");
+ taskCompletionSource.SetResult((int)result);
+ });
+
+ BridgeConnector.Socket.Emit("appImportCertificate", JObject.FromObject(options, _jsonSerializer));
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Memory and cpu usage statistics of all the processes associated with the app.
+ ///
+ ///
+ public async Task GetAppMetricsAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetAppMetricsCompleted", (result) =>
+ {
+ BridgeConnector.Socket.Off("appGetAppMetricsCompleted");
+ var processMetrics = ((JArray)result).ToObject();
+
+ taskCompletionSource.SetResult(processMetrics);
+ });
+
+ BridgeConnector.Socket.Emit("appGetAppMetrics");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// The Graphics Feature Status from chrome://gpu/.
+ ///
+ ///
+ public async Task GetGpuFeatureStatusAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetGpuFeatureStatusCompleted", (result) =>
+ {
+ BridgeConnector.Socket.Off("appGetGpuFeatureStatusCompleted");
+ var gpuFeatureStatus = ((JObject)result).ToObject();
+
+ taskCompletionSource.SetResult(gpuFeatureStatus);
+ });
+
+ BridgeConnector.Socket.Emit("appGetGpuFeatureStatus");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets the counter badge for current app. Setting the count to 0 will hide the
+ /// badge. On macOS it shows on the dock icon. On Linux it only works for Unity
+ /// launcher, Note: Unity launcher requires the existence of a.desktop file to
+ /// work, for more information please read Desktop Environment Integration.
+ ///
+ ///
+ /// Whether the call succeeded.
+ public async Task SetBadgeCountAsync(int count)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appSetBadgeCountCompleted", (success) =>
+ {
+ BridgeConnector.Socket.Off("appSetBadgeCountCompleted");
+ taskCompletionSource.SetResult((bool)success);
+ });
+
+ BridgeConnector.Socket.Emit("appSetBadgeCount", count);
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// The current value displayed in the counter badge.
+ ///
+ ///
+ public async Task GetBadgeCountAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetBadgeCountCompleted", (count) =>
+ {
+ BridgeConnector.Socket.Off("appGetBadgeCountCompleted");
+ taskCompletionSource.SetResult((int)count);
+ });
+
+ BridgeConnector.Socket.Emit("appGetBadgeCount");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Whether the current desktop environment is Unity launcher.
+ ///
+ ///
+ public async Task IsUnityRunningAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appIsUnityRunningCompleted", (isUnityRunning) =>
+ {
+ BridgeConnector.Socket.Off("appIsUnityRunningCompleted");
+ taskCompletionSource.SetResult((bool)isUnityRunning);
+ });
+
+ BridgeConnector.Socket.Emit("appIsUnityRunning");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// If you provided path and args options to app.setLoginItemSettings then you need
+ /// to pass the same arguments here for openAtLogin to be set correctly. Note: This
+ /// API has no effect on MAS builds.
+ ///
+ ///
+ public async Task GetLoginItemSettingsAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
+ {
+ BridgeConnector.Socket.Off("appGetLoginItemSettingsCompleted");
+ taskCompletionSource.SetResult((LoginItemSettings)loginItemSettings);
+ });
+
+ BridgeConnector.Socket.Emit("appGetLoginItemSettings");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// If you provided path and args options to app.setLoginItemSettings then you need
+ /// to pass the same arguments here for openAtLogin to be set correctly. Note: This
+ /// API has no effect on MAS builds.
+ ///
+ ///
+ ///
+ public async Task GetLoginItemSettingsAsync(LoginItemSettingsOptions options)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
+ {
+ BridgeConnector.Socket.Off("appGetLoginItemSettingsCompleted");
+ taskCompletionSource.SetResult((LoginItemSettings)loginItemSettings);
+ });
+
+ BridgeConnector.Socket.Emit("appGetLoginItemSettings", JObject.FromObject(options, _jsonSerializer));
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Set the app's login item settings. To work with Electron's autoUpdater on
+ /// Windows, which uses Squirrel, you'll want to set the launch path to Update.exe,
+ /// and pass arguments that specify your application name.
+ ///
+ ///
+ public void SetLoginItemSettings(LoginSettings loginSettings)
+ {
+ BridgeConnector.Socket.Emit("appSetLoginItemSettings", JObject.FromObject(loginSettings, _jsonSerializer));
+ }
+
+ ///
+ /// This API will return true if the use of assistive technologies,
+ /// such as screen readers, has been detected.
+ /// See https://www.chromium.org/developers/design-documents/accessibility for more details.
+ ///
+ /// true if Chrome’s accessibility support is enabled, false otherwise.
+ public async Task IsAccessibilitySupportEnabledAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appIsAccessibilitySupportEnabledCompleted", (isAccessibilitySupportEnabled) =>
+ {
+ BridgeConnector.Socket.Off("appIsAccessibilitySupportEnabledCompleted");
+ taskCompletionSource.SetResult((bool)isAccessibilitySupportEnabled);
+ });
+
+ BridgeConnector.Socket.Emit("appIsAccessibilitySupportEnabled");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Set the about panel options. This will override the values defined in the app's
+ /// .plist file. See the Apple docs for more details.
+ ///
+ ///
+ public void SetAboutPanelOptions(AboutPanelOptions options)
+ {
+ BridgeConnector.Socket.Emit("appSetAboutPanelOptions", JObject.FromObject(options, _jsonSerializer));
+ }
+
+ ///
+ /// Append a switch (with optional value) to Chromium's command line. Note: This
+ /// will not affect process.argv, and is mainly used by developers to control some
+ /// low-level Chromium behaviors.
+ ///
+ /// A command-line switch.
+ public void CommandLineAppendSwitch(string theSwtich)
+ {
+ BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", theSwtich);
+ }
+
+ ///
+ /// Append a switch (with optional value) to Chromium's command line. Note: This
+ /// will not affect process.argv, and is mainly used by developers to control some
+ /// low-level Chromium behaviors.
+ ///
+ /// A command-line switch.
+ /// A value for the given switch.
+ public void CommandLineAppendSwitch(string theSwtich, string value)
+ {
+ BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", theSwtich, value);
+ }
+
+ ///
+ /// Append an argument to Chromium's command line. The argument will be quoted
+ /// correctly.Note: This will not affect process.argv.
+ ///
+ /// The argument to append to the command line.
+ public void CommandLineAppendArgument(string value)
+ {
+ BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
+ }
+
+ ///
+ /// Enables mixed sandbox mode on the app. This method can only be called before app is ready.
+ ///
+ public void EnableMixedSandbox()
+ {
+ BridgeConnector.Socket.Emit("appEnableMixedSandbox");
+ }
+
+ ///
+ /// When critical is passed, the dock icon will bounce until either the application
+ /// becomes active or the request is canceled.When informational is passed, the
+ /// dock icon will bounce for one second.However, the request remains active until
+ /// either the application becomes active or the request is canceled.
+ ///
+ ///
+ ///
+ public async Task DockBounceAsync(DockBounceType type)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appDockBounceCompleted", (id) =>
+ {
+ BridgeConnector.Socket.Off("appDockBounceCompleted");
+ taskCompletionSource.SetResult((int)id);
+ });
+
+ BridgeConnector.Socket.Emit("appDockBounce", type.ToString());
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Cancel the bounce of id.
+ ///
+ ///
+ public void DockCancelBounce(int id)
+ {
+ BridgeConnector.Socket.Emit("appDockCancelBounce", id);
+ }
+
+ ///
+ /// Bounces the Downloads stack if the filePath is inside the Downloads folder.
+ ///
+ ///
+ public void DockDownloadFinished(string filePath)
+ {
+ BridgeConnector.Socket.Emit("appDockDownloadFinished", filePath);
+ }
+
+ ///
+ /// Sets the string to be displayed in the dock’s badging area.
+ ///
+ ///
+ public void DockSetBadge(string text)
+ {
+ BridgeConnector.Socket.Emit("appDockSetBadge", text);
+ }
+
+ ///
+ /// Gets the string to be displayed in the dock’s badging area.
+ ///
+ ///
+ public async Task DockGetBadgeAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appDockGetBadgeCompleted", (text) =>
+ {
+ BridgeConnector.Socket.Off("appDockGetBadgeCompleted");
+ taskCompletionSource.SetResult((string)text);
+ });
+
+ BridgeConnector.Socket.Emit("appDockGetBadge");
+
+ return await taskCompletionSource.Task;
+ }
+
+ ///
+ /// Hides the dock icon.
+ ///
+ public void DockHide()
+ {
+ BridgeConnector.Socket.Emit("appDockHide");
+ }
+
+ ///
+ /// Shows the dock icon.
+ ///
+ public void DockShow()
+ {
+ BridgeConnector.Socket.Emit("appDockShow");
+ }
+
+ ///
+ /// Whether the dock icon is visible. The app.dock.show() call is asynchronous
+ /// so this method might not return true immediately after that call.
+ ///
+ ///
+ public async Task DockIsVisibleAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("appDockIsVisibleCompleted", (isVisible) =>
+ {
+ BridgeConnector.Socket.Off("appDockIsVisibleCompleted");
+ taskCompletionSource.SetResult((bool)isVisible);
+ });
+
+ BridgeConnector.Socket.Emit("appDockIsVisible");
+
+ return await taskCompletionSource.Task;
+ }
+
+ // TODO: Menu lösung muss gemacht werden und imeplementiert
+ ///
+ /// Sets the application's dock menu.
+ ///
+ public void DockSetMenu()
+ {
+ BridgeConnector.Socket.Emit("appDockSetMenu");
+ }
+
+ ///
+ /// Sets the image associated with this dock icon.
+ ///
+ ///
+ public void DockSetIcon(string image)
+ {
+ BridgeConnector.Socket.Emit("appDockSetIcon", image);
+ }
+
+ ///
+ /// Sets the image associated with this dock icon.
+ ///
+ ///
+ //public static void DockSetIcon(NativeImage image)
+ //{
+ // BridgeConnector.Socket.Emit("appDockSetIcon", JObject.FromObject(image, _jsonSerializer));
+ //}
}
}
diff --git a/ElectronNET.API/BridgeConnector.cs b/ElectronNET.API/BridgeConnector.cs
new file mode 100644
index 0000000..bac492d
--- /dev/null
+++ b/ElectronNET.API/BridgeConnector.cs
@@ -0,0 +1,19 @@
+using Quobject.SocketIoClientDotNet.Client;
+using System;
+
+namespace ElectronNET.API
+{
+ internal static class BridgeConnector
+ {
+ public static Socket Socket;
+
+ public static void StartConnection()
+ {
+ Socket = IO.Socket("http://localhost:" + BridgeSettings.SocketPort);
+ Socket.On(Socket.EVENT_CONNECT, () =>
+ {
+ Console.WriteLine("BridgeConnector connected!");
+ });
+ }
+ }
+}
diff --git a/ElectronNET.API/BrowserWindow.cs b/ElectronNET.API/BrowserWindow.cs
new file mode 100644
index 0000000..790f0f0
--- /dev/null
+++ b/ElectronNET.API/BrowserWindow.cs
@@ -0,0 +1,612 @@
+using ElectronNET.API.Entities;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json.Serialization;
+using System.Threading.Tasks;
+
+namespace ElectronNET.API
+{
+ public class BrowserWindow
+ {
+ public int Id { get; private set; }
+
+ internal BrowserWindow(int id) {
+ Id = id;
+ }
+
+ ///
+ /// Force closing the window, the unload and beforeunload event won’t be
+ /// emitted for the web page, and close event will also not be emitted
+ /// for this window, but it guarantees the closed event will be emitted.
+ ///
+ public void Destroy()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-destroy", Id);
+ }
+
+ ///
+ /// Try to close the window. This has the same effect as a user manually
+ /// clicking the close button of the window. The web page may cancel the close though.
+ ///
+ public void Close()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-close", Id);
+ }
+
+ ///
+ /// Focuses on the window.
+ ///
+ public void Focus()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-focus", Id);
+ }
+
+ ///
+ /// Removes focus from the window.
+ ///
+ public void Blur()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-blur", Id);
+ }
+
+ ///
+ /// Whether the window is focused.
+ ///
+ ///
+ public Task IsFocusedAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isFocused-completed", (isFocused) => {
+ BridgeConnector.Socket.Off("browserWindow-isFocused-completed");
+
+ taskCompletionSource.SetResult((bool)isFocused);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isFocused", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Whether the window is destroyed.
+ ///
+ ///
+ public Task IsDestroyedAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isDestroyed-completed", (isDestroyed) => {
+ BridgeConnector.Socket.Off("browserWindow-isDestroyed-completed");
+
+ taskCompletionSource.SetResult((bool)isDestroyed);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isDestroyed", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Shows and gives focus to the window.
+ ///
+ public void Show()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-show", Id);
+ }
+
+ ///
+ /// Shows the window but doesn’t focus on it.
+ ///
+ public void ShowInactive()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-showInactive", Id);
+ }
+
+ ///
+ /// Hides the window.
+ ///
+ public void Hide()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-hide", Id);
+ }
+
+ ///
+ /// Whether the window is visible to the user.
+ ///
+ ///
+ public Task IsVisibleAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isVisible-completed", (isVisible) => {
+ BridgeConnector.Socket.Off("browserWindow-isVisible-completed");
+
+ taskCompletionSource.SetResult((bool)isVisible);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isVisible", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Whether current window is a modal window.
+ ///
+ ///
+ public Task IsModalAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isModal-completed", (isModal) => {
+ BridgeConnector.Socket.Off("browserWindow-isModal-completed");
+
+ taskCompletionSource.SetResult((bool)isModal);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isModal", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Maximizes the window. This will also show (but not focus) the window if it isn’t being displayed already.
+ ///
+ public void Maximize()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-maximize", Id);
+ }
+
+ ///
+ /// Unmaximizes the window.
+ ///
+ public void Unmaximize()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-unmaximize", Id);
+ }
+
+ ///
+ /// Whether the window is maximized.
+ ///
+ ///
+ public Task IsMaximizedAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isMaximized-completed", (isMaximized) => {
+ BridgeConnector.Socket.Off("browserWindow-isMaximized-completed");
+
+ taskCompletionSource.SetResult((bool)isMaximized);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isMaximized", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Minimizes the window. On some platforms the minimized window will be shown in the Dock.
+ ///
+ public void Minimize()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-minimize", Id);
+ }
+
+ ///
+ /// Restores the window from minimized state to its previous state.
+ ///
+ public void Restore()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-restore", Id);
+ }
+
+ ///
+ /// Whether the window is minimized.
+ ///
+ ///
+ public Task IsMinimizedAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isMinimized-completed", (isMinimized) => {
+ BridgeConnector.Socket.Off("browserWindow-isMinimized-completed");
+
+ taskCompletionSource.SetResult((bool)isMinimized);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isMinimized", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets whether the window should be in fullscreen mode.
+ ///
+ public void SetFullScreen(bool flag)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setFullScreen", Id, flag);
+ }
+
+ ///
+ /// Whether the window is in fullscreen mode.
+ ///
+ ///
+ public Task IsFullScreenAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isFullScreen-completed", (isFullScreen) => {
+ BridgeConnector.Socket.Off("browserWindow-isFullScreen-completed");
+
+ taskCompletionSource.SetResult((bool)isFullScreen);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isFullScreen", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// This will make a window maintain an aspect ratio. The extra size allows a developer to have space,
+ /// specified in pixels, not included within the aspect ratio calculations. This API already takes into
+ /// account the difference between a window’s size and its content size.
+ ///
+ /// Consider a normal window with an HD video player and associated controls.Perhaps there are 15 pixels
+ /// of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below
+ /// the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within
+ /// the player itself we would call this function with arguments of 16/9 and[40, 50]. The second argument
+ /// doesn’t care where the extra width and height are within the content view–only that they exist. Just
+ /// sum any extra width and height areas you have within the overall content view.
+ ///
+ /// The aspect ratio to maintain for some portion of the content view.
+ /// The extra size not to be included while maintaining the aspect ratio.
+ public void SetAspectRatio(int aspectRatio, Size extraSize)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setAspectRatio", Id, aspectRatio, JObject.FromObject(extraSize, _jsonSerializer));
+ }
+
+ ///
+ /// Uses Quick Look to preview a file at a given path.
+ ///
+ /// The absolute path to the file to preview with QuickLook. This is important as
+ /// Quick Look uses the file name and file extension on the path to determine the content type of the
+ /// file to open.
+ public void PreviewFile(string path)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-previewFile", Id, path);
+ }
+
+ ///
+ /// Uses Quick Look to preview a file at a given path.
+ ///
+ /// The absolute path to the file to preview with QuickLook. This is important as
+ /// Quick Look uses the file name and file extension on the path to determine the content type of the
+ /// file to open.
+ /// The name of the file to display on the Quick Look modal view. This is
+ /// purely visual and does not affect the content type of the file. Defaults to path.
+ public void PreviewFile(string path, string displayname)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-previewFile", Id, path, displayname);
+ }
+
+ ///
+ /// Closes the currently open Quick Look panel.
+ ///
+ public void CloseFilePreview()
+ {
+ BridgeConnector.Socket.Emit("browserWindow-closeFilePreview", Id);
+ }
+
+ ///
+ /// Resizes and moves the window to the supplied bounds
+ ///
+ ///
+ public void SetBounds(Rectangle bounds)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setBounds", Id, JObject.FromObject(bounds, _jsonSerializer));
+ }
+
+ ///
+ /// Resizes and moves the window to the supplied bounds
+ ///
+ ///
+ ///
+ public void SetBounds(Rectangle bounds, bool animate)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setBounds", Id, JObject.FromObject(bounds, _jsonSerializer), animate);
+ }
+
+ public Task GetBoundsAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-getBounds-completed", (getBounds) => {
+ BridgeConnector.Socket.Off("browserWindow-getBounds-completed");
+
+ taskCompletionSource.SetResult(((JObject)getBounds).ToObject());
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-getBounds", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.
+ ///
+ ///
+ public void SetContentBounds(Rectangle bounds)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setContentBounds", Id, JObject.FromObject(bounds, _jsonSerializer));
+ }
+
+ ///
+ /// Resizes and moves the window’s client area (e.g. the web page) to the supplied bounds.
+ ///
+ ///
+ ///
+ public void SetContentBounds(Rectangle bounds, bool animate)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setContentBounds", Id, JObject.FromObject(bounds, _jsonSerializer), animate);
+ }
+
+ public Task GetContentBoundsAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-getContentBounds-completed", (getContentBounds) => {
+ BridgeConnector.Socket.Off("browserWindow-getContentBounds-completed");
+
+ taskCompletionSource.SetResult(((JObject)getContentBounds).ToObject());
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-getContentBounds", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Resizes the window to width and height.
+ ///
+ ///
+ ///
+ ///
+ public void SetSize(int width, int height)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setSize", Id, width, height);
+ }
+
+ ///
+ /// Resizes the window to width and height.
+ ///
+ ///
+ ///
+ ///
+ public void SetSize(int width, int height, bool animate)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setSize", Id, width, height, animate);
+ }
+
+ ///
+ /// Contains the window’s width and height.
+ ///
+ ///
+ public Task GetSizeAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-getSize-completed", (size) => {
+ BridgeConnector.Socket.Off("browserWindow-getSize-completed");
+
+ taskCompletionSource.SetResult(((JArray)size).ToObject());
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-getSize", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Resizes the window’s client area (e.g. the web page) to width and height.
+ ///
+ ///
+ ///
+ ///
+ public void SetContentSize(int width, int height)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setContentSize", Id, width, height);
+ }
+
+ ///
+ /// Resizes the window’s client area (e.g. the web page) to width and height.
+ ///
+ ///
+ ///
+ ///
+ public void SetContentSize(int width, int height, bool animate)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setContentSize", Id, width, height, animate);
+ }
+
+ ///
+ /// Contains the window’s client area’s width and height.
+ ///
+ ///
+ public Task GetContentSizeAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-getContentSize-completed", (size) => {
+ BridgeConnector.Socket.Off("browserWindow-getContentSize-completed");
+
+ taskCompletionSource.SetResult(((JArray)size).ToObject());
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-getContentSize", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets the minimum size of window to width and height.
+ ///
+ ///
+ ///
+ public void SetMinimumSize(int width, int height)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setMinimumSize", Id, width, height);
+ }
+
+ ///
+ /// Contains the window’s minimum width and height.
+ ///
+ ///
+ public Task GetMinimumSizeAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-getMinimumSize-completed", (size) => {
+ BridgeConnector.Socket.Off("browserWindow-getMinimumSize-completed");
+
+ taskCompletionSource.SetResult(((JArray)size).ToObject());
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-getMinimumSize", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets the maximum size of window to width and height.
+ ///
+ ///
+ ///
+ public void SetMaximumSize(int width, int height)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setMaximumSize", Id, width, height);
+ }
+
+ ///
+ /// Contains the window’s maximum width and height.
+ ///
+ ///
+ public Task GetMaximumSizeAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-getMaximumSize-completed", (size) => {
+ BridgeConnector.Socket.Off("browserWindow-getMaximumSize-completed");
+
+ taskCompletionSource.SetResult(((JArray)size).ToObject());
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-getMaximumSize", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets whether the window can be manually resized by user.
+ ///
+ ///
+ public void SetResizable(bool resizable)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setResizable", Id, resizable);
+ }
+
+ ///
+ /// Whether the window can be manually resized by user.
+ ///
+ ///
+ public Task IsResizableAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isResizable-completed", (resizable) => {
+ BridgeConnector.Socket.Off("browserWindow-isResizable-completed");
+
+ taskCompletionSource.SetResult((bool)resizable);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isResizable", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets whether the window can be moved by user. On Linux does nothing.
+ ///
+ ///
+ public void SetMovable(bool movable)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setMovable", Id, movable);
+ }
+
+ ///
+ /// Whether the window can be moved by user.
+ ///
+ /// On Linux always returns true.
+ ///
+ /// On Linux always returns true.
+ public Task IsMovableAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isMovable-completed", (movable) => {
+ BridgeConnector.Socket.Off("browserWindow-isMovable-completed");
+
+ taskCompletionSource.SetResult((bool)movable);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isMovable", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets whether the window can be manually minimized by user. On Linux does nothing.
+ ///
+ ///
+ public void SetMinimizable(bool minimizable)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setMinimizable", Id, minimizable);
+ }
+
+ ///
+ /// Whether the window can be manually minimized by user.
+ ///
+ /// On Linux always returns true.
+ ///
+ /// On Linux always returns true.
+ public Task IsMinimizableAsync()
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("browserWindow-isMinimizable-completed", (minimizable) => {
+ BridgeConnector.Socket.Off("browserWindow-isMinimizable-completed");
+
+ taskCompletionSource.SetResult((bool)minimizable);
+ });
+
+ BridgeConnector.Socket.Emit("browserWindow-isMinimizable", Id);
+
+ return taskCompletionSource.Task;
+ }
+
+ ///
+ /// Sets whether the window can be manually maximized by user. On Linux does nothing.
+ ///
+ ///
+ public void SetMaximizable(bool maximizable)
+ {
+ BridgeConnector.Socket.Emit("browserWindow-setMaximizable", Id, maximizable);
+ }
+
+ private JsonSerializer _jsonSerializer = new JsonSerializer()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver(),
+ NullValueHandling = NullValueHandling.Ignore,
+ DefaultValueHandling = DefaultValueHandling.Ignore
+ };
+ }
+}
diff --git a/ElectronNET.API/Dialog.cs b/ElectronNET.API/Dialog.cs
new file mode 100644
index 0000000..f47afac
--- /dev/null
+++ b/ElectronNET.API/Dialog.cs
@@ -0,0 +1,89 @@
+using ElectronNET.API.Entities;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json.Serialization;
+using System;
+using System.Threading.Tasks;
+
+namespace ElectronNET.API
+{
+ public sealed class Dialog
+ {
+ private static Dialog _dialog;
+
+ internal Dialog() { }
+
+ internal static Dialog Instance
+ {
+ get
+ {
+ if (_dialog == null)
+ {
+ _dialog = new Dialog();
+ }
+
+ return _dialog;
+ }
+ }
+
+ ///
+ /// Shows a message box, it will block the process until the message box is closed.
+ /// It returns the index of the clicked button. The browserWindow argument allows
+ /// the dialog to attach itself to a parent window, making it modal. If a callback
+ /// is passed, the dialog will not block the process.The API call will be
+ /// asynchronous and the result will be passed via callback(response).
+ ///
+ ///
+ /// The API call will be asynchronous and the result will be passed via MessageBoxResult.
+ public async Task ShowMessageBoxAsync(MessageBoxOptions messageBoxOptions)
+ {
+ return await ShowMessageBoxAsync(null, messageBoxOptions);
+ }
+
+ ///
+ /// Shows a message box, it will block the process until the message box is closed.
+ /// It returns the index of the clicked button. If a callback
+ /// is passed, the dialog will not block the process.
+ ///
+ /// The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.
+ ///
+ /// The API call will be asynchronous and the result will be passed via MessageBoxResult.
+ public Task ShowMessageBoxAsync(BrowserWindow browserWindow, MessageBoxOptions messageBoxOptions)
+ {
+ var taskCompletionSource = new TaskCompletionSource();
+
+ BridgeConnector.Socket.On("showMessageBoxComplete", (args) =>
+ {
+ BridgeConnector.Socket.Off("showMessageBoxComplete");
+
+ var result = ((JArray)args);
+
+ taskCompletionSource.SetResult(new MessageBoxResult
+ {
+ Response = (int)result.First,
+ CheckboxChecked = (bool)result.Last
+ });
+
+ });
+
+ if (browserWindow == null)
+ {
+ BridgeConnector.Socket.Emit("showMessageBox", JObject.FromObject(messageBoxOptions, _jsonSerializer));
+ } else
+ {
+ BridgeConnector.Socket.Emit("showMessageBox",
+ JObject.FromObject(browserWindow, _jsonSerializer),
+ JObject.FromObject(messageBoxOptions, _jsonSerializer));
+ }
+
+ return taskCompletionSource.Task;
+ }
+
+ private JsonSerializer _jsonSerializer = new JsonSerializer()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver(),
+ NullValueHandling = NullValueHandling.Ignore,
+ DefaultValueHandling = DefaultValueHandling.Ignore
+ };
+ }
+}
diff --git a/ElectronNET.API/Electron.cs b/ElectronNET.API/Electron.cs
new file mode 100644
index 0000000..6002677
--- /dev/null
+++ b/ElectronNET.API/Electron.cs
@@ -0,0 +1,40 @@
+namespace ElectronNET.API
+{
+ public static class Electron
+ {
+ ///
+ /// Communicate asynchronously from the main process to renderer processes.
+ ///
+ public static IpcMain IpcMain { get { return IpcMain.Instance; } }
+
+ ///
+ /// Control your application's event lifecycle.
+ ///
+ public static App App { get { return App.Instance; } }
+
+ ///
+ /// Control your windows.
+ ///
+ public static WindowManager WindowManager { get { return WindowManager.Instance; } }
+
+ ///
+ /// Create native application menus and context menus.
+ ///
+ public static Menu Menu { get { return Menu.Instance; } }
+
+ ///
+ /// Display native system dialogs for opening and saving files, alerting, etc.
+ ///
+ public static Dialog Dialog { get { return Dialog.Instance; } }
+
+ ///
+ /// Create OS desktop notifications
+ ///
+ public static Notification Notification { get { return Notification.Instance; } }
+
+ ///
+ /// Add icons and context menus to the system’s notification area.
+ ///
+ public static Tray Tray { get { return Tray.Instance; } }
+ }
+}
diff --git a/ElectronNET.API/Entities/AboutPanelOptions.cs b/ElectronNET.API/Entities/AboutPanelOptions.cs
new file mode 100644
index 0000000..db47d7e
--- /dev/null
+++ b/ElectronNET.API/Entities/AboutPanelOptions.cs
@@ -0,0 +1,30 @@
+namespace ElectronNET.API.Entities
+{
+ public class AboutPanelOptions
+ {
+ ///
+ /// The app's name.
+ ///
+ public string ApplicationName { get; set; }
+
+ ///
+ /// The app's version.
+ ///
+ public string ApplicationVersion { get; set; }
+
+ ///
+ /// Copyright information.
+ ///
+ public string Copyright { get; set; }
+
+ ///
+ /// Credit information.
+ ///
+ public string Credits { get; set; }
+
+ ///
+ /// The app's build version number.
+ ///
+ public string Version { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/BrowserWindowOptions.cs b/ElectronNET.API/Entities/BrowserWindowOptions.cs
index 8a817e7..9e6ed33 100644
--- a/ElectronNET.API/Entities/BrowserWindowOptions.cs
+++ b/ElectronNET.API/Entities/BrowserWindowOptions.cs
@@ -2,8 +2,243 @@
{
public class BrowserWindowOptions
{
+ ///
+ /// Window's width in pixels. Default is 800.
+ ///
public int Width { get; set; }
+
+ ///
+ /// Window's height in pixels. Default is 600.
+ ///
public int Height { get; set; }
+
+ ///
+ /// ( if y is used) Window's left offset from screen. Default is to center the
+ /// window.
+ ///
+ public int X { get; set; }
+
+ ///
+ /// ( if x is used) Window's top offset from screen. Default is to center the
+ /// window.
+ ///
+ public int Y { get; set; }
+
+ ///
+ /// The width and height would be used as web page's size, which means the actual
+ /// window's size will include window frame's size and be slightly larger.Default
+ /// is false.
+ ///
+ public bool UseContentSize { get; set; }
+
+ ///
+ /// Show window in the center of the screen.
+ ///
+ public bool Center { get; set; }
+
+ ///
+ /// Window's minimum width. Default is 0.
+ ///
+ public int MinWidth { get; set; }
+
+ ///
+ /// Window's minimum height. Default is 0.
+ ///
+ public int MinHeight { get; set; }
+
+ ///
+ /// Window's maximum width. Default is no limit.
+ ///
+ public int MaxWidth { get; set; }
+
+ ///
+ /// Window's maximum height. Default is no limit.
+ ///
+ public int MaxHeight { get; set; }
+
+ ///
+ /// Whether window is resizable. Default is true.
+ ///
+ public bool Resizable { get; set; }
+
+ ///
+ /// Whether window is movable. This is not implemented on Linux. Default is true.
+ ///
+ public bool Movable { get; set; }
+
+ ///
+ /// Whether window is minimizable. This is not implemented on Linux. Default is true.
+ ///
+ public bool Minimizable { get; set; }
+
+ ///
+ /// Whether window is maximizable. This is not implemented on Linux. Default is true.
+ ///
+ public bool Maximizable { get; set; }
+
+ ///
+ /// Whether window is closable. This is not implemented on Linux. Default is true.
+ ///
+ public bool Closable { get; set; }
+
+ ///
+ /// Whether the window can be focused. Default is true. On Windows setting
+ /// focusable: false also implies setting skipTaskbar: true. On Linux setting
+ /// focusable: false makes the window stop interacting with wm, so the window will
+ /// always stay on top in all workspaces.
+ ///
+ public bool Focusable { get; set; }
+
+ ///
+ /// Whether the window should always stay on top of other windows. Default is false.
+ ///
+ public bool AlwaysOnTop { get; set; }
+
+ ///
+ /// Whether the window should show in fullscreen. When explicitly set to false the
+ /// fullscreen button will be hidden or disabled on macOS.Default is false.
+ ///
+ public bool Fullscreen { get; set; }
+
+ ///
+ /// Whether the window can be put into fullscreen mode. On macOS, also whether the
+ /// maximize/zoom button should toggle full screen mode or maximize window.Default
+ /// is true.
+ ///
+ public bool Fullscreenable { get; set; }
+
+ ///
+ /// Whether to show the window in taskbar. Default is false.
+ ///
+ public bool SkipTaskbar { get; set; }
+
+ ///
+ /// The kiosk mode. Default is false.
+ ///
+ public bool Kiosk { get; set; }
+
+ ///
+ /// Default window title. Default is "Electron.NET".
+ ///
+ public string Title { get; set; } = "Electron.NET";
+
+ ///
+ /// The window icon. On Windows it is recommended to use ICO icons to get best
+ /// visual effects, you can also leave it undefined so the executable's icon will be used.
+ ///
+ public string Icon { get; set; }
+
+ ///
+ /// Whether window should be shown when created. Default is true.
+ ///
public bool Show { get; set; }
+
+ ///
+ /// Specify false to create a . Default is true.
+ ///
+ public bool Frame { get; set; }
+
+ ///
+ /// Whether this is a modal window. This only works when the window is a child
+ /// window.Default is false.
+ ///
+ public bool Modal { get; set; }
+
+ ///
+ /// Whether the web view accepts a single mouse-down event that simultaneously
+ /// activates the window.Default is false.
+ ///
+ public bool AcceptFirstMouse { get; set; }
+
+ ///
+ /// Whether to hide cursor when typing. Default is false.
+ ///
+ public bool DisableAutoHideCursor { get; set; }
+
+ ///
+ /// Auto hide the menu bar unless the Alt key is pressed. Default is false.
+ ///
+ public bool AutoHideMenuBar { get; set; }
+
+ ///
+ /// Enable the window to be resized larger than screen. Default is false.
+ ///
+ public bool EnableLargerThanScreen { get; set; }
+
+ ///
+ /// Window's background color as Hexadecimal value, like #66CD00 or #FFF or
+ /// #80FFFFFF (alpha is supported). Default is #FFF (white).
+ ///
+ public string BackgroundColor { get; set; }
+
+ ///
+ /// Whether window should have a shadow. This is only implemented on macOS. Default
+ /// is true.
+ ///
+ public bool HasShadow { get; set; }
+
+ ///
+ /// Forces using dark theme for the window, only works on some GTK+3 desktop
+ /// environments.Default is false.
+ ///
+ public bool DarkTheme { get; set; }
+
+ ///
+ /// Makes the window . Default is false.
+ ///
+ public bool Transparent { get; set; }
+
+ ///
+ /// The type of window, default is normal window.
+ ///
+ public string Type { get; set; }
+
+ ///
+ /// The style of window title bar. Default is default. Possible values are:
+ /// 'default' | 'hidden' | 'hidden-inset' | 'hiddenInset' | 'customButtonsOnHover'
+ ///
+ public string TitleBarStyle { get; set; }
+
+ ///
+ /// Shows the title in the tile bar in full screen mode on macOS for all
+ /// titleBarStyle options.Default is false.
+ ///
+ public bool FullscreenWindowTitle { get; set; }
+
+ ///
+ /// Use WS_THICKFRAME style for frameless windows on Windows, which adds standard
+ /// window frame.Setting it to false will remove window shadow and window
+ /// animations.Default is true.
+ ///
+ public bool ThickFrame { get; set; }
+
+ ///
+ /// Add a type of vibrancy effect to the window, only on macOS. Can be
+ /// appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
+ /// medium-light or ultra-dark.
+ ///
+ public string Vibrancy { get; set; }
+
+ ///
+ /// Controls the behavior on macOS when option-clicking the green stoplight button
+ /// on the toolbar or by clicking the Window > Zoom menu item.If true, the window
+ /// will grow to the preferred width of the web page when zoomed, false will cause
+ /// it to zoom to the width of the screen.This will also affect the behavior when
+ /// calling maximize() directly.Default is false.
+ ///
+ public bool ZoomToPageWidth { get; set; }
+
+ ///
+ /// Tab group name, allows opening the window as a native tab on macOS 10.12+.
+ /// Windows with the same tabbing identifier will be grouped together.This also
+ /// adds a native new tab button to your window's tab bar and allows your app and
+ /// window to receive the new-window-for-tab event.
+ ///
+ public string TabbingIdentifier { get; set; }
+
+ ///
+ /// Settings of web page's features.
+ ///
+ public WebPreferences WebPreferences { get; set; }
}
}
diff --git a/ElectronNET.API/Entities/CPUUsage.cs b/ElectronNET.API/Entities/CPUUsage.cs
new file mode 100644
index 0000000..0fb461a
--- /dev/null
+++ b/ElectronNET.API/Entities/CPUUsage.cs
@@ -0,0 +1,16 @@
+namespace ElectronNET.API.Entities
+{
+ public class CPUUsage
+ {
+ ///
+ /// The number of average idle cpu wakeups per second since the last call to
+ /// getCPUUsage.First call returns 0.
+ ///
+ public int IdleWakeupsPerSecond { get; set; }
+
+ ///
+ /// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
+ ///
+ public int PercentCPUUsage { get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/DockBounceType.cs b/ElectronNET.API/Entities/DockBounceType.cs
new file mode 100644
index 0000000..5af53ed
--- /dev/null
+++ b/ElectronNET.API/Entities/DockBounceType.cs
@@ -0,0 +1,8 @@
+namespace ElectronNET.API
+{
+ public enum DockBounceType
+ {
+ critical,
+ informational
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/FileIconOptions.cs b/ElectronNET.API/Entities/FileIconOptions.cs
new file mode 100644
index 0000000..4293a0a
--- /dev/null
+++ b/ElectronNET.API/Entities/FileIconOptions.cs
@@ -0,0 +1,12 @@
+namespace ElectronNET.API.Entities
+{
+ public class FileIconOptions
+ {
+ public string Size { get; private set; }
+
+ public FileIconOptions(FileIconSize fileIconSize)
+ {
+ Size = fileIconSize.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/FileIconSize.cs b/ElectronNET.API/Entities/FileIconSize.cs
new file mode 100644
index 0000000..7841ee8
--- /dev/null
+++ b/ElectronNET.API/Entities/FileIconSize.cs
@@ -0,0 +1,9 @@
+namespace ElectronNET.API.Entities
+{
+ public enum FileIconSize
+ {
+ small,
+ normal,
+ large
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/GPUFeatureStatus.cs b/ElectronNET.API/Entities/GPUFeatureStatus.cs
new file mode 100644
index 0000000..a21aac5
--- /dev/null
+++ b/ElectronNET.API/Entities/GPUFeatureStatus.cs
@@ -0,0 +1,82 @@
+using Newtonsoft.Json;
+
+namespace ElectronNET.API.Entities
+{
+ public class GPUFeatureStatus
+ {
+ ///
+ /// Canvas
+ ///
+ [JsonProperty("2d_canvas")]
+ public string Canvas { get; set; }
+
+ ///
+ /// Flash
+ ///
+ [JsonProperty("flash_3d")]
+ public string Flash3D { get; set; }
+
+ ///
+ /// Flash Stage3D
+ ///
+ [JsonProperty("flash_stage3d")]
+ public string FlashStage3D { get; set; }
+
+ ///
+ /// Flash Stage3D Baseline profile
+ ///
+ [JsonProperty("flash_stage3d_baseline")]
+ public string FlashStage3dBaseline { get; set; }
+
+ ///
+ /// Compositing
+ ///
+ [JsonProperty("gpu_compositing")]
+ public string GpuCompositing { get; set; }
+
+ ///
+ /// Multiple Raster Threads
+ ///
+ [JsonProperty("multiple_raster_threads")]
+ public string MultipleRasterThreads { get; set; }
+
+ ///
+ /// Native GpuMemoryBuffers
+ ///
+ [JsonProperty("native_gpu_memory_buffers")]
+ public string NativeGpuMemoryBuffers { get; set; }
+
+ ///
+ /// Rasterization
+ ///
+ public string Rasterization { get; set; }
+
+ ///
+ /// Video Decode
+ ///
+ [JsonProperty("video_decode")]
+ public string VideoDecode { get; set; }
+
+ ///
+ /// Video Encode
+ ///
+ [JsonProperty("video_encode")]
+ public string VideoEncode { get; set; }
+
+ ///
+ /// VPx Video Decode
+ ///
+ [JsonProperty("vpx_decode")]
+ public string VpxDecode { get; set; }
+
+ ///
+ /// WebGL
+ ///
+ public string Webgl { get; set; }
+
+ ///
+ /// WebGL2
+ ///
+ public string Webgl2 { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/ImportCertificateOptions.cs b/ElectronNET.API/Entities/ImportCertificateOptions.cs
new file mode 100644
index 0000000..779992c
--- /dev/null
+++ b/ElectronNET.API/Entities/ImportCertificateOptions.cs
@@ -0,0 +1,15 @@
+namespace ElectronNET.API.Entities
+{
+ public class ImportCertificateOptions
+ {
+ ///
+ /// Path for the pkcs12 file.
+ ///
+ public string Certificate { get; set; }
+
+ ///
+ /// Passphrase for the certificate.
+ ///
+ public string Password {get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/JumpListCategory.cs b/ElectronNET.API/Entities/JumpListCategory.cs
new file mode 100644
index 0000000..e7ca486
--- /dev/null
+++ b/ElectronNET.API/Entities/JumpListCategory.cs
@@ -0,0 +1,22 @@
+using ElectronNET.API.Entities;
+
+namespace ElectronNET.API
+{
+ public class JumpListCategory
+ {
+ ///
+ /// Must be set if type is custom, otherwise it should be omitted.
+ ///
+ public string Name { get; set; } = string.Empty;
+
+ ///
+ /// Array of objects if type is tasks or custom, otherwise it should be omitted.
+ ///
+ public JumpListItem[] Items { get; set; } = new JumpListItem[0];
+
+ ///
+ /// One of the following: "tasks" | "frequent" | "recent" | "custom"
+ ///
+ public string Type { get; set; } = "tasks";
+ }
+}
diff --git a/ElectronNET.API/Entities/JumpListItem.cs b/ElectronNET.API/Entities/JumpListItem.cs
new file mode 100644
index 0000000..8d1ac63
--- /dev/null
+++ b/ElectronNET.API/Entities/JumpListItem.cs
@@ -0,0 +1,51 @@
+namespace ElectronNET.API.Entities
+{
+ public class JumpListItem
+ {
+ ///
+ /// The command line arguments when program is executed. Should only be set if type is task.
+ ///
+ public string Args { get; set; } = string.Empty;
+
+ ///
+ /// Description of the task (displayed in a tooltip). Should only be set if type is task.
+ ///
+ public string Description { get; set; } = string.Empty;
+
+ ///
+ /// The index of the icon in the resource file. If a resource file contains multiple
+ /// icons this value can be used to specify the zero-based index of the icon that
+ /// should be displayed for this task.If a resource file contains only one icon,
+ /// this property should be set to zero.
+ ///
+ public int IconIndex { get; set; } = 0;
+
+ ///
+ /// The absolute path to an icon to be displayed in a Jump List, which can be an
+ /// arbitrary resource file that contains an icon(e.g. .ico, .exe, .dll). You can
+ /// usually specify process.execPath to show the program icon.
+ ///
+ public string IconPath { get; set; } = string.Empty;
+
+ ///
+ /// Path of the file to open, should only be set if type is file.
+ ///
+ public string Path { get; set; } = string.Empty;
+
+ ///
+ /// Path of the program to execute, usually you should specify process.execPath
+ /// which opens the current program.Should only be set if type is task.
+ ///
+ public string Program { get; set; } = string.Empty;
+
+ ///
+ /// The text to be displayed for the item in the Jump List. Should only be set if type is task.
+ ///
+ public string Title { get; set; } = string.Empty;
+
+ ///
+ /// One of the following: "task" | "separator" | "file"
+ ///
+ public string Type {get; set; } = string.Empty;
+ }
+}
diff --git a/ElectronNET.API/Entities/JumpListSettings.cs b/ElectronNET.API/Entities/JumpListSettings.cs
new file mode 100644
index 0000000..b7964cd
--- /dev/null
+++ b/ElectronNET.API/Entities/JumpListSettings.cs
@@ -0,0 +1,15 @@
+namespace ElectronNET.API.Entities
+{
+ public class JumpListSettings
+ {
+ ///
+ /// The minimum number of items that will be shown in the Jump List (for a more detailed description of this value see the MSDN docs).
+ ///
+ public int MinItems { get; set; } = 0;
+
+ ///
+ /// Array of JumpListItem objects that correspond to items that the user has explicitly removed from custom categories in the Jump List. These items must not be re-added to the Jump List in the next call to app.setJumpList(), Windows will not display any custom category that contains any of the removed items.
+ ///
+ public JumpListItem[] RemovedItems { get; set; } = new JumpListItem[0];
+ }
+}
diff --git a/ElectronNET.API/Entities/LoginItemSettings.cs b/ElectronNET.API/Entities/LoginItemSettings.cs
new file mode 100644
index 0000000..67e9535
--- /dev/null
+++ b/ElectronNET.API/Entities/LoginItemSettings.cs
@@ -0,0 +1,36 @@
+namespace ElectronNET.API.Entities
+{
+ public class LoginItemSettings
+ {
+ ///
+ /// true if the app is set to open at login.
+ ///
+ public bool OpenAtLogin { get; set; }
+
+ ///
+ /// true if the app is set to open as hidden at login. This setting is only
+ /// supported on macOS.
+ ///
+ public bool OpenAsHidden { get; set; }
+
+ ///
+ /// true if the app was opened at login automatically. This setting is only
+ /// supported on macOS.
+ ///
+ public bool WasOpenedAtLogin { get; set; }
+
+ ///
+ /// true if the app was opened as a hidden login item. This indicates that the app
+ /// should not open any windows at startup.This setting is only supported on macOS.
+ ///
+ public bool WasOpenedAsHidden { get; set; }
+
+ ///
+ /// true if the app was opened as a login item that should restore the state from
+ /// the previous session.This indicates that the app should restore the windows
+ /// that were open the last time the app was closed.This setting is only supported
+ /// on macOS.
+ ///
+ public bool RestoreState { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/LoginItemSettingsOptions.cs b/ElectronNET.API/Entities/LoginItemSettingsOptions.cs
new file mode 100644
index 0000000..aee888d
--- /dev/null
+++ b/ElectronNET.API/Entities/LoginItemSettingsOptions.cs
@@ -0,0 +1,15 @@
+namespace ElectronNET.API.Entities
+{
+ public class LoginItemSettingsOptions
+ {
+ ///
+ /// The executable path to compare against. Defaults to process.execPath.
+ ///
+ public string Path { get; set; }
+
+ ///
+ /// The command-line arguments to compare against. Defaults to an empty array.
+ ///
+ public string[] Args { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/LoginSettings.cs b/ElectronNET.API/Entities/LoginSettings.cs
new file mode 100644
index 0000000..aec8203
--- /dev/null
+++ b/ElectronNET.API/Entities/LoginSettings.cs
@@ -0,0 +1,30 @@
+namespace ElectronNET.API.Entities
+{
+ public class LoginSettings
+ {
+ ///
+ /// true to open the app at login, false to remove the app as a login item. Defaults
+ /// to false.
+ ///
+ public bool OpenAtLogin { get; set; }
+
+ ///
+ /// true to open the app as hidden. Defaults to false. The user can edit this
+ /// setting from the System Preferences so
+ /// app.getLoginItemStatus().wasOpenedAsHidden should be checked when the app is
+ /// opened to know the current value.This setting is only supported on macOS.
+ ///
+ public bool OpenAsHidden { get; set; }
+
+ ///
+ /// The executable to launch at login. Defaults to process.execPath.
+ ///
+ public string Path { get; set; }
+
+ ///
+ /// The command-line arguments to pass to the executable. Defaults to an empty
+ /// array.Take care to wrap paths in quotes.
+ ///
+ public string[] Args { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/MemoryInfo.cs b/ElectronNET.API/Entities/MemoryInfo.cs
new file mode 100644
index 0000000..f31423b
--- /dev/null
+++ b/ElectronNET.API/Entities/MemoryInfo.cs
@@ -0,0 +1,33 @@
+namespace ElectronNET.API.Entities
+{
+ public class MemoryInfo
+ {
+ ///
+ /// The maximum amount of memory that has ever been pinned to actual physical RAM.
+ /// On macOS its value will always be 0.
+ ///
+ public int PeakWorkingSetSize { get; set; }
+
+ ///
+ /// Process id of the process.
+ ///
+ public int Pid { get; set; }
+
+ ///
+ /// The amount of memory not shared by other processes, such as JS heap or HTML
+ /// content.
+ ///
+ public int PrivateBytes { get; set; }
+
+ ///
+ /// The amount of memory shared between processes, typically memory consumed by the
+ /// Electron code itself
+ ///
+ public int SharedBytes { get; set; }
+
+ ///
+ /// The amount of memory currently pinned to actual physical RAM.
+ ///
+ public int WorkingSetSize {get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/MenuItem.cs b/ElectronNET.API/Entities/MenuItem.cs
new file mode 100644
index 0000000..667993b
--- /dev/null
+++ b/ElectronNET.API/Entities/MenuItem.cs
@@ -0,0 +1,72 @@
+using Newtonsoft.Json;
+using System;
+
+namespace ElectronNET.API.Entities
+{
+ public class MenuItem
+ {
+ ///
+ /// Will be called with click(menuItem, browserWindow, event) when the menu item is
+ /// clicked.
+ ///
+ [JsonIgnore]
+ public Action Click { get; set; }
+
+ ///
+ /// Define the action of the menu item, when specified the click property will be
+ /// ignored.
+ ///
+ public string Role { get; set; }
+
+ ///
+ /// Can be normal, separator, submenu, checkbox or radio.
+ ///
+ public string Type { get; set; }
+
+
+ public string Label { get; set; }
+
+
+ public string Sublabel { get; set; }
+
+
+ public string Accelerator { get; set; }
+
+
+ public string Icon { get; set; }
+
+ ///
+ /// If false, the menu item will be greyed out and unclickable.
+ ///
+ public bool Enabled { get; set; }
+
+ ///
+ /// If false, the menu item will be entirely hidden.
+ ///
+ public bool Visible { get; set; }
+
+ ///
+ /// Should only be specified for checkbox or radio type menu items.
+ ///
+ public bool Checked { get; set; }
+
+ ///
+ /// Should be specified for submenu type menu items. If submenu is specified, the
+ /// type: 'submenu' can be omitted.If the value is not a Menu then it will be
+ /// automatically converted to one using Menu.buildFromTemplate.
+ ///
+ public MenuItem[] Submenu { get; set; }
+
+ ///
+ /// Unique within a single menu. If defined then it can be used as a reference to
+ /// this item by the position attribute.
+ ///
+ public string Id { get; internal set; }
+
+ ///
+ /// This field allows fine-grained definition of the specific location within a
+ /// given menu.
+ ///
+ public string Position { get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/MessageBoxOptions.cs b/ElectronNET.API/Entities/MessageBoxOptions.cs
new file mode 100644
index 0000000..960471c
--- /dev/null
+++ b/ElectronNET.API/Entities/MessageBoxOptions.cs
@@ -0,0 +1,84 @@
+namespace ElectronNET.API.Entities
+{
+ public class MessageBoxOptions
+ {
+ ///
+ /// Can be "none", "info", "error", "question" or "warning". On Windows, "question"
+ /// displays the same icon as "info", unless you set an icon using the "icon"
+ /// option.On macOS, both "warning" and "error" display the same warning icon.
+ ///
+ public string Type { get; set; }
+
+ ///
+ /// Array of texts for buttons. On Windows, an empty array will result in one button
+ /// labeled "OK".
+ ///
+ public string[] Buttons { get; set; }
+
+ ///
+ /// Index of the button in the buttons array which will be selected by default when
+ /// the message box opens.
+ ///
+ public int DefaultId { get; set; }
+
+ ///
+ /// Title of the message box, some platforms will not show it.
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// Content of the message box.
+ ///
+ public string Message { get; set; }
+
+ ///
+ /// Extra information of the message.
+ ///
+ public string Detail { get; set; }
+
+ ///
+ /// If provided, the message box will include a checkbox with the given label. The
+ /// checkbox state can be inspected only when using callback.
+ ///
+ public string CheckboxLabel { get; set; }
+
+ ///
+ /// Initial checked state of the checkbox. false by default.
+ ///
+ public bool CheckboxChecked { get; set; }
+
+ public string Icon { get; set; }
+
+ ///
+ /// The index of the button to be used to cancel the dialog, via the Esc key. By
+ /// default this is assigned to the first button with "cancel" or "no" as the label.
+ /// If no such labeled buttons exist and this option is not set, 0 will be used as
+ /// the return value or callback response. This option is ignored on Windows.
+ ///
+ public int CancelId { get; set; }
+
+ ///
+ /// On Windows Electron will try to figure out which one of the buttons are common
+ /// buttons(like "Cancel" or "Yes"), and show the others as command links in the
+ /// dialog.This can make the dialog appear in the style of modern Windows apps. If
+ /// you don't like this behavior, you can set noLink to true.
+ ///
+ public bool NoLink { get; set; }
+
+ ///
+ /// Normalize the keyboard access keys across platforms. Default is false. Enabling
+ /// this assumes & is used in the button labels for the placement of the keyboard
+ /// shortcut access key and labels will be converted so they work correctly on each
+ /// platform, & characters are removed on macOS, converted to _ on Linux, and left
+ /// untouched on Windows.For example, a button label of Vie&w will be converted to
+ /// Vie_w on Linux and View on macOS and can be selected via Alt-W on Windows and
+ /// Linux.
+ ///
+ public bool NormalizeAccessKeys { get; set; }
+
+ public MessageBoxOptions(string message)
+ {
+ Message = message;
+ }
+ }
+}
diff --git a/ElectronNET.API/Entities/MessageBoxResult.cs b/ElectronNET.API/Entities/MessageBoxResult.cs
new file mode 100644
index 0000000..20a19b6
--- /dev/null
+++ b/ElectronNET.API/Entities/MessageBoxResult.cs
@@ -0,0 +1,9 @@
+namespace ElectronNET.API.Entities
+{
+ public class MessageBoxResult
+ {
+ public int Response { get; set; }
+
+ public bool CheckboxChecked { get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/NativeImage.cs b/ElectronNET.API/Entities/NativeImage.cs
new file mode 100644
index 0000000..deb6210
--- /dev/null
+++ b/ElectronNET.API/Entities/NativeImage.cs
@@ -0,0 +1,106 @@
+namespace ElectronNET.API.Entities
+{
+ // TODO: Fertig coden
+ public class NativeImage
+ {
+ // public static NativeImage CreateEmpty()
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public static NativeImage CreateFromBuffer(byte[] buffer)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public static NativeImage CreateFromBuffer(byte[] buffer, CreateFromBufferOptions options)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public static NativeImage CreateFromDataURL(string dataURL)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public static NativeImage CreateFromPath(string path)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public void AddRepresentation(AddRepresentationOptions options)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public NativeImage Crop(Rectangle rect)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public int GetAspectRatio()
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public byte[] GetBitmap()
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public byte[] GetBitmap(BitmapOptions options)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public byte[] GetNativeHandle()
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public Size GetSize()
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public bool IsEmpty()
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public bool IsTemplateImage()
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public NativeImage Resize(ResizeOptions options)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public void SetTemplateImage(bool option)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public byte[] ToBitmap(ToBitmapOptions options)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public string ToDataURL(ToDataURLOptions options)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public byte[] ToJPEG(int quality)
+ // {
+ // throw new NotImplementedException();
+ // }
+
+ // public byte[] ToPNG(ToPNGOptions options)
+ // {
+ // throw new NotImplementedException();
+ // }
+ }
+}
diff --git a/ElectronNET.API/Entities/NotificationOptions.cs b/ElectronNET.API/Entities/NotificationOptions.cs
index b58e954..efa127f 100644
--- a/ElectronNET.API/Entities/NotificationOptions.cs
+++ b/ElectronNET.API/Entities/NotificationOptions.cs
@@ -2,7 +2,52 @@
{
public class NotificationOptions
{
+ ///
+ /// A title for the notification, which will be shown at the top of the notification
+ /// window when it is shown
+ ///
public string Title { get; set; }
+
+ ///
+ /// The body text of the notification, which will be displayed below the title or
+ /// subtitle
+ ///
public string Body { get; set; }
+
+ ///
+ /// A subtitle for the notification, which will be displayed below the title.
+ ///
+ public string Subtitle { get; set; }
+
+ ///
+ /// Whether or not to emit an OS notification noise when showing the notification
+ ///
+ public bool Silent { get; set; }
+
+ ///
+ /// An icon to use in the notification
+ ///
+ public string Icon { get; set; }
+
+ ///
+ /// Whether or not to add an inline reply option to the notification.
+ ///
+ public bool HasReply { get; set; }
+
+ ///
+ /// The placeholder to write in the inline reply input field.
+ ///
+ public string ReplyPlaceholder { get; set; }
+
+ ///
+ /// The name of the sound file to play when the notification is shown.
+ ///
+ public string Sound { get; set; }
+
+ public NotificationOptions(string title, string body)
+ {
+ Title = title;
+ Body = body;
+ }
}
}
diff --git a/ElectronNET.API/Entities/PathName.cs b/ElectronNET.API/Entities/PathName.cs
new file mode 100644
index 0000000..0435b4c
--- /dev/null
+++ b/ElectronNET.API/Entities/PathName.cs
@@ -0,0 +1,76 @@
+namespace ElectronNET.API.Entities
+{
+ public enum PathName
+ {
+ ///
+ /// User’s home directory.
+ ///
+ home,
+
+ ///
+ /// Per-user application data directory.
+ ///
+ appData,
+
+ ///
+ /// The directory for storing your app’s configuration files,
+ /// which by default it is the appData directory appended with your app’s name.
+ ///
+ userData,
+
+ ///
+ /// Temporary directory.
+ ///
+ temp,
+
+ ///
+ /// The current executable file.
+ ///
+ exe,
+
+ ///
+ /// The libchromiumcontent library.
+ ///
+ module,
+
+ ///
+ /// The current user’s Desktop directory.
+ ///
+ desktop,
+
+ ///
+ /// Directory for a user’s “My Documents”.
+ ///
+ documents,
+
+ ///
+ /// Directory for a user’s downloads.
+ ///
+ downloads,
+
+ ///
+ /// Directory for a user’s music.
+ ///
+ music,
+
+ ///
+ /// Directory for a user’s pictures.
+ ///
+ pictures,
+
+ ///
+ /// Directory for a user’s videos.
+ ///
+ videos,
+
+ ///
+ ///
+ ///
+ logs,
+
+ ///
+ /// Full path to the system version of the Pepper Flash plugin.
+ ///
+ pepperFlashSystemPlugin
+ }
+}
diff --git a/ElectronNET.API/Entities/ProcessMetric.cs b/ElectronNET.API/Entities/ProcessMetric.cs
new file mode 100644
index 0000000..79cab89
--- /dev/null
+++ b/ElectronNET.API/Entities/ProcessMetric.cs
@@ -0,0 +1,25 @@
+namespace ElectronNET.API.Entities
+{
+ public class ProcessMetric
+ {
+ ///
+ /// CPU usage of the process.
+ ///
+ public CPUUsage Cpu { get; set; }
+
+ ///
+ /// Memory information for the process.
+ ///
+ public MemoryInfo Memory {get; set;}
+
+ ///
+ /// Process id of the process.
+ ///
+ public int Pid { get; set; }
+
+ ///
+ /// Process type (Browser or Tab or GPU etc).
+ ///
+ public string Type { get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/Rectangle.cs b/ElectronNET.API/Entities/Rectangle.cs
new file mode 100644
index 0000000..7e1a8eb
--- /dev/null
+++ b/ElectronNET.API/Entities/Rectangle.cs
@@ -0,0 +1,10 @@
+namespace ElectronNET.API.Entities
+{
+ public class Rectangle
+ {
+ public int X { get; set; }
+ public int Y { get; set; }
+ public int Width { get; set; }
+ public int Height { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/RelaunchOptions.cs b/ElectronNET.API/Entities/RelaunchOptions.cs
new file mode 100644
index 0000000..55ff88e
--- /dev/null
+++ b/ElectronNET.API/Entities/RelaunchOptions.cs
@@ -0,0 +1,8 @@
+namespace ElectronNET.API.Entities
+{
+ public class RelaunchOptions
+ {
+ public string[] Args { get; set; }
+ public string ExecPath { get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/Size.cs b/ElectronNET.API/Entities/Size.cs
new file mode 100644
index 0000000..459428a
--- /dev/null
+++ b/ElectronNET.API/Entities/Size.cs
@@ -0,0 +1,9 @@
+namespace ElectronNET.API.Entities
+{
+ public class Size
+ {
+ public int Width { get; set; }
+
+ public int Height { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Entities/UserTask.cs b/ElectronNET.API/Entities/UserTask.cs
new file mode 100644
index 0000000..1b37d67
--- /dev/null
+++ b/ElectronNET.API/Entities/UserTask.cs
@@ -0,0 +1,12 @@
+namespace ElectronNET.API.Entities
+{
+ public class UserTask
+ {
+ public string Arguments { get; set; }
+ public string Description { get; set; }
+ public int IconIndex { get; set; }
+ public string IconPath { get; set; }
+ public string Program { get; set; }
+ public string Title { get; set; }
+ }
+}
diff --git a/ElectronNET.API/Entities/WebPreferences.cs b/ElectronNET.API/Entities/WebPreferences.cs
new file mode 100644
index 0000000..8f4e738
--- /dev/null
+++ b/ElectronNET.API/Entities/WebPreferences.cs
@@ -0,0 +1,186 @@
+namespace ElectronNET.API.Entities
+{
+ public class WebPreferences
+ {
+ ///
+ /// Whether to enable DevTools. If it is set to false, can not use
+ /// BrowserWindow.webContents.openDevTools() to open DevTools.Default is true.
+ ///
+ public bool DevTools { get; set; }
+
+ ///
+ /// Whether node integration is enabled. Default is true.
+ ///
+ public bool NodeIntegration { get; set; }
+
+ ///
+ /// Whether node integration is enabled in web workers. Default is false.
+ ///
+ public bool NodeIntegrationInWorker { get; set; }
+
+ ///
+ /// Specifies a script that will be loaded before other scripts run in the page.
+ /// This script will always have access to node APIs no matter whether node
+ /// integration is turned on or off.The value should be the absolute file path to
+ /// the script. When node integration is turned off, the preload script can
+ /// reintroduce Node global symbols back to the global scope.
+ ///
+ public string Preload { get; set; }
+
+ ///
+ /// If set, this will sandbox the renderer associated with the window, making it
+ /// compatible with the Chromium OS-level sandbox and disabling the Node.js engine.
+ /// This is not the same as the nodeIntegration option and the APIs available to the
+ /// preload script are more limited. Read more about the option.This option is
+ /// currently experimental and may change or be removed in future Electron releases.
+ ///
+ public bool Sandbox { get; set; }
+
+ ///
+ /// Sets the session used by the page according to the session's partition string.
+ /// If partition starts with persist:, the page will use a persistent session
+ /// available to all pages in the app with the same partition.If there is no
+ /// persist: prefix, the page will use an in-memory session. By assigning the same
+ /// partition, multiple pages can share the same session.Default is the default
+ /// session.
+ ///
+ public string Partition { get; set; }
+
+ ///
+ /// The default zoom factor of the page, 3.0 represents 300%. Default is 1.0.
+ ///
+ public int ZoomFactor { get; set; }
+
+ ///
+ /// Enables JavaScript support. Default is true.
+ ///
+ public bool Javascript { get; set; }
+
+ ///
+ /// When false, it will disable the same-origin policy (usually using testing
+ /// websites by people), and set allowRunningInsecureContent to true if this options
+ /// has not been set by user.Default is true.
+ ///
+ public bool WebSecurity { get; set; }
+
+ ///
+ /// Allow an https page to run JavaScript, CSS or plugins from http URLs. Default is
+ /// false.
+ ///
+ public bool AllowRunningInsecureContent { get; set; }
+
+ ///
+ /// Enables image support. Default is true.
+ ///
+ public bool Images { get; set; }
+
+ ///
+ /// Make TextArea elements resizable. Default is true.
+ ///
+ public bool TextAreasAreResizable { get; set; }
+
+ ///
+ /// Enables WebGL support. Default is true.
+ ///
+ public bool Webgl { get; set; }
+
+ ///
+ /// Enables WebAudio support. Default is true.
+ ///
+ public bool Webaudio { get; set; }
+
+ ///
+ /// Whether plugins should be enabled. Default is false.
+ ///
+ public bool Plugins { get; set; }
+
+ ///
+ /// Enables Chromium's experimental features. Default is false.
+ ///
+ public bool ExperimentalFeatures { get; set; }
+
+ ///
+ /// Enables Chromium's experimental canvas features. Default is false.
+ ///
+ public bool ExperimentalCanvasFeatures { get; set; }
+
+ ///
+ /// Enables scroll bounce (rubber banding) effect on macOS. Default is false.
+ ///
+ public bool ScrollBounce { get; set; }
+
+ ///
+ /// A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
+ /// enable.The full list of supported feature strings can be found in the file.
+ ///
+ public string BlinkFeatures { get; set; }
+
+ ///
+ /// A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
+ /// disable.The full list of supported feature strings can be found in the file.
+ ///
+ public string DisableBlinkFeatures { get; set; }
+
+ ///
+ /// Defaults to 16.
+ ///
+ public int DefaultFontSize { get; set; }
+
+ ///
+ /// Defaults to 13.
+ ///
+ public int DefaultMonospaceFontSize { get; set; }
+
+ ///
+ /// Defaults to 0.
+ ///
+ public int MinimumFontSize { get; set; }
+
+ ///
+ /// Defaults to ISO-8859-1.
+ ///
+ public string DefaultEncoding { get; set; }
+
+ ///
+ /// Whether to throttle animations and timers when the page becomes background. This
+ /// also affects the[Page Visibility API][#page-visibility]. Defaults to true.
+ ///
+ public bool BackgroundThrottling { get; set; }
+
+ ///
+ /// Whether to enable offscreen rendering for the browser window. Defaults to false.
+ ///
+ public bool Offscreen { get; set; }
+
+ ///
+ /// Whether to run Electron APIs and the specified preload script in a separate
+ /// JavaScript context.Defaults to false. The context that the preload script runs
+ /// in will still have full access to the document and window globals but it will
+ /// use its own set of JavaScript builtins (Array, Object, JSON, etc.) and will be
+ /// isolated from any changes made to the global environment by the loaded page.The
+ /// Electron API will only be available in the preload script and not the loaded
+ /// page. This option should be used when loading potentially untrusted remote
+ /// content to ensure the loaded content cannot tamper with the preload script and
+ /// any Electron APIs being used. This option uses the same technique used by . You
+ /// can access this context in the dev tools by selecting the 'Electron Isolated
+ /// Context' entry in the combo box at the top of the Console tab. This option is
+ /// currently experimental and may change or be removed in future Electron releases.
+ ///
+ public bool ContextIsolation { get; set; }
+
+ ///
+ /// Whether to use native window.open(). Defaults to false. This option is currently experimental.
+ ///
+ public bool NativeWindowOpen { get; set; }
+
+ ///
+ /// Whether to enable the . Defaults to the value of the nodeIntegration option. The
+ /// preload script configured for the will have node integration enabled
+ /// when it is executed so you should ensure remote/untrusted content is not able to
+ /// create a tag with a possibly malicious preload script.You can use the
+ /// will-attach-webview event on to strip away the preload script and to validate or
+ /// alter the's initial settings.
+ ///
+ public bool WebviewTag { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ElectronNET.API/Extensions/MenuItemExtensions.cs b/ElectronNET.API/Extensions/MenuItemExtensions.cs
new file mode 100644
index 0000000..ba5f8b5
--- /dev/null
+++ b/ElectronNET.API/Extensions/MenuItemExtensions.cs
@@ -0,0 +1,53 @@
+using ElectronNET.API.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace ElectronNET.API.Extensions
+{
+ internal static class MenuItemExtensions
+ {
+ public static MenuItem[] AddMenuItemsId(this MenuItem[] menuItems)
+ {
+ for (int index = 0; index < menuItems.Length; index++)
+ {
+ var menuItem = menuItems[index];
+ if (menuItem?.Submenu?.Length > 0)
+ {
+ AddMenuItemsId(menuItem.Submenu);
+ }
+
+ if (string.IsNullOrEmpty(menuItem.Role) &&
+ string.IsNullOrEmpty(menuItem.Id))
+ {
+ menuItem.Id = Guid.NewGuid().ToString();
+ }
+ }
+
+ return menuItems;
+ }
+
+ public static MenuItem GetMenuItem(this List