implement enum for types, implement OpenDialog from Dialog-API

This commit is contained in:
Gregor Biswanger
2017-10-17 05:12:35 +02:00
parent 2bace2d215
commit b28fa9465a
31 changed files with 527 additions and 38 deletions

View File

@@ -1496,9 +1496,9 @@ namespace ElectronNET.API
/// <param name="level">Values include normal, floating, torn-off-menu, modal-panel, main-menu,
/// status, pop-up-menu and screen-saver. The default is floating.
/// See the macOS docs</param>
public void SetAlwaysOnTop(bool flag, string level)
public void SetAlwaysOnTop(bool flag, OnTopLevel level)
{
BridgeConnector.Socket.Emit("browserWindowSetAlwaysOnTop", Id, flag, level);
BridgeConnector.Socket.Emit("browserWindowSetAlwaysOnTop", Id, flag, level.GetDescription());
}
/// <summary>
@@ -1512,9 +1512,9 @@ namespace ElectronNET.API
/// See the macOS docs</param>
/// <param name="relativeLevel">The number of layers higher to set this window relative to the given level.
/// The default is 0. Note that Apple discourages setting levels higher than 1 above screen-saver.</param>
public void SetAlwaysOnTop(bool flag, string level, int relativeLevel)
public void SetAlwaysOnTop(bool flag, OnTopLevel level, int relativeLevel)
{
BridgeConnector.Socket.Emit("browserWindowSetAlwaysOnTop", Id, flag, level, relativeLevel);
BridgeConnector.Socket.Emit("browserWindowSetAlwaysOnTop", Id, flag, level.GetDescription(), relativeLevel);
}
/// <summary>
@@ -2143,9 +2143,9 @@ namespace ElectronNET.API
/// <param name="type">Can be appearance-based, light, dark, titlebar, selection,
/// menu, popover, sidebar, medium-light or ultra-dark.
/// See the macOS documentation for more details.</param>
public void SetVibrancy(string type)
public void SetVibrancy(Vibrancy type)
{
BridgeConnector.Socket.Emit("browserWindowSetVibrancy", Id, type);
BridgeConnector.Socket.Emit("browserWindowSetVibrancy", Id, type.GetDescription());
}
private JsonSerializer _jsonSerializer = new JsonSerializer()

View File

