Skip to content

Commit 519fb53

Browse files
authored
Merge pull request #2 from ElectronNET/master
merge with original
2 parents 1238854 + 8c8115f commit 519fb53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2271
-1000
lines changed

Changelog.md

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

3-
# 8.31.3
3+
# 9.31.1
44

55
ElectronNET.CLI:
66

77
* New Feature: Added config parameter (thanks [konstantingross](https://github.com/konstantingross)) [\#409](https://github.com/ElectronNET/Electron.NET/pull/409)
8+
* New Feature: Set the configuration environment with the electron.manifest.json file.
9+
* Fixed bug: Custom user path removed and replaced by the correct directory with VS macro (When ElectronNET.CLI is the Startup Project, press F5 (Debug) and the ElectronNET.WebApp starts correctly without error!) (thanks [konstantingross](https://github.com/konstantingross)) [\#409](https://github.com/ElectronNET/Electron.NET/pull/409)
810

911
ElectronNET.API:
1012

11-
* New Feature: PowerMonitor API Support (thanks [gustavo-lara-molina](https://github.com/gustavo-lara-molina)) [\#399](https://github.com/ElectronNET/Electron.NET/pull/399)
13+
* New Feature: Native Electron 9.0.1 support, but not all new features (we search contributors)
14+
* 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)
1215
* New Feature: NativeTheme API Support (thanks [konstantingross](https://github.com/konstantingross)) [\#402](https://github.com/ElectronNET/Electron.NET/pull/402)
16+
* New Feature: Cookie API Support (thanks [freosc](https://github.com/freosc)) [\#413](https://github.com/ElectronNET/Electron.NET/pull/413)
17+
* Changed Feature: Removed dock methods from App API and moved to Dock API (thanks [konstantingross](https://github.com/konstantingross)) [\#422](https://github.com/ElectronNET/Electron.NET/pull/422)
1318
* App-Api Enhancement: MenuItems with Submenus need an submenu type workaround [\#412](https://github.com/ElectronNET/Electron.NET/issues/412)
1419
* App-Api Enhancement: Added UserAgentFallback (thanks [Mandrakia](https://github.com/Mandrakia)) [\#406](https://github.com/ElectronNET/Electron.NET/pull/406)
20+
* App-Api Enhancement: Summaries rewritten, new App.IsReady / App.HasSingleInstanceLock property, App.Ready event, App.Focus with force parameter method, many parameters changes (thanks [konstantingross](https://github.com/konstantingross)) [\#415](https://github.com/ElectronNET/Electron.NET/pull/415) [\#422](https://github.com/ElectronNET/Electron.NET/pull/422)
21+
* App-Api Enhancement: New App.IsReady property and App.Ready event (thanks [konstantingross](https://github.com/konstantingross)) [\#415](https://github.com/ElectronNET/Electron.NET/pull/415)
22+
* 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)
1523
* Notification-Api Enhancement: Added missing properties in Notifications (thanks [konstantingross](https://github.com/konstantingross)) [\#410](https://github.com/ElectronNET/Electron.NET/pull/410)
24+
* 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)
1625
* MacOS Enhancement: Application exit logic (thanks [dafergu2](https://github.com/dafergu2)) [\#405](https://github.com/ElectronNET/Electron.NET/pull/405)
1726
* Fixed bug: ElectronNET.API.Entities.WebPreferences.ContextIsolation [DefaultValue(true)] [\#411](https://github.com/ElectronNET/Electron.NET/issues/411)
1827

28+
ElectronNET.WebApp (internal use):
29+
* 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)
30+
* Fixed bug: Cannot find modules in ElectronHostHook (thanks [konstantingross](https://github.com/konstantingross)) [\#425](https://github.com/ElectronNET/Electron.NET/pull/425)
31+
1932
# Released
2033

2134
# 8.31.2

ElectronNET.API/App.cs

Lines changed: 480 additions & 533 deletions
Large diffs are not rendered by default.

ElectronNET.API/Dock.cs

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using ElectronNET.API.Entities;
4+
using ElectronNET.API.Extensions;
5+
using Newtonsoft.Json.Linq;
6+
7+
namespace ElectronNET.API
8+
{
9+
/// <summary>
10+
/// Control your app in the macOS dock.
11+
/// </summary>
12+
public sealed class Dock
13+
{
14+
private static Dock _dock;
15+
private static object _syncRoot = new object();
16+
17+
internal Dock()
18+
{
19+
}
20+
21+
internal static Dock Instance
22+
{
23+
get
24+
{
25+
if (_dock == null)
26+
{
27+
lock (_syncRoot)
28+
{
29+
if (_dock == null)
30+
{
31+
_dock = new Dock();
32+
}
33+
}
34+
}
35+
36+
return _dock;
37+
}
38+
}
39+
40+
/// <summary>
41+
/// When <see cref="DockBounceType.Critical"/> is passed, the dock icon will bounce until either the application becomes
42+
/// active or the request is canceled. When <see cref="DockBounceType.Informational"/> is passed, the dock icon will bounce
43+
/// for one second. However, the request remains active until either the application becomes active or the request is canceled.
44+
/// <para/>
45+
/// Note: This method can only be used while the app is not focused; when the app is focused it will return -1.
46+
/// </summary>
47+
/// <param name="type">Can be critical or informational. The default is informational.</param>
48+
/// <param name="cancellationToken">The cancellation token.</param>
49+
/// <returns>Return an ID representing the request.</returns>
50+
public async Task<int> BounceAsync(DockBounceType type, CancellationToken cancellationToken = default)
51+
{
52+
cancellationToken.ThrowIfCancellationRequested();
53+
54+
var taskCompletionSource = new TaskCompletionSource<int>();
55+
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
56+
{
57+
BridgeConnector.Socket.On("dock-bounce-completed", (id) =>
58+
{
59+
BridgeConnector.Socket.Off("dock-bounce-completed");
60+
taskCompletionSource.SetResult((int) id);
61+
});
62+
63+
BridgeConnector.Socket.Emit("dock-bounce", type.GetDescription());
64+
65+
return await taskCompletionSource.Task
66+
.ConfigureAwait(false);
67+
}
68+
}
69+
70+
/// <summary>
71+
/// Cancel the bounce of id.
72+
/// </summary>
73+
/// <param name="id">Id of the request.</param>
74+
public void CancelBounce(int id)
75+
{
76+
BridgeConnector.Socket.Emit("dock-cancelBounce", id);
77+
}
78+
79+
/// <summary>
80+
/// Bounces the Downloads stack if the filePath is inside the Downloads folder.
81+
/// </summary>
82+
/// <param name="filePath"></param>
83+
public void DownloadFinished(string filePath)
84+
{
85+
BridgeConnector.Socket.Emit("dock-downloadFinished", filePath);
86+
}
87+
88+
/// <summary>
89+
/// Sets the string to be displayed in the dock’s badging area.
90+
/// </summary>
91+
/// <param name="text"></param>
92+
public void SetBadge(string text)
93+
{
94+
BridgeConnector.Socket.Emit("dock-setBadge", text);
95+
}
96+
97+
/// <summary>
98+
/// Gets the string to be displayed in the dock’s badging area.
99+
/// </summary>
100+
/// <param name="cancellationToken">The cancellation token.</param>
101+
/// <returns>The badge string of the dock.</returns>
102+
public async Task<string> GetBadgeAsync(CancellationToken cancellationToken = default)
103+
{
104+
cancellationToken.ThrowIfCancellationRequested();
105+
106+
var taskCompletionSource = new TaskCompletionSource<string>();
107+
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
108+
{
109+
BridgeConnector.Socket.On("dock-getBadge-completed", (text) =>
110+
{
111+
BridgeConnector.Socket.Off("dock-getBadge-completed");
112+
taskCompletionSource.SetResult((string) text);
113+
});
114+
115+
BridgeConnector.Socket.Emit("dock-getBadge");
116+
117+
return await taskCompletionSource.Task
118+
.ConfigureAwait(false);
119+
}
120+
}
121+
122+
/// <summary>
123+
/// Hides the dock icon.
124+
/// </summary>
125+
public void Hide()
126+
{
127+
BridgeConnector.Socket.Emit("dock-hide");
128+
}
129+
130+
/// <summary>
131+
/// Shows the dock icon.
132+
/// </summary>
133+
public void Show()
134+
{
135+
BridgeConnector.Socket.Emit("dock-show");
136+
}
137+
138+
/// <summary>
139+
/// Whether the dock icon is visible. The app.dock.show() call is asynchronous
140+
/// so this method might not return true immediately after that call.
141+
/// </summary>
142+
/// <param name="cancellationToken">The cancellation token.</param>
143+
/// <returns>Whether the dock icon is visible.</returns>
144+
public async Task<bool> IsVisibleAsync(CancellationToken cancellationToken = default)
145+
{
146+
cancellationToken.ThrowIfCancellationRequested();
147+
148+
var taskCompletionSource = new TaskCompletionSource<bool>();
149+
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
150+
{
151+
BridgeConnector.Socket.On("dock-isVisible-completed", (isVisible) =>
152+
{
153+
BridgeConnector.Socket.Off("dock-isVisible-completed");
154+
taskCompletionSource.SetResult((bool) isVisible);
155+
});
156+
157+
BridgeConnector.Socket.Emit("dock-isVisible");
158+
159+
return await taskCompletionSource.Task
160+
.ConfigureAwait(false);
161+
}
162+
}
163+
164+
/// <summary>
165+
/// TODO: Menu (macOS) still to be implemented
166+
/// Sets the application's dock menu.
167+
/// </summary>
168+
public void SetMenu()
169+
{
170+
BridgeConnector.Socket.Emit("dock-setMenu");
171+
}
172+
173+
/// <summary>
174+
/// TODO: Menu (macOS) still to be implemented
175+
/// Gets the application's dock menu.
176+
/// </summary>
177+
public async Task<Menu> GetMenu(CancellationToken cancellationToken = default)
178+
{
179+
cancellationToken.ThrowIfCancellationRequested();
180+
181+
var taskCompletionSource = new TaskCompletionSource<Menu>();
182+
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
183+
{
184+
BridgeConnector.Socket.On("dock-getMenu-completed", (menu) =>
185+
{
186+
BridgeConnector.Socket.Off("dock-getMenu-completed");
187+
taskCompletionSource.SetResult(((JObject)menu).ToObject<Menu>());
188+
});
189+
190+
BridgeConnector.Socket.Emit("dock-getMenu");
191+
192+
return await taskCompletionSource.Task
193+
.ConfigureAwait(false);
194+
}
195+
}
196+
197+
/// <summary>
198+
/// Sets the image associated with this dock icon.
199+
/// </summary>
200+
/// <param name="image"></param>
201+
public void SetIcon(string image)
202+
{
203+
BridgeConnector.Socket.Emit("dock-setIcon", image);
204+
}
205+
}
206+
}

ElectronNET.API/Electron.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,10 @@ public static class Electron
8383
/// Read and respond to changes in Chromium's native color theme.
8484
/// </summary>
8585
public static NativeTheme NativeTheme { get { return NativeTheme.Instance; } }
86+
87+
/// <summary>
88+
/// Control your app in the macOS dock.
89+
/// </summary>
90+
public static Dock Dock { get { return Dock.Instance; } }
8691
}
87-
}
92+
}

ElectronNET.API/Entities/AboutPanelOptions.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace ElectronNET.API.Entities
22
{
33
/// <summary>
4-
///
4+
/// About panel options.
55
/// </summary>
66
public class AboutPanelOptions
77
{
@@ -20,14 +20,29 @@ public class AboutPanelOptions
2020
/// </summary>
2121
public string Copyright { get; set; }
2222

23+
/// <summary>
24+
/// The app's build version number.
25+
/// </summary>
26+
public string Version { get; set; }
27+
2328
/// <summary>
2429
/// Credit information.
2530
/// </summary>
2631
public string Credits { get; set; }
2732

2833
/// <summary>
29-
/// The app's build version number.
34+
/// List of app authors.
3035
/// </summary>
31-
public string Version { get; set; }
36+
public string[] Authors { get; set; }
37+
38+
/// <summary>
39+
/// The app's website.
40+
/// </summary>
41+
public string Website { get; set; }
42+
43+
/// <summary>
44+
/// Path to the app's icon. On Linux, will be shown as 64x64 pixels while retaining aspect ratio.
45+
/// </summary>
46+
public string IconPath { get; set; }
3247
}
3348
}

ElectronNET.API/Entities/CPUUsage.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
public class CPUUsage
77
{
88
/// <summary>
9-
/// The number of average idle cpu wakeups per second since the last call to
10-
/// getCPUUsage.First call returns 0.
9+
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
1110
/// </summary>
12-
public int IdleWakeupsPerSecond { get; set; }
11+
public int PercentCPUUsage { get; set; }
1312

1413
/// <summary>
15-
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
14+
/// The number of average idle cpu wakeups per second since the last call to
15+
/// getCPUUsage.First call returns 0.
1616
/// </summary>
17-
public int PercentCPUUsage { get; set; }
17+
public int IdleWakeupsPerSecond { get; set; }
1818
}
1919
}
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
namespace ElectronNET.API
1+
using System.ComponentModel;
2+
3+
namespace ElectronNET.API.Entities
24
{
35
/// <summary>
4-
///
6+
/// Defines the DockBounceType enumeration.
57
/// </summary>
68
public enum DockBounceType
79
{
810
/// <summary>
9-
/// The critical
11+
/// Dock icon will bounce until either the application becomes active or the request is canceled.
1012
/// </summary>
11-
critical,
13+
[Description("critical")]
14+
Critical,
1215

1316
/// <summary>
14-
/// The informational
17+
/// The dock icon will bounce for one second.
1518
/// </summary>
16-
informational
19+
[Description("informational")]
20+
Informational
1721
}
1822
}

ElectronNET.API/Entities/Error.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
/// Controls the behavior of <see cref="App.Focus(FocusOptions)"/>.
5+
/// </summary>
6+
public class FocusOptions
7+
{
8+
/// <summary>
9+
/// Make the receiver the active app even if another app is currently active.
10+
/// <para/>
11+
/// You should seek to use the <see cref="Steal"/> option as sparingly as possible.
12+
/// </summary>
13+
public bool Steal { get; set; }
14+
}
15+
}

0 commit comments

Comments
 (0)