Skip to content

Commit c12c26b

Browse files
2 parents df02855 + 6ddce85 commit c12c26b

File tree

8 files changed

+48
-25
lines changed

8 files changed

+48
-25
lines changed

Changelog.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
# Not released
22

3+
4+
5+
# Released
6+
37
# 8.31.2
48

9+
ElectronNET.CLI:
10+
* New Feature: Deactivate PublishReadyToRun for build or start [\#395](https://github.com/ElectronNET/Electron.NET/issues/395)
11+
12+
`electronize build /target win /PublishReadyToRun false`
13+
`electronize start /PublishReadyToRun false`
14+
* Fixed bug: Application window doesn't open after packaging [\#387](https://github.com/ElectronNET/Electron.NET/issues/387)
15+
516
ElectronNET.API:
617

718
* New Feature: NativeImage Support (thanks [ThrDev](https://github.com/ThrDev)) [\#394](https://github.com/ElectronNET/Electron.NET/pull/394)
19+
* New Feature: Update menu items for context menu and system tray on-the-fly. [\#270](https://github.com/ElectronNET/Electron.NET/pull/270)
820

9-
# Released
1021

1122
# 8.31.1
1223

ElectronNET.API/Entities/MenuItem.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@ public class MenuItem
6969
/// <summary>
7070
/// If false, the menu item will be greyed out and unclickable.
7171
/// </summary>
72-
[DefaultValue(true)]
7372
public bool Enabled { get; set; } = true;
7473

7574
/// <summary>
7675
/// If false, the menu item will be entirely hidden.
7776
/// </summary>
78-
[DefaultValue(true)]
7977
public bool Visible { get; set; } = true;
8078

8179
/// <summary>

ElectronNET.API/Menu.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,25 @@ public void SetApplicationMenu(MenuItem[] menuItems)
8282
/// <param name="menuItems">The menu items.</param>
8383
public void SetContextMenu(BrowserWindow browserWindow, MenuItem[] menuItems)
8484
{
85+
menuItems.AddMenuItemsId();
86+
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
87+
8588
if (!_contextMenuItems.ContainsKey(browserWindow.Id))
8689
{
87-
menuItems.AddMenuItemsId();
88-
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
8990
_contextMenuItems.Add(browserWindow.Id, menuItems.ToList());
90-
9191
var x = _contextMenuItems.ToDictionary(kv => kv.Key, kv => kv.Value.AsReadOnly());
9292
ContextMenuItems = new ReadOnlyDictionary<int, ReadOnlyCollection<MenuItem>>(x);
93+
}
9394

94-
BridgeConnector.Socket.Off("contextMenuItemClicked");
95-
BridgeConnector.Socket.On("contextMenuItemClicked", (results) =>
96-
{
97-
var id = ((JArray)results).First.ToString();
98-
var browserWindowId = (int)((JArray)results).Last;
95+
BridgeConnector.Socket.Off("contextMenuItemClicked");
96+
BridgeConnector.Socket.On("contextMenuItemClicked", (results) =>
97+
{
98+
var id = ((JArray)results).First.ToString();
99+
var browserWindowId = (int)((JArray)results).Last;
99100

100-
MenuItem menuItem = _contextMenuItems[browserWindowId].GetMenuItem(id);
101-
menuItem.Click?.Invoke();
102-
});
103-
}
101+
MenuItem menuItem = _contextMenuItems[browserWindowId].GetMenuItem(id);
102+
menuItem.Click?.Invoke();
103+
});
104104
}
105105

106106
/// <summary>
@@ -115,8 +115,7 @@ public void ContextMenuPopup(BrowserWindow browserWindow)
115115
private JsonSerializer _jsonSerializer = new JsonSerializer()
116116
{
117117
ContractResolver = new CamelCasePropertyNamesContractResolver(),
118-
NullValueHandling = NullValueHandling.Ignore,
119-
DefaultValueHandling = DefaultValueHandling.Ignore
118+
NullValueHandling = NullValueHandling.Ignore
120119
};
121120
}
122121
}

ElectronNET.API/Tray.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ public void Show(string image, MenuItem[] menuItems)
252252
{
253253
menuItems.AddMenuItemsId();
254254
BridgeConnector.Socket.Emit("create-tray", image, JArray.FromObject(menuItems, _jsonSerializer));
255+
_items.Clear();
255256
_items.AddRange(menuItems);
256257

257258
BridgeConnector.Socket.Off("trayMenuItemClicked");
@@ -339,8 +340,7 @@ public Task<bool> IsDestroyedAsync()
339340
private JsonSerializer _jsonSerializer = new JsonSerializer()
340341
{
341342
ContractResolver = new CamelCasePropertyNamesContractResolver(),
342-
NullValueHandling = NullValueHandling.Ignore,
343-
DefaultValueHandling = DefaultValueHandling.Ignore
343+
NullValueHandling = NullValueHandling.Ignore
344344
};
345345
}
346346
}

ElectronNET.Host/api/menu.js

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/menu.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/menu.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ export = (socket: SocketIO.Socket) => {
1111
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
1212
});
1313

14-
contextMenuItems.push({
14+
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId);
15+
16+
const contextMenuItem = {
1517
menu: menu,
1618
browserWindowId: browserWindowId
17-
});
19+
};
20+
21+
if (index === -1) {
22+
contextMenuItems.push(contextMenuItem);
23+
} else {
24+
contextMenuItems[index] = contextMenuItem;
25+
}
1826
});
1927

2028
function addContextMenuItemClickConnector(menuItems, browserWindowId, callback) {

buildReleaseNuGetPackages.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set ENETVER=8.31.1
1+
set ENETVER=8.31.2
22
echo "Start building Electron.NET dev stack..."
33
echo "Restore & Build API"
44
cd ElectronNet.API

0 commit comments

Comments
 (0)