mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-08-11 18:49:57 +00:00
Merge branch 'master' of https://github.com/GregorBiswanger/Electron.NET
This commit is contained in:
9
ElectronNET.API/Entities/DisplayBalloonOptions.cs
Normal file
9
ElectronNET.API/Entities/DisplayBalloonOptions.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
public class DisplayBalloonOptions
|
||||
{
|
||||
public string Icon { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Content { get; set; }
|
||||
}
|
||||
}
|
||||
20
ElectronNET.API/Entities/HighlightMode.cs
Normal file
20
ElectronNET.API/Entities/HighlightMode.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public enum HighlightMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Highlight the tray icon when it is clicked and also when its context menu is open. This is the default.
|
||||
/// </summary>
|
||||
selection,
|
||||
|
||||
/// <summary>
|
||||
/// Always highlight the tray icon.
|
||||
/// </summary>
|
||||
always,
|
||||
|
||||
/// <summary>
|
||||
/// Never highlight the tray icon.
|
||||
/// </summary>
|
||||
never
|
||||
}
|
||||
}
|
||||
15
ElectronNET.API/Entities/NotificationAction.cs
Normal file
15
ElectronNET.API/Entities/NotificationAction.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class NotificationOptions
|
||||
{
|
||||
@@ -44,6 +47,63 @@
|
||||
/// </summary>
|
||||
public string Sound { 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>
|
||||
/// 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; }
|
||||
|
||||
[JsonProperty]
|
||||
internal string ShowID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when the notification is clicked by the user.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Action OnClick { get; set; }
|
||||
|
||||
[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; }
|
||||
|
||||
[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; }
|
||||
|
||||
[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; }
|
||||
|
||||
[JsonProperty]
|
||||
internal string ActionID { get; set; }
|
||||
|
||||
public NotificationOptions(string title, string body)
|
||||
{
|
||||
Title = title;
|
||||
|
||||
10
ElectronNET.API/Entities/TrayClickEventArgs.cs
Normal file
10
ElectronNET.API/Entities/TrayClickEventArgs.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
public class TrayClickEventArgs
|
||||
{
|
||||
public bool AltKey { get; set; }
|
||||
public bool ShiftKey { get; set; }
|
||||
public bool CtrlKey { get; set; }
|
||||
public bool MetaKey { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,10 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -24,11 +28,105 @@ namespace ElectronNET.API
|
||||
}
|
||||
}
|
||||
|
||||
private static List<NotificationOptions> _notificationOptions = new List<NotificationOptions>();
|
||||
|
||||
/// <summary>
|
||||
/// Create OS desktop notifications
|
||||
/// </summary>
|
||||
/// <param name="notificationOptions"></param>
|
||||
public void Show(NotificationOptions notificationOptions)
|
||||
{
|
||||
GenerateIDsForDefinedActions(notificationOptions);
|
||||
|
||||
BridgeConnector.Socket.Emit("createNotification", JObject.FromObject(notificationOptions, _jsonSerializer));
|
||||
}
|
||||
|
||||
private static void GenerateIDsForDefinedActions(NotificationOptions notificationOptions)
|
||||
{
|
||||
bool isActionDefined = false;
|
||||
|
||||
if (notificationOptions.OnShow != null)
|
||||
{
|
||||
notificationOptions.ShowID = Guid.NewGuid().ToString();
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventShow");
|
||||
BridgeConnector.Socket.On("NotificationEventShow", (id) => {
|
||||
_notificationOptions.Single(x => x.ShowID == id.ToString()).OnShow();
|
||||
});
|
||||
}
|
||||
|
||||
if (notificationOptions.OnClick != null)
|
||||
{
|
||||
notificationOptions.ClickID = Guid.NewGuid().ToString();
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventClick");
|
||||
BridgeConnector.Socket.On("NotificationEventClick", (id) => {
|
||||
_notificationOptions.Single(x => x.ClickID == id.ToString()).OnClick();
|
||||
});
|
||||
}
|
||||
|
||||
if (notificationOptions.OnClose != null)
|
||||
{
|
||||
notificationOptions.CloseID = Guid.NewGuid().ToString();
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventClose");
|
||||
BridgeConnector.Socket.On("NotificationEventClose", (id) => {
|
||||
_notificationOptions.Single(x => x.CloseID == id.ToString()).OnClose();
|
||||
});
|
||||
}
|
||||
|
||||
if (notificationOptions.OnReply != null)
|
||||
{
|
||||
notificationOptions.ReplyID = Guid.NewGuid().ToString();
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventReply");
|
||||
BridgeConnector.Socket.On("NotificationEventReply", (args) => {
|
||||
var arguments = ((JArray)args).ToObject<string[]>();
|
||||
_notificationOptions.Single(x => x.ReplyID == arguments[0].ToString()).OnReply(arguments[1].ToString());
|
||||
});
|
||||
}
|
||||
|
||||
if (notificationOptions.OnAction != null)
|
||||
{
|
||||
notificationOptions.ActionID = Guid.NewGuid().ToString();
|
||||
isActionDefined = true;
|
||||
|
||||
BridgeConnector.Socket.Off("NotificationEventAction");
|
||||
BridgeConnector.Socket.On("NotificationEventAction", (args) => {
|
||||
var arguments = ((JArray)args).ToObject<string[]>();
|
||||
_notificationOptions.Single(x => x.ReplyID == arguments[0].ToString()).OnAction(arguments[1].ToString());
|
||||
});
|
||||
}
|
||||
|
||||
if (isActionDefined)
|
||||
{
|
||||
_notificationOptions.Add(notificationOptions);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not desktop notifications are supported on the current system.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsSupportedAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("notificationIsSupportedComplete", (isSupported) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("notificationIsSupportedComplete");
|
||||
taskCompletionSource.SetResult((bool)isSupported);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("notificationIsSupported");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
|
||||
@@ -3,12 +3,182 @@ using ElectronNET.API.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
public sealed class Tray
|
||||
{
|
||||
/// <summary>
|
||||
/// Emitted when the tray icon is clicked.
|
||||
/// </summary>
|
||||
public event Action<TrayClickEventArgs, Rectangle> OnClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_click == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-click-event", (result) =>
|
||||
{
|
||||
var args = ((JArray)result).ToObject<object[]>();
|
||||
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
|
||||
var bounds = ((JObject)args[1]).ToObject<Rectangle>();
|
||||
_click(trayClickEventArgs, bounds);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-click");
|
||||
}
|
||||
_click += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_click -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<TrayClickEventArgs, Rectangle> _click;
|
||||
|
||||
/// <summary>
|
||||
/// macOS, Windows: Emitted when the tray icon is right clicked.
|
||||
/// </summary>
|
||||
public event Action<TrayClickEventArgs, Rectangle> OnRightClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_rightClick == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-right-click-event", (result) =>
|
||||
{
|
||||
var args = ((JArray)result).ToObject<object[]>();
|
||||
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
|
||||
var bounds = ((JObject)args[1]).ToObject<Rectangle>();
|
||||
_rightClick(trayClickEventArgs, bounds);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-right-click");
|
||||
}
|
||||
_rightClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_rightClick -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<TrayClickEventArgs, Rectangle> _rightClick;
|
||||
|
||||
/// <summary>
|
||||
/// macOS, Windows: Emitted when the tray icon is double clicked.
|
||||
/// </summary>
|
||||
public event Action<TrayClickEventArgs, Rectangle> OnDoubleClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_doubleClick == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-double-click-event", (result) =>
|
||||
{
|
||||
var args = ((JArray)result).ToObject<object[]>();
|
||||
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
|
||||
var bounds = ((JObject)args[1]).ToObject<Rectangle>();
|
||||
_doubleClick(trayClickEventArgs, bounds);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-double-click");
|
||||
}
|
||||
_doubleClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_doubleClick -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<TrayClickEventArgs, Rectangle> _doubleClick;
|
||||
|
||||
/// <summary>
|
||||
/// Windows: Emitted when the tray balloon shows.
|
||||
/// </summary>
|
||||
public event Action OnBalloonShow
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_balloonShow == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-balloon-show-event", () =>
|
||||
{
|
||||
_balloonShow();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-balloon-show");
|
||||
}
|
||||
_balloonShow += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_balloonShow -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action _balloonShow;
|
||||
|
||||
/// <summary>
|
||||
/// Windows: Emitted when the tray balloon is clicked.
|
||||
/// </summary>
|
||||
public event Action OnBalloonClick
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_balloonClick == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-balloon-click-event", () =>
|
||||
{
|
||||
_balloonClick();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-balloon-click");
|
||||
}
|
||||
_balloonClick += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_balloonClick -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action _balloonClick;
|
||||
|
||||
/// <summary>
|
||||
/// Windows: Emitted when the tray balloon is closed
|
||||
/// because of timeout or user manually closes it.
|
||||
/// </summary>
|
||||
public event Action OnBalloonClosed
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_balloonClosed == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("tray-balloon-closed-event", () =>
|
||||
{
|
||||
_balloonClosed();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-tray-balloon-closed");
|
||||
}
|
||||
_balloonClosed += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_balloonClosed -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action _balloonClosed;
|
||||
|
||||
// TODO: Implement macOS Events
|
||||
|
||||
private static Tray _tray;
|
||||
|
||||
internal Tray() { }
|
||||
@@ -42,6 +212,91 @@ namespace ElectronNET.API
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys the tray icon immediately.
|
||||
/// </summary>
|
||||
public void Destroy()
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-destroy");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the image associated with this tray icon.
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
public void SetImage(string image)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-setImage", image);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the image associated with this tray icon when pressed on macOS.
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
public void SetPressedImage(string image)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-setPressedImage", image);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the hover text for this tray icon.
|
||||
/// </summary>
|
||||
/// <param name="toolTip"></param>
|
||||
public void SetToolTip(string toolTip)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-setToolTip", toolTip);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// macOS: Sets the title displayed aside of the tray icon in the status bar.
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
public void SetTitle(string title)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-setTitle", title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// macOS: Sets when the tray’s icon background becomes highlighted (in blue).
|
||||
///
|
||||
/// Note: You can use highlightMode with a BrowserWindow by toggling between
|
||||
/// 'never' and 'always' modes when the window visibility changes.
|
||||
/// </summary>
|
||||
/// <param name="highlightMode"></param>
|
||||
public void SetHighlightMode(HighlightMode highlightMode)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-setHighlightMode", highlightMode.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Windows: Displays a tray balloon.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public void DisplayBalloon(DisplayBalloonOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-displayBalloon", JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the tray icon is destroyed.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDestroyedAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("tray-isDestroyedCompleted", (isDestroyed) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("tray-isDestroyedCompleted");
|
||||
|
||||
taskCompletionSource.SetResult((bool)isDestroyed);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("tray-isDestroyed");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
|
||||
@@ -1,10 +1,49 @@
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var electron_1 = require("electron");
|
||||
var notifications = [];
|
||||
module.exports = function (socket) {
|
||||
socket.on('createNotification', function (options) {
|
||||
var notification = new electron_1.Notification(options);
|
||||
var haveEvent = false;
|
||||
if (options.showID) {
|
||||
haveEvent = true;
|
||||
notification.on('show', function () {
|
||||
socket.emit('NotificationEventShow', options.showID);
|
||||
});
|
||||
}
|
||||
if (options.clickID) {
|
||||
haveEvent = true;
|
||||
notification.on('click', function () {
|
||||
socket.emit('NotificationEventClick', options.clickID);
|
||||
});
|
||||
}
|
||||
if (options.closeID) {
|
||||
haveEvent = true;
|
||||
notification.on('close', function () {
|
||||
socket.emit('NotificationEventClose', options.closeID);
|
||||
});
|
||||
}
|
||||
if (options.replyID) {
|
||||
haveEvent = true;
|
||||
notification.on('reply', function (event, value) {
|
||||
socket.emit('NotificationEventReply', [options.replyID, value]);
|
||||
});
|
||||
}
|
||||
if (options.actionID) {
|
||||
haveEvent = true;
|
||||
notification.on('action', function (event, value) {
|
||||
socket.emit('NotificationEventAction', [options.actionID, value]);
|
||||
});
|
||||
}
|
||||
if (haveEvent) {
|
||||
notifications.push(notification);
|
||||
}
|
||||
notification.show();
|
||||
});
|
||||
socket.on('notificationIsSupported', function (options) {
|
||||
var isSupported = electron_1.Notification.isSupported;
|
||||
socket.emit('notificationIsSupportedComplete', isSupported);
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=notification.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"notification.js","sourceRoot":"","sources":["notification.ts"],"names":[],"mappings":";;AAAA,qCAAwC;AAExC,MAAM,CAAC,OAAO,GAAG,UAAC,MAAuB;IACrC,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,OAAO;QACpC,IAAM,YAAY,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QAC/C,YAAY,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACP,CAAC,CAAA"}
|
||||
{"version":3,"file":"notification.js","sourceRoot":"","sources":["notification.ts"],"names":[],"mappings":";;AAAA,qCAAwC;AACxC,IAAM,aAAa,GAA4B,EAAE,CAAC;AAElD,MAAM,CAAC,OAAO,GAAG,UAAC,MAAuB;IACrC,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,OAAO;QACpC,IAAM,YAAY,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,EAAE,CAAA,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YAChB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE;gBACpB,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;QACP,CAAC;QAED,EAAE,CAAA,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACjB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;QACP,CAAC;QAED,EAAE,CAAA,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACjB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;QACP,CAAC;QAED,EAAE,CAAA,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACjB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,KAAK,EAAE,KAAK;gBAClC,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC;QACP,CAAC;QAED,EAAE,CAAA,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAC,KAAK,EAAE,KAAK;gBACnC,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YACtE,CAAC,CAAC,CAAC;QACP,CAAC;QAED,EAAE,CAAA,CAAC,SAAS,CAAC,CAAC,CAAC;YACX,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC;QAED,YAAY,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,UAAC,OAAO;QACzC,IAAM,WAAW,GAAG,uBAAY,CAAC,WAAW,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE,WAAW,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACP,CAAC,CAAA"}
|
||||
@@ -1,8 +1,55 @@
|
||||
import { Notification } from "electron";
|
||||
const notifications: Electron.Notification[] = [];
|
||||
|
||||
module.exports = (socket: SocketIO.Server) => {
|
||||
socket.on('createNotification', (options) => {
|
||||
const notification = new Notification(options);
|
||||
let haveEvent = false;
|
||||
|
||||
if(options.showID) {
|
||||
haveEvent = true;
|
||||
notification.on('show', () => {
|
||||
socket.emit('NotificationEventShow', options.showID);
|
||||
});
|
||||
}
|
||||
|
||||
if(options.clickID) {
|
||||
haveEvent = true;
|
||||
notification.on('click', () => {
|
||||
socket.emit('NotificationEventClick', options.clickID);
|
||||
});
|
||||
}
|
||||
|
||||
if(options.closeID) {
|
||||
haveEvent = true;
|
||||
notification.on('close', () => {
|
||||
socket.emit('NotificationEventClose', options.closeID);
|
||||
});
|
||||
}
|
||||
|
||||
if(options.replyID) {
|
||||
haveEvent = true;
|
||||
notification.on('reply', (event, value) => {
|
||||
socket.emit('NotificationEventReply', [options.replyID, value]);
|
||||
});
|
||||
}
|
||||
|
||||
if(options.actionID) {
|
||||
haveEvent = true;
|
||||
notification.on('action', (event, value) => {
|
||||
socket.emit('NotificationEventAction', [options.actionID, value]);
|
||||
});
|
||||
}
|
||||
|
||||
if(haveEvent) {
|
||||
notifications.push(notification);
|
||||
}
|
||||
|
||||
notification.show();
|
||||
});
|
||||
|
||||
socket.on('notificationIsSupported', (options) => {
|
||||
const isSupported = Notification.isSupported;
|
||||
socket.emit('notificationIsSupportedComplete', isSupported);
|
||||
});
|
||||
}
|
||||
@@ -4,6 +4,48 @@ var electron_1 = require("electron");
|
||||
var path = require('path');
|
||||
var tray;
|
||||
module.exports = function (socket) {
|
||||
socket.on('register-tray-click', function () {
|
||||
if (tray) {
|
||||
tray.on('click', function (event, bounds) {
|
||||
socket.emit('tray-click-event', [event.__proto__, bounds]);
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-right-click', function () {
|
||||
if (tray) {
|
||||
tray.on('right-click', function (event, bounds) {
|
||||
socket.emit('tray-right-click-event', [event.__proto__, bounds]);
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-double-click', function () {
|
||||
if (tray) {
|
||||
tray.on('double-click', function (event, bounds) {
|
||||
socket.emit('tray-double-click-event', [event.__proto__, bounds]);
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-balloon-show', function () {
|
||||
if (tray) {
|
||||
tray.on('balloon-show', function () {
|
||||
socket.emit('tray-balloon-show-event');
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-balloon-click', function () {
|
||||
if (tray) {
|
||||
tray.on('balloon-click', function () {
|
||||
socket.emit('tray-balloon-click-event');
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('register-tray-balloon-closed', function () {
|
||||
if (tray) {
|
||||
tray.on('balloon-closed', function () {
|
||||
socket.emit('tray-balloon-closed-event');
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('create-tray', function (image, menuItems) {
|
||||
var menu = electron_1.Menu.buildFromTemplate(menuItems);
|
||||
addMenuItemClickConnector(menu.items, function (id) {
|
||||
@@ -13,6 +55,48 @@ module.exports = function (socket) {
|
||||
tray = new electron_1.Tray(imagePath);
|
||||
tray.setContextMenu(menu);
|
||||
});
|
||||
socket.on('tray-destroy', function () {
|
||||
if (tray) {
|
||||
tray.destroy();
|
||||
}
|
||||
});
|
||||
socket.on('tray-setImage', function (image) {
|
||||
if (tray) {
|
||||
tray.setImage(image);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setPressedImage', function (image) {
|
||||
if (tray) {
|
||||
var img = electron_1.nativeImage.createFromPath(image);
|
||||
tray.setPressedImage(img);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setToolTip', function (toolTip) {
|
||||
if (tray) {
|
||||
tray.setToolTip(toolTip);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setTitle', function (title) {
|
||||
if (tray) {
|
||||
tray.setTitle(title);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setHighlightMode', function (mode) {
|
||||
if (tray) {
|
||||
tray.setHighlightMode(mode);
|
||||
}
|
||||
});
|
||||
socket.on('tray-displayBalloon', function (options) {
|
||||
if (tray) {
|
||||
tray.displayBalloon(options);
|
||||
}
|
||||
});
|
||||
socket.on('tray-isDestroyed', function () {
|
||||
if (tray) {
|
||||
var isDestroyed = tray.isDestroyed();
|
||||
socket.emit('tray-isDestroyedCompleted', isDestroyed);
|
||||
}
|
||||
});
|
||||
function addMenuItemClickConnector(menuItems, callback) {
|
||||
menuItems.forEach(function (item) {
|
||||
if (item.submenu && item.submenu.items.length > 0) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"tray.js","sourceRoot":"","sources":["tray.ts"],"names":[],"mappings":";;AAAA,qCAAsC;AACtC,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAI,IAAI,CAAC;AAET,MAAM,CAAC,OAAO,GAAG,UAAC,MAAuB;IACrC,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,UAAC,KAAK,EAAE,SAAS;QACtC,IAAM,IAAI,GAAG,eAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAE/C,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,UAAC,EAAE;YACrC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAExE,IAAI,GAAG,IAAI,eAAI,CAAC,SAAS,CAAC,CAAC;QAC3B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,mCAAmC,SAAS,EAAE,QAAQ;QAClD,SAAS,CAAC,OAAO,CAAC,UAAC,IAAI;YACnB,EAAE,CAAA,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC/C,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,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
|
||||
let tray;
|
||||
let tray: Electron.Tray;
|
||||
|
||||
module.exports = (socket: SocketIO.Server) => {
|
||||
socket.on('register-tray-click', () => {
|
||||
if (tray) {
|
||||
tray.on('click', (event, bounds) => {
|
||||
socket.emit('tray-click-event', [(<any>event).__proto__, bounds]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('register-tray-right-click', () => {
|
||||
if (tray) {
|
||||
tray.on('right-click', (event, bounds) => {
|
||||
socket.emit('tray-right-click-event', [(<any>event).__proto__, bounds]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('register-tray-double-click', () => {
|
||||
if (tray) {
|
||||
tray.on('double-click', (event, bounds) => {
|
||||
socket.emit('tray-double-click-event', [(<any>event).__proto__, bounds]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('register-tray-balloon-show', () => {
|
||||
if (tray) {
|
||||
tray.on('balloon-show', () => {
|
||||
socket.emit('tray-balloon-show-event');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('register-tray-balloon-click', () => {
|
||||
if (tray) {
|
||||
tray.on('balloon-click', () => {
|
||||
socket.emit('tray-balloon-click-event');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('register-tray-balloon-closed', () => {
|
||||
if (tray) {
|
||||
tray.on('balloon-closed', () => {
|
||||
socket.emit('tray-balloon-closed-event');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('create-tray', (image, menuItems) => {
|
||||
const menu = Menu.buildFromTemplate(menuItems);
|
||||
|
||||
@@ -16,13 +64,63 @@ module.exports = (socket: SocketIO.Server) => {
|
||||
tray.setContextMenu(menu);
|
||||
});
|
||||
|
||||
socket.on('tray-destroy', () => {
|
||||
if (tray) {
|
||||
tray.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-setImage', (image) => {
|
||||
if (tray) {
|
||||
tray.setImage(image);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-setPressedImage', (image) => {
|
||||
if (tray) {
|
||||
let img = nativeImage.createFromPath(image);
|
||||
tray.setPressedImage(img);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-setToolTip', (toolTip) => {
|
||||
if (tray) {
|
||||
tray.setToolTip(toolTip);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-setTitle', (title) => {
|
||||
if (tray) {
|
||||
tray.setTitle(title);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-setHighlightMode', (mode) => {
|
||||
if (tray) {
|
||||
tray.setHighlightMode(mode);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-displayBalloon', (options) => {
|
||||
if (tray) {
|
||||
tray.displayBalloon(options);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-isDestroyed', () => {
|
||||
if (tray) {
|
||||
let isDestroyed = tray.isDestroyed();
|
||||
socket.emit('tray-isDestroyedCompleted', isDestroyed);
|
||||
}
|
||||
});
|
||||
|
||||
function addMenuItemClickConnector(menuItems, callback) {
|
||||
menuItems.forEach((item) => {
|
||||
if(item.submenu && item.submenu.items.length > 0) {
|
||||
if (item.submenu && item.submenu.items.length > 0) {
|
||||
addMenuItemClickConnector(item.submenu.items, callback);
|
||||
}
|
||||
|
||||
if("id" in item && item.id) {
|
||||
|
||||
if ("id" in item && item.id) {
|
||||
item.click = () => { callback(item.id); };
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,7 +11,13 @@ namespace ElectronNET.WebApp.Controllers
|
||||
{
|
||||
Electron.IpcMain.On("SayHello", async (args) =>
|
||||
{
|
||||
Electron.Notification.Show(new NotificationOptions("Hallo Robert", "Nachricht von ASP.NET Core App"));
|
||||
Electron.Notification.Show(new NotificationOptions("Hallo Robert", "Nachricht von ASP.NET Core App") {
|
||||
OnClick = async () => { await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions("Notification clicked")); },
|
||||
OnShow = async () => { await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions("Notification show")); },
|
||||
OnClose = async () => { await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions("Notification closed")); },
|
||||
OnAction = async (value) => { await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions("Notification Action")); },
|
||||
OnReply = async (value) => { await Electron.Dialog.ShowMessageBoxAsync(new MessageBoxOptions("Notification Reply")); }
|
||||
});
|
||||
Electron.IpcMain.Send(Electron.WindowManager.BrowserWindows.First(), "Goodbye", "Elephant!");
|
||||
|
||||
var currentBrowserWindow = Electron.WindowManager.BrowserWindows.First();
|
||||
@@ -28,6 +34,8 @@ namespace ElectronNET.WebApp.Controllers
|
||||
|
||||
Electron.IpcMain.On("GetPath", async (args) =>
|
||||
{
|
||||
Electron.Notification.Show(new NotificationOptions("test", "test2"));
|
||||
|
||||
var currentBrowserWindow = Electron.WindowManager.BrowserWindows.First();
|
||||
|
||||
string pathName = await Electron.App.GetPathAsync(PathName.pictures);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
49
README.md
49
README.md
@@ -4,6 +4,42 @@ Master: [ Electron API include the [ElectronNET.API NuGet package](https://www.nuget.org/packages/ElectronNET.API/) in your ASP.NET Core app.
|
||||
|
||||
* For the tooling you will need your dotnet-electronize package [ElectronNET.CLI NuGet package](https://www.nuget.org/packages/ElectronNET.CLI/). This package __must__ be referenced in the .csproj like this:
|
||||
|
||||
```
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="ElectronNET.CLI" Version="*" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
* Make sure you have node.js and on OSX/Ubuntu the electron-packager installed (via "sudo npm install electron-packager --global")
|
||||
* In your ASP.NET Core folder run:
|
||||
|
||||
```
|
||||
dotnet electronize init
|
||||
```
|
||||
|
||||
* Now a electronnet.manifest.json should appear in your ASP.NET Core project
|
||||
* Now run the following:
|
||||
|
||||
```
|
||||
dotnet electronize build
|
||||
```
|
||||
|
||||
* In your default setting we just build the application for the OS you are running (Windows builds Windows, OSX builds OSX etc.), but this can be changed with:
|
||||
|
||||
```
|
||||
dotnet electronize build win
|
||||
dotnet electronize build osx
|
||||
dotnet electronize build linux
|
||||
```
|
||||
|
||||
* The end result should be a electron app under your /bin/desktop folder
|
||||
|
||||
## Dev Notes:
|
||||
|
||||
Currently there are two main projects and a "WebApp" that serves as a demo playground.
|
||||
@@ -13,12 +49,7 @@ Currently there are two main projects and a "WebApp" that serves as a demo playg
|
||||
|
||||
Both projects create their own nuget package. The resulting nuget packages are saved under "/artifacts".
|
||||
|
||||
__Currently__ the packages are just build with version 1.0.0.
|
||||
If you change something you need to clear the nuget cache under this directory (because the version number doesn't change):
|
||||
|
||||
%userprofile%\.nuget\packages
|
||||
|
||||
The solution contains a NuGet.config which points to the artifacts directory, so we can just use the produced NuGet packages without uploading to NuGet.org.
|
||||
__Currently__ the packages are just build with version 1.0.0 on your machine. NuGet might pick the wrong version from its own cache, so please read the dev notes if you want to develop!
|
||||
|
||||
__ElectronNET.WebApp:__
|
||||
|
||||
@@ -28,11 +59,7 @@ The WebApp now has referenced the API NuGet package and via the .csproj referenc
|
||||
<DotNetCliToolReference Include="ElectronNET.CLI" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
## Dev Notes: Usage
|
||||
|
||||
Navigate to the WebApp folder and type this in a command prompt:
|
||||
|
||||
dotnet electronize
|
||||
|
||||
# Dev Notes: Dev Workflow
|
||||
|
||||
@@ -41,5 +68,5 @@ Navigate to the WebApp folder and type this in a command prompt:
|
||||
* Change something in the CLI project
|
||||
* rebuild the project (a nuget package should now appear in the /artifacts directory)
|
||||
* make sure there is no ElectronNET.CLI package in your %userprofile%\.nuget\packages cache with the same version
|
||||
* execute dotnet restore in the WebApp
|
||||
* execute dotnet restore in the WebApp
|
||||
* execute dotnet electronize
|
||||
|
||||
Reference in New Issue
Block a user