Skip to content

Commit f1ceaa2

Browse files
authored
Merge pull request #3 from ElectronNET/master
903
2 parents 37ae869 + 5e00549 commit f1ceaa2

File tree

11 files changed

+69
-23
lines changed

11 files changed

+69
-23
lines changed

Changelog.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Not released
22

3+
# Released
4+
35
# 9.31.1
46

57
ElectronNET.CLI:
@@ -10,7 +12,7 @@ ElectronNET.CLI:
1012

1113
ElectronNET.API:
1214

13-
* New Feature: Native Electron 9.0.1 support, but not all new features (we search contributors)
15+
* New Feature: Native Electron 9.0.3 support, but not all new features (we search contributors)
1416
* New Feature: PowerMonitor API Support (thanks [gustavo-lara-molina](https://github.com/gustavo-lara-molina)) [\#399](https://github.com/ElectronNET/Electron.NET/pull/399) [\#423](https://github.com/ElectronNET/Electron.NET/pull/423)
1517
* New Feature: NativeTheme API Support (thanks [konstantingross](https://github.com/konstantingross)) [\#402](https://github.com/ElectronNET/Electron.NET/pull/402)
1618
* New Feature: Cookie API Support (thanks [freosc](https://github.com/freosc)) [\#413](https://github.com/ElectronNET/Electron.NET/pull/413)
@@ -22,14 +24,15 @@ ElectronNET.API:
2224
* Shell-Api Enhancement: API fixes for Electron 9.0.0 / Added missing parameters / Summaries rewritten (thanks [konstantingross](https://github.com/konstantingross)) [\#417](https://github.com/ElectronNET/Electron.NET/pull/417) [\#418](https://github.com/ElectronNET/Electron.NET/pull/418)
2325
* Notification-Api Enhancement: Added missing properties in Notifications (thanks [konstantingross](https://github.com/konstantingross)) [\#410](https://github.com/ElectronNET/Electron.NET/pull/410)
2426
* BrowserWindows-Api Enhancement: Add missing API call for SetProgressBar options (thanks [konstantingross](https://github.com/konstantingross)) [\#416](https://github.com/ElectronNET/Electron.NET/pull/416)
27+
* BrowserWindow Enhancement: Add BrowserWindow.GetNativeWindowHandle() (thanks [kdlslyv](https://github.com/kdlslyv)) [\#429](https://github.com/ElectronNET/Electron.NET/pull/429)
2528
* MacOS Enhancement: Application exit logic (thanks [dafergu2](https://github.com/dafergu2)) [\#405](https://github.com/ElectronNET/Electron.NET/pull/405)
2629
* Fixed bug: ElectronNET.API.Entities.WebPreferences.ContextIsolation [DefaultValue(true)] [\#411](https://github.com/ElectronNET/Electron.NET/issues/411)
2730

2831
ElectronNET.WebApp (internal use):
2932
* Improvement debugging and testing new API calls (without install ElectronNET.CLI) (thanks [konstantingross](https://github.com/konstantingross)) [\#425](https://github.com/ElectronNET/Electron.NET/pull/425)
3033
* Fixed bug: Cannot find modules in ElectronHostHook (thanks [konstantingross](https://github.com/konstantingross)) [\#425](https://github.com/ElectronNET/Electron.NET/pull/425)
3134

32-
# Released
35+
Thank you for donation [Phil Seeman](https://github.com/mpnow)
3336

3437
# 8.31.2
3538

ElectronNET.API/BrowserWindow.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,25 @@ public Task<bool> IsKioskAsync()
18091809
return taskCompletionSource.Task;
18101810
}
18111811

1812+
/// <summary>
1813+
/// Returns the native type of the handle is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.
1814+
/// </summary>
1815+
/// <returns>string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.</returns>
1816+
public Task<string> GetNativeWindowHandle()
1817+
{
1818+
var taskCompletionSource = new TaskCompletionSource<string>();
1819+
1820+
BridgeConnector.Socket.On("browserWindow-getNativeWindowHandle-completed", (nativeWindowHandle) =>
1821+
{
1822+
BridgeConnector.Socket.Off("browserWindow-getNativeWindowHandle-completed");
1823+
taskCompletionSource.SetResult(nativeWindowHandle.ToString());
1824+
});
1825+
1826+
BridgeConnector.Socket.Emit("browserWindowGetNativeWindowHandle", Id);
1827+
1828+
return taskCompletionSource.Task;
1829+
}
1830+
18121831
/// <summary>
18131832
/// Sets the pathname of the file the window represents,
18141833
/// and the icon of the file will show in window’s title bar.

ElectronNET.API/Tray.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ public void Show(string image, MenuItem[] menuItems)
263263
});
264264
}
265265

266+
/// <summary>
267+
/// Shows the Traybar (empty).
268+
/// </summary>
269+
/// <param name="image">The image.</param>
270+
public void Show(string image)
271+
{
272+
BridgeConnector.Socket.Emit("create-tray", image);
273+
}
274+
266275
/// <summary>
267276
/// Destroys the tray icon immediately.
268277
/// </summary>

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public Task<bool> ExecuteAsync()
186186
ProcessHelper.CmdExecute($"node build-helper.js " + manifestFileName, tempPath);
187187

188188
Console.WriteLine($"Package Electron App for Platform {platformInfo.ElectronPackerPlatform}...");
189-
ProcessHelper.CmdExecute($"npx electron-builder . --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=9.0.1 {electronParams}", tempPath);
189+
ProcessHelper.CmdExecute($"npx electron-builder --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=9.0.3 {electronParams}", tempPath);
190190

191191
Console.WriteLine("... done");
192192

ElectronNET.Host/api/browserWindows.js

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

ElectronNET.Host/api/browserWindows.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/browserWindows.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
553553
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
554554
});
555555

556+
socket.on('browserWindowGetNativeWindowHandle', (id) => {
557+
const nativeWindowHandle = getWindowById(id).getNativeWindowHandle().readInt32LE(0).toString(16);
558+
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
559+
});
560+
556561
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
557562
getWindowById(id).setRepresentedFilename(filename);
558563
});

ElectronNET.Host/api/tray.js

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

ElectronNET.Host/api/tray.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ export = (socket: SocketIO.Socket) => {
5353
});
5454

5555
socket.on('create-tray', (image, menuItems) => {
56-
const menu = Menu.buildFromTemplate(menuItems);
57-
58-
addMenuItemClickConnector(menu.items, (id) => {
59-
electronSocket.emit('trayMenuItemClicked', id);
60-
});
61-
6256
const trayIcon = nativeImage.createFromPath(image);
6357

6458
tray = new Tray(trayIcon);
65-
tray.setContextMenu(menu);
59+
60+
if (menuItems) {
61+
const menu = Menu.buildFromTemplate(menuItems);
62+
63+
addMenuItemClickConnector(menu.items, (id) => {
64+
electronSocket.emit('trayMenuItemClicked', id);
65+
});
66+
tray.setContextMenu(menu);
67+
}
6668
});
6769

6870
socket.on('tray-destroy', () => {

ElectronNET.Host/package-lock.json

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

0 commit comments

Comments
 (0)