Merge branch 'develop'

This commit is contained in:
Florian Rappl
2025-10-31 17:52:49 +01:00
350 changed files with 22446 additions and 5830 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,621 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Enable apps to automatically update themselves. Based on electron-updater.
/// </summary>
public sealed class AutoUpdater
{
/// <summary>
/// Whether to automatically download an update when it is found. (Default is true)
/// </summary>
public bool AutoDownload
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-autoDownload-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-autoDownload-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-set", value);
}
}
/// <summary>
/// Whether to automatically install a downloaded update on app quit (if `QuitAndInstall` was not called before).
///
/// Applicable only on Windows and Linux.
/// </summary>
public bool AutoInstallOnAppQuit
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-autoInstallOnAppQuit-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-autoInstallOnAppQuit-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-set", value);
}
}
/// <summary>
/// *GitHub provider only.* Whether to allow update to pre-release versions.
/// Defaults to "true" if application version contains prerelease components (e.g. "0.12.1-alpha.1", here "alpha" is a prerelease component), otherwise "false".
///
/// If "true", downgrade will be allowed("allowDowngrade" will be set to "true").
/// </summary>
public bool AllowPrerelease
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-allowPrerelease-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-allowPrerelease-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-set", value);
}
}
/// <summary>
/// *GitHub provider only.*
/// Get all release notes (from current version to latest), not just the latest (Default is false).
/// </summary>
public bool FullChangelog
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-fullChangelog-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-fullChangelog-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-set", value);
}
}
/// <summary>
/// Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).
/// Taken in account only if channel differs (pre-release version component in terms of semantic versioning).
/// Default is false.
/// </summary>
public bool AllowDowngrade
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-allowDowngrade-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-allowDowngrade-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-set", value);
}
}
/// <summary>
/// For test only.
/// </summary>
public string UpdateConfigPath
{
get
{
return Task.Run<string>(() =>
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("autoUpdater-updateConfigPath-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-updateConfigPath-get-reply");
taskCompletionSource.SetResult(result.ToString());
});
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
return taskCompletionSource.Task;
}).Result;
}
}
/// <summary>
/// The current application version
/// </summary>
public Task<SemVer> CurrentVersionAsync
{
get
{
return Task.Run<SemVer>(() =>
{
var taskCompletionSource = new TaskCompletionSource<SemVer>();
BridgeConnector.Socket.On("autoUpdater-currentVersion-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-currentVersion-get-reply");
SemVer version = ((JObject)result).ToObject<SemVer>();
taskCompletionSource.SetResult(version);
});
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// Get the update channel. Not applicable for GitHub.
/// Doesnt return channel from the update configuration, only if was previously set.
/// </summary>
[Obsolete("Use the asynchronous version ChannelAsync instead")]
public string Channel
{
get
{
return ChannelAsync.Result;
}
}
/// <summary>
/// Get the update channel. Not applicable for GitHub.
/// Doesnt return channel from the update configuration, only if was previously set.
/// </summary>
public Task<string> ChannelAsync
{
get
{
return Task.Run<string>(() =>
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("autoUpdater-channel-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
taskCompletionSource.SetResult(result.ToString());
});
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// The request headers.
/// </summary>
public Task<Dictionary<string, string>> RequestHeadersAsync
{
get
{
return Task.Run(() =>
{
var taskCompletionSource = new TaskCompletionSource<Dictionary<string, string>>();
BridgeConnector.Socket.On("autoUpdater-requestHeaders-get-reply", (headers) =>
{
BridgeConnector.Socket.Off("autoUpdater-requestHeaders-get-reply");
Dictionary<string, string> result = ((JObject)headers).ToObject<Dictionary<string, string>>();
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// The request headers.
/// </summary>
public Dictionary<string, string> RequestHeaders
{
set
{
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
}
}
/// <summary>
/// Emitted when there is an error while updating.
/// </summary>
public event Action<string> OnError
{
add
{
if (_error == null)
{
BridgeConnector.Socket.On("autoUpdater-error" + GetHashCode(), (message) =>
{
_error(message.ToString());
});
BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode());
}
_error += value;
}
remove
{
_error -= value;
if (_error == null)
BridgeConnector.Socket.Off("autoUpdater-error" + GetHashCode());
}
}
private event Action<string> _error;
/// <summary>
/// Emitted when checking if an update has started.
/// </summary>
public event Action OnCheckingForUpdate
{
add
{
if (_checkingForUpdate == null)
{
BridgeConnector.Socket.On("autoUpdater-checking-for-update" + GetHashCode(), () =>
{
_checkingForUpdate();
});
BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode());
}
_checkingForUpdate += value;
}
remove
{
_checkingForUpdate -= value;
if (_checkingForUpdate == null)
BridgeConnector.Socket.Off("autoUpdater-checking-for-update" + GetHashCode());
}
}
private event Action _checkingForUpdate;
/// <summary>
/// Emitted when there is an available update.
/// The update is downloaded automatically if AutoDownload is true.
/// </summary>
public event Action<UpdateInfo> OnUpdateAvailable
{
add
{
if (_updateAvailable == null)
{
BridgeConnector.Socket.On("autoUpdater-update-available" + GetHashCode(), (updateInfo) =>
{
_updateAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode());
}
_updateAvailable += value;
}
remove
{
_updateAvailable -= value;
if (_updateAvailable == null)
BridgeConnector.Socket.Off("autoUpdater-update-available" + GetHashCode());
}
}
private event Action<UpdateInfo> _updateAvailable;
/// <summary>
/// Emitted when there is no available update.
/// </summary>
public event Action<UpdateInfo> OnUpdateNotAvailable
{
add
{
if (_updateNotAvailable == null)
{
BridgeConnector.Socket.On("autoUpdater-update-not-available" + GetHashCode(), (updateInfo) =>
{
_updateNotAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode());
}
_updateNotAvailable += value;
}
remove
{
_updateNotAvailable -= value;
if (_updateNotAvailable == null)
BridgeConnector.Socket.Off("autoUpdater-update-not-available" + GetHashCode());
}
}
private event Action<UpdateInfo> _updateNotAvailable;
/// <summary>
/// Emitted on download progress.
/// </summary>
public event Action<ProgressInfo> OnDownloadProgress
{
add
{
if (_downloadProgress == null)
{
BridgeConnector.Socket.On("autoUpdater-download-progress" + GetHashCode(), (progressInfo) =>
{
_downloadProgress(JObject.Parse(progressInfo.ToString()).ToObject<ProgressInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode());
}
_downloadProgress += value;
}
remove
{
_downloadProgress -= value;
if (_downloadProgress == null)
BridgeConnector.Socket.Off("autoUpdater-download-progress" + GetHashCode());
}
}
private event Action<ProgressInfo> _downloadProgress;
/// <summary>
/// Emitted on download complete.
/// </summary>
public event Action<UpdateInfo> OnUpdateDownloaded
{
add
{
if (_updateDownloaded == null)
{
BridgeConnector.Socket.On("autoUpdater-update-downloaded" + GetHashCode(), (updateInfo) =>
{
_updateDownloaded(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode());
}
_updateDownloaded += value;
}
remove
{
_updateDownloaded -= value;
if (_updateDownloaded == null)
BridgeConnector.Socket.Off("autoUpdater-update-downloaded" + GetHashCode());
}
}
private event Action<UpdateInfo> _updateDownloaded;
private static AutoUpdater _autoUpdater;
private static object _syncRoot = new object();
internal AutoUpdater() { }
internal static AutoUpdater Instance
{
get
{
if (_autoUpdater == null)
{
lock (_syncRoot)
{
if (_autoUpdater == null)
{
_autoUpdater = new AutoUpdater();
}
}
}
return _autoUpdater;
}
}
/// <summary>
/// Asks the server whether there is an update.
/// </summary>
/// <returns></returns>
public Task<UpdateCheckResult> CheckForUpdatesAsync()
{
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
{
try
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesError" + guid, (error) =>
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
string message = "An error occurred in CheckForUpdatesAsync";
if (error != null && !string.IsNullOrEmpty(error.ToString()))
message = JsonConvert.SerializeObject(error);
taskCompletionSource.SetException(new Exception(message));
});
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Asks the server whether there is an update.
///
/// This will immediately download an update, then install when the app quits.
/// </summary>
/// <returns></returns>
public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
{
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
{
try
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
if (updateCheckResult == null)
taskCompletionSource.SetResult(null);
else
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyError" + guid, (error) =>
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
string message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify";
if (error != null)
message = JsonConvert.SerializeObject(error);
taskCompletionSource.SetException(new Exception(message));
});
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Restarts the app and installs the update after it has been downloaded.
/// It should only be called after `update-downloaded` has been emitted.
///
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
/// This is different from the normal quit event sequence.
/// </summary>
/// <param name="isSilent">*windows-only* Runs the installer in silent mode. Defaults to `false`.</param>
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
{
BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
}
/// <summary>
/// Start downloading update manually. You can use this method if "AutoDownload" option is set to "false".
/// </summary>
/// <returns>Path to downloaded file.</returns>
public Task<string> DownloadUpdateAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
{
BridgeConnector.Socket.Off("autoUpdaterDownloadUpdateComplete" + guid);
taskCompletionSource.SetResult(downloadedPath.ToString());
});
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Feed URL.
/// </summary>
/// <returns>Feed URL.</returns>
public Task<string> GetFeedURLAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
{
BridgeConnector.Socket.Off("autoUpdaterGetFeedURLComplete" + guid);
taskCompletionSource.SetResult(downloadedPath.ToString());
});
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
return taskCompletionSource.Task;
}
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
}
}

View File

@@ -0,0 +1,97 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
/// It is like a child window, except that it is positioned relative to its owning window.
/// It is meant to be an alternative to the webview tag.
/// </summary>
public class BrowserView
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; internal set; }
/// <summary>
/// Render and control web pages.
/// </summary>
public WebContents WebContents { get; internal set; }
/// <summary>
/// Resizes and moves the view to the supplied bounds relative to the window.
///
/// (experimental)
/// </summary>
public Rectangle Bounds
{
get
{
return Task.Run<Rectangle>(() =>
{
var taskCompletionSource = new TaskCompletionSource<Rectangle>();
BridgeConnector.Socket.On("browserView-getBounds-reply", (result) =>
{
BridgeConnector.Socket.Off("browserView-getBounds-reply");
taskCompletionSource.SetResult((Rectangle)result);
});
BridgeConnector.Socket.Emit("browserView-getBounds", Id);
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
}
}
/// <summary>
/// BrowserView
/// </summary>
internal BrowserView(int id)
{
Id = id;
// Workaround: increase the Id so as not to conflict with BrowserWindow id
// the backend detect about the value an BrowserView
WebContents = new WebContents(id + 1000);
}
/// <summary>
/// (experimental)
/// </summary>
/// <param name="options"></param>
public void SetAutoResize(AutoResizeOptions options)
{
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
}
/// <summary>
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
///
/// (experimental)
/// </summary>
/// <param name="color">Color in #aarrggbb or #argb form. The alpha channel is optional.</param>
public void SetBackgroundColor(string color)
{
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,281 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Perform copy and paste operations on the system clipboard.
/// </summary>
public sealed class Clipboard
{
private static Clipboard _clipboard;
private static object _syncRoot = new object();
internal Clipboard() { }
internal static Clipboard Instance
{
get
{
if (_clipboard == null)
{
lock (_syncRoot)
{
if (_clipboard == null)
{
_clipboard = new Clipboard();
}
}
}
return _clipboard;
}
}
/// <summary>
/// Read the content in the clipboard as plain text.
/// </summary>
/// <param name="type"></param>
/// <returns>The content in the clipboard as plain text.</returns>
public Task<string> ReadTextAsync(string type = "")
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("clipboard-readText-Completed", (text) =>
{
BridgeConnector.Socket.Off("clipboard-readText-Completed");
taskCompletionSource.SetResult(text.ToString());
});
BridgeConnector.Socket.Emit("clipboard-readText", type);
return taskCompletionSource.Task;
}
/// <summary>
/// Writes the text into the clipboard as plain text.
/// </summary>
/// <param name="text"></param>
/// <param name="type"></param>
public void WriteText(string text, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeText", text, type);
}
/// <summary>
/// The content in the clipboard as markup.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public Task<string> ReadHTMLAsync(string type = "")
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("clipboard-readHTML-Completed", (text) =>
{
BridgeConnector.Socket.Off("clipboard-readHTML-Completed");
taskCompletionSource.SetResult(text.ToString());
});
BridgeConnector.Socket.Emit("clipboard-readHTML", type);
return taskCompletionSource.Task;
}
/// <summary>
/// Writes markup to the clipboard.
/// </summary>
/// <param name="markup"></param>
/// <param name="type"></param>
public void WriteHTML(string markup, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeHTML", markup, type);
}
/// <summary>
/// The content in the clipboard as RTF.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public Task<string> ReadRTFAsync(string type = "")
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("clipboard-readRTF-Completed", (text) =>
{
BridgeConnector.Socket.Off("clipboard-readRTF-Completed");
taskCompletionSource.SetResult(text.ToString());
});
BridgeConnector.Socket.Emit("clipboard-readRTF", type);
return taskCompletionSource.Task;
}
/// <summary>
/// Writes the text into the clipboard in RTF.
/// </summary>
/// <param name="text"></param>
/// <param name="type"></param>
public void WriteRTF(string text, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeHTML", text, type);
}
/// <summary>
/// Returns an Object containing title and url keys representing
/// the bookmark in the clipboard. The title and url values will
/// be empty strings when the bookmark is unavailable.
/// </summary>
/// <returns></returns>
public Task<ReadBookmark> ReadBookmarkAsync()
{
var taskCompletionSource = new TaskCompletionSource<ReadBookmark>();
BridgeConnector.Socket.On("clipboard-readBookmark-Completed", (bookmark) =>
{
BridgeConnector.Socket.Off("clipboard-readBookmark-Completed");
taskCompletionSource.SetResult(((JObject)bookmark).ToObject<ReadBookmark>());
});
BridgeConnector.Socket.Emit("clipboard-readBookmark");
return taskCompletionSource.Task;
}
/// <summary>
/// Writes the title and url into the clipboard as a bookmark.
///
/// Note: Most apps on Windows dont support pasting bookmarks
/// into them so you can use clipboard.write to write both a
/// bookmark and fallback text to the clipboard.
/// </summary>
/// <param name="title"></param>
/// <param name="url"></param>
/// <param name="type"></param>
public void WriteBookmark(string title, string url, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeBookmark", title, url, type);
}
/// <summary>
/// macOS: The text on the find pasteboard. This method uses synchronous IPC
/// when called from the renderer process. The cached value is reread from the
/// find pasteboard whenever the application is activated.
/// </summary>
/// <returns></returns>
public Task<string> ReadFindTextAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("clipboard-readFindText-Completed", (text) =>
{
BridgeConnector.Socket.Off("clipboard-readFindText-Completed");
taskCompletionSource.SetResult(text.ToString());
});
BridgeConnector.Socket.Emit("clipboard-readFindText");
return taskCompletionSource.Task;
}
/// <summary>
/// macOS: Writes the text into the find pasteboard as plain text. This method uses
/// synchronous IPC when called from the renderer process.
/// </summary>
/// <param name="text"></param>
public void WriteFindText(string text)
{
BridgeConnector.Socket.Emit("clipboard-writeFindText", text);
}
/// <summary>
/// Clears the clipboard content.
/// </summary>
/// <param name="type"></param>
public void Clear(string type = "")
{
BridgeConnector.Socket.Emit("clipboard-clear", type);
}
/// <summary>
/// An array of supported formats for the clipboard type.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public Task<string[]> AvailableFormatsAsync(string type = "")
{
var taskCompletionSource = new TaskCompletionSource<string[]>();
BridgeConnector.Socket.On("clipboard-availableFormats-Completed", (formats) =>
{
BridgeConnector.Socket.Off("clipboard-availableFormats-Completed");
taskCompletionSource.SetResult(((JArray)formats).ToObject<string[]>());
});
BridgeConnector.Socket.Emit("clipboard-availableFormats", type);
return taskCompletionSource.Task;
}
/// <summary>
/// Writes data to the clipboard.
/// </summary>
/// <param name="data"></param>
/// <param name="type"></param>
public void Write(Data data, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-write", JObject.FromObject(data, _jsonSerializer), type);
}
/// <summary>
/// Reads an image from the clipboard.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public Task<NativeImage> ReadImageAsync(string type = "")
{
var taskCompletionSource = new TaskCompletionSource<NativeImage>();
BridgeConnector.Socket.On("clipboard-readImage-Completed", (image) =>
{
BridgeConnector.Socket.Off("clipboard-readImage-Completed");
var nativeImage = ((JObject)image).ToObject<NativeImage>();
taskCompletionSource.SetResult(nativeImage);
});
BridgeConnector.Socket.Emit("clipboard-readImage", type);
return taskCompletionSource.Task;
}
/// <summary>
/// Writes an image to the clipboard.
/// </summary>
/// <param name="image"></param>
/// <param name="type"></param>
public void WriteImage(NativeImage image, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonConvert.SerializeObject(image), type);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
}

View File

@@ -0,0 +1,116 @@
using System.Threading;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Manipulate the command line arguments for your app that Chromium reads.
/// </summary>
public sealed class CommandLine
{
internal CommandLine() { }
internal static CommandLine Instance
{
get
{
if (_commandLine == null)
{
lock (_syncRoot)
{
if (_commandLine == null)
{
_commandLine = new CommandLine();
}
}
}
return _commandLine;
}
}
private static CommandLine _commandLine;
private static object _syncRoot = new object();
/// <summary>
/// Append a switch (with optional value) to Chromium's command line.
/// </summary>
/// <param name="the_switch">A command-line switch, without the leading --</param>
/// <param name="value">(optional) - A value for the given switch</param>
/// <remarks>
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
/// </remarks>
public void AppendSwitch(string the_switch, string value = "")
{
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", the_switch, value);
}
/// <summary>
/// Append an argument to Chromium's command line. The argument will be quoted correctly. Switches will precede arguments regardless of appending order.
///
/// If you're appending an argument like <code>--switch=value</code>, consider using <code>appendSwitch('switch', 'value')</code> instead.
/// </summary>
/// <param name="value">The argument to append to the command line</param>
/// <remarks>
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
/// </remarks>
public void AppendArgument(string value)
{
BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
}
/// <summary>
/// Whether the command-line switch is present.
/// </summary>
/// <param name="switchName">A command-line switch</param>
/// <param name="cancellationToken"></param>
/// <returns>Whether the command-line switch is present.</returns>
public async Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<bool>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("appCommandLineHasSwitchCompleted", (result) =>
{
BridgeConnector.Socket.Off("appCommandLineHasSwitchCompleted");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("appCommandLineHasSwitch", switchName);
return await taskCompletionSource.Task.ConfigureAwait(false);
}
}
/// <summary>
/// The command-line switch value.
/// </summary>
/// <param name="switchName">A command-line switch</param>
/// <param name="cancellationToken"></param>
/// <returns>The command-line switch value.</returns>
/// <remarks>
/// Note: When the switch is not present or has no value, it returns empty string.
/// </remarks>
public async Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<string>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("appCommandLineGetSwitchValueCompleted", (result) =>
{
BridgeConnector.Socket.Off("appCommandLineGetSwitchValueCompleted");
taskCompletionSource.SetResult((string)result);
});
BridgeConnector.Socket.Emit("appCommandLineGetSwitchValue", switchName);
return await taskCompletionSource.Task.ConfigureAwait(false);
}
}
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace ElectronNET.API
{
/// <summary>
/// Query and modify a session's cookies.
/// </summary>
public class Cookies
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; private set; }
internal Cookies(int id)
{
Id = id;
}
/// <summary>
/// Emitted when a cookie is changed because it was added, edited, removed, or expired.
/// </summary>
public event Action<Cookie, CookieChangedCause, bool> OnChanged
{
add
{
if (_changed == null)
{
BridgeConnector.Socket.On("webContents-session-cookies-changed" + Id, (args) =>
{
Cookie cookie = ((JArray)args)[0].ToObject<Cookie>();
CookieChangedCause cause = ((JArray)args)[1].ToObject<CookieChangedCause>();
bool removed = ((JArray)args)[2].ToObject<bool>();
_changed(cookie, cause, removed);
});
BridgeConnector.Socket.Emit("register-webContents-session-cookies-changed", Id);
}
_changed += value;
}
remove
{
_changed -= value;
if (_changed == null)
BridgeConnector.Socket.Off("webContents-session-cookies-changed" + Id);
}
}
private event Action<Cookie, CookieChangedCause, bool> _changed;
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
}

View File

@@ -0,0 +1,238 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Display native system dialogs for opening and saving files, alerting, etc.
/// </summary>
public sealed class Dialog
{
private static Dialog _dialog;
private static object _syncRoot = new object();
internal Dialog() { }
internal static Dialog Instance
{
get
{
if (_dialog == null)
{
lock (_syncRoot)
{
if(_dialog == null)
{
_dialog = new Dialog();
}
}
}
return _dialog;
}
}
/// <summary>
/// Note: On Windows and Linux an open dialog can not be both a file selector
/// and a directory selector, so if you set properties to ['openFile', 'openDirectory']
/// on these platforms, a directory selector will be shown.
/// </summary>
/// <param name="browserWindow">The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.</param>
/// <param name="options"></param>
/// <returns>An array of file paths chosen by the user</returns>
public Task<string[]> ShowOpenDialogAsync(BrowserWindow browserWindow, OpenDialogOptions options)
{
var taskCompletionSource = new TaskCompletionSource<string[]>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showOpenDialogComplete" + guid, (filePaths) =>
{
BridgeConnector.Socket.Off("showOpenDialogComplete" + guid);
var result = ((JArray)filePaths).ToObject<string[]>();
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("showOpenDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer), guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Dialog for save files.
/// </summary>
/// <param name="browserWindow">The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.</param>
/// <param name="options"></param>
/// <returns>Returns String, the path of the file chosen by the user, if a callback is provided it returns an empty string.</returns>
public Task<string> ShowSaveDialogAsync(BrowserWindow browserWindow, SaveDialogOptions options)
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showSaveDialogComplete" + guid, (filename) =>
{
BridgeConnector.Socket.Off("showSaveDialogComplete" + guid);
taskCompletionSource.SetResult(filename.ToString());
});
BridgeConnector.Socket.Emit("showSaveDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer),
guid);
return taskCompletionSource.Task;
}
/// <summary>
/// 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).
/// </summary>
/// <param name="message"></param>
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
public async Task<MessageBoxResult> ShowMessageBoxAsync(string message)
{
return await this.ShowMessageBoxAsync(null, new MessageBoxOptions(message)).ConfigureAwait(false);
}
/// <summary>
/// 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).
/// </summary>
/// <param name="messageBoxOptions"></param>
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
public async Task<MessageBoxResult> ShowMessageBoxAsync(MessageBoxOptions messageBoxOptions)
{
return await this.ShowMessageBoxAsync(null, messageBoxOptions).ConfigureAwait(false);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="browserWindow">The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.</param>
/// <param name="message"></param>
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
public async Task<MessageBoxResult> ShowMessageBoxAsync(BrowserWindow browserWindow, string message)
{
return await this.ShowMessageBoxAsync(browserWindow, new MessageBoxOptions(message)).ConfigureAwait(false);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="browserWindow">The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.</param>
/// <param name="messageBoxOptions"></param>
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
public Task<MessageBoxResult> ShowMessageBoxAsync(BrowserWindow browserWindow, MessageBoxOptions messageBoxOptions)
{
var taskCompletionSource = new TaskCompletionSource<MessageBoxResult>();
var guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showMessageBoxComplete" + guid, (args) =>
{
BridgeConnector.Socket.Off("showMessageBoxComplete" + guid);
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), guid);
} else
{
BridgeConnector.Socket.Emit("showMessageBox",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(messageBoxOptions, _jsonSerializer),
guid);
}
return taskCompletionSource.Task;
}
/// <summary>
/// Displays a modal dialog that shows an error message.
///
/// This API can be called safely before the ready event the app module emits,
/// it is usually used to report errors in early stage of startup.If called
/// before the app readyevent on Linux, the message will be emitted to stderr,
/// and no GUI dialog will appear.
/// </summary>
/// <param name="title">The title to display in the error box.</param>
/// <param name="content">The text content to display in the error box.</param>
public void ShowErrorBox(string title, string content)
{
BridgeConnector.Socket.Emit("showErrorBox", title, content);
}
/// <summary>
/// On macOS, this displays a modal dialog that shows a message and certificate information,
/// and gives the user the option of trusting/importing the certificate. If you provide a
/// browserWindow argument the dialog will be attached to the parent window, making it modal.
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public Task ShowCertificateTrustDialogAsync(CertificateTrustDialogOptions options)
{
return ShowCertificateTrustDialogAsync(null, options);
}
/// <summary>
/// On macOS, this displays a modal dialog that shows a message and certificate information,
/// and gives the user the option of trusting/importing the certificate. If you provide a
/// browserWindow argument the dialog will be attached to the parent window, making it modal.
/// </summary>
/// <param name="browserWindow"></param>
/// <param name="options"></param>
/// <returns></returns>
public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options)
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showCertificateTrustDialogComplete" + guid, () =>
{
BridgeConnector.Socket.Off("showCertificateTrustDialogComplete" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("showCertificateTrustDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer),
guid);
return taskCompletionSource.Task;
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
}

View File

@@ -0,0 +1,232 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace ElectronNET.API
{
/// <summary>
/// Control your app in the macOS dock.
/// </summary>
public sealed class Dock
{
private static Dock _dock;
private static object _syncRoot = new object();
internal Dock()
{
}
internal static Dock Instance
{
get
{
if (_dock == null)
{
lock (_syncRoot)
{
if (_dock == null)
{
_dock = new Dock();
}
}
}
return _dock;
}
}
/// <summary>
/// When <see cref="DockBounceType.Critical"/> is passed, the dock icon will bounce until either the application becomes
/// active or the request is canceled. When <see cref="DockBounceType.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.
/// <para/>
/// Note: This method can only be used while the app is not focused; when the app is focused it will return -1.
/// </summary>
/// <param name="type">Can be critical or informational. The default is informational.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Return an ID representing the request.</returns>
public async Task<int> BounceAsync(DockBounceType type, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<int>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-bounce-completed", (id) =>
{
BridgeConnector.Socket.Off("dock-bounce-completed");
taskCompletionSource.SetResult((int) id);
});
BridgeConnector.Socket.Emit("dock-bounce", type.GetDescription());
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Cancel the bounce of id.
/// </summary>
/// <param name="id">Id of the request.</param>
public void CancelBounce(int id)
{
BridgeConnector.Socket.Emit("dock-cancelBounce", id);
}
/// <summary>
/// Bounces the Downloads stack if the filePath is inside the Downloads folder.
/// </summary>
/// <param name="filePath"></param>
public void DownloadFinished(string filePath)
{
BridgeConnector.Socket.Emit("dock-downloadFinished", filePath);
}
/// <summary>
/// Sets the string to be displayed in the docks badging area.
/// </summary>
/// <param name="text"></param>
public void SetBadge(string text)
{
BridgeConnector.Socket.Emit("dock-setBadge", text);
}
/// <summary>
/// Gets the string to be displayed in the docks badging area.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The badge string of the dock.</returns>
public async Task<string> GetBadgeAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<string>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-getBadge-completed", (text) =>
{
BridgeConnector.Socket.Off("dock-getBadge-completed");
taskCompletionSource.SetResult((string) text);
});
BridgeConnector.Socket.Emit("dock-getBadge");
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Hides the dock icon.
/// </summary>
public void Hide()
{
BridgeConnector.Socket.Emit("dock-hide");
}
/// <summary>
/// Shows the dock icon.
/// </summary>
public void Show()
{
BridgeConnector.Socket.Emit("dock-show");
}
/// <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>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the dock icon is visible.</returns>
public async Task<bool> IsVisibleAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<bool>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-isVisible-completed", (isVisible) =>
{
BridgeConnector.Socket.Off("dock-isVisible-completed");
taskCompletionSource.SetResult((bool) isVisible);
});
BridgeConnector.Socket.Emit("dock-isVisible");
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Gets the dock menu items.
/// </summary>
/// <value>
/// The menu items.
/// </value>
public IReadOnlyCollection<MenuItem> MenuItems { get { return _items.AsReadOnly(); } }
private List<MenuItem> _items = new List<MenuItem>();
/// <summary>
/// Sets the application's dock menu.
/// </summary>
public void SetMenu(MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
BridgeConnector.Socket.Emit("dock-setMenu", JArray.FromObject(menuItems, _jsonSerializer));
_items.AddRange(menuItems);
BridgeConnector.Socket.Off("dockMenuItemClicked");
BridgeConnector.Socket.On("dockMenuItemClicked", (id) => {
MenuItem menuItem = _items.GetMenuItem(id.ToString());
menuItem?.Click();
});
}
/// <summary>
/// TODO: Menu (macOS) still to be implemented
/// Gets the application's dock menu.
/// </summary>
public async Task<Menu> GetMenu(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<Menu>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-getMenu-completed", (menu) =>
{
BridgeConnector.Socket.Off("dock-getMenu-completed");
taskCompletionSource.SetResult(((JObject)menu).ToObject<Menu>());
});
BridgeConnector.Socket.Emit("dock-getMenu");
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Sets the image associated with this dock icon.
/// </summary>
/// <param name="image"></param>
public void SetIcon(string image)
{
BridgeConnector.Socket.Emit("dock-setIcon", image);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
}
}

View File

@@ -0,0 +1,97 @@
namespace ElectronNET.API
{
/// <summary>
/// The Electron.NET API
/// </summary>
public static class Electron
{
/// <summary>
/// Communicate asynchronously from the main process to renderer processes.
/// </summary>
public static IpcMain IpcMain { get { return IpcMain.Instance; } }
/// <summary>
/// Control your application's event lifecycle.
/// </summary>
public static App App { get { return App.Instance; } }
/// <summary>
/// Enable apps to automatically update themselves. Based on electron-updater.
/// </summary>
public static AutoUpdater AutoUpdater { get { return AutoUpdater.Instance; } }
/// <summary>
/// Control your windows.
/// </summary>
public static WindowManager WindowManager { get { return WindowManager.Instance; } }
/// <summary>
/// Create native application menus and context menus.
/// </summary>
public static Menu Menu { get { return Menu.Instance; } }
/// <summary>
/// Display native system dialogs for opening and saving files, alerting, etc.
/// </summary>
public static Dialog Dialog { get { return Dialog.Instance; } }
/// <summary>
/// Create OS desktop notifications
/// </summary>
public static Notification Notification { get { return Notification.Instance; } }
/// <summary>
/// Add icons and context menus to the systems notification area.
/// </summary>
public static Tray Tray { get { return Tray.Instance; } }
/// <summary>
/// Detect keyboard events when the application does not have keyboard focus.
/// </summary>
public static GlobalShortcut GlobalShortcut { get { return GlobalShortcut.Instance; } }
/// <summary>
/// Manage files and URLs using their default applications.
/// </summary>
public static Shell Shell { get { return Shell.Instance; } }
/// <summary>
/// Retrieve information about screen size, displays, cursor position, etc.
/// </summary>
public static Screen Screen { get { return Screen.Instance; } }
/// <summary>
/// Perform copy and paste operations on the system clipboard.
/// </summary>
public static Clipboard Clipboard { get { return Clipboard.Instance; } }
/// <summary>
/// Allows you to execute native JavaScript/TypeScript code from the host process.
///
/// It is only possible if the Electron.NET CLI has previously added an
/// ElectronHostHook directory:
/// <c>electronize add HostHook</c>
/// </summary>
public static HostHook HostHook { get { return HostHook.Instance; } }
/// <summary>
/// Allows you to execute native Lock and Unlock process.
/// </summary>
public static PowerMonitor PowerMonitor { get { return PowerMonitor.Instance; } }
/// <summary>
/// Read and respond to changes in Chromium's native color theme.
/// </summary>
public static NativeTheme NativeTheme { get { return NativeTheme.Instance; } }
/// <summary>
/// Control your app in the macOS dock.
/// </summary>
public static Dock Dock { get { return Dock.Instance; } }
/// <summary>
/// Electeon extensions to the Nodejs process object.
/// </summary>
public static Process Process { get { return Process.Instance; } }
}
}

View File

@@ -0,0 +1,48 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// About panel options.
/// </summary>
public class AboutPanelOptions
{
/// <summary>
/// The app's name.
/// </summary>
public string ApplicationName { get; set; }
/// <summary>
/// The app's version.
/// </summary>
public string ApplicationVersion { get; set; }
/// <summary>
/// Copyright information.
/// </summary>
public string Copyright { get; set; }
/// <summary>
/// The app's build version number.
/// </summary>
public string Version { get; set; }
/// <summary>
/// Credit information.
/// </summary>
public string Credits { get; set; }
/// <summary>
/// List of app authors.
/// </summary>
public string[] Authors { get; set; }
/// <summary>
/// The app's website.
/// </summary>
public string Website { get; set; }
/// <summary>
/// Path to the app's icon. On Linux, will be shown as 64x64 pixels while retaining aspect ratio.
/// </summary>
public string IconPath { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class AddRepresentationOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the buffer
/// </summary>
public byte[] Buffer { get; set; }
/// <summary>
/// Gets or sets the dataURL
/// </summary>
public string DataUrl { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class AppDetailsOptions
{
/// <summary>
/// Windows App User Model ID. It has to be set, otherwise the other options will have no effect.
/// </summary>
public string AppId { get; set; }
/// <summary>
/// Windows Relaunch Icon.
/// </summary>
public string AppIconPath { get; set; }
/// <summary>
/// Index of the icon in appIconPath. Ignored when appIconPath is not set. Default is 0.
/// </summary>
public int AppIconIndex { get; set; }
/// <summary>
/// Windows Relaunch Command.
/// </summary>
public string RelaunchCommand { get; set; }
/// <summary>
/// Windows Relaunch Display Name.
/// </summary>
public string RelaunchDisplayName { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class AutoResizeOptions
{
/// <summary>
/// If `true`, the view's width will grow and shrink together with the window.
/// `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Width { get; set; } = false;
/// <summary>
/// If `true`, the view's height will grow and shrink together with the window.
/// `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Height { get; set; } = false;
/// <summary>
/// If `true`, the view's x position and width will grow and shrink proportionally
/// with the window. `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Horizontal { get; set; } = false;
/// <summary>
/// If `true`, the view's y position and height will grow and shrink proportionally
/// with the window. `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Vertical { get; set; } = false;
}
}

View File

@@ -0,0 +1,13 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BitmapOptions
{
/// <summary>
/// Gets or sets the scale factor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Blob : IPostData
{
/// <summary>
/// The object represents a Blob
/// </summary>
public string Type { get; } = "blob";
/// <summary>
/// The UUID of the Blob being uploaded
/// </summary>
public string BlobUUID { get; set; }
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BlockMapDataHolder
{
/// <summary>
/// The file size. Used to verify downloaded size (save one HTTP request to get length).
/// Also used when block map data is embedded into the file(appimage, windows web installer package).
/// </summary>
public double Size { get; set; }
/// <summary>
/// The block map file size. Used when block map data is embedded into the file (appimage, windows web installer package).
/// This information can be obtained from the file itself, but it requires additional HTTP request,
/// so, to reduce request count, block map size is specified in the update metadata too.
/// </summary>
public double BlockMapSize { get; set; }
/// <summary>
/// The file checksum.
/// </summary>
public string Sha512 { get; set; }
/// <summary>
///
/// </summary>
public bool IsAdminRightsRequired { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BrowserViewConstructorOptions
{
/// <summary>
/// See BrowserWindow.
/// </summary>
public WebPreferences WebPreferences { get; set; }
/// <summary>
/// A proxy to set on creation in the format host:port.
/// The proxy can be alternatively set using the BrowserView.WebContents.SetProxyAsync function.
/// </summary>
public string Proxy { get; set; }
/// <summary>
/// The credentials of the Proxy in the format username:password.
/// These will only be used if the Proxy field is also set.
/// </summary>
public string ProxyCredentials { get; set; }
}
}

View File

@@ -0,0 +1,274 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BrowserWindowOptions
{
/// <summary>
/// Window's width in pixels. Default is 800.
/// </summary>
public int Width { get; set; } = 800;
/// <summary>
/// Window's height in pixels. Default is 600.
/// </summary>
public int Height { get; set; } = 600;
/// <summary>
/// ( if y is used) Window's left offset from screen. Default is to center the
/// window.
/// </summary>
public int X { get; set; } = -1;
/// <summary>
/// ( if x is used) Window's top offset from screen. Default is to center the
/// window.
/// </summary>
public int Y { get; set; } = -1;
/// <summary>
/// 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.
/// </summary>
public bool UseContentSize { get; set; }
/// <summary>
/// Show window in the center of the screen.
/// </summary>
public bool Center { get; set; }
/// <summary>
/// Window's minimum width. Default is 0.
/// </summary>
public int MinWidth { get; set; }
/// <summary>
/// Window's minimum height. Default is 0.
/// </summary>
public int MinHeight { get; set; }
/// <summary>
/// Window's maximum width. Default is no limit.
/// </summary>
public int MaxWidth { get; set; }
/// <summary>
/// Window's maximum height. Default is no limit.
/// </summary>
public int MaxHeight { get; set; }
/// <summary>
/// Whether window is resizable. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Resizable { get; set; } = true;
/// <summary>
/// Whether window is movable. This is not implemented on Linux. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Movable { get; set; } = true;
/// <summary>
/// Whether window is minimizable. This is not implemented on Linux. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Minimizable { get; set; } = true;
/// <summary>
/// Whether window is maximizable. This is not implemented on Linux. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Maximizable { get; set; } = true;
/// <summary>
/// Whether window is closable. This is not implemented on Linux. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Closable { get; set; } = true;
/// <summary>
/// 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.
/// </summary>
[DefaultValue(true)]
public bool Focusable { get; set; } = true;
/// <summary>
/// Whether the window should always stay on top of other windows. Default is false.
/// </summary>
public bool AlwaysOnTop { get; set; }
/// <summary>
/// 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.
/// </summary>
public bool Fullscreen { get; set; }
/// <summary>
/// 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.
/// </summary>
public bool Fullscreenable { get; set; }
/// <summary>
/// Whether to show the window in taskbar. Default is false.
/// </summary>
public bool SkipTaskbar { get; set; }
/// <summary>
/// The kiosk mode. Default is false.
/// </summary>
public bool Kiosk { get; set; }
/// <summary>
/// Default window title. Default is "Electron.NET".
/// </summary>
public string Title { get; set; } = "Electron.NET";
/// <summary>
/// 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.
/// </summary>
public string Icon { get; set; }
/// <summary>
/// Whether window should be shown when created. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Show { get; set; } = true;
/// <summary>
/// Specify false to create a . Default is true.
/// </summary>
[DefaultValue(true)]
public bool Frame { get; set; } = true;
/// <summary>
/// Whether this is a modal window. This only works when the window is a child
/// window.Default is false.
/// </summary>
public bool Modal { get; set; }
/// <summary>
/// Whether the web view accepts a single mouse-down event that simultaneously
/// activates the window.Default is false.
/// </summary>
public bool AcceptFirstMouse { get; set; }
/// <summary>
/// Whether to hide cursor when typing. Default is false.
/// </summary>
public bool DisableAutoHideCursor { get; set; }
/// <summary>
/// Auto hide the menu bar unless the Alt key is pressed. Default is false.
/// </summary>
public bool AutoHideMenuBar { get; set; }
/// <summary>
/// Enable the window to be resized larger than screen. Default is false.
/// </summary>
public bool EnableLargerThanScreen { get; set; }
/// <summary>
/// Window's background color as Hexadecimal value, like #66CD00 or #FFF or
/// #80FFFFFF (alpha is supported). Default is #FFF (white).
/// </summary>
public string BackgroundColor { get; set; }
/// <summary>
/// Whether window should have a shadow. This is only implemented on macOS. Default
/// is true.
/// </summary>
public bool HasShadow { get; set; }
/// <summary>
/// Forces using dark theme for the window, only works on some GTK+3 desktop
/// environments.Default is false.
/// </summary>
public bool DarkTheme { get; set; }
/// <summary>
/// Makes the window . Default is false.
/// </summary>
public bool Transparent { get; set; }
/// <summary>
/// The type of window, default is normal window.
/// </summary>
public string Type { get; set; }
/// <summary>
/// The style of window title bar. Default is default. Possible values are:
/// 'default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover'
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public TitleBarStyle TitleBarStyle { get; set; }
/// <summary>
/// Shows the title in the tile bar in full screen mode on macOS for all
/// titleBarStyle options.Default is false.
/// </summary>
public bool FullscreenWindowTitle { get; set; }
/// <summary>
/// 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.
/// </summary>
[DefaultValue(true)]
public bool ThickFrame { get; set; } = true;
/// <summary>
/// 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.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public Vibrancy Vibrancy { get; set; }
/// <summary>
/// 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.
/// </summary>
public bool ZoomToPageWidth { get; set; }
/// <summary>
/// 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.
/// </summary>
public string TabbingIdentifier { get; set; }
/// <summary>
/// Settings of web page's features.
/// </summary>
public WebPreferences WebPreferences { get; set; }
/// <summary>
/// A proxy to set on creation in the format host:port.
/// The proxy can be alternatively set using the BrowserWindow.WebContents.SetProxyAsync function.
/// </summary>
public string Proxy { get; set; }
/// <summary>
/// The credentials of the Proxy in the format username:password.
/// These will only be used if the Proxy field is also set.
/// </summary>
public string ProxyCredentials { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CPUUsage
{
/// <summary>
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
/// </summary>
public int PercentCPUUsage { get; set; }
/// <summary>
/// The number of average idle cpu wakeups per second since the last call to
/// getCPUUsage.First call returns 0.
/// </summary>
public int IdleWakeupsPerSecond { get; set; }
}
}

View File

@@ -0,0 +1,58 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Certificate
{
/// <summary>
/// PEM encoded data
/// </summary>
public string Data { get; set; }
/// <summary>
/// Fingerprint of the certificate
/// </summary>
public string Fingerprint { get; set; }
/// <summary>
/// Issuer principal
/// </summary>
public CertificatePrincipal Issuer { get; set; }
/// <summary>
/// Issuer certificate (if not self-signed)
/// </summary>
public Certificate IssuerCert { get; set; }
/// <summary>
/// Issuer's Common Name
/// </summary>
public string IssuerName { get; set; }
/// <summary>
/// Hex value represented string
/// </summary>
public string SerialNumber { get; set; }
/// <summary>
/// Subject principal
/// </summary>
public CertificatePrincipal Subject { get; set; }
/// <summary>
/// Subject's Common Name
/// </summary>
public string SubjectName { get; set; }
/// <summary>
/// End date of the certificate being valid in seconds
/// </summary>
public int ValidExpiry { get; set; }
/// <summary>
/// Start date of the certificate being valid in seconds
/// </summary>
public int ValidStart { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CertificatePrincipal
{
/// <summary>
/// Common Name
/// </summary>
public string CommonName { get; set; }
/// <summary>
/// Country or region
/// </summary>
public string Country { get; set; }
/// <summary>
/// Locality
/// </summary>
public string Locality { get; set; }
/// <summary>
/// Organization names
/// </summary>
public string[] Organizations { get; set; }
/// <summary>
/// Organization Unit names
/// </summary>
public string[] OrganizationUnits { get; set; }
/// <summary>
/// State or province
/// </summary>
public string State { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CertificateTrustDialogOptions
{
/// <summary>
/// The certificate to trust/import.
/// </summary>
public Certificate Certificate { get; set; }
/// <summary>
/// The message to display to the user.
/// </summary>
public string Message { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Provide metadata about the current loaded Chrome extension
/// </summary>
public class ChromeExtensionInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="ChromeExtensionInfo"/> class.
/// </summary>
/// <param name="name">The name of the Chrome extension.</param>
/// <param name="version">The version of the Chrome extension.</param>
public ChromeExtensionInfo(string name, string version)
{
Name = name;
Version = version;
}
/// <summary>
/// Name of the Chrome extension
/// </summary>
public string Name { get; set; }
/// <summary>
/// Version of the Chrome extension
/// </summary>
public string Version { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ClearStorageDataOptions
{
/// <summary>
/// Should follow window.location.origins representation scheme://host:port.
/// </summary>
public string Origin { get; set; }
/// <summary>
/// The types of storages to clear, can contain: appcache, cookies, filesystem,
/// indexdb, localstorage, shadercache, websql, serviceworkers, cachestorage.
/// </summary>
public string[] Storages { get; set; }
/// <summary>
/// The types of quotas to clear, can contain: temporary, persistent, syncable.
/// </summary>
public string[] Quotas { get; set; }
}
}

View File

@@ -0,0 +1,51 @@
namespace ElectronNET.API.Entities {
/// <summary>
///
/// </summary>
public class Cookie {
/// <summary>
/// The name of the cookie.
/// </summary>
public string Name { get; set;}
/// <summary>
/// The value of the cookie.
/// </summary>
public string Value { get; set; }
/// <summary>
/// (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains.
/// </summary>
public string Domain { get; set; }
/// <summary>
/// (optional) - Whether the cookie is a host-only cookie; this will only be true if no domain was passed.
/// </summary>
public bool HostOnly { get; set; }
/// <summary>
/// (optional) - The path of the cookie.
/// </summary>
public string Path { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as secure.
/// </summary>
public bool Secure { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as HTTP only.
/// </summary>
public bool HttpOnly { get; set; }
/// <summary>
/// (optional) - Whether the cookie is a session cookie or a persistent cookie with an expiration date.
/// </summary>
public bool Session { get; set; }
/// <summary>
/// (optional) - The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.
/// </summary>
public long ExpirationDate { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities {
/// <summary>
/// The cause of the change
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum CookieChangedCause
{
/// <summary>
///The cookie was changed directly by a consumer's action.
/// </summary>
[JsonProperty("explicit")]
@explicit,
/// <summary>
/// The cookie was automatically removed due to an insert operation that overwrote it.
/// </summary>
overwrite,
/// <summary>
/// The cookie was automatically removed as it expired.
/// </summary>
expired,
/// <summary>
/// The cookie was automatically evicted during garbage collection.
/// </summary>
evicted,
/// <summary>
/// The cookie was overwritten with an already-expired expiration date.
/// </summary>
[JsonProperty("expired_overwrite")]
expiredOverwrite
}
}

View File

@@ -0,0 +1,56 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities {
/// <summary>
///
/// </summary>
public class CookieDetails {
/// <summary>
/// The URL to associate the cookie with. The callback will be rejected if the URL is invalid.
/// </summary>
public string Url { get; set; }
/// <summary>
/// (optional) - The name of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Name { get; set; }
/// <summary>
/// (optional) - The value of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Value { get; set; }
/// <summary>
/// (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Domain { get; set; }
/// <summary>
/// (optional) - The path of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Path { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as secure. Defaults to false.
/// </summary>
[DefaultValue(false)]
public bool Secure { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as HTTP only. Defaults to false.
/// </summary>
[DefaultValue(false)]
public bool HttpOnly { get; set; }
/// <summary>
/// (optional) - The expiration date of the cookie as the number of seconds since the UNIX epoch.
/// If omitted then the cookie becomes a session cookie and will not be retained between sessions.
/// </summary>
[DefaultValue(0)]
public long ExpirationDate { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CookieFilter
{
/// <summary>
/// (optional) - Retrieves cookies which are associated with url.Empty implies retrieving cookies of all URLs.
/// </summary>
public string Url { get; set; }
/// <summary>
/// (optional) - Filters cookies by name.
/// </summary>
public string Name { get; set; }
/// <summary>
/// (optional) - Retrieves cookies whose domains match or are subdomains of domains.
/// </summary>
public string Domain { get; set; }
/// <summary>
/// (optional) - Retrieves cookies whose path matches path.
/// </summary>
public string Path { get; set; }
/// <summary>
/// (optional) - Filters cookies by their Secure property.
/// </summary>
public bool Secure { get; set; }
/// <summary>
/// (optional) - Filters out session or persistent cookies.
/// </summary>
public bool Session { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateFromBitmapOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateFromBufferOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,67 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateInterruptedDownloadOptions
{
/// <summary>
/// Absolute path of the download.
/// </summary>
public string Path { get; set; }
/// <summary>
/// Complete URL chain for the download.
/// </summary>
public string[] UrlChain { get; set; }
/// <summary>
///
/// </summary>
public string MimeType { get; set; }
/// <summary>
/// Start range for the download.
/// </summary>
public int Offset { get; set; }
/// <summary>
/// Total length of the download.
/// </summary>
public int Length { get; set; }
/// <summary>
/// Last-Modified header value.
/// </summary>
public string LastModified { get; set; }
/// <summary>
/// ETag header value.
/// </summary>
public string ETag { get; set; }
/// <summary>
/// Time when download was started in number of seconds since UNIX epoch.
/// </summary>
public int StartTime { get; set; }
/// <summary>
///
/// </summary>
/// <param name="path">Absolute path of the download.</param>
/// <param name="urlChain">Complete URL chain for the download.</param>
/// <param name="offset">Start range for the download.</param>
/// <param name="length">Total length of the download.</param>
/// <param name="lastModified">Last-Modified header value.</param>
/// <param name="eTag">ETag header value.</param>
public CreateInterruptedDownloadOptions(string path, string[] urlChain, int offset, int length, string lastModified, string eTag)
{
Path = path;
UrlChain = urlChain;
Offset = offset;
Length = length;
LastModified = lastModified;
ETag = eTag;
}
}
}

View File

@@ -0,0 +1,38 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Data
{
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>
/// The text.
/// </value>
public string Text { get; set; }
/// <summary>
/// Gets or sets the HTML.
/// </summary>
/// <value>
/// The HTML.
/// </value>
public string Html { get; set; }
/// <summary>
/// Gets or sets the RTF.
/// </summary>
/// <value>
/// The RTF.
/// </value>
public string Rtf { get; set; }
/// <summary>
/// The title of the url at text.
/// </summary>
public string Bookmark { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class DefaultFontFamily
{
/// <summary>
/// Defaults to Times New Roman.
/// </summary>
public string Standard { get; set; }
/// <summary>
/// Defaults to Times New Roman.
/// </summary>
public string Serif { get; set; }
/// <summary>
/// Defaults to Arial.
/// </summary>
public string SansSerif { get; set; }
/// <summary>
/// Defaults to Courier New.
/// </summary>
public string Monospace { get; set; }
/// <summary>
/// Defaults to Script.
/// </summary>
public string Cursive { get; set; }
/// <summary>
/// Defaults to Impact.
/// </summary>
public string Fantasy { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Opens the devtools with specified dock state, can be right, bottom, undocked,
/// detach.Defaults to last used dock state.In undocked mode it's possible to dock
/// back.In detach mode it's not.
/// </summary>
public enum DevToolsMode
{
/// <summary>
/// The right
/// </summary>
right,
/// <summary>
/// The bottom
/// </summary>
bottom,
/// <summary>
/// The undocked
/// </summary>
undocked,
/// <summary>
/// The detach
/// </summary>
detach
}
}

View File

@@ -0,0 +1,100 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Display
{
/// <summary>
/// Can be available, unavailable, unknown.
/// </summary>
public string AccelerometerSupport { get; set; }
/// <summary>
/// Gets or sets the bounds.
/// </summary>
/// <value>
/// The bounds of the display in DIP points.
/// </value>
public Rectangle Bounds { get; set; }
/// <summary>
/// The number of bits per pixel.
/// </summary>
public int ColorDepth { get; set; }
/// <summary>
/// Represent a color space (three-dimensional object which contains all realizable color combinations) for the purpose of color conversions.
/// </summary>
public string ColorSpace { get; set; }
/// <summary>
/// The number of bits per color component.
/// </summary>
public int DepthPerComponent { get; set; }
/// <summary>
/// The display refresh rate.
/// </summary>
public int DisplayFrequency { get; set; }
/// <summary>
/// Unique identifier associated with the display.
/// </summary>
public string Id { get; set; }
/// <summary>
/// true for an internal display and false for an external display.
/// </summary>
public bool Internal { get; set; }
/// <summary>
/// User-friendly label, determined by the platform.
/// </summary>
public string Label { get; set; }
/// <summary>
/// Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.
/// </summary>
public int Rotation { get; set; }
/// <summary>
/// Output device's pixel scale factor.
/// </summary>
public int ScaleFactor { get; set; }
/// <summary>
/// Can be available, unavailable, unknown.
/// </summary>
public string TouchSupport { get; set; }
/// <summary>
/// Whether or not the display is a monochrome display.
/// </summary>
public bool Monochrome { get; set; }
/// <summary>
/// Gets or sets the size.
/// </summary>
/// <value>
/// The size.
/// </value>
public Size Size { get; set; }
/// <summary>
/// Gets or sets the work area.
/// </summary>
/// <value>
/// The work area.
/// </value>
public Rectangle WorkArea { get; set; }
/// <summary>
/// Gets or sets the size of the work area.
/// </summary>
/// <value>
/// The size of the work area.
/// </value>
public Size WorkAreaSize { get; set; }
}
}

View File

@@ -0,0 +1,32 @@
namespace ElectronNET.API
{
/// <summary>
///
/// </summary>
public class DisplayBalloonOptions
{
/// <summary>
/// Gets or sets the icon.
/// </summary>
/// <value>
/// The icon.
/// </value>
public string Icon { get; set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
public string Title { get; set; }
/// <summary>
/// Gets or sets the content.
/// </summary>
/// <value>
/// The content.
/// </value>
public string Content { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Defines the DockBounceType enumeration.
/// </summary>
public enum DockBounceType
{
/// <summary>
/// Dock icon will bounce until either the application becomes active or the request is canceled.
/// </summary>
[Description("critical")]
Critical,
/// <summary>
/// The dock icon will bounce for one second.
/// </summary>
[Description("informational")]
Informational
}
}

View File

@@ -0,0 +1,28 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class EnableNetworkEmulationOptions
{
/// <summary>
/// Whether to emulate network outage. Defaults to false.
/// </summary>
public bool Offline { get; set; } = false;
/// <summary>
/// RTT in ms. Defaults to 0 which will disable latency throttling.
/// </summary>
public int Latency { get; set; }
/// <summary>
/// Download rate in Bps. Defaults to 0 which will disable download throttling.
/// </summary>
public int DownloadThroughput { get; set; }
/// <summary>
/// Upload rate in Bps. Defaults to 0 which will disable upload throttling.
/// </summary>
public int UploadThroughput { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Docs: https://electronjs.org/docs/api/structures/extension
/// </summary>
public class Extension
{
/// <summary>
///
/// </summary>
public string Id { get; set; }
/// <summary>
/// Copy of the extension's manifest data.
/// </summary>
public dynamic Manifest { get; set; }
/// <summary>
///
/// </summary>
public string Name { get; set; }
/// <summary>
/// The extension's file path.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The extension's `chrome-extension://` URL.
/// </summary>
public string Url { get; set; }
/// <summary>
///
/// </summary>
public string Version { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class FileFilter
{
/// <summary>
/// Gets or sets the extensions.
/// </summary>
/// <value>
/// The extensions.
/// </value>
public string[] Extensions { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class FileIconOptions
{
/// <summary>
/// Gets the size.
/// </summary>
/// <value>
/// The size.
/// </value>
public string Size { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="FileIconOptions"/> class.
/// </summary>
/// <param name="fileIconSize">Size of the file icon.</param>
public FileIconOptions(FileIconSize fileIconSize)
{
Size = fileIconSize.ToString();
}
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum FileIconSize
{
/// <summary>
/// The small
/// </summary>
small,
/// <summary>
/// The normal
/// </summary>
normal,
/// <summary>
/// The large
/// </summary>
large
}
}

View File

@@ -0,0 +1,15 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Controls the behavior of <see cref="App.Focus(FocusOptions)"/>.
/// </summary>
public class FocusOptions
{
/// <summary>
/// Make the receiver the active app even if another app is currently active.
/// <para/>
/// You should seek to use the <see cref="Steal"/> option as sparingly as possible.
/// </summary>
public bool Steal { get; set; }
}
}

View File

@@ -0,0 +1,85 @@
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class GPUFeatureStatus
{
/// <summary>
/// Canvas.
/// </summary>
[JsonProperty("2d_canvas")]
public string Canvas { get; set; }
/// <summary>
/// Flash.
/// </summary>
[JsonProperty("flash_3d")]
public string Flash3D { get; set; }
/// <summary>
/// Flash Stage3D.
/// </summary>
[JsonProperty("flash_stage3d")]
public string FlashStage3D { get; set; }
/// <summary>
/// Flash Stage3D Baseline profile.
/// </summary>
[JsonProperty("flash_stage3d_baseline")]
public string FlashStage3dBaseline { get; set; }
/// <summary>
/// Compositing.
/// </summary>
[JsonProperty("gpu_compositing")]
public string GpuCompositing { get; set; }
/// <summary>
/// Multiple Raster Threads.
/// </summary>
[JsonProperty("multiple_raster_threads")]
public string MultipleRasterThreads { get; set; }
/// <summary>
/// Native GpuMemoryBuffers.
/// </summary>
[JsonProperty("native_gpu_memory_buffers")]
public string NativeGpuMemoryBuffers { get; set; }
/// <summary>
/// Rasterization.
/// </summary>
public string Rasterization { get; set; }
/// <summary>
/// Video Decode.
/// </summary>
[JsonProperty("video_decode")]
public string VideoDecode { get; set; }
/// <summary>
/// Video Encode.
/// </summary>
[JsonProperty("video_encode")]
public string VideoEncode { get; set; }
/// <summary>
/// VPx Video Decode.
/// </summary>
[JsonProperty("vpx_decode")]
public string VpxDecode { get; set; }
/// <summary>
/// WebGL.
/// </summary>
public string Webgl { get; set; }
/// <summary>
/// WebGL2.
/// </summary>
public string Webgl2 { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Interface to use Electrons PostData Object
/// </summary>
public interface IPostData
{
/// <summary>
/// One of the following:
/// rawData - <see cref="UploadRawData"/> The data is available as a Buffer, in the rawData field.
/// file - <see cref="UploadFile"/> The object represents a file. The filePath, offset, length and modificationTime fields will be used to describe the file.
/// blob - <see cref="Blob"/> The object represents a Blob. The blobUUID field will be used to describe the Blob.
/// </summary>
public string Type { get; }
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ImportCertificateOptions
{
/// <summary>
/// Path for the pkcs12 file.
/// </summary>
public string Certificate { get; set; }
/// <summary>
/// Passphrase for the certificate.
/// </summary>
public string Password {get; set; }
}
}

View File

@@ -0,0 +1,82 @@
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
using ElectronNET.Converter;
/// <summary>
///
/// </summary>
public class InputEvent
{
/// <summary>
/// Equivalent to KeyboardEvent.key.
/// </summary>
public string Key { get; set; } = "";
/// <summary>
/// Equivalent to KeyboardEvent.code.
/// </summary>
public string Code { get; set; } = "";
/// <summary>
/// Equivalent to KeyboardEvent.repeat.
/// </summary>
public bool IsAutoRepeat { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.isComposing.
/// </summary>
public bool IsComposing { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.shiftKey.
/// </summary>
public bool Shift { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.controlKey.
/// </summary>
public bool Control { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.altKey.
/// </summary>
public bool Alt { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.metaKey.
/// </summary>
public bool Meta { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.location.
/// </summary>
public int Location { get; set; } = 0;
/// <summary>
/// An array of modifiers of the event, can be `shift`, `control`, `ctrl`, `alt`,
/// `meta`, `command`, `cmd`, `isKeypad`, `isAutoRepeat`, `leftButtonDown`,
/// `middleButtonDown`, `rightButtonDown`, `capsLock`, `numLock`, `left`, `right`
/// </summary>
[JsonConverter(typeof(ModifierTypeListConverter))]
public List<ModifierType> Modifiers { get; set; }
/// <summary>
/// Can be `undefined`, `mouseDown`, `mouseUp`, `mouseMove`, `mouseEnter`,
/// `mouseLeave`, `contextMenu`, `mouseWheel`, `rawKeyDown`, `keyDown`, `keyUp`,
/// `gestureScrollBegin`, `gestureScrollEnd`, `gestureScrollUpdate`,
/// `gestureFlingStart`, `gestureFlingCancel`, `gesturePinchBegin`,
/// `gesturePinchEnd`, `gesturePinchUpdate`, `gestureTapDown`, `gestureShowPress`,
/// `gestureTap`, `gestureTapCancel`, `gestureShortPress`, `gestureLongPress`,
/// `gestureLongTap`, `gestureTwoFingerTap`, `gestureTapUnconfirmed`,
/// `gestureDoubleTap`, `touchStart`, `touchMove`, `touchEnd`, `touchCancel`,
/// `touchScrollStarted`, `pointerDown`, `pointerUp`, `pointerMove`,
/// `pointerRawUpdate`, `pointerCancel` or `pointerCausedUaAction`.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public InputEventType Type { get; set; }
}
}

View File

@@ -0,0 +1,201 @@
namespace ElectronNET.API.Entities;
/// <summary>
///
/// </summary>
public enum InputEventType
{
/// <summary>
///
/// </summary>
undefined,
/// <summary>
///
/// </summary>
mouseDown,
/// <summary>
///
/// </summary>
mouseUp,
/// <summary>
///
/// </summary>
mouseMove,
/// <summary>
///
/// </summary>
mouseEnter,
/// <summary>
///
/// </summary>
mouseLeave,
/// <summary>
///
/// </summary>
contextMenu,
/// <summary>
///
/// </summary>
mouseWheel,
/// <summary>
///
/// </summary>
rawKeyDown,
/// <summary>
///
/// </summary>
keyDown,
/// <summary>
///
/// </summary>
keyUp,
/// <summary>
///
/// </summary>
gestureScrollBegin,
/// <summary>
///
/// </summary>
gestureScrollEnd,
/// <summary>
///
/// </summary>
gestureScrollUpdate,
/// <summary>
///
/// </summary>
gestureFlingStart,
/// <summary>
///
/// </summary>
gestureFlingCancel,
/// <summary>
///
/// </summary>
gesturePinchBegin,
/// <summary>
///
/// </summary>
gesturePinchEnd,
/// <summary>
///
/// </summary>
gesturePinchUpdate,
/// <summary>
///
/// </summary>
gestureTapDown,
/// <summary>
///
/// </summary>
gestureShowPress,
/// <summary>
///
/// </summary>
gestureTap,
/// <summary>
///
/// </summary>
gestureTapCancel,
/// <summary>
///
/// </summary>
gestureShortPress,
/// <summary>
///
/// </summary>
gestureLongPress,
/// <summary>
///
/// </summary>
gestureLongTap,
/// <summary>
///
/// </summary>
gestureTwoFingerTap,
/// <summary>
///
/// </summary>
gestureTapUnconfirmed,
/// <summary>
///
/// </summary>
gestureDoubleTap,
/// <summary>
///
/// </summary>
touchStart,
/// <summary>
///
/// </summary>
touchMove,
/// <summary>
///
/// </summary>
touchEnd,
/// <summary>
///
/// </summary>
touchCancel,
/// <summary>
///
/// </summary>
touchScrollStarted,
/// <summary>
///
/// </summary>
pointerDown,
/// <summary>
///
/// </summary>
pointerUp,
/// <summary>
///
/// </summary>
pointerMove,
/// <summary>
///
/// </summary>
pointerRawUpdate,
/// <summary>
///
/// </summary>
pointerCancel,
/// <summary>
///
/// </summary>
pointerCausedUaAction
}

View File

@@ -0,0 +1,27 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class JumpListCategory
{
/// <summary>
/// Must be set if type is custom, otherwise it should be omitted.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Array of objects if type is tasks or custom, otherwise it should be omitted.
/// </summary>
public JumpListItem[] Items { get; set; }
/// <summary>
/// One of the following: "tasks" | "frequent" | "recent" | "custom"
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public JumpListCategoryType Type { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum JumpListCategoryType
{
/// <summary>
/// The tasks
/// </summary>
tasks,
/// <summary>
/// The frequent
/// </summary>
frequent,
/// <summary>
/// The recent
/// </summary>
recent,
/// <summary>
/// The custom
/// </summary>
custom
}
}

View File

@@ -0,0 +1,58 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
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; }
/// <summary>
/// Description of the task (displayed in a tooltip). Should only be set if type is task.
/// </summary>
public string Description { get; set; }
/// <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; }
/// <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; }
/// <summary>
/// Path of the file to open, should only be set if type is file.
/// </summary>
public string Path { get; set; }
/// <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; }
/// <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; }
/// <summary>
/// One of the following: "task" | "separator" | "file"
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public JumpListItemType Type { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum JumpListItemType
{
/// <summary>
/// The task
/// </summary>
task,
/// <summary>
/// The separator
/// </summary>
separator,
/// <summary>
/// The file
/// </summary>
file
}
}

View File

@@ -0,0 +1,21 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
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
/// <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx">MSDN</see> 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 <see cref="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

@@ -0,0 +1,36 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class LoadURLOptions
{
/// <summary>
/// A HTTP Referrer url.
/// </summary>
public string HttpReferrer { get; set; }
/// <summary>
/// A user agent originating the request.
/// </summary>
public string UserAgent { get; set; }
/// <summary>
/// Base url (with trailing path separator) for files to be loaded by the data url.
/// This is needed only if the specified url is a data url and needs to load other
/// files.
/// </summary>
public string BaseURLForDataURL { get; set; }
/// <summary>
/// Extra headers for the request.
/// </summary>
public string ExtraHeaders { get; set; }
/// <summary>
/// PostData Object for the request.
/// Can be <see cref="UploadRawData"/>, <see cref="UploadFile"/> or <see cref="Blob"/>
/// </summary>
public IPostData[] PostData { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class LoginItemSettings
{
/// <summary>
/// <see langword="true"/> if the app is set to open at login.
/// </summary>
public bool OpenAtLogin { get; set; }
/// <summary>
/// <see langword="true"/> if the app is set to open as hidden at login. This setting is not available
/// on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool OpenAsHidden { get; set; }
/// <summary>
/// <see langword="true"/> if the app was opened at login automatically. This setting is not available
/// on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool WasOpenedAtLogin { get; set; }
/// <summary>
/// <see langword="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 not available on
/// <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool WasOpenedAsHidden { get; set; }
/// <summary>
/// <see langword="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 not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool RestoreState { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class LoginItemSettingsOptions
{
/// <summary>
/// The executable path to compare against. Defaults to process.execPath.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The command-line arguments to compare against. Defaults to an empty array.
/// </summary>
public string[] Args { get; set; }
}
}

View File

@@ -0,0 +1,32 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class LoginSettings
{
/// <summary>
/// <see langword="true"/> to open the app at login, <see langword="false"/> to remove the app as a login item.
/// Defaults to <see langword="false"/>.
/// </summary>
public bool OpenAtLogin { get; set; }
/// <summary>
/// <see langword="true"/> to open the app as hidden. Defaults to <see langword="false"/>. The user can edit this
/// setting from the System Preferences so app.getLoginItemSettings().wasOpenedAsHidden should be checked when the app is
/// opened to know the current value. This setting is not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool OpenAsHidden { get; set; }
/// <summary>
/// The executable to launch at login. Defaults to process.execPath.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The command-line arguments to pass to the executable. Defaults to an empty
/// array.Take care to wrap paths in quotes.
/// </summary>
public string[] Args { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities;
/// <summary>
///
/// </summary>
public class Margins
{
/// <summary>
/// Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
/// you will also need to specify `top`, `bottom`, `left`, and `right`.
/// </summary>
public string MarginType { get; set; }
/// <summary>
/// The top margin of the printed web page, in pixels.
/// </summary>
public int Top { get; set; }
/// <summary>
/// The bottom margin of the printed web page, in pixels.
/// </summary>
public int Bottom { get; set; }
/// <summary>
/// The left margin of the printed web page, in pixels.
/// </summary>
public int Left { get; set; }
/// <summary>
/// The right margin of the printed web page, in pixels.
/// </summary>
public int Right { get; set; }
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class MemoryInfo
{
/// <summary>
/// The amount of memory currently pinned to actual physical RAM.
/// </summary>
public int WorkingSetSize { get; set; }
/// <summary>
/// The maximum amount of memory that has ever been pinned to actual physical RAM.
/// </summary>
public int PeakWorkingSetSize { get; set; }
/// <summary>
/// The amount of memory not shared by other processes, such as JS heap or HTML
/// content.
/// </summary>
public int PrivateBytes { get; set; }
}
}

View File

@@ -0,0 +1,103 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class MenuItem
{
/// <summary>
/// Will be called with click(menuItem, browserWindow, event) when the menu item is
/// clicked.
/// </summary>
[JsonIgnore]
public Action Click { get; set; }
/// <summary>
/// Define the action of the menu item, when specified the click property will be
/// ignored.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public MenuRole Role { get; set; }
/// <summary>
/// Can be normal, separator, submenu, checkbox or radio.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public MenuType Type { get; set; }
/// <summary>
/// Gets or sets the label.
/// </summary>
/// <value>
/// The label.
/// </value>
public string Label { get; set; }
/// <summary>
/// Gets or sets the sublabel.
/// </summary>
/// <value>
/// The sublabel.
/// </value>
public string Sublabel { get; set; }
/// <summary>
/// Gets or sets the accelerator.
/// </summary>
/// <value>
/// The accelerator.
/// </value>
public string Accelerator { get; set; }
/// <summary>
/// Gets or sets the icon.
/// </summary>
/// <value>
/// The icon.
/// </value>
public string Icon { get; set; }
/// <summary>
/// If false, the menu item will be greyed out and unclickable.
/// </summary>
public bool Enabled { get; set; } = true;
/// <summary>
/// If false, the menu item will be entirely hidden.
/// </summary>
public bool Visible { get; set; } = true;
/// <summary>
/// Should only be specified for checkbox or radio type menu items.
/// </summary>
public bool Checked { get; set; }
/// <summary>
/// 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.
/// </summary>
public MenuItem[] Submenu { get; set; }
/// <summary>
/// Unique within a single menu. If defined then it can be used as a reference to
/// this item by the position attribute.
/// </summary>
public string Id { get; internal set; }
/// <summary>
/// This field allows fine-grained definition of the specific location within a
/// given menu.
/// </summary>
public string Position { get; set; }
}
}

View File

@@ -0,0 +1,163 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum MenuRole
{
/// <summary>
/// The undo
/// </summary>
undo = 1,
/// <summary>
/// The redo
/// </summary>
redo,
/// <summary>
/// The cut
/// </summary>
cut,
/// <summary>
/// The copy
/// </summary>
copy,
/// <summary>
/// The paste
/// </summary>
paste,
/// <summary>
/// The pasteandmatchstyle
/// </summary>
pasteandmatchstyle,
/// <summary>
/// The selectall
/// </summary>
selectall,
/// <summary>
/// The delete
/// </summary>
delete,
/// <summary>
/// Minimize current window
/// </summary>
minimize,
/// <summary>
/// Close current window
/// </summary>
close,
/// <summary>
/// Quit the application
/// </summary>
quit,
/// <summary>
/// Reload the current window
/// </summary>
reload,
/// <summary>
/// Reload the current window ignoring the cache.
/// </summary>
forcereload,
/// <summary>
/// Toggle developer tools in the current window
/// </summary>
toggledevtools,
/// <summary>
/// Toggle full screen mode on the current window
/// </summary>
togglefullscreen,
/// <summary>
/// Reset the focused pages zoom level to the original size
/// </summary>
resetzoom,
/// <summary>
/// Zoom in the focused page by 10%
/// </summary>
zoomin,
/// <summary>
/// Zoom out the focused page by 10%
/// </summary>
zoomout,
/// <summary>
/// Whole default “Edit” menu (Undo, Copy, etc.)
/// </summary>
editMenu,
/// <summary>
/// Whole default “Window” menu (Minimize, Close, etc.)
/// </summary>
windowMenu,
/// <summary>
/// Only macOS: Map to the orderFrontStandardAboutPanel action
/// </summary>
about,
/// <summary>
/// Only macOS: Map to the hide action
/// </summary>
hide,
/// <summary>
/// Only macOS: Map to the hideOtherApplications action
/// </summary>
hideothers,
/// <summary>
/// Only macOS: Map to the unhideAllApplications action
/// </summary>
unhide,
/// <summary>
/// Only macOS: Map to the startSpeaking action
/// </summary>
startspeaking,
/// <summary>
/// Only macOS: Map to the stopSpeaking action
/// </summary>
stopspeaking,
/// <summary>
/// Only macOS: Map to the arrangeInFront action
/// </summary>
front,
/// <summary>
/// Only macOS: Map to the performZoom action
/// </summary>
zoom,
/// <summary>
/// Only macOS: The submenu is a “Window” menu
/// </summary>
window,
/// <summary>
/// Only macOS: The submenu is a “Help” menu
/// </summary>
help,
/// <summary>
/// Only macOS: The submenu is a “Services” menu
/// </summary>
services
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum MenuType
{
/// <summary>
/// The normal
/// </summary>
normal,
/// <summary>
/// The separator
/// </summary>
separator,
/// <summary>
/// The submenu
/// </summary>
submenu,
/// <summary>
/// The checkbox
/// </summary>
checkbox,
/// <summary>
/// The radio
/// </summary>
radio
}
}

View File

@@ -0,0 +1,101 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class MessageBoxOptions
{
/// <summary>
/// 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.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public MessageBoxType Type { get; set; }
/// <summary>
/// Array of texts for buttons. On Windows, an empty array will result in one button
/// labeled "OK".
/// </summary>
public string[] Buttons { get; set; }
/// <summary>
/// Index of the button in the buttons array which will be selected by default when
/// the message box opens.
/// </summary>
public int DefaultId { get; set; }
/// <summary>
/// Title of the message box, some platforms will not show it.
/// </summary>
public string Title { get; set; }
/// <summary>
/// Content of the message box.
/// </summary>
public string Message { get; set; }
/// <summary>
/// Extra information of the message.
/// </summary>
public string Detail { get; set; }
/// <summary>
/// If provided, the message box will include a checkbox with the given label. The
/// checkbox state can be inspected only when using callback.
/// </summary>
public string CheckboxLabel { get; set; }
/// <summary>
/// Initial checked state of the checkbox. false by default.
/// </summary>
public bool CheckboxChecked { get; set; }
/// <summary>
/// Gets or sets the icon.
/// </summary>
/// <value>
/// The icon.
/// </value>
public string Icon { get; set; }
/// <summary>
/// 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.
/// </summary>
public int CancelId { get; set; }
/// <summary>
/// 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.
/// </summary>
public bool NoLink { get; set; }
/// <summary>
/// Normalize the keyboard access keys across platforms. Default is false. Enabling
/// this assumes AND character 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, AND characters are removed on macOS, converted to _ on Linux, and left
/// untouched on Windows.For example, a button label of VieANDw will be converted to
/// Vie_w on Linux and View on macOS and can be selected via Alt-W on Windows and
/// Linux.
/// </summary>
public bool NormalizeAccessKeys { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="MessageBoxOptions"/> class.
/// </summary>
/// <param name="message">The message.</param>
public MessageBoxOptions(string message)
{
Message = message;
}
}
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class MessageBoxResult
{
/// <summary>
/// Gets or sets the response.
/// </summary>
/// <value>
/// The response.
/// </value>
public int Response { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [checkbox checked].
/// </summary>
/// <value>
/// <c>true</c> if [checkbox checked]; otherwise, <c>false</c>.
/// </value>
public bool CheckboxChecked { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum MessageBoxType
{
/// <summary>
/// The none
/// </summary>
none,
/// <summary>
/// The information
/// </summary>
info,
/// <summary>
/// The error
/// </summary>
error,
/// <summary>
/// The question
/// </summary>
question,
/// <summary>
/// The warning
/// </summary>
warning
}
}

View File

@@ -0,0 +1,87 @@
namespace ElectronNET.API.Entities;
/// <summary>
/// Specifies the possible modifier keys for a keyboard input.
/// </summary>
public enum ModifierType
{
/// <summary>
/// The Shift key.
/// </summary>
shift,
/// <summary>
/// The Control key.
/// </summary>
control,
/// <summary>
/// The Control key (alias for control).
/// </summary>
ctrl,
/// <summary>
/// The Alt key.
/// </summary>
alt,
/// <summary>
/// The Meta key.
/// </summary>
meta,
/// <summary>
/// The Command key.
/// </summary>
command,
/// <summary>
/// The Command key (alias for command).
/// </summary>
cmd,
/// <summary>
/// Indicates whether the keypad modifier key is pressed.
/// </summary>
isKeypad,
/// <summary>
/// Indicates whether the key is an auto-repeated key.
/// </summary>
isAutoRepeat,
/// <summary>
/// Indicates whether the left mouse button is pressed.
/// </summary>
leftButtonDown,
/// <summary>
/// Indicates whether the middle mouse button is pressed.
/// </summary>
middleButtonDown,
/// <summary>
/// Indicates whether the right mouse button is pressed.
/// </summary>
rightButtonDown,
/// <summary>
/// The Caps Lock key.
/// </summary>
capsLock,
/// <summary>
/// The Num Lock key.
/// </summary>
numlock,
/// <summary>
/// The Left key.
/// </summary>
left,
/// <summary>
/// The Right key.
/// </summary>
right
}

View File

@@ -0,0 +1,453 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Native Image handler for Electron.NET
/// </summary>
[JsonConverter(typeof(NativeImageJsonConverter))]
public class NativeImage
{
private readonly Dictionary<float, Image> _images = new Dictionary<float, Image>();
private bool _isTemplateImage;
private static readonly Dictionary<string, float> ScaleFactorPairs = new Dictionary<string, float>
{
{"@2x", 2.0f}, {"@3x", 3.0f}, {"@1x", 1.0f}, {"@4x", 4.0f},
{"@5x", 5.0f}, {"@1.25x", 1.25f}, {"@1.33x", 1.33f}, {"@1.4x", 1.4f},
{"@1.5x", 1.5f}, {"@1.8x", 1.8f}, {"@2.5x", 2.5f}
};
private static float? ExtractDpiFromFilePath(string filePath)
{
var withoutExtension = Path.GetFileNameWithoutExtension(filePath);
return ScaleFactorPairs
.Where(p => withoutExtension.EndsWith(p.Key))
.Select(p => p.Value)
.FirstOrDefault();
}
private static Image BytesToImage(byte[] bytes)
{
var ms = new MemoryStream(bytes);
return Image.FromStream(ms);
}
/// <summary>
/// Creates an empty NativeImage
/// </summary>
public static NativeImage CreateEmpty()
{
return new NativeImage();
}
/// <summary>
///
/// </summary>
public static NativeImage CreateFromBitmap(Bitmap bitmap, CreateFromBitmapOptions options = null)
{
if (options is null)
{
options = new CreateFromBitmapOptions();
}
return new NativeImage(bitmap, options.ScaleFactor);
}
/// <summary>
/// Creates a NativeImage from a byte array.
/// </summary>
public static NativeImage CreateFromBuffer(byte[] buffer, CreateFromBufferOptions options = null)
{
if (options is null)
{
options = new CreateFromBufferOptions();
}
var ms = new MemoryStream(buffer);
var image = Image.FromStream(ms);
return new NativeImage(image, options.ScaleFactor);
}
/// <summary>
/// Creates a NativeImage from a base64 encoded data URL.
/// </summary>
/// <param name="dataUrl">A data URL with a base64 encoded image.</param>
public static NativeImage CreateFromDataURL(string dataUrl)
{
var images = new Dictionary<float,Image>();
var parsedDataUrl = Regex.Match(dataUrl, @"data:image/(?<type>.+?),(?<data>.+)");
var actualData = parsedDataUrl.Groups["data"].Value;
var binData = Convert.FromBase64String(actualData);
var image = BytesToImage(binData);
images.Add(1.0f, image);
return new NativeImage(images);
}
/// <summary>
/// Creates a NativeImage from an image on the disk.
/// </summary>
/// <param name="path">The path of the image</param>
public static NativeImage CreateFromPath(string path)
{
var images = new Dictionary<float,Image>();
if (Regex.IsMatch(path, "(@.+?x)"))
{
var dpi = ExtractDpiFromFilePath(path);
if (dpi == null)
{
throw new Exception($"Invalid scaling factor for '{path}'.");
}
images[dpi.Value] = Image.FromFile(path);
}
else
{
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
var extension = Path.GetExtension(path);
// Load as 1x dpi
images[1.0f] = Image.FromFile(path);
foreach (var scale in ScaleFactorPairs)
{
var fileName = $"{fileNameWithoutExtension}{scale}.{extension}";
if (File.Exists(fileName))
{
var dpi = ExtractDpiFromFilePath(fileName);
if (dpi != null)
{
images[dpi.Value] = Image.FromFile(fileName);
}
}
}
}
return new NativeImage(images);
}
/// <summary>
/// Creates an empty NativeImage
/// </summary>
public NativeImage()
{
}
/// <summary>
/// Creates a NativeImage from a bitmap and scale factor
/// </summary>
public NativeImage(Image bitmap, float scaleFactor = 1.0f)
{
_images.Add(scaleFactor, bitmap);
}
/// <summary>
/// Creates a NativeImage from a dictionary of scales and images.
/// </summary>
public NativeImage(Dictionary<float, Image> imageDictionary)
{
_images = imageDictionary;
}
/// <summary>
/// Crops the image specified by the input rectangle and computes scale factor
/// </summary>
public NativeImage Crop(Rectangle rect)
{
var images = new Dictionary<float,Image>();
foreach (var image in _images)
{
images.Add(image.Key, Crop(rect.X, rect.Y, rect.Width, rect.Height, image.Key));
}
return new NativeImage(images);
}
/// <summary>
/// Resizes the image and computes scale factor
/// </summary>
public NativeImage Resize(ResizeOptions options)
{
var images = new Dictionary<float, Image>();
foreach (var image in _images)
{
images.Add(image.Key, Resize(options.Width, options.Height, image.Key));
}
return new NativeImage(images);
}
/// <summary>
/// Add an image representation for a specific scale factor.
/// </summary>
/// <param name="options"></param>
public void AddRepresentation(AddRepresentationOptions options)
{
if (options.Buffer.Length > 0)
{
_images[options.ScaleFactor] =
CreateFromBuffer(options.Buffer, new CreateFromBufferOptions {ScaleFactor = options.ScaleFactor})
.GetScale(options.ScaleFactor);
}
else if (!string.IsNullOrEmpty(options.DataUrl))
{
_images[options.ScaleFactor] = CreateFromDataURL(options.DataUrl).GetScale(options.ScaleFactor);
}
}
/// <summary>
/// Gets the aspect ratio for the image based on scale factor
/// </summary>
/// <param name="scaleFactor">Optional</param>
public float GetAspectRatio(float scaleFactor = 1.0f)
{
var image = GetScale(scaleFactor);
if (image != null)
{
return image.Width / image.Height;
}
return 0f;
}
/// <summary>
/// Returns a byte array that contains the image's raw bitmap pixel data.
/// </summary>
public byte[] GetBitmap(BitmapOptions options)
{
return ToBitmap(new ToBitmapOptions{ ScaleFactor = options.ScaleFactor });
}
/// <summary>
/// Returns a byte array that contains the image's raw bitmap pixel data.
/// </summary>
public byte[] GetNativeHandle()
{
return ToBitmap(new ToBitmapOptions());
}
/// <summary>
/// Gets the size of the specified image based on scale factor
/// </summary>
public Size GetSize(float scaleFactor = 1.0f)
{
if (_images.ContainsKey(scaleFactor))
{
var image = _images[scaleFactor];
return new Size
{
Width = image.Width,
Height = image.Height
};
}
return null;
}
/// <summary>
/// Checks to see if the NativeImage instance is empty.
/// </summary>
public bool IsEmpty()
{
return _images.Count <= 0;
}
/// <summary>
/// Deprecated. Whether the image is a template image.
/// </summary>
public bool IsTemplateImage => _isTemplateImage;
/// <summary>
/// Deprecated. Marks the image as a template image.
/// </summary>
public void SetTemplateImage(bool option)
{
_isTemplateImage = option;
}
/// <summary>
/// Outputs a bitmap based on the scale factor
/// </summary>
public byte[] ToBitmap(ToBitmapOptions options)
{
return ImageToBytes(ImageFormat.Bmp, options.ScaleFactor);
}
/// <summary>
/// Outputs a data URL based on the scale factor
/// </summary>
public string ToDataURL(ToDataUrlOptions options)
{
if (!_images.ContainsKey(options.ScaleFactor))
{
return null;
}
var image = _images[options.ScaleFactor];
var mimeType = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == image.RawFormat.Guid)?.MimeType;
if (mimeType is null)
{
mimeType = "image/png";
}
var bytes = ImageToBytes(image.RawFormat, options.ScaleFactor);
var base64 = Convert.ToBase64String(bytes);
return $"data:{mimeType};base64,{base64}";
}
/// <summary>
/// Outputs a JPEG for the default scale factor
/// </summary>
public byte[] ToJPEG(int quality)
{
return ImageToBytes(ImageFormat.Jpeg, 1.0f, quality);
}
/// <summary>
/// Outputs a PNG for the specified scale factor
/// </summary>
public byte[] ToPNG(ToPNGOptions options)
{
return ImageToBytes(ImageFormat.Png, options.ScaleFactor);
}
private byte[] ImageToBytes(ImageFormat imageFormat = null, float scaleFactor = 1.0f, int quality = 100)
{
using var ms = new MemoryStream();
if (_images.ContainsKey(scaleFactor))
{
var image = _images[scaleFactor];
var encoderCodecInfo = GetEncoder(imageFormat ?? image.RawFormat);
var encoder = Encoder.Quality;
var encoderParameters = new EncoderParameters(1)
{
Param = new[]
{
new EncoderParameter(encoder, quality)
}
};
image.Save(ms, encoderCodecInfo, encoderParameters);
return ms.ToArray();
}
return null;
}
private Image Resize(int? width, int? height, float scaleFactor = 1.0f)
{
if (!_images.ContainsKey(scaleFactor) || (width is null && height is null))
{
return null;
}
var image = _images[scaleFactor];
using (var g = Graphics.FromImage(image))
{
g.CompositingQuality = CompositingQuality.HighQuality;
var aspect = GetAspectRatio(scaleFactor);
width ??= Convert.ToInt32(image.Width * aspect);
height ??= Convert.ToInt32(image.Height * aspect);
width = Convert.ToInt32(width * scaleFactor);
height = Convert.ToInt32(height * scaleFactor);
var bmp = new Bitmap(width.Value, height.Value);
g.DrawImage(bmp,
new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
GraphicsUnit.Pixel);
return bmp;
}
}
private Image Crop(int? x, int? y, int? width, int? height, float scaleFactor = 1.0f)
{
if (!_images.ContainsKey(scaleFactor))
{
return null;
}
var image = _images[scaleFactor];
using (var g = Graphics.FromImage(image))
{
g.CompositingQuality = CompositingQuality.HighQuality;
x ??= 0;
y ??= 0;
x = Convert.ToInt32(x * scaleFactor);
y = Convert.ToInt32(y * scaleFactor);
width ??= image.Width;
height ??= image.Height;
width = Convert.ToInt32(width * scaleFactor);
height = Convert.ToInt32(height * scaleFactor);
var bmp = new Bitmap(width.Value, height.Value);
g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, image.Width, image.Height), new System.Drawing.Rectangle(x.Value, y.Value, width.Value, height.Value), GraphicsUnit.Pixel);
return bmp;
}
}
private ImageCodecInfo GetEncoder(ImageFormat format)
{
var codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
internal Dictionary<float,string> GetAllScaledImages()
{
var dict = new Dictionary<float,string>();
try
{
foreach (var (scale, image) in _images)
{
dict.Add(scale, Convert.ToBase64String(ImageToBytes(null, scale)));
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
return dict;
}
internal Image GetScale(float scaleFactor)
{
if (_images.ContainsKey(scaleFactor))
{
return _images[scaleFactor];
}
return null;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
internal class NativeImageJsonConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value is NativeImage nativeImage)
{
var scaledImages = nativeImage.GetAllScaledImages();
serializer.Serialize(writer, scaledImages);
}
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var dict = serializer.Deserialize<Dictionary<float, string>>(reader);
var newDictionary = new Dictionary<float, Image>();
foreach (var item in dict)
{
var bytes = Convert.FromBase64String(item.Value);
newDictionary.Add(item.Key, Image.FromStream(new MemoryStream(bytes)));
}
return new NativeImage(newDictionary);
}
public override bool CanConvert(Type objectType) => objectType == typeof(NativeImage);
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class NotificationAction
{
/// <summary>
/// The label for the given action.
/// </summary>
public string Text { get; set; }
/// <summary>
/// The type of action, can be button.
/// </summary>
public string Type { get; set; }
}
}

View File

@@ -0,0 +1,167 @@
using Newtonsoft.Json;
using System;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class NotificationOptions
{
/// <summary>
/// A title for the notification, which will be shown at the top of the notification
/// window when it is shown.
/// </summary>
public string Title { get; set; }
/// <summary>
/// A subtitle for the notification, which will be displayed below the title.
/// </summary>
public string SubTitle { get; set; }
/// <summary>
/// The body text of the notification, which will be displayed below the title or
/// subtitle.
/// </summary>
public string Body { get; set; }
/// <summary>
/// Whether or not to emit an OS notification noise when showing the notification.
/// </summary>
public bool Silent { get; set; }
/// <summary>
/// An icon to use in the notification.
/// </summary>
public string Icon { get; set; }
/// <summary>
/// Whether or not to add an inline reply option to the notification.
/// </summary>
public bool HasReply { get; set; }
/// <summary>
/// The timeout duration of the notification. Can be 'default' or 'never'.
/// </summary>
public string TimeoutType { get; set; }
/// <summary>
/// The placeholder to write in the inline reply input field.
/// </summary>
public string ReplyPlaceholder { get; set; }
/// <summary>
/// The name of the sound file to play when the notification is shown.
/// </summary>
public string Sound { get; set; }
/// <summary>
/// The urgency level of the notification. Can be 'normal', 'critical', or 'low'.
/// </summary>
public string Urgency { get; set; }
/// <summary>
/// Actions to add to the notification. Please read the available actions and
/// limitations in the NotificationAction documentation.
/// </summary>
public NotificationAction Actions { get; set; }
/// <summary>
/// A custom title for the close button of an alert. An empty string will cause the
/// default localized text to be used.
/// </summary>
public string CloseButtonText { get; set; }
/// <summary>
/// Emitted when the notification is shown to the user, note this could be fired
/// multiple times as a notification can be shown multiple times through the Show()
/// method.
/// </summary>
[JsonIgnore]
public Action OnShow { get; set; }
/// <summary>
/// Gets or sets the show identifier.
/// </summary>
/// <value>
/// The show identifier.
/// </value>
[JsonProperty]
internal string ShowID { get; set; }
/// <summary>
/// Emitted when the notification is clicked by the user.
/// </summary>
[JsonIgnore]
public Action OnClick { get; set; }
/// <summary>
/// Gets or sets the click identifier.
/// </summary>
/// <value>
/// The click identifier.
/// </value>
[JsonProperty]
internal string ClickID { get; set; }
/// <summary>
/// Emitted when the notification is closed by manual intervention from the user.
///
/// This event is not guarunteed to be emitted in all cases where the notification is closed.
/// </summary>
[JsonIgnore]
public Action OnClose { get; set; }
/// <summary>
/// Gets or sets the close identifier.
/// </summary>
/// <value>
/// The close identifier.
/// </value>
[JsonProperty]
internal string CloseID { get; set; }
/// <summary>
/// macOS only: Emitted when the user clicks the “Reply” button on a notification with hasReply: true.
///
/// The string the user entered into the inline reply field
/// </summary>
[JsonIgnore]
public Action<string> OnReply { get; set; }
/// <summary>
/// Gets or sets the reply identifier.
/// </summary>
/// <value>
/// The reply identifier.
/// </value>
[JsonProperty]
internal string ReplyID { get; set; }
/// <summary>
/// macOS only - The index of the action that was activated
/// </summary>
[JsonIgnore]
public Action<string> OnAction { get; set; }
/// <summary>
/// Gets or sets the action identifier.
/// </summary>
/// <value>
/// The action identifier.
/// </value>
[JsonProperty]
internal string ActionID { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="NotificationOptions"/> class.
/// </summary>
/// <param name="title">The title.</param>
/// <param name="body">The body.</param>
public NotificationOptions(string title, string body)
{
Title = title;
Body = body;
}
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities;
/// <summary>
/// 'OnDidFailLoad' event details.
/// </summary>
public class OnDidFailLoadInfo
{
/// <summary>
/// The full list of error codes and their meaning is available here
/// https://source.chromium.org/chromium/chromium/src/+/main:net/base/net_error_list.h
/// </summary>
public int ErrorCode { get; set; }
/// <summary>
/// Validated URL.
/// </summary>
public string ValidatedUrl { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace ElectronNET.API.Entities;
/// <summary>
/// 'OnDidNavigate' event details.
/// </summary>
public class OnDidNavigateInfo
{
/// <summary>
/// Navigated URL.
/// </summary>
public string Url { get; set; }
/// <summary>
/// HTTP response code.
/// </summary>
public int HttpResponseCode { get; set; }
}

View File

@@ -0,0 +1,55 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum OnTopLevel
{
/// <summary>
/// The normal
/// </summary>
normal,
/// <summary>
/// The floating
/// </summary>
floating,
/// <summary>
/// The torn off menu
/// </summary>
[Description("torn-off-menu")]
tornOffMenu,
/// <summary>
/// The modal panel
/// </summary>
[Description("modal-panel")]
modalPanel,
/// <summary>
/// The main menu
/// </summary>
[Description("main-menu")]
mainMenu,
/// <summary>
/// The status
/// </summary>
status,
/// <summary>
/// The pop up menu
/// </summary>
[Description("pop-up-menu")]
popUpMenu,
/// <summary>
/// The screen saver
/// </summary>
[Description("screen-saver")]
screenSaver
}
}

View File

@@ -0,0 +1,19 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class OpenDevToolsOptions
{
/// <summary>
/// Opens the devtools with specified dock state, can be right, bottom, undocked,
/// detach.Defaults to last used dock state.In undocked mode it's possible to dock
/// back.In detach mode it's not.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public DevToolsMode Mode { get; set; }
}
}

View File

@@ -0,0 +1,61 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class OpenDialogOptions
{
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
public string Title { get; set; }
/// <summary>
/// Gets or sets the default path.
/// </summary>
/// <value>
/// The default path.
/// </value>
public string DefaultPath { get; set; }
/// <summary>
/// Custom label for the confirmation button, when left empty the default label will be used.
/// </summary>
public string ButtonLabel { get; set; }
/// <summary>
/// Contains which features the dialog should use. The following values are supported:
/// 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'
/// </summary>
[JsonProperty("properties", ItemConverterType = typeof(StringEnumConverter))]
public OpenDialogProperty[] Properties { get; set; }
/// <summary>
/// Message to display above input boxes.
/// </summary>
public string Message { get; set; }
/// <summary>
/// The filters specifies an array of file types that can be displayed or
/// selected when you want to limit the user to a specific type. For example:
/// </summary>
/// <example>
/// <code>
/// new FileFilter[]
/// {
/// new FileFiler { Name = "Images", Extensions = new string[] { "jpg", "png", "gif" } },
/// new FileFiler { Name = "Movies", Extensions = new string[] { "mkv", "avi", "mp4" } },
/// new FileFiler { Name = "Custom File Type", Extensions= new string[] {"as" } },
/// new FileFiler { Name = "All Files", Extensions= new string[] { "*" } }
/// }
/// </code>
/// </example>
public FileFilter[] Filters { get; set; }
}
}

View File

@@ -0,0 +1,48 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum OpenDialogProperty
{
/// <summary>
/// The open file
/// </summary>
openFile,
/// <summary>
/// The open directory
/// </summary>
openDirectory,
/// <summary>
/// The multi selections
/// </summary>
multiSelections,
/// <summary>
/// The show hidden files
/// </summary>
showHiddenFiles,
/// <summary>
/// The create directory
/// </summary>
createDirectory,
/// <summary>
/// The prompt to create
/// </summary>
promptToCreate,
/// <summary>
/// The no resolve aliases
/// </summary>
noResolveAliases,
/// <summary>
/// The treat package as directory
/// </summary>
treatPackageAsDirectory
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Controls the behavior of OpenExternal.
/// </summary>
public class OpenExternalOptions
{
/// <summary>
/// <see langword="true"/> to bring the opened application to the foreground. The default is <see langword="true"/>.
/// </summary>
[DefaultValue(true)]
public bool Activate { get; set; } = true;
/// <summary>
/// The working directory.
/// </summary>
public string WorkingDirectory { get; set; }
}
}

View File

@@ -0,0 +1,95 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Defines the PathName enumeration.
/// </summary>
public enum PathName
{
/// <summary>
/// Users home directory.
/// </summary>
[Description("home")]
Home,
/// <summary>
/// Per-user application data directory.
/// </summary>
[Description("appData")]
AppData,
/// <summary>
/// The directory for storing your apps configuration files,
/// which by default it is the appData directory appended with your apps name.
/// </summary>
[Description("userData")]
UserData,
/// <summary>
/// Temporary directory.
/// </summary>
[Description("temp")]
Temp,
/// <summary>
/// The current executable file.
/// </summary>
[Description("exe")]
Exe,
/// <summary>
/// The libchromiumcontent library.
/// </summary>
[Description("Module")]
Module,
/// <summary>
/// The current users Desktop directory.
/// </summary>
[Description("desktop")]
Desktop,
/// <summary>
/// Directory for a users “My Documents”.
/// </summary>
[Description("documents")]
Documents,
/// <summary>
/// Directory for a users downloads.
/// </summary>
[Description("downloads")]
Downloads,
/// <summary>
/// Directory for a users music.
/// </summary>
[Description("music")]
Music,
/// <summary>
/// Directory for a users pictures.
/// </summary>
[Description("pictures")]
Pictures,
/// <summary>
/// Directory for a users videos.
/// </summary>
[Description("videos")]
Videos,
/// <summary>
/// The logs.
/// </summary>
[Description("logs")]
Logs,
/// <summary>
/// Full path to the system version of the Pepper Flash plugin.
/// </summary>
[Description("PepperFlashSystemPlugin")]
PepperFlashSystemPlugin
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Point
{
/// <summary>
/// Gets or sets the x.
/// </summary>
/// <value>
/// The x.
/// </value>
public int X { get; set; }
/// <summary>
/// Gets or sets the y.
/// </summary>
/// <value>
/// The y.
/// </value>
public int Y { get; set; }
/// <summary>
/// Convert this <see cref="Point"/> to <see cref="System.Drawing.Point"/>.
/// </summary>
/// <param name="point">The point.</param>
public static implicit operator System.Drawing.Point(Point point)
{
return new System.Drawing.Point(point.X, point.Y);
}
}
}

View File

@@ -0,0 +1,107 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Print dpi
/// </summary>
public class PrintDpi
{
/// <summary>
/// The horizontal dpi
/// </summary>
public float Horizontal { get; set; }
/// <summary>
/// The vertical dpi
/// </summary>
public float Vertical { get; set; }
}
/// <summary>
/// The page range to print
/// </summary>
public class PrintPageRange
{
/// <summary>
/// From
/// </summary>
public int From { get; set; }
/// <summary>
/// To
/// </summary>
public int To { get; set; }
}
/// <summary>
/// Print options
/// </summary>
public class PrintOptions
{
/// <summary>
/// Don't ask user for print settings
/// </summary>
public bool Silent { get; set; }
/// <summary>
/// Prints the background color and image of the web page
/// </summary>
public bool PrintBackground { get; set; }
/// <summary>
/// Set the printer device name to use
/// </summary>
public string DeviceName { get; set; }
/// <summary>
/// Set whether the printed web page will be in color or grayscale
/// </summary>
public bool Color { get; set; }
/// <summary>
/// Specifies the type of margins to use. Uses 0 for default margin, 1 for no
/// margin, and 2 for minimum margin.
/// </summary>
public int MarginsType { get; set; }
/// <summary>
/// true for landscape, false for portrait.
/// </summary>
public bool Landscape { get; set; }
/// <summary>
/// The scale factor of the web page
/// </summary>
public float ScaleFactor { get; set; }
/// <summary>
/// The number of pages to print per page sheet
/// </summary>
public int PagesPerSheet { get; set; }
/// <summary>
/// The number of copies of the web page to print
/// </summary>
public bool Copies { get; set; }
/// <summary>
/// Whether the web page should be collated
/// </summary>
public bool Collate { get; set; }
/// <summary>
/// The page range to print
/// </summary>
public PrintPageRange PageRanges { get; set; }
/// <summary>
/// Set the duplex mode of the printed web page. Can be simplex, shortEdge, or longEdge.
/// </summary>
public string DuplexMode { get; set; }
/// <summary>
/// Dpi
/// </summary>
public PrintDpi Dpi { get; set; }
}
}

View File

@@ -0,0 +1,63 @@
namespace ElectronNET.API.Entities;
/// <summary>
///
/// </summary>
public class PrintToPDFOptions
{
/// <summary>
/// Paper orientation. `true` for landscape, `false` for portrait. Defaults to false.
/// </summary>
public bool Landscape { get; set; } = false;
/// <summary>
/// Whether to display header and footer. Defaults to false.
/// </summary>
public bool DisplayHeaderFooter { get; set; } = false;
/// <summary>
/// Whether to print background graphics. Defaults to false.
/// </summary>
public bool PrintBackground { get; set; } = false;
/// <summary>
/// Scale of the webpage rendering. Defaults to 1.
/// </summary>
public double Scale { get; set; } = 1;
/// <summary>
/// Specify page size of the generated PDF. Can be `A0`, `A1`, `A2`, `A3`, `A4`,
/// `A5`, `A6`, `Legal`, `Letter`, `Tabloid`, `Ledger`, or an Object containing
/// `height` and `width` in inches. Defaults to `Letter`.
/// </summary>
public string PageSize { get; set; } = "Letter";
/// <summary>
/// Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string,
/// which means print all pages.
/// </summary>
public string PageRanges { get; set; } = "";
/// <summary>
/// HTML template for the print header. Should be valid HTML markup with following
/// classes used to inject printing values into them: `date` (formatted print date),
/// `title` (document title), `url` (document location), `pageNumber` (current page
/// number) and `totalPages` (total pages in the document). For example, `<span class="title"></span>`
/// would generate span containing the title.
/// </summary>
public string HeaderTemplate { get; set; }
/// <summary>
/// HTML template for the print footer. Should use the same format as the
/// `headerTemplate`.
/// </summary>
public string FooterTemplate { get; set; }
/// <summary>
/// Whether or not to prefer page size as defined by css. Defaults to false, in
/// which case the content will be scaled to fit the paper size.
/// </summary>
public bool PreferCSSPageSize { get; set; } = false;
public Margins Margins { get; set; }
}

View File

@@ -0,0 +1,29 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Printer info
/// </summary>
public class PrinterInfo
{
/// <summary>
/// Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Name
/// </summary>
public string Description { get; set; }
/// <summary>
/// Status
/// </summary>
public int Status { get; set; }
/// <summary>
/// Is default
/// </summary>
public bool IsDefault { get; set; }
}
}

View File

@@ -0,0 +1,46 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ProcessMetric
{
/// <summary>
/// Process id of the process.
/// </summary>
public int PId { get; set; }
/// <summary>
/// Process type (Browser or Tab or GPU etc).
/// </summary>
public string Type { get; set; }
/// <summary>
/// CPU usage of the process.
/// </summary>
public CPUUsage Cpu { get; set; }
/// <summary>
/// Creation time for this process. The time is represented as number of milliseconds since epoch.
/// Since the <see cref="PId"/> can be reused after a process dies, it is useful to use both the <see cref="PId"/>
/// and the <see cref="CreationTime"/> to uniquely identify a process.
/// </summary>
public int CreationTime { get; set; }
/// <summary>
/// Memory information for the process.
/// </summary>
public MemoryInfo Memory { get; set; }
/// <summary>
/// Whether the process is sandboxed on OS level.
/// </summary>
public bool Sandboxed { get; set; }
/// <summary>
/// One of the following values:
/// untrusted | low | medium | high | unknown
/// </summary>
public string IntegrityLevel { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum ProgressBarMode
{
/// <summary>
/// The none
/// </summary>
none,
/// <summary>
/// The normal
/// </summary>
normal,
/// <summary>
/// The indeterminate
/// </summary>
indeterminate,
/// <summary>
/// The error
/// </summary>
error,
/// <summary>
/// The paused
/// </summary>
paused
}
}

View File

@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ProgressBarOptions
{
/// <summary>
/// Mode for the progress bar. Can be 'none' | 'normal' | 'indeterminate' | 'error' | 'paused'.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public ProgressBarMode Mode { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ProgressInfo
{
/// <summary>
///
/// </summary>
public string Progress { get; set; }
/// <summary>
///
/// </summary>
public string BytesPerSecond { get; set; }
/// <summary>
///
/// </summary>
public string Percent { get; set; }
/// <summary>
///
/// </summary>
public string Total { get; set; }
/// <summary>
///
/// </summary>
public string Transferred { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ProxyConfig
{
/// <summary>
/// The URL associated with the PAC file.
/// </summary>
public string PacScript { get; set; }
/// <summary>
/// Rules indicating which proxies to use.
/// </summary>
public string ProxyRules { get; set; }
/// <summary>
/// Rules indicating which URLs should bypass the proxy settings.
/// </summary>
public string ProxyBypassRules { get; set; }
/// <summary>
///
/// </summary>
/// <param name="pacScript">The URL associated with the PAC file.</param>
/// <param name="proxyRules">Rules indicating which proxies to use.</param>
/// <param name="proxyBypassRules">Rules indicating which URLs should bypass the proxy settings.</param>
public ProxyConfig(string pacScript, string proxyRules, string proxyBypassRules)
{
PacScript = pacScript;
ProxyRules = proxyRules;
ProxyBypassRules = proxyBypassRules;
}
}
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ReadBookmark
{
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
public string Title { get; set; }
/// <summary>
/// Gets or sets the URL.
/// </summary>
/// <value>
/// The URL.
/// </value>
public string Url { get; set; }
}
}

View File

@@ -0,0 +1,49 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Rectangle
{
/// <summary>
/// Gets or sets the x.
/// </summary>
/// <value>
/// The x.
/// </value>
public int X { get; set; }
/// <summary>
/// Gets or sets the y.
/// </summary>
/// <value>
/// The y.
/// </value>
public int Y { get; set; }
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>
/// The width.
/// </value>
public int Width { get; set; }
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>
/// The height.
/// </value>
public int Height { get; set; }
/// <summary>
/// Convert this <see cref="Rectangle"/> to <see cref="System.Drawing.Rectangle"/>.
/// </summary>
/// <param name="rectangle">The rectangle.</param>
public static implicit operator System.Drawing.Rectangle(Rectangle rectangle)
{
return new System.Drawing.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
}
}
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Controls the behavior of <see cref="App.Relaunch(RelaunchOptions)"/>.
/// </summary>
public class RelaunchOptions
{
/// <summary>
/// Gets or sets the arguments.
/// </summary>
/// <value>
/// The arguments.
/// </value>
public string[] Args { get; set; }
/// <summary>
/// Gets or sets the execute path.
/// </summary>
/// <value>
/// The execute path.
/// </value>
public string ExecPath { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ReleaseNoteInfo
{
/// <summary>
/// The version.
/// </summary>
public string Version { get; set; }
/// <summary>
/// The note.
/// </summary>
public string Note { get; set; }
}
}

View File

@@ -0,0 +1,53 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class RemovePassword
{
/// <summary>
/// When provided, the authentication info related to the origin will only be
/// removed otherwise the entire cache will be cleared.
/// </summary>
public string Origin { get; set; }
/// <summary>
/// Credentials of the authentication. Must be provided if removing by origin.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Realm of the authentication. Must be provided if removing by origin.
/// </summary>
public string Realm { get; set; }
/// <summary>
/// Scheme of the authentication. Can be basic, digest, ntlm, negotiate.
/// Must be provided if removing by origin.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public Scheme Scheme { get; set; }
/// <summary>
/// password.
/// </summary>
public string Type { get; set; }
/// <summary>
/// Credentials of the authentication. Must be provided if removing by origin.
/// </summary>
public string Username { get; set; }
/// <summary>
///
/// </summary>
/// <param name="type">password.</param>
public RemovePassword(string type)
{
Type = type;
}
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ResizeOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// good, better, or best. Default is "best";
/// </summary>
public string Quality { get; set; } = "best";
}
}

View File

@@ -0,0 +1,61 @@
using ElectronNET.API.Entities;
namespace ElectronNET.API
{
/// <summary>
///
/// </summary>
public class SaveDialogOptions
{
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
public string Title { get; set; }
/// <summary>
/// Absolute directory path, absolute file path, or file name to use by default.
/// </summary>
public string DefaultPath { get; set; }
/// <summary>
/// Custom label for the confirmation button, when left empty the default label will
/// be used.
/// </summary>
public string ButtonLabel { get; set; }
/// <summary>
/// The filters specifies an array of file types that can be displayed or
/// selected when you want to limit the user to a specific type. For example:
/// </summary>
/// <example>
/// <code>
/// new FileFilter[]
/// {
/// new FileFiler { Name = "Images", Extensions = new string[] { "jpg", "png", "gif" } },
/// new FileFiler { Name = "Movies", Extensions = new string[] { "mkv", "avi", "mp4" } },
/// new FileFiler { Name = "Custom File Type", Extensions= new string[] {"as" } },
/// new FileFiler { Name = "All Files", Extensions= new string[] { "*" } }
/// }
/// </code>
/// </example>
public FileFilter[] Filters { get; set; }
/// <summary>
/// Message to display above text fields.
/// </summary>
public string Message { get; set; }
/// <summary>
/// Custom label for the text displayed in front of the filename text field.
/// </summary>
public string NameFieldLabel { get; set; }
/// <summary>
/// Show the tags input box, defaults to true.
/// </summary>
public bool ShowsTagField { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum Scheme
{
/// <summary>
///
/// </summary>
basic,
/// <summary>
///
/// </summary>
digest,
/// <summary>
///
/// </summary>
ntlm,
/// <summary>
///
/// </summary>
negotiate
}
}

View File

@@ -0,0 +1,59 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class SemVer
{
/// <summary>
///
/// </summary>
public string Raw { get; set; }
/// <summary>
///
/// </summary>
public bool Loose { get; set; }
/// <summary>
///
/// </summary>
public SemVerOptions Options { get; set; }
/// <summary>
///
/// </summary>
public int Major { get; set; }
/// <summary>
///
/// </summary>
public int Minor { get; set; }
/// <summary>
///
/// </summary>
public int Patch { get; set; }
/// <summary>
///
/// </summary>
public string Version { get; set; }
/// <summary>
///
/// </summary>
public string[] Build { get; set; }
/// <summary>
///
/// </summary>
public string[] Prerelease { get; set; }
}
/// <summary>
///
/// </summary>
public class SemVerOptions {
/// <summary>
///
/// </summary>
public bool? Loose { get; set; }
/// <summary>
///
/// </summary>
public bool? IncludePrerelease { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Structure of a shortcut.
/// </summary>
public class ShortcutDetails
{
/// <summary>
/// The Application User Model ID. Default is <see cref="string.Empty"/>.
/// </summary>
public string AppUserModelId { get; set; }
/// <summary>
/// The arguments to be applied to <see cref="Target"/> when launching from this shortcut. Default is <see cref="string.Empty"/>.
/// </summary>
public string Args { get; set; }
/// <summary>
/// The working directory. Default is <see cref="string.Empty"/>.
/// </summary>
public string Cwd { get; set; }
/// <summary>
/// The description of the shortcut. Default is <see cref="string.Empty"/>.
/// </summary>
public string Description { get; set; }
/// <summary>
/// The path to the icon, can be a DLL or EXE. <see cref="Icon"/> and <see cref="IconIndex"/> have to be set
/// together. Default is <see cref="string.Empty"/>, which uses the target's icon.
/// </summary>
public string Icon { get; set; }
/// <summary>
/// The resource ID of icon when <see cref="Icon"/> is a DLL or EXE. Default is 0.
/// </summary>
public int IconIndex { get; set; }
/// <summary>
/// The target to launch from this shortcut.
/// </summary>
public string Target { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Defines the ShortcutLinkOperation enumeration.
/// </summary>
public enum ShortcutLinkOperation
{
/// <summary>
/// Creates a new shortcut, overwriting if necessary.
/// </summary>
[Description("create")]
Create,
/// <summary>
/// Updates specified properties only on an existing shortcut.
/// </summary>
[Description("update")]
Update,
/// <summary>
/// Overwrites an existing shortcut, fails if the shortcut doesn't exist.
/// </summary>
[Description("replace")]
Replace
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Size
{
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>
/// The width.
/// </value>
public int Width { get; set; }
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>
/// The height.
/// </value>
public int Height { get; set; }
/// <summary>
/// Convert this <see cref="Size"/> to <see cref="System.Drawing.Size"/>.
/// </summary>
/// <param name="size">The size.</param>
public static implicit operator System.Drawing.Size(Size size)
{
return new System.Drawing.Size(size.Width, size.Height);
}
}
}

Some files were not shown because too many files have changed in this diff Show More