using Microsoft.Extensions.Logging;
using System.Runtime.Versioning;
using System;
namespace ElectronNET.API
{
///
/// The Electron.NET API
///
public static class Electron
{
private static ILoggerFactory loggerFactory;
///
/// Reads the auth key from the command line. This method must be called first thing.
///
///
public static void ReadAuth()
{
var line = Console.ReadLine();
if(line.StartsWith("Auth="))
{
BridgeConnector.AuthKey = line.Substring("Auth=".Length);
}
else
{
throw new Exception("The call to Electron.ReadAuth must be the first thing your app entry point does");
}
}
///
/// Sets the logger factory to be used by Electron, if any
///
public static ILoggerFactory LoggerFactory
{
private get => loggerFactory; set
{
loggerFactory = value;
BridgeConnector.Logger = value.CreateLogger();
}
}
///
/// Communicate asynchronously from the main process to renderer processes.
///
public static IpcMain IpcMain { get { return IpcMain.Instance; } }
///
/// Control your application's event lifecycle.
///
public static App App { get { return App.Instance; } }
///
/// Enable apps to automatically update themselves. Based on electron-updater.
///
public static AutoUpdater AutoUpdater { get { return AutoUpdater.Instance; } }
///
/// Control your windows.
///
public static WindowManager WindowManager { get { return WindowManager.Instance; } }
///
/// Create native application menus and context menus.
///
public static Menu Menu { get { return Menu.Instance; } }
///
/// Display native system dialogs for opening and saving files, alerting, etc.
///
public static Dialog Dialog { get { return Dialog.Instance; } }
///
/// Create OS desktop notifications
///
public static Notification Notification { get { return Notification.Instance; } }
///
/// Add icons and context menus to the system’s notification area.
///
public static Tray Tray { get { return Tray.Instance; } }
///
/// Detect keyboard events when the application does not have keyboard focus.
///
public static GlobalShortcut GlobalShortcut { get { return GlobalShortcut.Instance; } }
///
/// Manage files and URLs using their default applications.
///
public static Shell Shell { get { return Shell.Instance; } }
///
/// Retrieve information about screen size, displays, cursor position, etc.
///
public static Screen Screen { get { return Screen.Instance; } }
///
/// Access information about media sources that can be used to capture audio and video from the desktop using the navigator.mediaDevices.getUserMedia API.
///
public static DesktopCapturer DesktopCapturer { get { return DesktopCapturer.Instance; } }
///
/// Perform copy and paste operations on the system clipboard.
///
public static Clipboard Clipboard { get { return Clipboard.Instance; } }
///
/// 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:
/// electronize add HostHook
///
public static HostHook HostHook { get { return HostHook.Instance; } }
///
/// Allows you to execute native Lock and Unlock process.
///
public static PowerMonitor PowerMonitor { get { return PowerMonitor.Instance; } }
///
/// Read and respond to changes in Chromium's native color theme.
///
public static NativeTheme NativeTheme { get { return NativeTheme.Instance; } }
///
/// Control your app in the macOS dock.
///
[SupportedOSPlatform("macos")]
public static Dock Dock { get { return Dock.Instance; } }
}
}