write code documentation for App-API and IpcMain-API

This commit is contained in:
Gregor Biswanger
2017-10-14 14:41:11 +02:00
parent aa526c4bcb
commit 9848a38b0d
7 changed files with 564 additions and 42 deletions

View File

@@ -10,6 +10,9 @@ namespace ElectronNET.API
{
public static class App
{
/// <summary>
/// Communicate asynchronously from the main process to renderer processes.
/// </summary>
public static IpcMain IpcMain { get; private set; }
private static Socket _socket;
@@ -45,41 +48,89 @@ namespace ElectronNET.API
_socket.Emit("createNotification", JObject.FromObject(notificationOptions, _jsonSerializer));
}
/// <summary>
/// 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.
/// </summary>
public static void Quit()
{
_socket.Emit("appQuit");
}
/// <summary>
/// All windows will be closed immediately without asking user and
/// the before-quit and will-quit events will not be emitted.
/// </summary>
/// <param name="exitCode">Exits immediately with exitCode. exitCode defaults to 0.</param>
public static void Exit(int exitCode = 0)
{
_socket.Emit("appExit", exitCode);
}
/// <summary>
/// Relaunches the app when current instance exits. By default the new instance will
/// use the same working directory and command line arguments with current instance.
/// 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.
/// </summary>
public static void Relaunch()
{
_socket.Emit("appRelaunch");
}
/// <summary>
/// Relaunches the app when current instance exits. By default the new instance will
/// use the same working directory and command line arguments with current instance.
/// 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.
/// </summary>
/// <param name="relaunchOptions"></param>
public static void Relaunch(RelaunchOptions relaunchOptions)
{
_socket.Emit("appRelaunch", JObject.FromObject(relaunchOptions, _jsonSerializer));
}
/// <summary>
/// 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.
/// </summary>
public static void Focus()
{
_socket.Emit("appFocus");
}
/// <summary>
/// Hides all application windows without minimizing them.
/// </summary>
public static void Hide()
{
_socket.Emit("appHide");
}
/// <summary>
/// Shows application windows after they were hidden. Does not automatically focus them.
/// </summary>
public static void Show()
{
_socket.Emit("appShow");
}
/// <summary>
/// The current application directory.
/// </summary>
/// <returns></returns>
public async static Task<string> GetAppPathAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
@@ -95,6 +146,11 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// You can request the following paths by the name.
/// </summary>
/// <param name="pathName"></param>
/// <returns>A path to a special directory or file associated with name.</returns>
public async static Task<string> GetPathAsync(PathName pathName)
{
var taskCompletionSource = new TaskCompletionSource<string>();
@@ -112,6 +168,12 @@ namespace ElectronNET.API
}
// TODO: Fertig coden
/// <summary>
/// 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.
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
//public async static Task<NativeImage> GetFileIconAsync(string filePath)
//{
// var taskCompletionSource = new TaskCompletionSource<NativeImage>();
@@ -133,6 +195,14 @@ namespace ElectronNET.API
//}
// TODO: Fertig coden
/// <summary>
/// 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.
/// </summary>
/// <param name="filePath"></param>
/// <param name="fileIconOptions"></param>
/// <returns></returns>
//public async static Task<NativeImage> GetFileIconAsync(string filePath, FileIconOptions fileIconOptions)
//{
// var taskCompletionSource = new TaskCompletionSource<NativeImage>();
@@ -150,11 +220,27 @@ namespace ElectronNET.API
// return await taskCompletionSource.Task;
//}
/// <summary>
/// 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.
/// </summary>
/// <param name="name"></param>
/// <param name="path"></param>
public static void SetPath(string name, string path)
{
_socket.Emit("appSetPath", name, path);
}
/// <summary>
/// The version of the loaded application.
/// If no version is found in the applications package.json file,
/// the version of the current bundle or executable is returned.
/// </summary>
/// <returns></returns>
public async static Task<string> GetVersionAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
@@ -170,6 +256,13 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <returns>The current applications name, which is the name in the applications package.json file.</returns>
public async static Task<string> GetNameAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
@@ -185,11 +278,21 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Overrides the current application's name.
/// </summary>
/// <param name="name">Application's name</param>
public static void SetName(string name)
{
_socket.Emit("appSetName", name);
}
/// <summary>
/// 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.
/// </summary>
/// <returns></returns>
public async static Task<string> GetLocaleAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
@@ -205,16 +308,43 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="path"></param>
public static void AddRecentDocument(string path)
{
_socket.Emit("appAddRecentDocument", path);
}
/// <summary>
/// Clears the recent documents list.
/// </summary>
public static void ClearRecentDocuments()
{
_socket.Emit("appClearRecentDocuments");
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.
/// If you want your app to handle electron:// links,
/// call this method with electron as the parameter.</param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> SetAsDefaultProtocolClientAsync(string protocol)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -230,6 +360,25 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.
/// If you want your app to handle electron:// links,
/// call this method with electron as the parameter.</param>
/// <param name="path">Defaults to process.execPath</param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -245,6 +394,26 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.
/// If you want your app to handle electron:// links,
/// call this method with electron as the parameter.</param>
/// <param name="path">Defaults to process.execPath</param>
/// <param name="args">Defaults to an empty array</param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path, string[] args)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -260,6 +429,12 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -275,6 +450,13 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <param name="path">Defaults to process.execPath.</param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -290,6 +472,14 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <param name="path">Defaults to process.execPath.</param>
/// <param name="args">Defaults to an empty array.</param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -305,6 +495,17 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <returns>Returns Boolean</returns>
public async static Task<bool> IsDefaultProtocolClientAsync(string protocol)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -320,6 +521,18 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <param name="path">Defaults to process.execPath.</param>
/// <returns>Returns Boolean</returns>
public async static Task<bool> IsDefaultProtocolClientAsync(string protocol, string path)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -335,6 +548,19 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="protocol">The name of your protocol, without ://.</param>
/// <param name="path">Defaults to process.execPath.</param>
/// <param name="args">Defaults to an empty array.</param>
/// <returns>Returns Boolean</returns>
public async static Task<bool> IsDefaultProtocolClientAsync(string protocol, string path, string[] args)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -350,6 +576,13 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="userTasks">Array of Task objects.</param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> SetUserTasksAsync(UserTask[] userTasks)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -365,6 +598,10 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Jump List settings for the application.
/// </summary>
/// <returns></returns>
public async static Task<JumpListSettings> GetJumpListSettingsAsync()
{
var taskCompletionSource = new TaskCompletionSource<JumpListSettings>();
@@ -380,11 +617,50 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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().
/// </summary>
/// <param name="jumpListCategories"></param>
public static void SetJumpList(JumpListCategory[] jumpListCategories)
{
_socket.Emit("appSetJumpList", JObject.FromObject(jumpListCategories, _jsonSerializer));
}
/// <summary>
/// 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.
/// </summary>
/// <param name="newInstanceOpened">Lambda with an array of the second instances command line arguments.
/// The second parameter is the working directory path.</param>
/// <returns>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.</returns>
public async static Task<bool> MakeSingleInstanceAsync(Action<string[], string> newInstanceOpened)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -410,21 +686,42 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Releases all locks that were created by makeSingleInstance. This will allow
/// multiple instances of the application to once again run side by side.
/// </summary>
public static void ReleaseSingleInstance()
{
_socket.Emit("appReleaseSingleInstance");
}
/// <summary>
/// Creates an NSUserActivity and sets it as the current activity. The activity is
/// eligible for Handoff to another device afterward.
/// </summary>
/// <param name="type">Uniquely identifies the activity. Maps to NSUserActivity.activityType.</param>
/// <param name="userInfo">App-specific state to store for use by another device.</param>
public static void SetUserActivity(string type, object userInfo)
{
_socket.Emit("appSetUserActivity", type, userInfo);
}
/// <summary>
/// Creates an NSUserActivity and sets it as the current activity. The activity is
/// eligible for Handoff to another device afterward.
/// </summary>
/// <param name="type">Uniquely identifies the activity. Maps to NSUserActivity.activityType.</param>
/// <param name="userInfo">App-specific state to store for use by another device.</param>
/// <param name="webpageURL">The webpage to load in a browser if no suitable app is installed on the resuming device. The scheme must be http or https.</param>
public static void SetUserActivity(string type, object userInfo, string webpageURL)
{
_socket.Emit("appSetUserActivity", type, userInfo, webpageURL);
}
/// <summary>
/// The type of the currently running activity.
/// </summary>
/// <returns></returns>
public async static Task<string> GetCurrentActivityTypeAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
@@ -440,11 +737,22 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Changes the Application User Model ID to id.
/// </summary>
/// <param name="id"></param>
public static void SetAppUserModelId(string id)
{
_socket.Emit("appSetAppUserModelId", id);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="options"></param>
/// <returns>Result of import. Value of 0 indicates success.</returns>
public async static Task<int> ImportCertificateAsync(ImportCertificateOptions options)
{
var taskCompletionSource = new TaskCompletionSource<int>();
@@ -460,6 +768,10 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Memory and cpu usage statistics of all the processes associated with the app.
/// </summary>
/// <returns></returns>
public async static Task<ProcessMetric[]> GetAppMetricsAsync()
{
var taskCompletionSource = new TaskCompletionSource<ProcessMetric[]>();
@@ -477,6 +789,10 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// The Graphics Feature Status from chrome://gpu/.
/// </summary>
/// <returns></returns>
public async static Task<GPUFeatureStatus> GetGpuFeatureStatusAsync()
{
var taskCompletionSource = new TaskCompletionSource<GPUFeatureStatus>();
@@ -494,6 +810,14 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="count"></param>
/// <returns>Whether the call succeeded.</returns>
public async static Task<bool> SetBadgeCountAsync(int count)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -509,6 +833,10 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// The current value displayed in the counter badge.
/// </summary>
/// <returns></returns>
public async static Task<int> GetBadgeCountAsync()
{
var taskCompletionSource = new TaskCompletionSource<int>();
@@ -524,6 +852,10 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Whether the current desktop environment is Unity launcher.
/// </summary>
/// <returns></returns>
public async static Task<bool> IsUnityRunningAsync()
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -539,6 +871,12 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <returns></returns>
public async static Task<LoginItemSettings> GetLoginItemSettingsAsync()
{
var taskCompletionSource = new TaskCompletionSource<LoginItemSettings>();
@@ -554,6 +892,13 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public async static Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options)
{
var taskCompletionSource = new TaskCompletionSource<LoginItemSettings>();
@@ -569,11 +914,23 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="loginSettings"></param>
public static void SetLoginItemSettings(LoginSettings loginSettings)
{
_socket.Emit("appSetLoginItemSettings", JObject.FromObject(loginSettings, _jsonSerializer));
}
/// <summary>
/// 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.
/// </summary>
/// <returns>true if Chromes accessibility support is enabled, false otherwise.</returns>
public async static Task<bool> IsAccessibilitySupportEnabledAsync()
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -589,31 +946,65 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Set the about panel options. This will override the values defined in the app's
/// .plist file. See the Apple docs for more details.
/// </summary>
/// <param name="options"></param>
public static void SetAboutPanelOptions(AboutPanelOptions options)
{
_socket.Emit("appSetAboutPanelOptions", JObject.FromObject(options, _jsonSerializer));
}
/// <summary>
/// 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.
/// </summary>
/// <param name="theSwtich">A command-line switch.</param>
public static void CommandLineAppendSwitch(string theSwtich)
{
_socket.Emit("appCommandLineAppendSwitch", theSwtich);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="theSwtich">A command-line switch.</param>
/// <param name="value">A value for the given switch.</param>
public static void CommandLineAppendSwitch(string theSwtich, string value)
{
_socket.Emit("appCommandLineAppendSwitch", theSwtich, value);
}
/// <summary>
/// Append an argument to Chromium's command line. The argument will be quoted
/// correctly.Note: This will not affect process.argv.
/// </summary>
/// <param name="value">The argument to append to the command line.</param>
public static void CommandLineAppendArgument(string value)
{
_socket.Emit("appCommandLineAppendArgument", value);
}
/// <summary>
/// Enables mixed sandbox mode on the app. This method can only be called before app is ready.
/// </summary>
public static void EnableMixedSandbox()
{
_socket.Emit("appEnableMixedSandbox");
}
/// <summary>
/// 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.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public async static Task<int> DockBounceAsync(DockBounceType type)
{
var taskCompletionSource = new TaskCompletionSource<int>();
@@ -629,21 +1020,37 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Cancel the bounce of id.
/// </summary>
/// <param name="id"></param>
public static void DockCancelBounce(int id)
{
_socket.Emit("appDockCancelBounce", id);
}
/// <summary>
/// Bounces the Downloads stack if the filePath is inside the Downloads folder.
/// </summary>
/// <param name="filePath"></param>
public static void DockDownloadFinished(string filePath)
{
_socket.Emit("appDockDownloadFinished", filePath);
}
/// <summary>
/// Sets the string to be displayed in the docks badging area.
/// </summary>
/// <param name="text"></param>
public static void DockSetBadge(string text)
{
_socket.Emit("appDockSetBadge", text);
}
/// <summary>
/// Gets the string to be displayed in the docks badging area.
/// </summary>
/// <returns></returns>
public async static Task<string> DockGetBadgeAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
@@ -659,16 +1066,27 @@ namespace ElectronNET.API
return await taskCompletionSource.Task;
}
/// <summary>
/// Hides the dock icon.
/// </summary>
public static void DockHide()
{
_socket.Emit("appDockHide");
}
/// <summary>
/// Shows the dock icon.
/// </summary>
public static void DockShow()
{
_socket.Emit("appDockShow");
}
/// <summary>
/// Whether the dock icon is visible. The app.dock.show() call is asynchronous
/// so this method might not return true immediately after that call.
/// </summary>
/// <returns></returns>
public async static Task<bool> DockIsVisibleAsync()
{
var taskCompletionSource = new TaskCompletionSource<bool>();
@@ -685,16 +1103,27 @@ namespace ElectronNET.API
}
// TODO: Menu lösung muss gemacht werden und imeplementiert
/// <summary>
/// Sets the application's dock menu.
/// </summary>
public static void DockSetMenu()
{
_socket.Emit("appDockSetMenu");
}
/// <summary>
/// Sets the image associated with this dock icon.
/// </summary>
/// <param name="image"></param>
public static void DockSetIcon(string image)
{
_socket.Emit("appDockSetIcon", image);
}
/// <summary>
/// Sets the image associated with this dock icon.
/// </summary>
/// <param name="image"></param>
//public static void DockSetIcon(NativeImage image)
//{
// _socket.Emit("appDockSetIcon", JObject.FromObject(image, _jsonSerializer));

View File

@@ -4,8 +4,19 @@ namespace ElectronNET.API
{
public class JumpListCategory
{
/// <summary>
/// Must be set if type is custom, otherwise it should be omitted.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Array of objects if type is tasks or custom, otherwise it should be omitted.
/// </summary>
public JumpListItem[] Items { get; set; } = new JumpListItem[0];
/// <summary>
/// One of the following: "tasks" | "frequent" | "recent" | "custom"
/// </summary>
public string Type { get; set; } = "tasks";
}
}

View File

@@ -2,13 +2,50 @@
{
public class JumpListItem
{
/// <summary>
/// The command line arguments when program is executed. Should only be set if type is task.
/// </summary>
public string Args { get; set; } = string.Empty;
/// <summary>
/// Description of the task (displayed in a tooltip). Should only be set if type is task.
/// </summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// 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.
/// </summary>
public int IconIndex { get; set; } = 0;
/// <summary>
/// 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.
/// </summary>
public string IconPath { get; set; } = string.Empty;
/// <summary>
/// Path of the file to open, should only be set if type is file.
/// </summary>
public string Path { get; set; } = string.Empty;
/// <summary>
/// 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.
/// </summary>
public string Program { get; set; } = string.Empty;
/// <summary>
/// The text to be displayed for the item in the Jump List. Should only be set if type is task.
/// </summary>
public string Title { get; set; } = string.Empty;
/// <summary>
/// One of the following: "task" | "separator" | "file"
/// </summary>
public string Type {get; set; } = string.Empty;
}
}

View File

@@ -2,8 +2,14 @@
{
public class JumpListSettings
{
/// <summary>
/// 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).
/// </summary>
public int MinItems { get; set; } = 0;
/// <summary>
/// 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.
/// </summary>
public JumpListItem[] RemovedItems { get; set; } = new JumpListItem[0];
}
}

View File

@@ -1,24 +1,76 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
namespace ElectronNET.API.Entities
{
public enum PathName
{
/// <summary>
/// Users home directory.
/// </summary>
home,
/// <summary>
/// Per-user application data directory.
/// </summary>
appData,
/// <summary>
/// The directory for storing your apps configuration files,
/// which by default it is the appData directory appended with your apps name.
/// </summary>
userData,
/// <summary>
/// Temporary directory.
/// </summary>
temp,
/// <summary>
/// The current executable file.
/// </summary>
exe,
/// <summary>
/// The libchromiumcontent library.
/// </summary>
module,
/// <summary>
/// The current users Desktop directory.
/// </summary>
desktop,
/// <summary>
/// Directory for a users “My Documents”.
/// </summary>
documents,
/// <summary>
/// Directory for a users downloads.
/// </summary>
downloads,
/// <summary>
/// Directory for a users music.
/// </summary>
music,
/// <summary>
/// Directory for a users pictures.
/// </summary>
pictures,
/// <summary>
/// Directory for a users videos.
/// </summary>
videos,
/// <summary>
///
/// </summary>
logs,
/// <summary>
/// Full path to the system version of the Pepper Flash plugin.
/// </summary>
pepperFlashSystemPlugin
}
}

View File

@@ -3,9 +3,9 @@ using Quobject.SocketIoClientDotNet.Client;
namespace ElectronNET.API
{
//
// Summary:
// Communicate asynchronously from the main process to renderer processes.
/// <summary>
/// Communicate asynchronously from the main process to renderer processes.
/// </summary>
public class IpcMain
{
private Socket _socket;
@@ -27,50 +27,35 @@ namespace ElectronNET.API
_socket.On(channel, listener);
}
// Summary:
// Adds a one time listener method for the event. This listener is invoked only
// the next time a message is sent to channel, after which it is removed.
//
// Parameters:
// channel:
// Channelname.
//
// listener:
// Callback Method.
//
/// <summary>
/// Adds a one time listener method for the event. This listener is invoked only
/// the next time a message is sent to channel, after which it is removed.
/// </summary>
/// <param name="channel">Channelname.</param>
/// <param name="listener">Callback Method.</param>
public void Once(string channel, Action<object> listener)
{
_socket.Emit("registerOnceIpcMainChannel", channel);
_socket.On(channel, listener);
}
//
// Summary:
// Removes listeners of the specified channel.
//
// Parameters:
// channel:
// Channelname.
//
/// <summary>
/// Removes listeners of the specified channel.
/// </summary>
/// <param name="channel">Channelname.</param>
public void RemoveAllListeners(string channel)
{
_socket.Emit("removeAllListenersIpcMainChannel", channel);
}
//
// Summary:
// Send a message to the renderer process asynchronously via channel, you can also send
// arbitrary arguments. Arguments will be serialized in JSON internally and hence
// no functions or prototype chain will be included. The renderer process handles it by
// listening for channel with ipcRenderer module.
//
// Parameters:
// channel:
// Channelname.
//
// data:
// Arguments data.
//
/// <summary>
/// Send a message to the renderer process asynchronously via channel, you can also send
/// arbitrary arguments. Arguments will be serialized in JSON internally and hence
/// no functions or prototype chain will be included. The renderer process handles it by
/// listening for channel with ipcRenderer module.
/// </summary>
/// <param name="channel">Channelname.</param>
/// <param name="data">Arguments data.</param>
public void Send(string channel, params object[] data)
{
_socket.Emit("sendToIpcRenderer", channel, data);