@@ -26,6 +26,33 @@ namespace ElectronNET.API
}
}
/// <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"></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[]>();
BridgeConnector.Socket.On("showOpenDialogComplete", (filePaths) =>
{
BridgeConnector.Socket.Off("showOpenDialogComplete");
var result = ((JArray)filePaths).ToObject<string[]>();
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("showOpenDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer));
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

View File

@@ -1,4 +1,6 @@
using System.ComponentModel;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
@@ -205,9 +207,10 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The style of window title bar. Default is default. Possible values are:
/// 'default' | 'hidden' | 'hidden-inset' | 'hiddenInset' | 'customButtonsOnHover'
/// 'default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover'
/// </summary>
public string TitleBarStyle { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public TitleBarStyle TitleBarStyle { get; set; }
/// <summary>
/// Shows the title in the tile bar in full screen mode on macOS for all
@@ -228,7 +231,8 @@ namespace ElectronNET.API.Entities
/// appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
/// medium-light or ultra-dark.
/// </summary>
public string Vibrancy { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Vibrancy Vibrancy { get; set; }
/// <summary>
/// Controls the behavior on macOS when option-clicking the green stoplight button

View File

@@ -0,0 +1,35 @@
namespace ElectronNET.API.Entities
{
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,8 @@
namespace ElectronNET.API.Entities
{
public class FileFilter
{
public string[] Extensions { get; set; }
public string Name { get; set; }
}
}

View File

@@ -1,4 +1,6 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API
{
@@ -7,16 +9,17 @@ namespace ElectronNET.API
/// <summary>
/// Must be set if type is custom, otherwise it should be omitted.
/// </summary>
public string Name { get; set; } = string.Empty;
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; } = new JumpListItem[0];
public JumpListItem[] Items { get; set; }
/// <summary>
/// One of the following: "tasks" | "frequent" | "recent" | "custom"
/// </summary>
public string Type { get; set; } = "tasks";
[JsonConverter(typeof(StringEnumConverter))]
public JumpListCategoryType Type { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace ElectronNET.API
{
public enum JumpListCategoryType
{
tasks,
frequent,
recent,
custom
}
}

View File

@@ -1,16 +1,19 @@
namespace ElectronNET.API.Entities
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class JumpListItem
{
/// <summary>
/// The command line arguments when program is executed. Should only be set if type is task.
/// </summary>
public string Args { get; set; } = string.Empty;
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; } = string.Empty;
public string Description { get; set; }
/// <summary>
/// The index of the icon in the resource file. If a resource file contains multiple
@@ -18,34 +21,35 @@
/// should be displayed for this task.If a resource file contains only one icon,
/// this property should be set to zero.
/// </summary>
public int IconIndex { get; set; } = 0;
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; } = string.Empty;
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; } = string.Empty;
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; } = string.Empty;
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; } = string.Empty;
public string Title { get; set; }
/// <summary>
/// One of the following: "task" | "separator" | "file"
/// </summary>
public string Type {get; set; } = string.Empty;
[JsonConverter(typeof(StringEnumConverter))]
public JumpListItemType Type { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace ElectronNET.API.Entities
{
public enum JumpListItemType
{
task,
separator,
file
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
namespace ElectronNET.API.Entities
@@ -16,12 +17,14 @@ namespace ElectronNET.API.Entities
/// Define the action of the menu item, when specified the click property will be
/// ignored.
/// </summary>
public string Role { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public MenuRole Role { get; set; }
/// <summary>
/// Can be normal, separator, submenu, checkbox or radio.
/// </summary>
public string Type { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public MenuType Type { get; set; }
public string Label { get; set; }

View File

@@ -0,0 +1,129 @@
namespace ElectronNET.API.Entities
{
public enum MenuRole
{
undo,
redo,
cut,
copy,
paste,
pasteandmatchstyle,
selectall,
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,11 @@
namespace ElectronNET.API.Entities
{
public enum MenuType
{
normal,
separator,
submenu,
checkbox,
radio
}
}

View File

@@ -1,13 +1,17 @@
namespace ElectronNET.API.Entities
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
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.
/// option. On macOS, both "warning" and "error" display the same warning icon.
/// </summary>
public string Type { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public MessageBoxType Type { get; set; }
/// <summary>
/// Array of texts for buttons. On Windows, an empty array will result in one button

View File

@@ -0,0 +1,11 @@
namespace ElectronNET.API.Entities
{
public enum MessageBoxType
{
none,
info,
error,
question,
warning
}
}

View File

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

View File

@@ -0,0 +1,45 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class OpenDialogOptions
{
public string Title { get; set; }
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,14 @@
namespace ElectronNET.API.Entities
{
public enum OpenDialogProperty
{
openFile,
openDirectory,
multiSelections,
showHiddenFiles,
createDirectory,
promptToCreate,
noResolveAliases,
treatPackageAsDirectory
}
}

View File

@@ -0,0 +1,11 @@
namespace ElectronNET.API.Entities
{
public enum ProgressBarMode
{
none,
normal,
indeterminate,
error,
paused
}
}

View File

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

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
namespace ElectronNET.API.Entities
@@ -20,7 +21,8 @@ namespace ElectronNET.API.Entities
/// hidden - The button is not shown to the user.
/// noninteractive - The button is enabled but not interactive; no pressed button state is drawn.This value is intended for instances where the button is used in a notification.
/// </summary>
public string[] Flags { get; set; }
[JsonProperty("flags", ItemConverterType = typeof(StringEnumConverter))]
public ThumbarButtonFlag[] Flags { get; set; }
/// <summary>
/// The icon showing in thumbnail toolbar.

View File

@@ -0,0 +1,35 @@
namespace ElectronNET.API.Entities
{
public enum ThumbarButtonFlag
{
/// <summary>
/// The button is active and available to the user.
/// </summary>
enabled,
/// <summary>
/// The button is disabled.It is present, but has a visual state indicating it will not respond to user action.
/// </summary>
disabled,
/// <summary>
/// When the button is clicked, the thumbnail window closes immediately.
/// </summary>
dismissonclick,
/// <summary>
/// Do not draw a button border, use only the image.
/// </summary>
nobackground,
/// <summary>
/// The button is not shown to the user.
/// </summary>
hidden,
/// <summary>
/// The button is enabled but not interactive; no pressed button state is drawn.This value is intended for instances where the button is used in a notification.
/// </summary>
noninteractive
}
}

View File

@@ -0,0 +1,13 @@
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
public enum TitleBarStyle
{
[JsonProperty("default")]
defaultStyle,
hidden,
hiddenInset,
customButtonsOnHover
}
}

View File

@@ -0,0 +1,21 @@
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
public enum Vibrancy
{
[JsonProperty("appearance-based")]
appearanceBased,
light,
dark,
titlebar,
selection,
menu,
popover,
sidebar,
[JsonProperty("medium-light")]
mediumLight,
[JsonProperty("ultra-dark")]
ultraDark
}
}

View File

@@ -1,4 +1,7 @@
namespace ElectronNET.API.Entities
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class WebPreferences
{
@@ -121,6 +124,11 @@
/// </summary>
public string DisableBlinkFeatures { get; set; }
/// <summary>
/// Sets the default font for the font-family.
/// </summary>
public DefaultFontFamily DefaultFontFamily { get; set; }
/// <summary>
/// Defaults to 16.
/// </summary>

View File

@@ -0,0 +1,34 @@
using System;
using System.ComponentModel;
using System.Reflection;
namespace ElectronNET.API.Extensions
{
internal static class EnumExtensions
{
public static string GetDescription<T>(this T enumerationValue) where T : struct
{
Type type = enumerationValue.GetType();
if (!type.IsEnum)
{
throw new ArgumentException("EnumerationValue must be of Enum type", "enumerationValue");
}
//Tries to find a DescriptionAttribute for a potential friendly name
//for the enum
MemberInfo[] memberInfo = type.GetMember(enumerationValue.ToString());
if (memberInfo != null && memberInfo.Length > 0)
{
object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs != null && attrs.Length > 0)
{
//Pull out the description value
return ((DescriptionAttribute)attrs[0]).Description;
}
}
//If we have no description attribute, just return the ToString of the enum
return enumerationValue.ToString();
}
}
}

View File

@@ -17,8 +17,7 @@ namespace ElectronNET.API.Extensions
AddMenuItemsId(menuItem.Submenu);
}
if (string.IsNullOrEmpty(menuItem.Role) &&
string.IsNullOrEmpty(menuItem.Id))
if (string.IsNullOrEmpty(menuItem.Id))
{
menuItem.Id = Guid.NewGuid().ToString();
}

View File

@@ -15,5 +15,11 @@ module.exports = function (socket) {
});
}
});
socket.on('showOpenDialog', function (browserWindow, options) {
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
electron_1.dialog.showOpenDialog(window, options, function (filePaths) {
socket.emit('showOpenDialogComplete', filePaths || []);
});
});
};
//# sourceMappingURL=dialog.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":";;AAAA,qCAAiD;AAEjD,MAAM,CAAC,OAAO,GAAG,UAAC,MAAuB;IACrC,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,UAAC,aAAa,EAAE,OAAO;QAC/C,EAAE,CAAA,CAAC,IAAI,IAAI,aAAa,CAAC,CAAC,CAAC;YACvB,IAAI,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAEpD,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,UAAC,QAAQ,EAAE,eAAe;gBAC7D,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACP,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,iBAAM,CAAC,cAAc,CAAC,aAAa,EAAE,UAAC,QAAQ,EAAE,eAAe;gBAC3D,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAA"}
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":";;AAAA,qCAAiD;AAEjD,MAAM,CAAC,OAAO,GAAG,UAAC,MAAuB;IACrC,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,UAAC,aAAa,EAAE,OAAO;QAC/C,EAAE,CAAA,CAAC,IAAI,IAAI,aAAa,CAAC,CAAC,CAAC;YACvB,IAAI,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAEpD,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,UAAC,QAAQ,EAAE,eAAe;gBAC7D,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACP,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,iBAAM,CAAC,cAAc,CAAC,aAAa,EAAE,UAAC,QAAQ,EAAE,eAAe;gBAC3D,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,UAAC,aAAa,EAAE,OAAO;QAC3C,IAAI,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACpD,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,UAAC,SAAS;YAC7C,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC,CAAA"}

View File

@@ -14,4 +14,11 @@ module.exports = (socket: SocketIO.Server) => {
});
}
});
socket.on('showOpenDialog', (browserWindow, options) => {
var window = BrowserWindow.fromId(browserWindow.id);
dialog.showOpenDialog(window, options, (filePaths) => {
socket.emit('showOpenDialogComplete', filePaths || []);
});
});
}

View File

@@ -9,10 +9,21 @@ namespace ElectronNET.WebApp.Controllers
{
public IActionResult Index()
{
Electron.IpcMain.On("SayHello", (args) => {
Electron.Notification.Show(new NotificationOptions("Hallo Robert","Nachricht von ASP.NET Core App"));
Electron.IpcMain.On("SayHello", async (args) =>
{
Electron.Notification.Show(new NotificationOptions("Hallo Robert", "Nachricht von ASP.NET Core App"));
Electron.IpcMain.Send(Electron.WindowManager.BrowserWindows.First(), "Goodbye", "Elephant!");
var currentBrowserWindow = Electron.WindowManager.BrowserWindows.First();
var openDialogOptions = new OpenDialogOptions
{
Title = "Wuhuuu",
ButtonLabel = "Mhh Okay",
DefaultPath = await Electron.App.GetPathAsync(PathName.pictures),
Message = "Hello World",
Properties = new OpenDialogProperty[] { OpenDialogProperty.openDirectory }
};
var filePaths = await Electron.Dialog.ShowOpenDialogAsync(currentBrowserWindow, openDialogOptions);
});
Electron.IpcMain.On("GetPath", async (args) =>

View File

@@ -62,7 +62,7 @@ namespace ElectronNET.WebApp
Click = async () => {
await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions("(c) 2017 Gregor Biswanger & Robert Muehsig") {
Title = "About us...",
Type = "info"
Type = MessageBoxType.info
});
}
}