Compare commits

...

469 Commits

Author SHA1 Message Date
Robert Muehsig
c2a8c627b9 13.5.1 2021-07-08 14:09:44 +02:00
Gregor Biswanger
1862094861 Merge pull request #585 from tub5/bug/584
If we provide the Version parameter and haven't included the version …
2021-07-02 17:18:41 +02:00
Gregor Biswanger
0ad89c7d22 RequestSingleInstanceLockAsync callback does work now - bug fix #519 2021-07-02 17:18:14 +02:00
tub5
0af664b8a6 If we provide the Version parameter and haven't included the version or product version dotnet flag then add them.
Fixes: #584
2021-07-02 16:07:31 +01:00
Gregor Biswanger
afcd113675 singleInstance handle command line arguments 2021-07-02 16:50:48 +02:00
Gregor Biswanger
0e22ee3fd3 Changed CLI help text 2021-07-02 12:47:51 +02:00
Gregor Biswanger
ce0cdf39c6 Update to native Electron 13.1.5, Update Changelog 2021-07-02 02:04:23 +02:00
Gregor Biswanger
305544ab42 Merge pull request #579 from tub5/bug/578
Upgrade to use Electron 12.0.12
2021-07-01 23:43:10 +02:00
Gregor Biswanger
78d9d601b1 Merge branch 'master' into bug/578 2021-07-01 23:42:09 +02:00
Gregor Biswanger
fdd643ba48 Merge pull request #573 from tantumalice/serialization-fix
Vibrancy serialization fix
2021-07-01 23:40:09 +02:00
Gregor Biswanger
29a257251f Merge pull request #570 from cristiangiagante/net5_compat
Changes PublishSingleFile default to false for NET5 compatibility
2021-07-01 23:38:27 +02:00
Gregor Biswanger
3676db89d3 Merge branch 'master' into net5_compat 2021-07-01 23:38:19 +02:00
Gregor Biswanger
29011189f8 Merge pull request #582 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/ws-7.4.6
Bump ws from 7.4.2 to 7.4.6 in /ElectronNET.Host
2021-07-01 23:25:54 +02:00
Gregor Biswanger
9d7d859764 Merge pull request #583 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21 in /ElectronNET.Host
2021-07-01 23:25:24 +02:00
Gregor Biswanger
5cdda5595a Merge pull request #581 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/normalize-url-4.5.1
Bump normalize-url from 4.5.0 to 4.5.1 in /ElectronNET.Host
2021-07-01 23:25:01 +02:00
Gregor Biswanger
62fe944ae3 Merge pull request #565 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.WebApp/ElectronHostHook/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21 in /ElectronNET.WebApp/ElectronHostHook
2021-07-01 23:24:25 +02:00
Gregor Biswanger
617eb15df8 Merge pull request #562 from TSrgy/using-exit-code
Using exit code instead of seek for the term 'error'
2021-07-01 23:24:10 +02:00
Gregor Biswanger
bff71dc86a Merge pull request #561 from nfichter/proxy-credentials
Add support for proxies that require basic username/password authentication
2021-07-01 23:20:36 +02:00
Gregor Biswanger
f0280f420a Merge pull request #560 from nfichter/ipc-to-browser-view
Allow IpcMain to send IPC messages to BrowserViews
2021-07-01 23:18:55 +02:00
Gregor Biswanger
9f7809810f Merge pull request #559 from nfichter/insert-css
Add WebContents insertCSS functionality
2021-07-01 23:16:53 +02:00
Gregor Biswanger
e610c96550 Merge pull request #547 from Funkrusha/feature/enable-post-requests
Add PostData to LoadURLOptions to allow http-posts in LoadURL calls
2021-07-01 23:13:19 +02:00
Gregor Biswanger
f3bd3d07d5 Merge pull request #546 from tub5/master
Fixes Add ability to pass an argument for "Version" for both the "dot…
2021-07-01 22:55:15 +02:00
Gregor Biswanger
0e8cfec689 Merge branch 'master' into master 2021-07-01 22:55:09 +02:00
Gregor Biswanger
c1b3d422d5 Merge pull request #540 from MiniguyBrendan/master
Resolve #539, #357 - Fix splash screen interaction causing crashes, ghost dragging, and resizable behavior
2021-07-01 22:41:00 +02:00
dependabot[bot]
fc12363e11 Bump lodash from 4.17.19 to 4.17.21 in /ElectronNET.Host
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

---
updated-dependencies:
- dependency-name: lodash
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:17:06 +00:00
dependabot[bot]
02f2fd770c Bump ws from 7.4.2 to 7.4.6 in /ElectronNET.Host
Bumps [ws](https://github.com/websockets/ws) from 7.4.2 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.2...7.4.6)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:16:42 +00:00
dependabot[bot]
5ee1918bb4 Bump normalize-url from 4.5.0 to 4.5.1 in /ElectronNET.Host
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:16:36 +00:00
dependabot[bot]
2213c61746 Bump lodash in /ElectronNET.WebApp/ElectronHostHook
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:16:36 +00:00
Gregor Biswanger
3cdff747fe Merge pull request #531 from stackify/issue/523
fixes #523 allow for property overrides to be passed in
2021-07-01 20:12:04 +02:00
tub5
476cc9e505 Updating ContextIsolation as per the comment from @danatcofo. "on electron v12 WebPreferences.contextIsolation defaults to true… this means that window.require() will no longer function" 2021-06-28 15:55:16 +01:00
tub5
fb8ca94e8e Upgrade to use Electron 12.0.12
Resolves #578
2021-06-28 12:46:17 +01:00
tub5
c94702fc60 Remove incorrect text at the top of the file 2021-06-28 12:10:05 +01:00
Alisa Semenova
cd9e06d5db Vibrancy serialization fix 2021-06-14 16:52:33 +03:00
Cristian Giagante
613f0a05b3 Changes PublishSingleFile default to false for NET5 compatibility 2021-06-02 22:39:28 -03:00
TSrgy
de2ce85a5c write command to console 2021-04-29 21:25:42 +05:00
TSrgy
e5d47e077b escape arguments for bash 2021-04-29 21:11:16 +05:00
TSrgy
ac77ccce9f Using exit code 2021-04-29 08:29:36 +05:00
Noah Fichter
504cc59760 Remove app argument from browserViewApi since it's no longer needed 2021-04-26 14:45:02 -04:00
Noah Fichter
0ee7097f31 Add support for proxies that require basic authentication 2021-04-26 14:38:41 -04:00
Noah Fichter
2d93d959f7 Allow IpcMain to send IPC messages to BrowserViews 2021-04-26 13:04:34 -04:00
Noah Fichter
a4d261a4e7 Add WebContents insertCSS functionality 2021-04-26 12:41:14 -04:00
Martin Schweizer
3838fe8971 Add PostData to LoadURLOptions to allow http-posts in LoadURL calls
Enable the possibility to post data to external Url's with the BrowserWindow.LoadURL function. The post data is provided through LoadURLOptions
2021-03-12 16:31:29 +01:00
tub5
b5e69f5dda Fixes Add ability to pass an argument for "Version" for both the "dotnet publish" and "electron-builder" commands #543 2021-03-04 14:45:52 +00:00
Brendan
55a3f10d37 Splash screen always renders on top 2021-02-18 13:32:45 -05:00
Brendan
7e494518f3 Fully ignore mouse events on splash screen (avoids drag + drop file into window) 2021-02-17 02:30:19 -05:00
Brendan
4596492cd9 Fix splash screen interaction causing crashes, fix splash screen content ghost drag, fix resizable splash screen. Resolves #539, #357
Using the browser-window-focus event would cause the splashScreen to be destroyed early (since regular mouse-focus events would cause the event to be fired).

Using the browser-window-created event produces the correct behavior.
2021-02-17 02:07:42 -05:00
Daniel Gidman
dd5bfd3961 Pass dotnet publsh /p: arguments to the publish command
use '/p:propertyName=value' or '/property:propertyName=value' to pass in dotnet build property overrides.

fixes #523
https://github.com/ElectronNET/Electron.NET/issues/523
2021-01-25 12:15:01 -06:00
dependabot[bot]
5d907864d8 Bump socket.io from 2.2.0 to 2.4.0 in /ElectronNET.Host
Bumps [socket.io](https://github.com/socketio/socket.io) from 2.2.0 to 2.4.0.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/2.4.0/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/2.2.0...2.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-25 10:14:46 -06:00
Gregor Biswanger
30941df39c Update to .NET 5 infos 2021-01-22 00:16:04 +01:00
Gregor Biswanger
3588a8696d Update Changelog 2021-01-22 00:12:40 +01:00
Robert Muehsig
876bb98d92 11.5.1 2021-01-21 23:55:24 +01:00
Gregor Biswanger
427b57a002 Update Changelog 2021-01-21 22:06:08 +01:00
Gregor Biswanger
cc0b15c61e Merge pull request #528 from stackify/issue/527
Issue/527
2021-01-21 21:45:15 +01:00
Dan
8a0276daf9 Add ability to enable remote module in browser
The jump from Election 9x to 11x changed the default setting.  This exposes it so that user can re-enable it if needed.
2021-01-20 11:49:50 -06:00
Dan
e94196504e Support subscribing to unmapped events on App and Tray modules
`Electron.App.On("eventName", () => {});` or `Electron.App.On("eventName", obj => {});`

fix #527
2021-01-18 19:52:58 -06:00
Dan
6076c727d1 By blow fix of documentation
fix #500
2021-01-18 19:52:58 -06:00
Dan
300dc49dde Update the buildAll.sh so that you can run it successfully on a Mac 2021-01-18 19:52:58 -06:00
Dan
ce0f3fd61e Dock Menu support
fix #527
2021-01-18 19:52:58 -06:00
Dan
12f5eae65c Expose Electron members to the service provider
Used for class composition with IServiceProvider
2021-01-18 13:09:10 -06:00
Dan
3ef44cf878 Merge remote-tracking branch 'ElectronNET/master' 2021-01-18 10:30:57 -06:00
Gregor Biswanger
41fa8e9e74 Update WebApp to Electron 11.1.1 - Fix Chrome breaking changes with link ref=imports 2021-01-12 03:12:01 +01:00
Gregor Biswanger
49e21de465 Merge pull request #486 from stackify/bug/442
442: maintain references between socket.io connection events
2021-01-11 23:27:51 +01:00
Dan Gidman
d2f6308dd2 Merge remote-tracking branch 'upstream/master' into bug/442 2021-01-11 15:50:28 -06:00
Gregor Biswanger
f06b95803f Update to native Electron 11.1.1 - Fix breaking changes and refactoring. 2021-01-11 01:56:39 +01:00
Gregor Biswanger
b9feff3436 Merge pull request #522 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/ini-1.3.7
Bump ini from 1.3.5 to 1.3.7 in /ElectronNET.Host
2021-01-11 00:12:49 +01:00
Gregor Biswanger
335489d2d9 Merge pull request #509 from scottkuhl/issues/491-upgrade-to-net-5
Upgrade to .NET 5
2021-01-11 00:10:09 +01:00
Gregor Biswanger
6fe0c6f085 Merge pull request #506 from nathanwienand/add-publish-single-file
Added new build and start commandline options for single exe
2021-01-11 00:07:53 +01:00
Gregor Biswanger
f82d185865 Merge pull request #505 from aarong-av/aarong-av/donfigurable-default-port
Adding a configurable default electron port.
2021-01-11 00:05:14 +01:00
Gregor Biswanger
550e2c2625 Merge pull request #487 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/electron-9.3.1
Bump electron from 9.2.0 to 9.3.1 in /ElectronNET.Host
2021-01-11 00:03:05 +01:00
Gregor Biswanger
61f54ebd55 Merge pull request #480 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.WebApp/ElectronHostHook/bl-4.0.3
Bump bl from 4.0.2 to 4.0.3 in /ElectronNET.WebApp/ElectronHostHook
2021-01-10 23:56:54 +01:00
Gregor Biswanger
c8c818a77a Merge pull request #478 from dlitty/master
Added support for launching the application with a file on MacOS
2021-01-10 23:55:20 +01:00
Gregor Biswanger
fc590f55d8 Merge pull request #474 from freosc/PullRequest
Avoid Blocking Calls in App and AutoUpdater
2021-01-10 23:50:48 +01:00
dependabot[bot]
5fbe01df30 Bump ini from 1.3.5 to 1.3.7 in /ElectronNET.Host
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-11 17:11:37 +00:00
Scott Kuhl
dbf4d0f720 Upgraded NuGet packages to the latest versions:
- Microsoft.SourceLink.GitHub 1.0.0-beta2-19367-01 > 1.0.0
- System.Drawing.Common 4.7.0 > 5.0.0
- Microsoft.VisualStudio.Web.CodeGeneration.Design 3.0.0 > 5.0.0
2020-11-21 16:24:24 -06:00
Scott Kuhl
f996b3023e Updated TypeScript from 3.8 to 4.0. 2020-11-21 16:13:49 -06:00
Scott Kuhl
7f62e7299b Updated .NET Core 3.1 to .NET 5.0. 2020-11-21 16:13:06 -06:00
Aaron Gilliland
b803e42a73 Minor fix due to a copy paste issue. 2020-11-14 19:15:54 -06:00
Nathan Wienand
da1838db60 adding new build and start commandline options for single exe 2020-11-12 11:15:37 +00:00
Aaron Gilliland
8af1f50b88 Adding a configurable default electron port. Our environment does not allow for random port assignment. Port 8000 is not an option for our environment. 2020-11-11 07:48:42 -06:00
dependabot[bot]
c4f2188c62 Bump electron from 9.2.0 to 9.3.1 in /ElectronNET.Host
Bumps [electron](https://github.com/electron/electron) from 9.2.0 to 9.3.1.
- [Release notes](https://github.com/electron/electron/releases)
- [Changelog](https://github.com/electron/electron/blob/master/docs/breaking-changes.md)
- [Commits](https://github.com/electron/electron/compare/v9.2.0...v9.3.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-06 18:02:00 +00:00
Dan Gidman
e73655bd68 442: maintain references between socket.io connection events
https://github.com/ElectronNET/Electron.NET/issues/442

remove deletes of modules during disconnect
add delete of hostHook during disconnect
check if modules exist before importing them curring connect
move local caches of modules into global scope.
2020-10-06 11:29:53 -05:00
dependabot[bot]
758424d3ce Bump bl from 4.0.2 to 4.0.3 in /ElectronNET.WebApp/ElectronHostHook
Bumps [bl](https://github.com/rvagg/bl) from 4.0.2 to 4.0.3.
- [Release notes](https://github.com/rvagg/bl/releases)
- [Commits](https://github.com/rvagg/bl/compare/v4.0.2...v4.0.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 17:53:24 +00:00
Dan Litty
7518acb3c2 Added support for launching the application with a file on MacOS by listening for the open-file and open-url events from the operating system, and forwarding them to the Electron.NET app when listeners are added 2020-08-31 16:47:05 -04:00
Fre
5522addc0b PR 2020-08-21 12:35:31 +02:00
Fre
7f204c2a42 PR 2020-08-21 12:32:33 +02:00
Fre
de13f49bb6 PR 2020-08-21 12:27:31 +02:00
Fre
bca37228d9 del asynchelper 2020-08-21 12:22:28 +02:00
Fre
e17a36f7cb small changes 2020-08-21 12:13:38 +02:00
Fre
deccebb582 Merge branch 'master' into freosc
# Conflicts:
#	ElectronNET.Host/main.js
2020-08-21 11:13:06 +02:00
Fre
776ccc21e8 Merge remote-tracking branch 'upstream/master' 2020-08-21 10:36:24 +02:00
Fre
d0c92cac85 avoid memory leak when re-adding the eventlisteners 2020-08-21 10:32:02 +02:00
Gregor Biswanger
b525bf1a9a Update Changelog for 9.31.3 - Update to the native Electron 9.2.0 support 2020-08-14 13:25:27 +02:00
Gregor Biswanger
6337cac588 Merge pull request #468 from duncanawoods/fix_bad_fontsize_if_position_is_set
set default WebPreferences.DefaultFontSize
2020-08-14 12:55:17 +02:00
Gregor Biswanger
5d4509babe Merge pull request #467 from duncanawoods/fix_ERR_UNKNOWN_URL_SCHEME
fix ERR_UNKNOWN_URL_SCHEME by intercepting file:// protocol
2020-08-14 12:51:56 +02:00
Gregor Biswanger
3eef85cddf Merge pull request #465 from duncanawoods/buildsh_linux_errors
buildAll.sh linux errors
2020-08-14 12:48:40 +02:00
Gregor Biswanger
3f582d6c4e Merge pull request #457 from kojo12228/add-fsharp-support
Search for .csproj and .fsproj in init and add commands
2020-08-14 12:44:45 +02:00
Gregor Biswanger
18c5a65d6d Merge pull request #453 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.WebApp/ElectronHostHook/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19 in /ElectronNET.WebApp/ElectronHostHook
2020-08-14 12:42:02 +02:00
Gregor Biswanger
f8bbb138d8 Merge pull request #450 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19 in /ElectronNET.Host
2020-08-14 12:41:50 +02:00
Gregor Biswanger
7880d56e4c Merge pull request #445 from rbaker26/master
Update Documentation in the README.md
2020-08-14 12:41:06 +02:00
Gregor Biswanger
c16a888699 Merge pull request #463 from code-lever/master
Add target command line option found in 'build' to 'start' in CLI to …
2020-08-14 12:37:49 +02:00
Gregor Biswanger
814e046d5c Merge pull request #433 from BurtsevC/master
description added to package.json
2020-08-14 12:31:27 +02:00
duncan
d2457203bc Add build electron host to buildAll.sh 2020-08-14 10:19:11 +01:00
duncan
a70304948a set default WebPreferences.DefaultFontSize to fix tiny text when possition is set 2020-08-13 22:54:45 +01:00
duncan
a49b2ce278 fix ERR_UNKNOWN_URL_SCHEME by intercepting file:// protocol
fix whitespace

Revert "fix whitespace"

This reverts commit 608e364ebbabb19ffd6c3e3e0f357251c2e8e348.

fix whitespace
2020-08-13 20:46:10 +01:00
duncan
1577146187 buildall.sh disable win/osx builds on linux 2020-08-13 13:18:49 +01:00
duncan
d61f20dd67 buildall.sh restore original paths using pushd/pops 2020-08-13 13:15:47 +01:00
Gabe Cook
f7217b417f Add target command line option found in 'build' to 'start' in CLI to support custom targets in development. 2020-08-07 10:09:27 -05:00
Fre
e136ed4127 Merge branch 'master' of https://github.com/freosc/Electron.NET into freosc 2020-08-03 08:50:02 +02:00
Kojo Amoasi
7489543c75 search for .csproj and .fsproj in init and add 2020-07-22 13:42:00 +01:00
dependabot[bot]
cbf3032617 Bump lodash in /ElectronNET.WebApp/ElectronHostHook
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-20 23:26:19 +00:00
dependabot[bot]
68c54b9917 Bump lodash from 4.17.15 to 4.17.19 in /ElectronNET.Host
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-17 20:44:42 +00:00
Robert Muehsig
26d10fca38 9.31.2 2020-07-08 12:56:51 +02:00
Gregor Biswanger
bd15587079 Update to Electron 9.0.5 2020-07-08 12:56:50 +02:00
Gregor Biswanger
42613f5b56 Rollback to socket.io 2.2.0 2020-07-08 12:56:49 +02:00
Gregor Biswanger
62117df108 Update Changelog 2020-07-08 12:56:49 +02:00
Fre V
f68ea25cba Merge pull request #4 from ElectronNET/master
nieuwe versie
2020-07-08 11:25:37 +02:00
Fre
4e9de2abfa Aanpassingen autoupdate & async code 2020-07-08 11:16:00 +02:00
Bob Baker
a08d274dc1 Update README.md 2020-07-06 12:02:42 -07:00
Robert Muehsig
3dea16798b 9.31.2 2020-07-06 19:00:17 +02:00
Gregor Biswanger
bf8c7c8fa1 Update to Electron 9.0.5 2020-07-06 18:37:31 +02:00
Gregor Biswanger
06724f6eae Rollback to socket.io 2.2.0 2020-07-06 18:24:23 +02:00
Gregor Biswanger
83e579d44b Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-07-06 18:19:08 +02:00
Gregor Biswanger
ed67aa8072 Update Changelog 2020-07-06 18:19:02 +02:00
Fre V
f1ceaa208e Merge pull request #3 from ElectronNET/master
903
2020-07-06 15:59:12 +02:00
Gregor Biswanger
5e005499ef Merge pull request #435 from writzx/master
Enabled empty tray icon
2020-07-05 00:26:51 +02:00
Gregor Biswanger
975e4020dc Merge pull request #443 from rbaker26/master
Bug Fix, Fixed Publishing Issue ("Unknown argument: .")
2020-07-05 00:24:21 +02:00
Bob Baker
15ce35a7d9 removed extra . cause build failures 2020-07-03 23:19:19 -07:00
Writwick Das
de1637672a enabled empty tray icon
(fixes click event on macos)
2020-06-15 17:01:31 +02:00
BurtsevC
6b75f63135 description added to package.json 2020-06-13 15:53:52 +03:00
Robert Muehsig
8f92d3986f 9.31.1 2020-06-12 23:27:53 +02:00
Gregor Biswanger
ca7414b8e6 Merge pull request #430 from freosc/master
HostHook.CallAsync should use TaskCompletionSource.SetException instead of throwing exception
2020-06-12 15:54:58 +02:00
Fre
37ae869dcb HostHook CallAsync 2020-06-12 13:32:26 +02:00
Gregor Biswanger
3420ee2de4 Update to Electron 9.0.3 build - Update Changelog for Electron.NET 9.31.1 2020-06-11 23:39:08 +02:00
Gregor Biswanger
0a76e951eb Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-06-11 23:14:13 +02:00
Gregor Biswanger
4db316eb15 Update to Electron 9.0.3 - Update Changelog 2020-06-11 23:14:02 +02:00
Gregor Biswanger
a867f23220 Merge pull request #429 from kdlslyv/master
Add BrowserWindow.GetNativeWindowHandle()
2020-06-11 23:10:16 +02:00
kdl
490440c23a Add BrowserWindow.GetNativeWindowHandle() 2020-06-11 22:45:18 +02:00
Fre V
519fb53c00 Merge pull request #2 from ElectronNET/master
merge with original
2020-06-08 09:20:41 +02:00
Fre V
12388541ab Merge pull request #1 from freosc/CookieHandling
Implementation for electronjs cookie handling
2020-06-08 09:09:14 +02:00
Gregor Biswanger
8c8115f3bd Update for Electron.NET 9.31.1 2020-06-03 00:26:10 +02:00
Gregor Biswanger
4286bc4f45 Update for Electron.NET 9.31.1 2020-06-03 00:24:07 +02:00
Gregor Biswanger
886f839482 Update for Electron.9.31.1 2020-06-03 00:20:21 +02:00
Gregor Biswanger
96abbd161c Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-06-03 00:14:01 +02:00
Gregor Biswanger
9baf1528ac Update for Electron.NET 9.31.1 2020-06-03 00:13:56 +02:00
Gregor Biswanger
380441c2c8 Merge pull request #425 from konstantingross/feature/Fix_Dock_API
Fix Dock API/ Electron 9.0.1 Update / ...
2020-06-02 23:47:12 +02:00
Konstantin Gross
a66375e37c Fix cannot find modules in ElectronHostHook 2020-06-02 23:41:19 +02:00
Konstantin Gross
606d00de5a Improvement debugging and testing new api calls (without install cli) 2020-06-02 23:40:21 +02:00
Konstantin Gross
b3266cd93f Electron 9.0.1 Update 2020-06-02 23:33:54 +02:00
Konstantin Gross
cb36e34dc3 Fix deployment dock.js 2020-06-02 23:33:14 +02:00
Gregor Biswanger
db7a5ff868 Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-06-02 22:04:40 +02:00
Gregor Biswanger
a030e3cbe7 update Electron.NET 9.31.1 2020-06-02 22:04:35 +02:00
Gregor Biswanger
b98c570b9d Merge pull request #423 from gustavo-lara-molina/powerMonitor
Power monitor - adding missing events
2020-06-02 22:04:03 +02:00
Gregor Biswanger
d106c6b193 Merge pull request #422 from konstantingross/feature/App_API_Enhancements
App API enhancements
2020-06-02 21:58:58 +02:00
Gustavo Lara Molina
c95bbe7ab2 Merge remote-tracking branch 'origin/master' into powerMonitor 2020-06-02 09:42:06 -05:00
Gustavo Lara Molina
258710bc52 removing PM methods with issues for this versión 2020-06-02 09:31:15 -05:00
Konstantin Gross
9ddb1b195e Removed dock methods from app API and moved to dock API 2020-06-01 01:59:40 +02:00
Konstantin Gross
eee84d214e App API:
* Summaries rewritten
* Added new parameters / Removed not supported parameters
* Added some new methods like appFocus(options), appHasSingleLock, etc.
2020-05-31 03:09:54 +02:00
Gregor Biswanger
1ab48350e1 Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-05-27 22:26:57 +02:00
Gregor Biswanger
874bc8eb94 Update for Electron.NET 9.31.1 2020-05-27 22:26:53 +02:00
Gregor Biswanger
7aa2268a81 Merge pull request #418 from konstantingross/master
Shell API adapted to Electron 9.0.0
2020-05-27 22:26:17 +02:00
Konstantin Gross
b08222bddc Updated NuGet Package version 2020-05-27 11:32:12 +02:00
Konstantin Gross
c5c822a028 Update Shell.cs 2020-05-27 01:06:31 +02:00
Konstantin Gross
ce4ef03636 Update ShortcutLinkOperation.cs 2020-05-27 01:04:28 +02:00
Konstantin Gross
641864b946 * Shell.OpenPath API fix for Electron 9.0.0
* Shell.OpenExternal API fix for Electron 9.0.0
* Shell.MoveItemToTrash API fix for Electron 9.0.0 and added new macOS parameter
* Shell.ReadShortcutLink API fix for Electron 9.0.0
* Summaries have been rewritten
2020-05-27 00:51:48 +02:00
Konstantin Gross
c6d67a9145 Log disconnect reason 2020-05-27 00:43:28 +02:00
Gregor Biswanger
fabd25a89e Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-05-26 22:03:30 +02:00
Gregor Biswanger
029b077602 manage the configuration environment with the electron.manifest.json 2020-05-26 22:03:05 +02:00
Konstantin Gross
0329530815 Shell.ShowItemInFolder API fix for Electron 9.0.0 2020-05-26 15:11:22 +02:00
Konstantin Gross
58ab180c94 Missing semicolon 2020-05-26 15:09:47 +02:00
Gregor Biswanger
a03dc1d195 Merge pull request #417 from konstantingross/master
Shell.OpenItem API fix for Electron 9.0.0
2020-05-25 21:43:06 +02:00
Konstantin Gross
76dcdc4137 Shell.OpenItem API fix for Electron 9.0.0 2020-05-25 17:31:27 +02:00
Gregor Biswanger
2b415e5b59 Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-05-25 14:53:41 +02:00
Gregor Biswanger
94055b985f Update for 9.31.1 2020-05-25 14:53:36 +02:00
Gregor Biswanger
596aa68c70 Merge pull request #416 from konstantingross/master
Add missing API call for SetProgressBar options
2020-05-25 14:50:51 +02:00
Konstantin Gross
485bce08d7 Add missing API call for SetProgressBar options 2020-05-25 11:24:29 +02:00
Gregor Biswanger
2ba49dbd6a Update for 9.31.1 2020-05-24 22:03:04 +02:00
Gregor Biswanger
39c3e92128 implement lazy App.Ready event 2020-05-24 22:00:32 +02:00
Gregor Biswanger
c552a04347 add App.Ready event 2020-05-24 18:50:35 +02:00
Gregor Biswanger
1541553ed1 Merge pull request #415 from konstantingross/feature/New_host_IsReady_property
New App.IsReady property
2020-05-24 13:34:51 +02:00
Konstantin Gross
52b850092c Context menu example modified 2020-05-24 02:52:27 +02:00
Konstantin Gross
cac9cfcec8 Add lifetime hosted service to detect fully started ASP.NET Core 2020-05-24 02:51:34 +02:00
Konstantin Gross
4ad39ba4c1 Removed double slash in args 2020-05-24 02:43:36 +02:00
Gregor Biswanger
95acbd5dea Update to the native Electron 9.0.0 - Update electron-updater 4.3.1 - Update Changelog 2020-05-23 12:17:53 +02:00
Gregor Biswanger
95f9a59431 Merge pull request #413 from freosc/CookieHandling
Implementation for electronjs cookie handling
2020-05-23 11:49:59 +02:00
Frederik Vermeersch
d409c3a0f9 Implementation for electronjs cookie handling 2020-05-22 16:38:34 +02:00
Gregor Biswanger
6d0fbde5ad set contectmenu on correct lifetime.. 2020-05-22 00:18:59 +02:00
Gregor Biswanger
b113532a86 update 8.31.3 infos 2020-05-21 23:04:55 +02:00
Gregor Biswanger
b043688f7f add workaround for #412 - update to socket.io 2.3.0 2020-05-21 22:58:17 +02:00
Gregor Biswanger
3b3e38f1bf update 8.31.3 infos 2020-05-21 22:41:27 +02:00
Gregor Biswanger
9502eb787a Fixed bug - #411 2020-05-21 22:39:52 +02:00
Gregor Biswanger
4a9b6fa9c1 Merge pull request #409 from konstantingross/feature/Add_missing_config_parameter_#407
Add missing config parameter fixes #407
2020-05-21 20:40:28 +02:00
Gregor Biswanger
fb308ed1c6 Merge pull request #410 from konstantingross/feature/NotificationOptions_fixes_#408
Added missing properties in Notifications
2020-05-21 13:29:43 +02:00
Konstantin Gross
d51a481e50 Added three missing propertys and fixing typos 2020-05-21 01:32:38 +02:00
Konstantin Gross
bb3d073fae Custom user path removed and replaced by the correct directory with VS macro 2020-05-20 19:02:15 +02:00
Konstantin Gross
8c250ae83e Add ConfigurationProfile paramter to electronize start command 2020-05-20 18:59:38 +02:00
Konstantin Gross
a5543bfe60 Typo in summary 2020-05-20 18:58:31 +02:00
Gregor Biswanger
c40affb32e Merge pull request #406 from Mandrakia/master
Added UserAgentFallback to App
2020-05-19 13:34:15 +02:00
Gregor Biswanger
e9331728b4 Merge branch 'master' into master 2020-05-19 13:34:04 +02:00
Gregor Biswanger
92b0388300 Merge pull request #405 from dafergu2/master
Update application exit logic
2020-05-19 13:19:47 +02:00
Gire Jean-Philippe
f4ea6df204 Added UserAgentFallback to App 2020-05-19 11:59:11 +02:00
Dave Ferguson
b027ca7c66 Exit net core backend on electron quit
This change explicitly cleans up the .net core http process when the
hosting electron application quits.  On macos, the child process was
sometimes left running depending on how the application was exited.

GH-346
2020-05-18 19:58:31 -04:00
Dave Ferguson
0573e92ed5 Fix logic of all windows closed event on macos
The application was not raising the all windows closed event which
didn't allow the .NET application to exit properly when the last window
was closed.

The recommendation by electronjs is to subscribe to the all windows
closed event and exit the app via code on macos.

This change allows the event to propagated up to the .NET application.

It may be better to move all of the logic surrounding this to the
ElectronNET.API project and allow the application developer full
control over the behavior.  For now, this fixes the immediate bug.

GH-346
2020-05-18 19:58:22 -04:00
Gregor Biswanger
672e3b86fd Merge pull request #402 from konstantingross/feature/Additional_NativeTheme_implementations
Remaining implementation of the NativeTheme API
2020-05-19 00:24:28 +02:00
Konstantin Gross
b7960eb772 PR fixes 2020-05-18 23:57:10 +02:00
Gustavo Lara
bbab114c54 Adding All PowerMonitor Methods, Fixing Comments 2020-05-18 16:14:03 -05:00
Konstantin Gross
e77f48b2c5 Fix formatting and summary 2020-05-18 21:01:47 +02:00
Gustavo Lara Molina
8fe60bfcda adding all powerMonitor api events 2020-05-17 22:16:31 -05:00
gustavo-lara-molina
09fa662ed1 Merge pull request #1 from ElectronNET/master
Updating fork
2020-05-17 20:44:15 -05:00
Konstantin Gross
7f2269c4bd Remaining implementation of the NativeTheme API: shouldUseHighContrastColors, shouldUseInvertedColorScheme, get/set themeSource and updated event 2020-05-17 02:54:01 +02:00
Gregor Biswanger
05de4071d1 Update 2020-05-15 00:18:38 +02:00
Gregor Biswanger
169abc2376 implement NativeTheme API with shouldUseDarkColors 2020-05-13 14:16:36 +02:00
Gregor Biswanger
12a3f2689e Update 8.31.3 2020-05-13 01:44:40 +02:00
Gregor Biswanger
14587463e7 add new powerMonitor API js file - fix formating 2020-05-13 01:41:09 +02:00
Gregor Biswanger
6690b4a76e Merge pull request #399 from gustavo-lara-molina/powerMonitor
Power monitor
2020-05-13 01:12:57 +02:00
Gustavo Lara Molina
c8e51ef21b Updating Comments 2020-05-12 10:50:08 -05:00
Gustavo Lara Molina
96a5189f14 Merge - from master 2020-05-12 10:11:04 -05:00
Gustavo Lara Molina
13fcedc3a0 Updating Labesl 2020-05-12 10:10:34 -05:00
Gustavo Lara Molina
c12c26b491 Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-05-12 09:12:22 -05:00
Robert Muehsig
6ddce85bdd 8.31.2 2020-05-12 01:00:31 +02:00
Gregor Biswanger
68ee626d07 Update Changelog for 8.31.2 2020-05-12 00:37:14 +02:00
Gregor Biswanger
fd5801ffdc Update Context Menu Item for tray app on-the-fly. #270 2020-05-12 00:21:18 +02:00
Rocket
df02855471 Added the API Power 2020-05-11 12:59:21 -05:00
Gregor Biswanger
b6417d0718 Implement new command: electronize build /target win /PublishReadyToRun false #395 - Add self contained app #387 2020-05-10 00:31:28 +02:00
Gregor Biswanger
6f1f7cbc5e Merge pull request #394 from shotr-io/master
Implement NativeImage support, fixes #14
2020-05-09 21:09:12 +02:00
Gregor Biswanger
aec0da6075 Update Changelog 📑 2020-05-07 21:58:32 +02:00
ThrDev
c9f0c43bc9 Remove using Clipboard 2020-05-06 19:17:25 -04:00
ThrDev
b87d7f9899 Add XML comments 2020-05-06 19:14:34 -04:00
ThrDev
fa51cdd72c Merge remote-tracking branch 'upstream/master' 2020-05-06 19:07:31 -04:00
ThrDev
9b270755d0 Add full NativeImage support for Electron.NET 2020-05-06 19:05:21 -04:00
Gregor Biswanger
c5db735773 update 2020-05-03 00:57:37 +02:00
Gregor Biswanger
88f5995f40 update 2020-05-03 00:54:30 +02:00
Gregor Biswanger
042cd7e6cb update 2020-05-03 00:50:04 +02:00
Gregor Biswanger
cb096212f9 Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-05-02 23:56:00 +02:00
Gregor Biswanger
0363dc8924 update 2020-05-02 23:55:56 +02:00
Robert Muehsig
8cf5053512 Update .travis.yml 2020-05-01 22:55:03 +02:00
Robert Muehsig
32046adfb5 Update README.md 2020-05-01 22:53:53 +02:00
Robert Muehsig
003a9d0d35 8.31.1 Release 2020-05-01 22:49:49 +02:00
Gregor Biswanger
db6bed43dc fix memory leak and remove package 2020-05-01 15:52:54 +02:00
Gregor Biswanger
80d160a71c Merge pull request #390 from syedadeel2/LiveReload
Live reload
2020-05-01 14:29:58 +02:00
Syed Adeel Hassan Rizvi
01d938fb1a Storing main window instance to reload later. 2020-05-01 22:12:28 +10:00
Syed Adeel Hassan Rizvi
00eb9869dc 1. Watch enabled successfully.
2. Reloading electron after build.
2020-05-01 17:29:56 +10:00
Syed Adeel Hassan Rizvi
2987e3143d commented out the code 2020-05-01 09:45:02 +10:00
Syed Adeel Hassan Rizvi
20ca72b794 my file deleted 2020-05-01 09:44:14 +10:00
Syed Adeel Hassan Rizvi
a0e0cc3bbc /watch arg added, main.js updated 2020-04-30 22:31:12 +10:00
ThrDev
e295558258 Fix MenusController.cs 2020-04-26 19:36:16 -04:00
ThrDev
e67f6c500b Merge remote-tracking branch 'upstream/master' 2020-04-26 19:29:39 -04:00
ThrDev
23015a9f3d Add System.Drawing.Common reference. 2020-04-26 19:26:45 -04:00
ThrDev
7daac2d04e Add NativeImage support, clipboard image read/write. 2020-04-26 19:21:29 -04:00
Gregor Biswanger
71955b9181 Fixed: Unable to disable WebSecurity along with NodeIntegration enabled #389 2020-04-24 00:59:38 +02:00
Gregor Biswanger
a619b6e5c9 Implemented BrowserView API #371 2020-04-23 03:29:52 +02:00
Gregor Biswanger
3ba3fa6414 Add new Electronize CLI command #273 2020-04-21 19:38:16 +02:00
Gregor Biswanger
11fbd6b259 Fixed: Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false #361 2020-04-21 14:39:21 +02:00
Gregor Biswanger
073eb0e00d Fixed: GetLoginItemSettingsAsync does not work #352 2020-04-21 01:00:59 +02:00
Gregor Biswanger
c0bf257b55 Increase startup time #356 🚀 2020-04-19 15:19:24 +02:00
Gregor Biswanger
62b37d059f add to set author and name in electron.manifest.json #348 2020-04-19 01:22:27 +02:00
Gregor Biswanger
ca8f4c454c MenuRole bug fix and add printer support. 2020-04-18 17:17:05 +02:00
Gregor Biswanger
d660dff871 changed App.GetNameAsync and App.SetNameAsync to App.Name - Fixed the Splashscreen bug #357 #350 2020-04-18 17:15:58 +02:00
Gregor Biswanger
c17720a4d7 Merge pull request #355 from x-xx-o/print
added print capability
2020-04-18 17:06:23 +02:00
Gregor Biswanger
274552f52b Merge pull request #369 from jjuback/master
Start MenuRole enum at 1.
2020-04-18 17:03:20 +02:00
Gregor Biswanger
1e3fe6183c update npm packages to newest version of electron, electron-updater, tslint and typescript 2020-04-18 15:09:44 +02:00
John Juback
88b04377a7 Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-02-07 15:00:17 -05:00
John Juback
92356d3587 Start MenuRole enum at 1. 2020-02-07 14:38:33 -05:00
Niko
a3c452eea5 add print capability 2019-12-15 09:56:14 +01:00
Gregor Biswanger
68288d9d73 Update Changelog.md 2019-12-03 11:45:50 +01:00
Robert Muehsig
022221307c Merge pull request #331 from ElectronNET/bug/318-rename-clitool
This should fix #318
2019-12-01 23:52:11 +01:00
Robert Muehsig
ffc6353bf2 Merge branch 'master' into bug/318-rename-clitool 2019-12-01 22:49:46 +01:00
Gregor Biswanger
f4d8144a8b update changelog with the new release 7.30.2 2019-12-01 01:17:00 +01:00
Gregor Biswanger
30d49ff6e8 Support for different manifest files (#340) 2019-11-30 23:30:15 +01:00
Gregor Biswanger
db9d3b1484 activate Electron 7.1.2 build 2019-11-30 02:48:23 +01:00
Gregor Biswanger
a788d71530 Implemented Electrons CommandLine-API, Implemented arguments support, Implemented different manifest file support 2019-11-30 01:30:22 +01:00
Gregor Biswanger
f5e2abfdb4 Change to Electron version 7, fix some breaking changes. 2019-11-28 22:34:49 +01:00
Gregor Biswanger
42f09de7b5 Merge pull request #323 from kant2002/cleanup-project
Cleanup project with regard to documentation
2019-11-27 20:50:13 +01:00
Andrii Kurdiumov
72d1f4b2b9 Cleanup project with regard to documentation
Was inspired when reviewing .NET Core 3 support
2019-11-27 21:31:19 +02:00
Gregor Biswanger
d2b3c28f91 Merge pull request #342 from jamiebrynes7/bugfix/check-required-args
Handle missing `/target` argument for `build` command.
2019-11-27 20:18:37 +01:00
Gregor Biswanger
94c4cd82b0 Merge pull request #334 from thecodejedi/master
#308 - Start process with listen port 8000 error.
2019-11-27 20:07:48 +01:00
Gregor Biswanger
600bc1a41b Merge pull request #322 from kant2002/improve-testability
Change test application initialization procedure.
2019-11-27 19:35:38 +01:00
Gregor Biswanger
4e8e771293 Merge pull request #311 from Daddoon/master
Support of AddExtension, RemoveExtension, GetExtensions
2019-11-27 19:27:08 +01:00
Jamie Brynes
4014ef7a4d changelog; 2019-11-16 15:17:55 +00:00
Jamie Brynes
364db7dc25 check for arg 2019-11-16 15:13:02 +00:00
Markus Hoffmann
3dda18ac9a use Electron Port as base 2019-11-02 13:31:18 +01:00
Robert Muehsig
7f92ffa20e 5.30.1 release 2019-10-29 00:33:03 +01:00
Robert Muehsig
b69d4d23bf Merge pull request #313 from ElectronNET/netcore30
Update to .NET Core 3.0
2019-10-29 00:21:32 +01:00
Robert Muehsig
eb4144053d This should fix #318 2019-10-28 23:58:43 +01:00
Robert Muehsig
239d914747 Merge pull request #328 from jimbuck/netcore30
Converted global npm dependencies to use npx
2019-10-28 23:36:00 +01:00
Robert Muehsig
5af8e489b9 Merge pull request #327 from tadic-luka/patch-1
Thanks!
2019-10-28 23:30:54 +01:00
Jim Buck
b6fb1cb0bf Converted global npm dependencies to use npx. 2019-10-22 23:59:47 -04:00
tadic-luka
aa98b85f18 Update README.md
EnableEndpointRouting should be set to false. Otherwise people will get error: 
Application startup exception: System.InvalidOperationException: Endpoint Routing does not support 'IApplicationBuilder.UseMvc(...)'. To use 'IApplicationBuilder.UseMvc' set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices(...). 
The solution is even proposed in stack trace.
Issue was opened on https://github.com/aspnet/AspNetCore/issues/9542 and it is explained there what should be done.
2019-10-22 10:48:55 +02:00
Robert Muehsig
af74d24f50 Merge pull request #326 from jbeals12/patch-1 2019-10-21 21:07:07 +02:00
Jason
2240ffca82 Grammar fix. 2019-10-21 11:28:33 -06:00
Robert Muehsig
f64b780a27 documentation and one minor adjustment 2019-10-15 00:21:36 +02:00
Robert Muehsig
fbc5b93513 Merge branch 'netcore30' of https://github.com/ElectronNET/Electron.NET into netcore30 2019-10-15 00:13:34 +02:00
Robert Muehsig
14d02706c0 small changes for version stuff 2019-10-15 00:13:22 +02:00
Robert Muehsig
2c14693430 Merge branch 'master' into netcore30 2019-10-15 00:10:14 +02:00
Robert Muehsig
54ff11acf5 beta... 2019-10-15 00:09:15 +02:00
Robert Muehsig
b7e7ace6f3 fix build issues on windows 2019-10-14 22:44:30 +02:00
Robert Muehsig
1f7908a0f1 Merge pull request #321 from kant2002/issue-320
Fix `buildAll.cmd` and `buildAll.sh` when running on clear repo
2019-10-14 21:45:54 +02:00
Andrii Kurdiumov
cafffde339 Change test application initialization procedure.
It essentially the same as before, but MVC test tooling expect Program to have CreateWebHostBuilder. I referer to ability to seamlessly use WebApplicationFactory
I understand that story for testing Electron application will be not easy as it is, but this is allow better defaults for testing web applications which can be run in hybrid mode.
2019-10-14 18:31:32 +03:00
Andrii Kurdiumov
6fbba52edd Fix buildAll.cmd and buildAll.sh when running on clear repo
This is followup to c91884a520 change which on itself was reaction to electron-builder changes in the command line parameters interface
2019-10-14 11:13:53 +03:00
Robert Muehsig
8dd5d1561a test 2019-10-07 23:16:08 +02:00
Robert Muehsig
25f35e34fe global npm outside of build commands 2019-10-07 22:53:50 +02:00
Robert Muehsig
f1eaffb203 update github sourcelink and framework reference 2019-10-07 22:48:49 +02:00
Robert Muehsig
69ca5d6f9e Merge pull request #314 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/lodash-4.17.15
Bump lodash from 4.17.11 to 4.17.15 in /ElectronNET.Host
2019-10-07 22:42:03 +02:00
Robert Muehsig
5cd11a8110 build 2019-10-03 23:36:21 +02:00
dependabot[bot]
c343b19a60 Bump lodash from 4.17.11 to 4.17.15 in /ElectronNET.Host
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15)

Signed-off-by: dependabot[bot] <support@github.com>
2019-10-03 21:16:04 +00:00
Robert Muehsig
b3bb3ceb97 fix build issues 2019-10-03 23:07:17 +02:00
Robert Muehsig
e25b89ff6a Update to .NET Core 3.0 2019-10-03 22:30:58 +02:00
Guillaume
28be0dd209 - Removed unused variable from a previous attempt. 2019-09-26 17:34:18 +02:00
Guillaume
8bf10c370c - Added XML documentation on ChromeExtensionInfo constructor 2019-09-26 17:30:21 +02:00
Guillaume
a32b50f86f - Fixed / Updated API for Chrome extensions
- Sample for quick testing will be put in the pull request
2019-09-26 17:26:33 +02:00
Guillaume
a781234d05 - Removed not existent parameter in method declaration of browserWindowGetExtensions in browserWindows.ts 2019-09-26 13:37:01 +02:00
Guillaume
8b66bdd7cb - Added BrowserWindow.AddExtension, RemoveExtension, GetExtensions support. Not yet tested 2019-09-26 13:27:22 +02:00
Guillaume
ba64639c1d - Added AddExtension, RemoveExtension and GetExtensions methods body
- Added a ChromeExtensionInfo class, that mimic the returned JS values from GetExtensions method (see https://electronjs.org/docs/api/browser-window#browserwindowgetextensions)
- GetExtensions return a Dictionary<string, ChromeExtensionInfo>, to respect JS documentation declaration.
2019-09-25 17:33:57 +02:00
Gregor Biswanger
5157561dc6 Merge pull request #303 from hack2root/master
fix issue #301
2019-08-21 17:10:47 +02:00
Gregor Biswanger
bbecd86cce Update Changelog.md 2019-08-21 17:10:10 +02:00
Artur Mustafin
bd99da560b fix issue #301 2019-08-21 06:43:56 +03:00
Gregor Biswanger
9278402d65 remove starter kits part
Is no longer actively maintained
2019-08-03 11:45:14 +02:00
Robert Muehsig
9bc1b46810 5.22.14 2019-07-29 22:04:52 +02:00
Gregor Biswanger
d2956e6f2f Fix Refresh-Window 2019-07-28 20:16:06 +02:00
Gregor Biswanger
da4e930478 New Feature: Support for set a custom static Port to ASP.NET Backend - #155 2019-07-28 14:14:15 +02:00
Gregor Biswanger
8e9f7b016a New Feature: Implement full support for Auto Updater - (Based on electron-updater - Version 4.0.6) 2019-07-28 13:32:34 +02:00
Gregor Biswanger
10e95afa5c Merge branch 'master' into dev/AutoUpdate 2019-07-28 13:24:41 +02:00
Gregor Biswanger
68505f8feb Create FUNDING.yml 2019-07-28 11:04:41 +02:00
Gregor Biswanger
c91884a520 Fixed bug: Build fails with latest electron-builder version - #288 2019-07-26 16:31:44 +02:00
Gregor Biswanger
ccf0a4c73b Merge pull request #262 from netpoetica/master
fix async issue where same port is considered open
2019-07-26 13:52:10 +02:00
Gregor Biswanger
660663d9c1 Merge pull request #286 from Tum4ik/master
Fixed bug: Electron tray icon TypeError
2019-07-26 13:21:10 +02:00
Robert Muehsig
36ee9c4dd7 Merge pull request #269 from ElectronNET/netcore2.2
update projects to use netcoreapp2.2
2019-07-15 22:29:11 +02:00
Robert Muehsig
9f7c99db53 Merge pull request #252 from Tum4ik/patch-1
Update README.md
2019-07-15 22:16:34 +02:00
Yevgeniy Tymchishin
b9ba162a88 Fixed bug: Electron tray icon TypeError 2019-07-05 23:33:04 +03:00
Robert Muehsig
ad399f50ee 5.22.13 release 2019-07-01 23:16:33 +02:00
Robert Muehsig
428e53e265 Merge pull request #266 from gfs/gfs/listen-on-127.0.0.1
Fix ASP.NET backend listening on 0.0.0.0
2019-07-01 23:10:40 +02:00
kthrose
0a02b7140b Fix filenames in shell script, ElectronNet != ElectionNET on Linux for builds. 2019-06-03 16:54:25 -04:00
Robert Muehsig
f6ea0dd8dc Merge branch 'master' into netcore2.2 2019-06-01 00:02:33 +02:00
Robert Muehsig
dc8987de5a Merge pull request #268 from ElectronNET/dotnet-travisci-dotnetcore
Use the most recent SDK
2019-05-31 23:56:42 +02:00
Robert Muehsig
dc73be0c81 update projects to use netcoreapp2.2 2019-05-31 23:54:47 +02:00
Robert Muehsig
4dc8f189f9 Update .travis.yml 2019-05-31 23:42:50 +02:00
Robert Muehsig
5ec179af5d Update .travis.yml 2019-05-31 23:28:02 +02:00
Gabe Stocco
802b1acf68 Update README.md 2019-05-31 09:12:07 -07:00
gfs
07a0bc9c7d Revert NodeIntegration Change
Add comment to note why it is true.
2019-05-31 08:57:21 -07:00
kthrose
43028afc02 add bash version of release script 2019-05-31 10:08:44 -04:00
gfs
d3d73611b7 Version in build script now a variable 2019-05-30 19:43:27 -07:00
gfs
6d31c41479 Change NodeIntegration Default to False
This should be the default as it is more secure. It is trivial for applications which wish to take on the additional attack surface to set "            browserWindowOptions.WebPreferences.NodeIntegration = false;"
2019-05-30 17:37:07 -07:00
gfs
98a549560f Prevents binding to 0.0.0.0 on Windows 2019-05-30 17:33:01 -07:00
kthrose
8a3b9951fa fix async issue where same port is considered open 2019-05-29 10:50:24 -04:00
Gregor Biswanger
552b4331b2 implement missing events and properties from the AutoUpdater-API 2019-05-23 23:10:45 +02:00
Gregor Biswanger
38785f9b18 Update README.md 2019-05-23 16:41:19 +02:00
Gregor Biswanger
886b4b81a5 Update Changelog.md 2019-05-23 16:15:24 +02:00
Gregor Biswanger
e6b6f990d7 Update Changelog.md 2019-05-23 16:14:48 +02:00
Gregor Biswanger
a2ada57292 Implement all electron-updater events 2019-05-23 02:59:30 +02:00
Gregor Biswanger
0cede6131e Fixed bug #257 - Menu Item visibility 2019-05-22 20:26:22 +02:00
Gregor Biswanger
ce52988aac Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2019-05-22 18:28:52 +02:00
Gregor Biswanger
3a52680a54 Bugfix #258: electron.manifest.json - singleInstance not working 2019-05-22 18:26:43 +02:00
Gregor Biswanger
6d28e57f04 Update README.md 2019-05-22 02:35:59 +02:00
Gregor Biswanger
a2cdabf8cb Update issue templates 2019-05-22 02:20:44 +02:00
Gregor Biswanger
25ab81ca8f Update README.md 2019-05-22 01:52:04 +02:00
Gregor Biswanger
5ba54ab40b Update README.md 2019-05-22 01:48:30 +02:00
Gregor Biswanger
cca8110c38 Update README.md 2019-05-22 00:54:50 +02:00
Gregor Biswanger
06f43032b4 Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2019-05-21 03:32:27 +02:00
Gregor Biswanger
0709d61120 add Auto Update demo sample 2019-05-21 03:32:18 +02:00
Robert Muehsig
aa09af8ad6 version bump 2019-05-20 22:47:21 +02:00
Gregor Biswanger
e90ef9e48d Merge branch 'dev/AutoUpdate' 2019-05-20 18:39:18 +02:00
Gregor Biswanger
6d076fb99a update version from Electron.Host/package.json by electron.manifest.json 2019-05-20 18:38:57 +02:00
Gregor Biswanger
131d1d9dd1 update changelog 2019-05-20 01:13:09 +02:00
Gregor Biswanger
e5132e8198 implement AutoUpdater 2019-05-20 01:08:26 +02:00
Tum4ik
6a7c60fdb5 Update README.md
Fixed documentation bug.
2019-05-19 15:37:48 +03:00
Gregor Biswanger
8605fab9a7 update changelog 2019-05-18 16:57:23 +02:00
Gregor Biswanger
c03d6e8976 implement splashscreen support 2019-05-18 15:04:11 +02:00
Gregor Biswanger
5e0ef7edb5 Merge pull request #250 from MaherJendoubi/spelling
Fixed some spelling issues
2019-05-18 02:06:21 +02:00
Gregor Biswanger
5300609360 implement electron-builder support, remove electron-packager 2019-05-18 02:01:06 +02:00
Maher Jendoubi
ed6ebe90b1 Fixed some spelling issues
* Cleanup of unnecessary usings
* Used language keywords instead of BCL types : Object --> object
* Fixed some spelling issues
2019-05-18 02:00:56 +02:00
Gregor Biswanger
4e95322468 update changelog 2019-05-16 18:07:46 +02:00
Gregor Biswanger
412f628422 implement Session-API, fix code selection problem for the Demo Web-App. 2019-05-16 18:03:31 +02:00
Gregor Biswanger
3cb92169dd Implement Electron 5.0.1 compatibility 2019-05-16 03:13:35 +02:00
Gregor Biswanger
aea2c7aff5 pull request #233 2019-05-16 01:29:34 +02:00
Gregor Biswanger
ba16c4e032 Merge pull request #228 from gfs/master
Adds new command line parameters to 'electronize build'
2019-05-16 01:07:04 +02:00
Gregor Biswanger
8b5bb636f3 Merge branch 'master' into master 2019-05-16 01:06:56 +02:00
Gregor Biswanger
0fac6ae1cd Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2019-05-16 00:53:40 +02:00
Gregor Biswanger
24d1f6f844 update changelog 2019-05-16 00:53:34 +02:00
Gregor Biswanger
73f7e5a7b2 Merge pull request #243 from Hecatron-Forks/hecatron-dev
Call electronize from the Path instead of via dotnet in launchSettings.json
2019-05-16 00:49:50 +02:00
Gregor Biswanger
01d1397a60 Merge pull request #241 from BorisTheBrave/improve-build-script
buildReleaseNuGetPackages should leave you in the same directory you …
2019-05-16 00:48:38 +02:00
Gregor Biswanger
77e7280b1f Merge pull request #240 from BorisTheBrave/set-progress-bar-fixes
Updates the C# API to accept floating point as in JS.
2019-05-16 00:47:55 +02:00
Gregor Biswanger
8d6a5a757e Merge pull request #236 from BorisTheBrave/electronize-cli-false-positive
Reduce chance of detecting false positives when scanning subprocesses for errors.
2019-05-16 00:46:59 +02:00
Gregor Biswanger
f2e0808ede Merge pull request #231 from CodeKenpachi/master
Fix BrowserWindow::SetMenu
2019-05-16 00:42:45 +02:00
Gregor Biswanger
aa7efbad4b Merge branch 'dev/hosthooks' 2019-05-15 23:58:40 +02:00
Gregor Biswanger
d0c52a1364 Implement HostHook logic to CLI and API. Implement an example in the Web-App. 2019-05-15 23:56:53 +02:00
grbd
4235aa4677 Calls electronize from the Path instead of via dotnet 2019-05-08 19:31:29 +01:00
Adam Newgas
8a3c86abc0 buildReleaseNuGetPackages should leave you in the same directory you started in. 2019-05-05 18:33:26 +01:00
Adam Newgas
eda9b08cac Updates the C# API to accept floating point as in JS.
Also adds supports for progress bar options.

Fixes #239
2019-05-05 18:30:07 +01:00
Adam Newgas
a5cee6e6d5 Reduce chance of detecting false positives when scanning subprocesses for errors.
Fixes #160
2019-04-27 19:05:26 +01:00
GLINTT\ppinto
4db0ac0ebb FIX application hangs after socket reconnect
Tray, Globalshortcut and other stop sending events with socket.emit after socket reconnect
2019-04-18 18:03:17 +01:00
Kevin Gaden
2a9c0e1d60 Fix BrowserWindow::SetMenu 2019-04-04 15:08:10 +02:00
Gabe Stocco
7dc3072b5f Adds additional new parameter to force a node install, instead of
skipping due to an existing node_modules folder. This is also implicitly
triggered by providing your own package.json file. This ensures that the
actual packages match the package.json.
2019-03-29 19:02:34 -07:00
Gabe Stocco
6642f9d505 Correct license information in package.json to match license file included with source. 2019-03-28 15:45:50 -07:00
Gabe Stocco
078ac99098 Revert version change. 2019-03-28 15:00:13 -07:00
Gabe Stocco
f7cc2a995f Adds three new command line options for build. Specifying the output path, and allowing specification of a package.json file to use. 2019-03-28 14:57:03 -07:00
Gabe Stocco
c0ee3b8859 Fixes directory change when running script. 2019-03-28 14:41:34 -07:00
Robert Muehsig
597df77508 Merge pull request #200 from yfrans/patch-1
Added Windows 32bit support for the start command
2019-01-19 21:36:21 +01:00
Robert Muehsig
f709f65f9e always invoke npm install 2019-01-15 22:21:25 +01:00
Robert Muehsig
71d2b88b02 fix build? 2019-01-15 20:54:32 +01:00
Gregor Biswanger
f4631c99f7 remove to listen on errors 2019-01-11 10:00:00 +01:00
Gregor Biswanger
04968d088b fix ElectronHostHook path, exception handling 2019-01-11 02:42:32 +01:00
Yossi Frances
5d446b23fa Added Windows 32bit support for the start command 2019-01-10 20:47:27 +02:00
Robert Muehsig
2b3eabf75a test 2019-01-09 23:04:56 +01:00
Robert Muehsig
27a5057bb0 fix build? 2019-01-09 00:06:40 +01:00
Robert Muehsig
28f0ffaf62 cleanup sample 2019-01-08 23:58:48 +01:00
Robert Muehsig
0f085fdb1d copy the right stuff and invoke npm 2019-01-08 23:56:19 +01:00
Robert Muehsig
7d8301af54 copy should be ok 2019-01-08 23:49:40 +01:00
Robert Muehsig
132b20b4ae adding the connector 2019-01-07 22:27:33 +01:00
Robert Muehsig
cca5f7f40d draft? 2019-01-07 20:59:02 +01:00
Gregor Biswanger
63c2bcdf7c prototype of electron host hook service and api implementation 2019-01-05 02:17:31 +01:00
Gregor Biswanger
cad371c221 implement Electron 4.0.0 support 2019-01-04 03:27:12 +01:00
Gregor Biswanger
f4efad299a fixed bug: X and Y options to not work #193 2019-01-03 20:20:21 +01:00
Robert Muehsig
17e4646d11 Merge pull request #199 from ElectronNET/bug/fix-vulnerabilities
"found 8 vulnerabilities (1 low, 5 moderate, 2 high)"
2019-01-02 23:55:03 +01:00
Robert Muehsig
977f389e2f found 8 vulnerabilities (1 low, 5 moderate, 2 high)
run `npm audit fix` to fix them, or `npm audit` for details
2019-01-02 23:39:47 +01:00
Robert Muehsig
b6ec73cb84 Merge pull request #198 from ElectronNET/dev/fix-firewall-triggers
Fix firewall triggers
2019-01-02 23:20:30 +01:00
Robert Muehsig
15499e38bf fix socket.io windows firewall trigger 2019-01-02 19:48:14 +01:00
Robert Muehsig
538bc02b54 WIP!
Swap portscanner package to a more windows firewall friendly version
fight against socket.io, which is the last part that triggers the firewall
2019-01-02 01:10:39 +01:00
Robert Muehsig
2fb3062d4b don't listen on 0.0.0.0 2019-01-01 22:56:22 +01:00
Robert Muehsig
8426c9cac2 Merge pull request #197 from ElectronNET/dev/cleanup-for-011
cleanups and licenseUrl for package fixed
2018-12-30 23:22:54 +01:00
Robert Muehsig
da4a8dfa9d cleanups and licenseUrl for package fixed 2018-12-30 23:18:18 +01:00
Robert Muehsig
a2efdb3670 Merge pull request #194 from ElectronNET/bug/fix-devDependencies-while-building
npm install without prod flag
2018-12-30 20:12:26 +01:00
Robert Muehsig
1ae940613c Fix 2018-12-28 22:25:14 +01:00
Robert Muehsig
117fd6e7f4 Merge pull request #192 from ElectronNET/Fix-Readme-After-GlobalTools
Fix readme after Global Tool usage
2018-12-27 19:10:38 +01:00
Robert Muehsig
f5434a086d Update README.md 2018-12-26 23:09:03 +01:00
Robert Muehsig
dc3eec37bb Update Changelog.md 2018-12-05 22:54:48 +01:00
Robert Muehsig
8c171ba948 0.0.10 2018-12-05 22:40:06 +01:00
Robert Muehsig
c1bd48b58d adding the resultcode to the output 2018-09-27 22:48:54 +02:00
Gregor Biswanger
c10e5b74bd Merge pull request #167 from smack0007/manifest-path
manifestJsonFilePath is now calculated with path.join instead of bein…
2018-09-26 22:46:39 +02:00
smack0007
0c024448b7 manifestJsonFilePath is now calculated with path.join instead of being a hard coded string. 2018-09-26 22:32:07 +02:00
Gregor Biswanger
ac9d346955 refactoring 2018-09-26 01:31:53 +02:00
Gregor Biswanger
524e6c8dff fix planned breaking API changes from Electron 4.0 2018-09-25 23:10:58 +02:00
Gregor Biswanger
17399f3f6c Merge pull request #162 from ElectronNET/dev/move-to-globaltool
CLI is now a dotnet tool
2018-09-25 18:33:24 +02:00
Robert Muehsig
d50984a465 path fix 2018-09-03 23:13:02 +02:00
Robert Muehsig
1b7dc7c0c4 next try 2018-09-03 22:59:19 +02:00
Robert Muehsig
c9d53d2fc1 draft 2018-08-30 21:54:42 +02:00
Robert Muehsig
e305029563 Update .travis.yml 2018-07-24 22:44:08 +02:00
Robert Muehsig
da643149bc Update .travis.yml 2018-07-24 22:42:09 +02:00
Robert Muehsig
c2d4821882 Update .travis.yml 2018-07-24 22:33:18 +02:00
Gregor Biswanger
344c5b7c13 packages update to Electron 2.0.5 2018-07-22 21:44:47 +02:00
Gregor Biswanger
dcd637ae0f fix migration problems 2018-07-22 21:35:44 +02:00
Gregor Biswanger
f832143135 Merge pull request #154 from manne/patch-1
uses correct project home url
2018-07-22 18:29:48 +02:00
Manuel Pfemeter
dc40a0ed9a uses correct project home url 2018-07-22 17:50:25 +02:00
Gregor Biswanger
3d65136337 Merge pull request #139 from deinok/updated-electron-version
Electron 2.0.2
2018-07-22 17:47:14 +02:00
Gregor Biswanger
b53442be89 Merge pull request #107 from ru-sh/master
WebContent.GetUrl() and LoadURLOptions.ExtraHeaders
2018-07-22 17:46:43 +02:00
Gregor Biswanger
a708ccfc22 Merge pull request #101 from ElectronNET/better-cwd
https://github.com/ElectronNET/Electron.NET/issues/72
2018-07-22 17:46:14 +02:00
Gregor Biswanger
65399c23fd Merge pull request #95 from mojinxun/master
fix: socket.connnect JS : Scope & Closures
2018-07-22 17:45:35 +02:00
yaofeng
85127be49e config 2018-07-16 14:07:51 +08:00
yaofeng
86aae5ee18 finish pack check 2018-07-14 15:55:09 +08:00
yaofeng
fcbefa62ca 中文问题编码 2018-07-14 13:50:45 +08:00
yaofeng
e7a9ee07e0 update manifestFile setting 2018-06-14 13:11:42 +08:00
yaofeng
8e38c1f79d add makeSingleInstance 2018-06-14 10:47:08 +08:00
yaofeng
a874243c9d loadingWindow add devTools 2018-06-13 15:12:41 +08:00
yaofeng
354b4f09e6 add loadingWindow 2018-06-13 15:03:12 +08:00
Raul Hidalgo Caballero
ff12da19f1 Electron 2.0.2 2018-06-06 16:57:38 +02:00
yaofeng
1bf274a73c 1. getWindowById(id) add undefined check
2. IpcMain add off
2018-05-31 11:05:36 +08:00
yaofeng
949741d992 getWindowById(id) add undefined check 2018-05-30 15:13:17 +08:00
yaofeng
e3eee0c32f 1 2018-05-30 10:38:41 +08:00
yaofeng
ef1f0ab330 registerIpcMainChannel remove channel 2018-05-07 17:18:17 +08:00
Robert Muehsig
5a676cb76a Merge pull request #123 from tomkerkhove/patch-1
Fix typo
2018-05-07 09:00:45 +02:00
Tom Kerkhove
44797e054c Fix typo 2018-05-07 08:07:04 +02:00
Robert Muehsig
11641c9424 Merge pull request #119 from 80er/master
added support for linux-arm platform
2018-04-19 21:57:18 +02:00
Marco Achtziger
c8254e2d84 added support for linux-arm platform 2018-04-19 21:14:00 +02:00
yaofeng
0997291484 fix: possible eventemitter memory leak delected
do: io.setMaxListeners(0);
2018-04-18 16:53:34 +08:00
Shakirov Ruslan
959def9c86 + WebContent.GetUrl()
+ LoadURLOptions.ExtraHeaders
2018-03-16 22:32:56 +03:00
yaofeng
e20dafbb66 resume csproj 2018-02-28 10:27:00 +08:00
Robert Muehsig
2e87bb3955 https://github.com/ElectronNET/Electron.NET/issues/72 2018-02-19 23:30:13 +01:00
Robert Muehsig
c4c0bbadea Update README.md 2018-02-19 23:11:12 +01:00
yaofeng
ad20230b20 Merge branch 'master' of https://github.com/mojinxun/Electron.NET 2018-02-09 23:22:28 +08:00
yaofeng
3ba46a3565 1 2018-02-09 23:22:03 +08:00
mojinxun
53c591f7b7 Merge pull request #1 from ElectronNET/master
fix: io.reconnect socket Closure
2018-02-09 23:16:20 +08:00
244 changed files with 13591 additions and 4178 deletions

12
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://donorbox.org/electron-net

27
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
<!-- Please search existing issues to avoid creating duplicates. -->
<!-- Which version of Electron.NET CLI and API are you using? -->
<!-- Please always try to use latest version before report. -->
* **Version**:
<!-- Which version of .NET Core and Node.js are you using (if applicable)? -->
<!-- What target are you building for? -->
* **Target**:
<!-- Enter your issue details below this comment. -->
<!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) -->
Steps to Reproduce:
1.
2.

View File

@@ -0,0 +1,13 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: Feature
assignees: ''
---
<!-- Please search existing feature request to avoid creating duplicates. -->
<!-- If you want, you can donate to increase feature request priority (https://donorbox.org/electron-net) -->
<!-- Describe the feature you'd like. -->

13
.github/ISSUE_TEMPLATE/question.md vendored Normal file
View File

@@ -0,0 +1,13 @@
---
name: Question
about: The issue tracker is not for questions. Please ask questions on https://stackoverflow.com/questions/tagged/electron.net
or via chat in https://gitter.im/ElectronNET/community.
title: ''
labels: question
assignees: ''
---
🚨 The issue tracker is not for questions 🚨
The issue tracker is not for questions. Please ask questions on https://stackoverflow.com/questions/tagged/electron.net or via chat in https://gitter.im/ElectronNET/community.

3
.gitignore vendored
View File

@@ -260,3 +260,6 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Mac Only settings file
.DS_Store

View File

@@ -1,7 +1,8 @@
language: csharp
mono: none
dotnet: 2.0.0
dist: xenial
dotnet: 3.1
before_script:
- npm install electron-packager --global
- export PATH="$PATH:/home/travis/.dotnet/tools"
script:
- ./buildAll.sh
- ./buildAll.sh

View File

@@ -1,4 +1,277 @@
# not release
# Not released
# 13.5.1
ElectronNET.CLI:
* New Feature: Using exit code instead of seek for the term 'error' (thanks [TSrgy](https://github.com/TSrgy)) [\#562](https://github.com/ElectronNET/Electron.NET/pull/562)
* Fixed bug: Allow for property overrides to be passed in (thanks [danatcofo](https://github.com/danatcofo)) [\#531](https://github.com/ElectronNET/Electron.NET/pull/531)
Use `/p:propertyName=value` or `/property:propertyName=value` to pass in property overrides. This is equivalent to the `-p:` option documented here: [https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish)
* Fixed bug: Add ability to pass an argument for "Version" for both the "dotnet publish" and "electron-builder" commands (thanks [tub5](https://github.com/tub5)) [\#546](https://github.com/ElectronNET/Electron.NET/pull/546)
* Fixed bug: Version flag not persisting with the referenced executable (thanks [tub5](https://github.com/tub5)) [\#585](https://github.com/ElectronNET/Electron.NET/pull/585)
* Fixed bug: Changes PublishSingleFile default to false for NET5 compatibility (thanks [cristiangiagante](https://github.com/cristiangiagante)) [\#570](https://github.com/ElectronNET/Electron.NET/pull/570)
ElectronNET.API:
* New Feature: Native Electron 13.1.5 support, but not all new features (we search contributors)
* Breaking API Changes (from native Electron 13.1.5):
- `Shell.MoveItemToTrashAsync` renamed with `Shell.TrashItemAsync`
- The deprecated extension APIs have been removed: `BrowserWindow.GetAllExtensionsAsync()`, `BrowserWindow.RemoveExtension()`, `BrowserWindow.AddExtensionAsync()`. Use the session APIs instead: `Session.GetAllExtensionsAsync()`, `Session.RemoveExtension()`, `Session.LoadExtensionAsync()`.
* New Feature: singleInstance handle command line arguments [\#520](https://github.com/ElectronNET/Electron.NET/issues/520)
* New Feature: Add WebContents [insertCSS](https://www.electronjs.org/docs/api/web-contents#contentsinsertcsscss-options) functionality (thanks [nfichter](https://github.com/nfichter)) [\#559](https://github.com/ElectronNET/Electron.NET/pull/559)
* New Feature: Allow IpcMain to send IPC messages to BrowserViews (thanks [nfichter](https://github.com/nfichter)) [\#560](https://github.com/ElectronNET/Electron.NET/pull/560)
* New Feature: Add support for proxies that require basic username/password authentication (thanks [nfichter](https://github.com/nfichter)) [\#561](https://github.com/ElectronNET/Electron.NET/pull/561)
* New Feature: Add PostData to LoadURLOptions to allow http-posts in LoadURL calls (thanks [Funkrusha](https://github.com/Funkrusha)) [\#547](https://github.com/ElectronNET/Electron.NET/pull/547)
* Fixed bug: Fix splash screen interaction causing crashes, ghost dragging, and resizable behavior #540 (thanks [MiniguyBrendan](https://github.com/MiniguyBrendan)) [\#540](https://github.com/ElectronNET/Electron.NET/pull/540)
* Fixed bug: Vibrancy serialization fix (thanks [tantumalice](https://github.com/tantumalice)) [\#573](https://github.com/ElectronNET/Electron.NET/pull/573)
# Released
# 11.5.1
ElectronNET.CLI:
* New Feature: Added new build and start commandline options for single exe (thanks [nathanwienand](https://github.com/nathanwienand)) [\#506](https://github.com/ElectronNET/Electron.NET/pull/506)
* New Feature: Set a description of the app in `electron.manifest.json` (thanks [BurtsevC](https://github.com/BurtsevC)) [\#433](https://github.com/ElectronNET/Electron.NET/pull/433)
* New Feature: Set a target for the start command (thanks [gabecook](https://github.com/gabecook)) [\#463](https://github.com/ElectronNET/Electron.NET/pull/463)
* New Feature: `electronize init` support for F# projects (thanks [kojo12228](https://github.com/kojo12228)) [\#457](https://github.com/ElectronNET/Electron.NET/pull/457)
* New Feature: Linux support for the buildAll.sh (thanks [duncanawoods](https://github.com/duncanawoods)) [\#465](https://github.com/ElectronNET/Electron.NET/pull/465)
* Fixed bug: ERR_UNKNOWN_URL_SCHEME by intercepting file:// protocol (thanks [duncanawoods](https://github.com/duncanawoods)) [\#467](https://github.com/ElectronNET/Electron.NET/pull/467)
ElectronNET.API:
* New Feature: Native Electron 11.1.1 support, but not all new features (we search contributors)
* Breaking API Changes (from native Electron 11.0): - Removed: BrowserView.{destroy, fromId, fromWebContents, getAllViews} and id property of BrowserView
* New Feature: Upgrade to .NET 5 (thanks [scottkuhl](https://github.com/scottkuhl)) [\#509](https://github.com/ElectronNET/Electron.NET/pull/509)
* New Feature: Extension Method for adding the Electron static class members to the standard MS DI Containers, this is a QOL issue only. `services.AddElectron()` (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
* New Feature: SetMenu completed for the Dock (MacOS) (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
Example for the Dock Menu
`Electron.Dock.SetMenu(new [] {
new MenuItem {
Label = "Dock Menu Item",
Click = () => {
// do something
}
},
});`
Example for consuming the activate event (MacOs only)
`Electron.App.On("activate", obj => {
var hasWindows = (bool)obj;
// do something
});`
* New Feature: On and Once implementations for the App and Tray to cover the plethora of events that are not mapped explicitly in those two modules. (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
* New Feature: Adding the `EnableRemoteModule` property to the WebPreferences object. As of Electron 10, this property defaulted to false and without it exposed you can't use the remote module within a window. (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
* New Feature: Adding a configurable default electron port. (thanks [aarong-av](https://github.com/aarong-av)) [\#505](https://github.com/ElectronNET/Electron.NET/pull/505)
* New Feature: Added support for launching the application with a file on MacOS (thanks [dlitty](https://github.com/dlitty)) [\#478](https://github.com/ElectronNET/Electron.NET/pull/478)
* Improved: Avoid Blocking Calls in App and AutoUpdater (thanks [freosc](https://github.com/freosc)) [\#474](https://github.com/ElectronNET/Electron.NET/pull/474)
* Fixed bug: Maintain references between socket.io connection events (thanks [danatcofo](https://github.com/danatcofo )) [\#468](https://github.com/ElectronNET/Electron.NET/pull/486)
* Fixed bug: Set default WebPreferences.DefaultFontSize (thanks [duncanawoods](https://github.com/duncanawoods)) [\#468](https://github.com/ElectronNET/Electron.NET/pull/468)
# 9.31.2
* Electron-Builder fixed for Windows builds.
# 9.31.1
ElectronNET.CLI:
* New Feature: Added config parameter (thanks [konstantingross](https://github.com/konstantingross)) [\#409](https://github.com/ElectronNET/Electron.NET/pull/409)
* New Feature: Set the configuration environment with the electron.manifest.json file.
* 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)
ElectronNET.API:
* New Feature: Native Electron 9.0.3 support, but not all new features (we search contributors)
* 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)
* New Feature: NativeTheme API Support (thanks [konstantingross](https://github.com/konstantingross)) [\#402](https://github.com/ElectronNET/Electron.NET/pull/402)
* New Feature: Cookie API Support (thanks [freosc](https://github.com/freosc)) [\#413](https://github.com/ElectronNET/Electron.NET/pull/413)
* 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)
* App-Api Enhancement: MenuItems with Submenus need an submenu type workaround [\#412](https://github.com/ElectronNET/Electron.NET/issues/412)
* App-Api Enhancement: Added UserAgentFallback (thanks [Mandrakia](https://github.com/Mandrakia)) [\#406](https://github.com/ElectronNET/Electron.NET/pull/406)
* 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)
* 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)
* 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)
* Notification-Api Enhancement: Added missing properties in Notifications (thanks [konstantingross](https://github.com/konstantingross)) [\#410](https://github.com/ElectronNET/Electron.NET/pull/410)
* 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)
* BrowserWindow Enhancement: Add BrowserWindow.GetNativeWindowHandle() (thanks [kdlslyv](https://github.com/kdlslyv)) [\#429](https://github.com/ElectronNET/Electron.NET/pull/429)
* HostHook-Api Enhancement: HostHook.CallAsync should use TaskCompletionSource.SetException instead of throwing exception (thanks [Fre V](https://github.com/freosc)) [\#430](https://github.com/ElectronNET/Electron.NET/pull/430)
* MacOS Enhancement: Application exit logic (thanks [dafergu2](https://github.com/dafergu2)) [\#405](https://github.com/ElectronNET/Electron.NET/pull/405)
* Fixed bug: ElectronNET.API.Entities.WebPreferences.ContextIsolation [DefaultValue(true)] [\#411](https://github.com/ElectronNET/Electron.NET/issues/411)
ElectronNET.WebApp (internal use):
* 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)
* Fixed bug: Cannot find modules in ElectronHostHook (thanks [konstantingross](https://github.com/konstantingross)) [\#425](https://github.com/ElectronNET/Electron.NET/pull/425)
Thank you for donation [Phil Seeman](https://github.com/mpnow) ❤
# 8.31.2
ElectronNET.CLI:
* New Feature: Deactivate PublishReadyToRun for build or start [\#395](https://github.com/ElectronNET/Electron.NET/issues/395)
`electronize build /target win /PublishReadyToRun false`
`electronize start /PublishReadyToRun false`
* Fixed bug: Application window doesn't open after packaging [\#387](https://github.com/ElectronNET/Electron.NET/issues/387)
ElectronNET.API:
* New Feature: NativeImage Support (thanks [ThrDev](https://github.com/ThrDev)) [\#394](https://github.com/ElectronNET/Electron.NET/pull/394)
* New Feature: Update menu items for context menu and system tray on-the-fly. [\#270](https://github.com/ElectronNET/Electron.NET/pull/270)
# 8.31.1
ElectronNET.CLI:
* New Feature: Set a name and author of the app in `electron.manifest.json` [\#348](https://github.com/ElectronNET/Electron.NET/issues/348#issuecomment-615977950) [\#310](https://github.com/ElectronNET/Electron.NET/issues/310#issuecomment-617361086)
* New Feature: Live reload (thanks [syedadeel2](https://github.com/syedadeel2)) [\#390](https://github.com/ElectronNET/Electron.NET/pull/390)
`electronize start /watch`
* New Feature: Every new window will created with an clear cache [\#273](https://github.com/ElectronNET/Electron.NET/issues/273)
`electronize start /clear-cache`
ElectronNET.API:
* New Feature: Native Electron 8.2.3 support, but not all new features (we search contributors)
* New Feature: We incease the startup time for ~25-36% [\#356](https://github.com/ElectronNET/Electron.NET/issues/356)
* New Feature: Added print capability (thanks [x-xx-o](https://github.com/x-xx-o)) [\#355](https://github.com/ElectronNET/Electron.NET/pull/355)
* New Feature: BrowserView API [\#371](https://github.com/ElectronNET/Electron.NET/issues/371)
* Changed App.GetNameAsync and App.SetNameAsync to the App.Name Property [\#350](https://github.com/ElectronNET/Electron.NET/issues/350)
* Fixed bug: Splash Screen disappearing on click [\#357](https://github.com/ElectronNET/Electron.NET/issues/357)
* Fixed bug: Start MenuRole enum at 1 (thanks [jjuback](https://github.com/jjuback)) [\#369](https://github.com/ElectronNET/Electron.NET/pull/369)
* Fixed bug: BridgeConnector not connected (spam console) [\#347](https://github.com/ElectronNET/Electron.NET/issues/347)
* Fixed bug: BrowserWindowOptions is not setting Width and Height properly [\#373](https://github.com/ElectronNET/Electron.NET/issues/373)
* Fixed bug: IpcMain.Once(string) is not one time use, is not removing listener [\#366](https://github.com/ElectronNET/Electron.NET/issues/366)
* Fixed bug: IpcMain.RemoveAllListeners(string) is not removing the listeners [\#365](https://github.com/ElectronNET/Electron.NET/issues/365)
* Fixed bug: GetLoginItemSettingsAsync does not work [\#352](https://github.com/ElectronNET/Electron.NET/issues/352)
* Fixed bug: Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false [\#361](https://github.com/ElectronNET/Electron.NET/issues/361)
* Fixed bug: Unable to disable WebSecurity along with NodeIntegration enabled [\#389](https://github.com/ElectronNET/Electron.NET/issues/389)
# 7.30.2
ElectronNET.CLI:
* New Feature: Different manifest file support [\#340](https://github.com/ElectronNET/Electron.NET/issues/340)
* Create a additional manifest file: `electronize init /manifest test`
* Start the app with your additional manifest file: `electronize start /manifest electron.manifest.test.json`
* Build the app with your additional manifest file: `electronize build /target win /manifest electron.manifest.test.json`.
* New Feature: Command Line support [\#337](https://github.com/ElectronNET/Electron.NET/issues/337)
* You can start the app with: `electronize start /args --dog=woof --test=true`
* Or as binary: `myapp.exe /args --dog=woof --test=true`
* Fixed bug: Start process with listen port 8000 error. [\#308](https://github.com/ElectronNET/Electron.NET/issues/308) (thanks [thecodejedi](https://github.com/thecodejedi))
* Fixed bug: `electronize build` with no arguments would throw a `KeyNotFoundException`. (thanks [jamiebrynes7](https://github.com/jamiebrynes7))
ElectronNET.API:
* New Feature: Electron 7.1.2 support, but not all new features (we search contributors) [\#341](https://github.com/ElectronNET/Electron.NET/issues/341)
* New Feature: Electron.App.CommandLine API [\#337](https://github.com/ElectronNET/Electron.NET/issues/337)
* New Feature: Support of BrowserWindow.AddExtension, BrowserWindow.RemoveExtension, BrowserWindow.GetExtensions (thanks [Daddoon](https://github.com/Daddoon))
Thank you for donation [robertmclaws](https://github.com/robertmclaws) ❤
# 5.30.1
ElectronNET.CLI:
* Move to .NET Core 3.0
* Use npm npx instead of global installations (thanks [jimbuck](https://github.com/jimbuck))
ElectronNET.API:
* Move to .NET Core 3.0
* New Feature: Add BrowserWindow.RemoveMenu() (thanks [hack2root](https://github.com/hack2root))
Thanks to [MaherJendoubi](https://github.com/MaherJendoubi), [kant2002](https://github.com/kant2002), [raz-canva](https://github.com/raz-canva) and [Daddoon](https://github.com/Daddoon) to give .NET Core 3.0 feedback!
# 5.22.14
ElectronNET.CLI:
* Fixed bug: Build fails with latest electron-builder version [\#288](https://github.com/ElectronNET/Electron.NET/issues/288)
ElectronNET.API:
* New Feature: Full support for Auto Updater [(Based on electron-updater - Version 4.0.6)](https://www.electron.build/auto-update)
* New Feature: Support for set a custom static Port to ASP.NET Backend [\#155](https://github.com/ElectronNET/Electron.NET/issues/155)
* Fixed bug: Electron tray icon TypeError ([Electron original issue](https://github.com/electron/electron/issues/7657)) (thanks [Tum4ik](https://github.com/Tum4ik))
* Fixed bug: Wrong tray icon path in the application built via `electronize build` command (thanks [Tum4ik](https://github.com/Tum4ik))
* Fixed bug: fix async issue where same port is considered open [\#261](https://github.com/ElectronNET/Electron.NET/issues/261) (thanks [netpoetica](https://github.com/netpoetica))
ElectronNET.WebApp:
* Fixed usage of the `Electron.Tray.Show` according fixed bugs in the ElectronNET.CLI (thanks [Tum4ik](https://github.com/Tum4ik))
# 5.22.13
ElectronNET.API:
* Fixed bug: Menu Item visibility [\#257](https://github.com/ElectronNET/Electron.NET/issues/257)
* Fixed bug: electron.manifest.json - singleInstance not working [\#258](https://github.com/ElectronNET/Electron.NET/issues/258)
* Fixed security issue: ASP.NET Core process is now bound to 127.0.0.1 instead of the broader localhost [\#258](https://github.com/ElectronNET/Electron.NET/pull/266)
# 5.22.12
ElectronNET.CLI:
* New Feature: Changed from **electron packager** to [**electron builder**](https://www.electron.build/)
* New Feature: 'add hosthook' command for add a ElectronHostHook-Directory
* Fixed bug: 'Unexpected firewall warnings' [\#181](https://github.com/ElectronNET/Electron.NET/issues/181)
* Fixed bug: 'found 8 vulnerabilities (1 low, 5 moderate, 2 high)' [\#199](https://github.com/ElectronNET/Electron.NET/pull/199)
* Merged pull request: Call electronize from the Path instead of via dotnet in launchSettings.json [\#243](https://github.com/ElectronNET/Electron.NET/pull/243) (thanks [grbd](https://github.com/grbd))
ElectronNET.API:
* New Feature: Electron 5.0.1 support, but not all new features
* New Feature: Auto Updater [(Based on electron-updater)](https://www.electron.build/auto-update)
* New Feature: Splashscreen-Support
* New Feature: HostHook-API for execute own TypeScript/JavaScript code on native Electron Main-Process
* New Feature: Session-API functions
* Fixed bug: Node process running after stopping app [\#96](https://github.com/ElectronNET/Electron.NET/issues/96)
* Fixed bug: 'X and Y options to not work on Windows 10' [\#193](https://github.com/ElectronNET/Electron.NET/issues/193)
* Fixed bug: Unable to clear cache [\#66](https://github.com/ElectronNET/Electron.NET/issues/66)
* Merged pull request: Fix BrowserWindow::SetMenu [\#231](https://github.com/ElectronNET/Electron.NET/pull/231) thanks (thanks [CodeKenpachi](https://github.com/CodeKenpachi))
* Merged pull request: FIX application hangs after socket reconnect [\#233](https://github.com/ElectronNET/Electron.NET/pull/233) (thanks [pedromrpinto](https://github.com/pedromrpinto))
* Merged pull request: Reduce chance of detecting false positives when scanning subprocesses for errors. [\#236](https://github.com/ElectronNET/Electron.NET/pull/236) (thanks [BorisTheBrave](https://github.com/BorisTheBrave))
* Merged pull request: Updates the C# API to accept floating point as in JS. [\#240](https://github.com/ElectronNET/Electron.NET/pull/240) (thanks [BorisTheBrave](https://github.com/BorisTheBrave))
* Merged pull request: buildReleaseNuGetPackages should leave you in the same directory you … [\#241](https://github.com/ElectronNET/Electron.NET/pull/241) (thanks [BorisTheBrave](https://github.com/BorisTheBrave))
ElectronNET.WebApp:
* Implemented a sample for the new HostHook-API
* Fixed bug: 'Electron.NET API Demo: unable to copy code?' [\#247](https://github.com/ElectronNET/Electron.NET/issues/247)
# 0.0.11
ElectronNET.CLI:
* Invoke 'npm install' without --prod flag to install needed devDependencies as well.
* Enable SourceLink
* NuGet Package License Information updated (deprecation of licenseUrl)
ElectronNET.API:
* Documentation added for WebContents.GetUrl()
* Enable SourceLink
* NuGet Package License Information updated (deprecation of licenseUrl)
# 0.0.10
ElectronNET.API:
* manifestJsonFilePath fixed (thanks @smack0007)
* Use Electron release 3.0.0 and updated packages (thanks @deinok)
* fixes for Socket interaction (thanks @mojinxun)
* Fixing SingleInstances (thanks @yaofeng)
* Enhance WebContent.GetUrl (thanks @ru-sh)
ElectronNET.CLI:
* Show Resultcode for better debugging when using Build/Start Command
* ElectronNET.CLI is now a global dotnet tool
# 0.0.9
@@ -9,12 +282,12 @@ ElectronNET.API:
ElectronNET.CLI:
* More options on the 'build' command, e.g. for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params "--prune=true "
* .NET Core project is now build with Release configuration, but can be adjusted with the new params.
* .NET Core project is now built with Release configuration but can be adjusted with the new params.
* Be aware: "Breaking" (but because of the alpha status of this project, we won't use SemVer)
# 0.0.8
This version was skipped because we unfortunatly released a pre version of this on NuGet.
This version was skipped because we unfortunately released a pre-version of this on NuGet.
# 0.0.7
@@ -27,7 +300,7 @@ ElectronNET.CLI:
ElectronNET.CLI:
* nuget packages are now release bits and have the correct assembly verion
* nuget packages are now release bits and have the correct assembly version
* Version command
* better devCleanup.cmd
* Better Platform Support Issue - thanks to @Petermarcu

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,621 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Enable apps to automatically update themselves. Based on electron-updater.
/// </summary>
public sealed class AutoUpdater
{
/// <summary>
/// Whether to automatically download an update when it is found. (Default is true)
/// </summary>
public bool AutoDownload
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-autoDownload-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-autoDownload-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-set", value);
}
}
/// <summary>
/// Whether to automatically install a downloaded update on app quit (if `QuitAndInstall` was not called before).
///
/// Applicable only on Windows and Linux.
/// </summary>
public bool AutoInstallOnAppQuit
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-autoInstallOnAppQuit-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-autoInstallOnAppQuit-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-set", value);
}
}
/// <summary>
/// *GitHub provider only.* Whether to allow update to pre-release versions.
/// Defaults to "true" if application version contains prerelease components (e.g. "0.12.1-alpha.1", here "alpha" is a prerelease component), otherwise "false".
///
/// If "true", downgrade will be allowed("allowDowngrade" will be set to "true").
/// </summary>
public bool AllowPrerelease
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-allowPrerelease-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-allowPrerelease-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-set", value);
}
}
/// <summary>
/// *GitHub provider only.*
/// Get all release notes (from current version to latest), not just the latest (Default is false).
/// </summary>
public bool FullChangelog
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-fullChangelog-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-fullChangelog-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-set", value);
}
}
/// <summary>
/// Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).
/// Taken in account only if channel differs (pre-release version component in terms of semantic versioning).
/// Default is false.
/// </summary>
public bool AllowDowngrade
{
get
{
return Task.Run<bool>(() =>
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("autoUpdater-allowDowngrade-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-allowDowngrade-get-reply");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-set", value);
}
}
/// <summary>
/// For test only.
/// </summary>
public string UpdateConfigPath
{
get
{
return Task.Run<string>(() =>
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("autoUpdater-updateConfigPath-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-updateConfigPath-get-reply");
taskCompletionSource.SetResult(result.ToString());
});
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
return taskCompletionSource.Task;
}).Result;
}
}
/// <summary>
/// The current application version
/// </summary>
public Task<SemVer> CurrentVersionAsync
{
get
{
return Task.Run<SemVer>(() =>
{
var taskCompletionSource = new TaskCompletionSource<SemVer>();
BridgeConnector.Socket.On("autoUpdater-currentVersion-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-currentVersion-get-reply");
SemVer version = ((JObject)result).ToObject<SemVer>();
taskCompletionSource.SetResult(version);
});
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// Get the update channel. Not applicable for GitHub.
/// Doesnt return channel from the update configuration, only if was previously set.
/// </summary>
[Obsolete("Use the asynchronous version ChannelAsync instead")]
public string Channel
{
get
{
return ChannelAsync.Result;
}
}
/// <summary>
/// Get the update channel. Not applicable for GitHub.
/// Doesnt return channel from the update configuration, only if was previously set.
/// </summary>
public Task<string> ChannelAsync
{
get
{
return Task.Run<string>(() =>
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("autoUpdater-channel-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
taskCompletionSource.SetResult(result.ToString());
});
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// The request headers.
/// </summary>
public Task<Dictionary<string, string>> RequestHeadersAsync
{
get
{
return Task.Run(() =>
{
var taskCompletionSource = new TaskCompletionSource<Dictionary<string, string>>();
BridgeConnector.Socket.On("autoUpdater-requestHeaders-get-reply", (headers) =>
{
BridgeConnector.Socket.Off("autoUpdater-requestHeaders-get-reply");
Dictionary<string, string> result = ((JObject)headers).ToObject<Dictionary<string, string>>();
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// The request headers.
/// </summary>
public Dictionary<string, string> RequestHeaders
{
set
{
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
}
}
/// <summary>
/// Emitted when there is an error while updating.
/// </summary>
public event Action<string> OnError
{
add
{
if (_error == null)
{
BridgeConnector.Socket.On("autoUpdater-error" + GetHashCode(), (message) =>
{
_error(message.ToString());
});
BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode());
}
_error += value;
}
remove
{
_error -= value;
if (_error == null)
BridgeConnector.Socket.Off("autoUpdater-error" + GetHashCode());
}
}
private event Action<string> _error;
/// <summary>
/// Emitted when checking if an update has started.
/// </summary>
public event Action OnCheckingForUpdate
{
add
{
if (_checkingForUpdate == null)
{
BridgeConnector.Socket.On("autoUpdater-checking-for-update" + GetHashCode(), () =>
{
_checkingForUpdate();
});
BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode());
}
_checkingForUpdate += value;
}
remove
{
_checkingForUpdate -= value;
if (_checkingForUpdate == null)
BridgeConnector.Socket.Off("autoUpdater-checking-for-update" + GetHashCode());
}
}
private event Action _checkingForUpdate;
/// <summary>
/// Emitted when there is an available update.
/// The update is downloaded automatically if AutoDownload is true.
/// </summary>
public event Action<UpdateInfo> OnUpdateAvailable
{
add
{
if (_updateAvailable == null)
{
BridgeConnector.Socket.On("autoUpdater-update-available" + GetHashCode(), (updateInfo) =>
{
_updateAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode());
}
_updateAvailable += value;
}
remove
{
_updateAvailable -= value;
if (_updateAvailable == null)
BridgeConnector.Socket.Off("autoUpdater-update-available" + GetHashCode());
}
}
private event Action<UpdateInfo> _updateAvailable;
/// <summary>
/// Emitted when there is no available update.
/// </summary>
public event Action<UpdateInfo> OnUpdateNotAvailable
{
add
{
if (_updateNotAvailable == null)
{
BridgeConnector.Socket.On("autoUpdater-update-not-available" + GetHashCode(), (updateInfo) =>
{
_updateNotAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode());
}
_updateNotAvailable += value;
}
remove
{
_updateNotAvailable -= value;
if (_updateNotAvailable == null)
BridgeConnector.Socket.Off("autoUpdater-update-not-available" + GetHashCode());
}
}
private event Action<UpdateInfo> _updateNotAvailable;
/// <summary>
/// Emitted on download progress.
/// </summary>
public event Action<ProgressInfo> OnDownloadProgress
{
add
{
if (_downloadProgress == null)
{
BridgeConnector.Socket.On("autoUpdater-download-progress" + GetHashCode(), (progressInfo) =>
{
_downloadProgress(JObject.Parse(progressInfo.ToString()).ToObject<ProgressInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode());
}
_downloadProgress += value;
}
remove
{
_downloadProgress -= value;
if (_downloadProgress == null)
BridgeConnector.Socket.Off("autoUpdater-download-progress" + GetHashCode());
}
}
private event Action<ProgressInfo> _downloadProgress;
/// <summary>
/// Emitted on download complete.
/// </summary>
public event Action<UpdateInfo> OnUpdateDownloaded
{
add
{
if (_updateDownloaded == null)
{
BridgeConnector.Socket.On("autoUpdater-update-downloaded" + GetHashCode(), (updateInfo) =>
{
_updateDownloaded(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
});
BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode());
}
_updateDownloaded += value;
}
remove
{
_updateDownloaded -= value;
if (_updateDownloaded == null)
BridgeConnector.Socket.Off("autoUpdater-update-downloaded" + GetHashCode());
}
}
private event Action<UpdateInfo> _updateDownloaded;
private static AutoUpdater _autoUpdater;
private static object _syncRoot = new object();
internal AutoUpdater() { }
internal static AutoUpdater Instance
{
get
{
if (_autoUpdater == null)
{
lock (_syncRoot)
{
if (_autoUpdater == null)
{
_autoUpdater = new AutoUpdater();
}
}
}
return _autoUpdater;
}
}
/// <summary>
/// Asks the server whether there is an update.
/// </summary>
/// <returns></returns>
public Task<UpdateCheckResult> CheckForUpdatesAsync()
{
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
{
try
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesError" + guid, (error) =>
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
string message = "An error occurred in CheckForUpdatesAsync";
if (error != null && !string.IsNullOrEmpty(error.ToString()))
message = JsonConvert.SerializeObject(error);
taskCompletionSource.SetException(new Exception(message));
});
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Asks the server whether there is an update.
///
/// This will immediately download an update, then install when the app quits.
/// </summary>
/// <returns></returns>
public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
{
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
{
try
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
if (updateCheckResult == null)
taskCompletionSource.SetResult(null);
else
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyError" + guid, (error) =>
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
string message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify";
if (error != null)
message = JsonConvert.SerializeObject(error);
taskCompletionSource.SetException(new Exception(message));
});
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Restarts the app and installs the update after it has been downloaded.
/// It should only be called after `update-downloaded` has been emitted.
///
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
/// This is different from the normal quit event sequence.
/// </summary>
/// <param name="isSilent">*windows-only* Runs the installer in silent mode. Defaults to `false`.</param>
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
{
BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
}
/// <summary>
/// Start downloading update manually. You can use this method if "AutoDownload" option is set to "false".
/// </summary>
/// <returns>Path to downloaded file.</returns>
public Task<string> DownloadUpdateAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
{
BridgeConnector.Socket.Off("autoUpdaterDownloadUpdateComplete" + guid);
taskCompletionSource.SetResult(downloadedPath.ToString());
});
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Feed URL.
/// </summary>
/// <returns>Feed URL.</returns>
public Task<string> GetFeedURLAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
{
BridgeConnector.Socket.Off("autoUpdaterGetFeedURLComplete" + guid);
taskCompletionSource.SetResult(downloadedPath.ToString());
});
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
return taskCompletionSource.Task;
}
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
}
}

View File

@@ -6,7 +6,7 @@ namespace ElectronNET.API
internal static class BridgeConnector
{
private static Socket _socket;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
public static Socket Socket
{

View File

@@ -0,0 +1,97 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
/// It is like a child window, except that it is positioned relative to its owning window.
/// It is meant to be an alternative to the webview tag.
/// </summary>
public class BrowserView
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; internal set; }
/// <summary>
/// Render and control web pages.
/// </summary>
public WebContents WebContents { get; internal set; }
/// <summary>
/// Resizes and moves the view to the supplied bounds relative to the window.
///
/// (experimental)
/// </summary>
public Rectangle Bounds
{
get
{
return Task.Run<Rectangle>(() =>
{
var taskCompletionSource = new TaskCompletionSource<Rectangle>();
BridgeConnector.Socket.On("browserView-getBounds-reply", (result) =>
{
BridgeConnector.Socket.Off("browserView-getBounds-reply");
taskCompletionSource.SetResult((Rectangle)result);
});
BridgeConnector.Socket.Emit("browserView-getBounds", Id);
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
}
}
/// <summary>
/// BrowserView
/// </summary>
internal BrowserView(int id)
{
Id = id;
// Workaround: increase the Id so as not to conflict with BrowserWindow id
// the backend detect about the value an BrowserView
WebContents = new WebContents(id + 1000);
}
/// <summary>
/// (experimental)
/// </summary>
/// <param name="options"></param>
public void SetAutoResize(AutoResizeOptions options)
{
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
}
/// <summary>
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
///
/// (experimental)
/// </summary>
/// <param name="color">Color in #aarrggbb or #argb form. The alpha channel is optional.</param>
public void SetBackgroundColor(string color)
{
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
}
}

View File

@@ -6,6 +6,7 @@ using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace ElectronNET.API
@@ -1657,6 +1658,13 @@ namespace ElectronNET.API
/// <param name="y"></param>
public void SetPosition(int x, int y)
{
// Workaround Windows 10 / Electron Bug
// https://github.com/electron/electron/issues/4045
if (isWindows10())
{
x = x - 7;
}
BridgeConnector.Socket.Emit("browserWindowSetPosition", Id, x, y);
}
@@ -1668,9 +1676,21 @@ namespace ElectronNET.API
/// <param name="animate"></param>
public void SetPosition(int x, int y, bool animate)
{
// Workaround Windows 10 / Electron Bug
// https://github.com/electron/electron/issues/4045
if (isWindows10())
{
x = x - 7;
}
BridgeConnector.Socket.Emit("browserWindowSetPosition", Id, x, y, animate);
}
private bool isWindows10()
{
return RuntimeInformation.OSDescription.Contains("Windows 10");
}
/// <summary>
/// Contains the windows current position.
/// </summary>
@@ -1789,6 +1809,25 @@ namespace ElectronNET.API
return taskCompletionSource.Task;
}
/// <summary>
/// Returns the native type of the handle is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.
/// </summary>
/// <returns>string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.</returns>
public Task<string> GetNativeWindowHandle()
{
var taskCompletionSource = new TaskCompletionSource<string>();
BridgeConnector.Socket.On("browserWindow-getNativeWindowHandle-completed", (nativeWindowHandle) =>
{
BridgeConnector.Socket.Off("browserWindow-getNativeWindowHandle-completed");
taskCompletionSource.SetResult(nativeWindowHandle.ToString());
});
BridgeConnector.Socket.Emit("browserWindowGetNativeWindowHandle", Id);
return taskCompletionSource.Task;
}
/// <summary>
/// Sets the pathname of the file the window represents,
/// and the icon of the file will show in windows title bar.
@@ -1909,7 +1948,7 @@ namespace ElectronNET.API
public void SetMenu(MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
BridgeConnector.Socket.Emit("browserWindowSetMenu", JArray.FromObject(menuItems, _jsonSerializer));
BridgeConnector.Socket.Emit("browserWindowSetMenu", Id, JArray.FromObject(menuItems, _jsonSerializer));
_items.AddRange(menuItems);
BridgeConnector.Socket.Off("windowMenuItemClicked");
@@ -1919,6 +1958,14 @@ namespace ElectronNET.API
});
}
/// <summary>
/// Remove the window's menu bar.
/// </summary>
public void RemoveMenu()
{
BridgeConnector.Socket.Emit("browserWindowRemoveMenu", Id);
}
/// <summary>
/// Sets progress value in progress bar. Valid range is [0, 1.0]. Remove progress
/// bar when progress smaler as 0; Change to indeterminate mode when progress bigger as 1. On Linux
@@ -1930,7 +1977,7 @@ namespace ElectronNET.API
/// assumed.
/// </summary>
/// <param name="progress"></param>
public void SetProgressBar(int progress)
public void SetProgressBar(double progress)
{
BridgeConnector.Socket.Emit("browserWindowSetProgressBar", Id, progress);
}
@@ -1947,7 +1994,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="progress"></param>
/// <param name="progressBarOptions"></param>
public void SetProgressBar(int progress, ProgressBarOptions progressBarOptions)
public void SetProgressBar(double progress, ProgressBarOptions progressBarOptions)
{
BridgeConnector.Socket.Emit("browserWindowSetProgressBar", Id, progress, JObject.FromObject(progressBarOptions, _jsonSerializer));
}
@@ -2277,6 +2324,17 @@ namespace ElectronNET.API
/// </summary>
public WebContents WebContents { get; internal set; }
/// <summary>
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
/// It is like a child window, except that it is positioned relative to its owning window.
/// It is meant to be an alternative to the webview tag.
/// </summary>
/// <param name="browserView"></param>
public void SetBrowserView(BrowserView browserView)
{
BridgeConnector.Socket.Emit("browserWindow-setBrowserView", Id, browserView.Id);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),

View File

@@ -2,7 +2,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Threading.Tasks;
namespace ElectronNET.API
@@ -13,7 +12,7 @@ namespace ElectronNET.API
public sealed class Clipboard
{
private static Clipboard _clipboard;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
internal Clipboard() { }
@@ -238,6 +237,40 @@ namespace ElectronNET.API
BridgeConnector.Socket.Emit("clipboard-write", JObject.FromObject(data, _jsonSerializer), type);
}
/// <summary>
/// Reads an image from the clipboard.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public Task<NativeImage> ReadImageAsync(string type = "")
{
var taskCompletionSource = new TaskCompletionSource<NativeImage>();
BridgeConnector.Socket.On("clipboard-readImage-Completed", (image) =>
{
BridgeConnector.Socket.Off("clipboard-readImage-Completed");
var nativeImage = ((JObject)image).ToObject<NativeImage>();
taskCompletionSource.SetResult(nativeImage);
});
BridgeConnector.Socket.Emit("clipboard-readImage", type);
return taskCompletionSource.Task;
}
/// <summary>
/// Writes an image to the clipboard.
/// </summary>
/// <param name="image"></param>
/// <param name="type"></param>
public void WriteImage(NativeImage image, string type = "")
{
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonConvert.SerializeObject(image), type);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),

View File

@@ -0,0 +1,116 @@
using System.Threading;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Manipulate the command line arguments for your app that Chromium reads.
/// </summary>
public sealed class CommandLine
{
internal CommandLine() { }
internal static CommandLine Instance
{
get
{
if (_commandLine == null)
{
lock (_syncRoot)
{
if (_commandLine == null)
{
_commandLine = new CommandLine();
}
}
}
return _commandLine;
}
}
private static CommandLine _commandLine;
private static object _syncRoot = new object();
/// <summary>
/// Append a switch (with optional value) to Chromium's command line.
/// </summary>
/// <param name="the_switch">A command-line switch, without the leading --</param>
/// <param name="value">(optional) - A value for the given switch</param>
/// <remarks>
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
/// </remarks>
public void AppendSwitch(string the_switch, string value = "")
{
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", the_switch, value);
}
/// <summary>
/// Append an argument to Chromium's command line. The argument will be quoted correctly. Switches will precede arguments regardless of appending order.
///
/// If you're appending an argument like <code>--switch=value</code>, consider using <code>appendSwitch('switch', 'value')</code> instead.
/// </summary>
/// <param name="value">The argument to append to the command line</param>
/// <remarks>
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
/// </remarks>
public void AppendArgument(string value)
{
BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
}
/// <summary>
/// Whether the command-line switch is present.
/// </summary>
/// <param name="switchName">A command-line switch</param>
/// <param name="cancellationToken"></param>
/// <returns>Whether the command-line switch is present.</returns>
public async Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<bool>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("appCommandLineHasSwitchCompleted", (result) =>
{
BridgeConnector.Socket.Off("appCommandLineHasSwitchCompleted");
taskCompletionSource.SetResult((bool)result);
});
BridgeConnector.Socket.Emit("appCommandLineHasSwitch", switchName);
return await taskCompletionSource.Task.ConfigureAwait(false);
}
}
/// <summary>
/// The command-line switch value.
/// </summary>
/// <param name="switchName">A command-line switch</param>
/// <param name="cancellationToken"></param>
/// <returns>The command-line switch value.</returns>
/// <remarks>
/// Note: When the switch is not present or has no value, it returns empty string.
/// </remarks>
public async Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<string>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("appCommandLineGetSwitchValueCompleted", (result) =>
{
BridgeConnector.Socket.Off("appCommandLineGetSwitchValueCompleted");
taskCompletionSource.SetResult((string)result);
});
BridgeConnector.Socket.Emit("appCommandLineGetSwitchValue", switchName);
return await taskCompletionSource.Task.ConfigureAwait(false);
}
}
}
}

154
ElectronNET.API/Cookies.cs Normal file
View File

@@ -0,0 +1,154 @@
using System;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace ElectronNET.API
{
/// <summary>
/// Query and modify a session's cookies.
/// </summary>
public class Cookies
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; private set; }
internal Cookies(int id)
{
Id = id;
}
/// <summary>
/// Emitted when a cookie is changed because it was added, edited, removed, or expired.
/// </summary>
public event Action<Cookie, CookieChangedCause, bool> OnChanged
{
add
{
if (_changed == null)
{
BridgeConnector.Socket.On("webContents-session-cookies-changed" + Id, (args) =>
{
Cookie cookie = ((JArray)args)[0].ToObject<Cookie>();
CookieChangedCause cause = ((JArray)args)[1].ToObject<CookieChangedCause>();
bool removed = ((JArray)args)[2].ToObject<bool>();
_changed(cookie, cause, removed);
});
BridgeConnector.Socket.Emit("register-webContents-session-cookies-changed", Id);
}
_changed += value;
}
remove
{
_changed -= value;
if (_changed == null)
BridgeConnector.Socket.Off("webContents-session-cookies-changed" + Id);
}
}
private event Action<Cookie, CookieChangedCause, bool> _changed;
/// <summary>
/// Sends a request to get all cookies matching filter, and resolves a callack with the response.
/// </summary>
/// <param name="filter">
/// </param>
/// <returns>A task which resolves an array of cookie objects.</returns>
public Task<Cookie[]> GetAsync(CookieFilter filter)
{
var taskCompletionSource = new TaskCompletionSource<Cookie[]>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-cookies-get-completed" + guid, (cookies) =>
{
Cookie[] result = ((JArray)cookies).ToObject<Cookie[]>();
BridgeConnector.Socket.Off("webContents-session-cookies-get-completed" + guid);
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("webContents-session-cookies-get", Id, JObject.FromObject(filter, _jsonSerializer), guid);
return taskCompletionSource.Task;
}
/// <summary>
///
/// </summary>
/// <param name="details"></param>
/// <returns></returns>
public Task SetAsync(CookieDetails details)
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-cookies-set-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-cookies-set-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-cookies-set", Id, JObject.FromObject(details, _jsonSerializer), guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Removes the cookies matching url and name
/// </summary>
/// <param name="url">The URL associated with the cookie.</param>
/// <param name="name">The name of cookie to remove.</param>
/// <returns>A task which resolves when the cookie has been removed</returns>
public Task RemoveAsync(string url, string name)
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-cookies-remove-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-cookies-remove-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-cookies-remove", Id, url, name, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Writes any unwritten cookies data to disk.
/// </summary>
/// <returns>A task which resolves when the cookie store has been flushed</returns>
public Task FlushStoreAsync()
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-cookies-flushStore-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-cookies-flushStore-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-cookies-flushStore", Id, guid);
return taskCompletionSource.Task;
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
}

View File

@@ -3,7 +3,9 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Web;
namespace ElectronNET.API
{
@@ -13,7 +15,7 @@ namespace ElectronNET.API
public sealed class Dialog
{
private static Dialog _dialog;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
internal Dialog() { }
@@ -54,14 +56,18 @@ namespace ElectronNET.API
BridgeConnector.Socket.Off("showOpenDialogComplete" + guid);
var result = ((JArray)filePaths).ToObject<string[]>();
taskCompletionSource.SetResult(result);
var list = new List<string>();
foreach (var item in result)
{
list.Add(HttpUtility.UrlDecode(item));
}
taskCompletionSource.SetResult(list.ToArray());
});
BridgeConnector.Socket.Emit("showOpenDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer),
guid);
JObject.FromObject(options, _jsonSerializer), guid);
return taskCompletionSource.Task;
}

232
ElectronNET.API/Dock.cs Normal file
View File

@@ -0,0 +1,232 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace ElectronNET.API
{
/// <summary>
/// Control your app in the macOS dock.
/// </summary>
public sealed class Dock
{
private static Dock _dock;
private static object _syncRoot = new object();
internal Dock()
{
}
internal static Dock Instance
{
get
{
if (_dock == null)
{
lock (_syncRoot)
{
if (_dock == null)
{
_dock = new Dock();
}
}
}
return _dock;
}
}
/// <summary>
/// When <see cref="DockBounceType.Critical"/> is passed, the dock icon will bounce until either the application becomes
/// active or the request is canceled. When <see cref="DockBounceType.Informational"/> is passed, the dock icon will bounce
/// for one second. However, the request remains active until either the application becomes active or the request is canceled.
/// <para/>
/// Note: This method can only be used while the app is not focused; when the app is focused it will return -1.
/// </summary>
/// <param name="type">Can be critical or informational. The default is informational.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Return an ID representing the request.</returns>
public async Task<int> BounceAsync(DockBounceType type, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<int>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-bounce-completed", (id) =>
{
BridgeConnector.Socket.Off("dock-bounce-completed");
taskCompletionSource.SetResult((int) id);
});
BridgeConnector.Socket.Emit("dock-bounce", type.GetDescription());
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Cancel the bounce of id.
/// </summary>
/// <param name="id">Id of the request.</param>
public void CancelBounce(int id)
{
BridgeConnector.Socket.Emit("dock-cancelBounce", id);
}
/// <summary>
/// Bounces the Downloads stack if the filePath is inside the Downloads folder.
/// </summary>
/// <param name="filePath"></param>
public void DownloadFinished(string filePath)
{
BridgeConnector.Socket.Emit("dock-downloadFinished", filePath);
}
/// <summary>
/// Sets the string to be displayed in the docks badging area.
/// </summary>
/// <param name="text"></param>
public void SetBadge(string text)
{
BridgeConnector.Socket.Emit("dock-setBadge", text);
}
/// <summary>
/// Gets the string to be displayed in the docks badging area.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The badge string of the dock.</returns>
public async Task<string> GetBadgeAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<string>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-getBadge-completed", (text) =>
{
BridgeConnector.Socket.Off("dock-getBadge-completed");
taskCompletionSource.SetResult((string) text);
});
BridgeConnector.Socket.Emit("dock-getBadge");
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Hides the dock icon.
/// </summary>
public void Hide()
{
BridgeConnector.Socket.Emit("dock-hide");
}
/// <summary>
/// Shows the dock icon.
/// </summary>
public void Show()
{
BridgeConnector.Socket.Emit("dock-show");
}
/// <summary>
/// Whether the dock icon is visible. The app.dock.show() call is asynchronous
/// so this method might not return true immediately after that call.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Whether the dock icon is visible.</returns>
public async Task<bool> IsVisibleAsync(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<bool>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-isVisible-completed", (isVisible) =>
{
BridgeConnector.Socket.Off("dock-isVisible-completed");
taskCompletionSource.SetResult((bool) isVisible);
});
BridgeConnector.Socket.Emit("dock-isVisible");
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Gets the dock menu items.
/// </summary>
/// <value>
/// The menu items.
/// </value>
public IReadOnlyCollection<MenuItem> MenuItems { get { return _items.AsReadOnly(); } }
private List<MenuItem> _items = new List<MenuItem>();
/// <summary>
/// Sets the application's dock menu.
/// </summary>
public void SetMenu(MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
BridgeConnector.Socket.Emit("dock-setMenu", JArray.FromObject(menuItems, _jsonSerializer));
_items.AddRange(menuItems);
BridgeConnector.Socket.Off("dockMenuItemClicked");
BridgeConnector.Socket.On("dockMenuItemClicked", (id) => {
MenuItem menuItem = _items.GetMenuItem(id.ToString());
menuItem?.Click();
});
}
/// <summary>
/// TODO: Menu (macOS) still to be implemented
/// Gets the application's dock menu.
/// </summary>
public async Task<Menu> GetMenu(CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
var taskCompletionSource = new TaskCompletionSource<Menu>();
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
{
BridgeConnector.Socket.On("dock-getMenu-completed", (menu) =>
{
BridgeConnector.Socket.Off("dock-getMenu-completed");
taskCompletionSource.SetResult(((JObject)menu).ToObject<Menu>());
});
BridgeConnector.Socket.Emit("dock-getMenu");
return await taskCompletionSource.Task
.ConfigureAwait(false);
}
}
/// <summary>
/// Sets the image associated with this dock icon.
/// </summary>
/// <param name="image"></param>
public void SetIcon(string image)
{
BridgeConnector.Socket.Emit("dock-setIcon", image);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
}
}

View File

@@ -15,6 +15,11 @@
/// </summary>
public static App App { get { return App.Instance; } }
/// <summary>
/// Enable apps to automatically update themselves. Based on electron-updater.
/// </summary>
public static AutoUpdater AutoUpdater { get { return AutoUpdater.Instance; } }
/// <summary>
/// Control your windows.
/// </summary>
@@ -59,5 +64,29 @@
/// Perform copy and paste operations on the system clipboard.
/// </summary>
public static Clipboard Clipboard { get { return Clipboard.Instance; } }
/// <summary>
/// Allows you to execute native JavaScript/TypeScript code from the host process.
///
/// It is only possible if the Electron.NET CLI has previously added an
/// ElectronHostHook directory:
/// <c>electronize add HostHook</c>
/// </summary>
public static HostHook HostHook { get { return HostHook.Instance; } }
/// <summary>
/// Allows you to execute native Lock and Unlock process.
/// </summary>
public static PowerMonitor PowerMonitor { get { return PowerMonitor.Instance; } }
/// <summary>
/// Read and respond to changes in Chromium's native color theme.
/// </summary>
public static NativeTheme NativeTheme { get { return NativeTheme.Instance; } }
/// <summary>
/// Control your app in the macOS dock.
/// </summary>
public static Dock Dock { get { return Dock.Instance; } }
}
}
}

View File

@@ -1,38 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>..\artifacts</PackageOutputPath>
<PackageId>ElectronNET.API</PackageId>
<Authors>Gregor Biswanger, Robert Muehsig</Authors>
<Company />
<Product>Electron.NET</Product>
<PackageLicenseUrl>https://github.com/ElectronNET/Electron.NET/blob/master/LICENSE</PackageLicenseUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/ElectronNET/Electron.NET/</PackageProjectUrl>
<Description>Building cross platform electron based desktop apps with .NET Core and ASP.NET NET Core.
<Description>Building cross platform electron based desktop apps with .NET Core and ASP.NET Core.
This package contains the API to access the "native" electron API.</Description>
<RepositoryUrl>https://github.com/ElectronNET/Electron.NET/</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageTags>electron aspnetcore</PackageTags>
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png</PackageIconUrl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
<PackageIcon>PackageIcon.png</PackageIcon>
<Version>99.0.0.0</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.0" />
<PackageReference Include="SocketIoClientDotNet" Version="1.0.3" />
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
@@ -41,5 +32,16 @@ This package contains the API to access the "native" electron API.</Description>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' != 'Windows_NT'">
<Exec Command="$(ProjectDir)devCleanup.sh" IgnoreExitCode="true" />
</Target>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SocketIoClientDotNet" Version="1.0.5" />
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
</ItemGroup>
</Project>

View File

@@ -1,7 +1,7 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// About panel options.
/// </summary>
public class AboutPanelOptions
{
@@ -20,14 +20,29 @@
/// </summary>
public string Copyright { get; set; }
/// <summary>
/// The app's build version number.
/// </summary>
public string Version { get; set; }
/// <summary>
/// Credit information.
/// </summary>
public string Credits { get; set; }
/// <summary>
/// The app's build version number.
/// List of app authors.
/// </summary>
public string Version { get; set; }
public string[] Authors { get; set; }
/// <summary>
/// The app's website.
/// </summary>
public string Website { get; set; }
/// <summary>
/// Path to the app's icon. On Linux, will be shown as 64x64 pixels while retaining aspect ratio.
/// </summary>
public string IconPath { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class AddRepresentationOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
/// <summary>
/// Gets or sets the buffer
/// </summary>
public byte[] Buffer { get; set; }
/// <summary>
/// Gets or sets the dataURL
/// </summary>
public string DataUrl { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class AutoResizeOptions
{
/// <summary>
/// If `true`, the view's width will grow and shrink together with the window.
/// `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Width { get; set; } = false;
/// <summary>
/// If `true`, the view's height will grow and shrink together with the window.
/// `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Height { get; set; } = false;
/// <summary>
/// If `true`, the view's x position and width will grow and shrink proportionally
/// with the window. `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Horizontal { get; set; } = false;
/// <summary>
/// If `true`, the view's y position and height will grow and shrink proportionally
/// with the window. `false` by default.
/// </summary>
[DefaultValue(false)]
public bool Vertical { get; set; } = false;
}
}

View File

@@ -0,0 +1,13 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BitmapOptions
{
/// <summary>
/// Gets or sets the scale factor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Blob : IPostData
{
/// <summary>
/// The object represents a Blob
/// </summary>
public string Type { get; } = "blob";
/// <summary>
/// The UUID of the Blob being uploaded
/// </summary>
public string BlobUUID { get; set; }
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BlockMapDataHolder
{
/// <summary>
/// The file size. Used to verify downloaded size (save one HTTP request to get length).
/// Also used when block map data is embedded into the file(appimage, windows web installer package).
/// </summary>
public double Size { get; set; }
/// <summary>
/// The block map file size. Used when block map data is embedded into the file (appimage, windows web installer package).
/// This information can be obtained from the file itself, but it requires additional HTTP request,
/// so, to reduce request count, block map size is specified in the update metadata too.
/// </summary>
public double BlockMapSize { get; set; }
/// <summary>
/// The file checksum.
/// </summary>
public string Sha512 { get; set; }
/// <summary>
///
/// </summary>
public bool IsAdminRightsRequired { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class BrowserViewConstructorOptions
{
/// <summary>
/// See BrowserWindow.
/// </summary>
public WebPreferences WebPreferences { get; set; }
/// <summary>
/// A proxy to set on creation in the format host:port.
/// The proxy can be alternatively set using the BrowserView.WebContents.SetProxyAsync function.
/// </summary>
public string Proxy { get; set; }
/// <summary>
/// The credentials of the Proxy in the format username:password.
/// These will only be used if the Proxy field is also set.
/// </summary>
public string ProxyCredentials { get; set; }
}
}

View File

@@ -12,24 +12,24 @@ namespace ElectronNET.API.Entities
/// <summary>
/// Window's width in pixels. Default is 800.
/// </summary>
public int Width { get; set; }
public int Width { get; set; } = 800;
/// <summary>
/// Window's height in pixels. Default is 600.
/// </summary>
public int Height { get; set; }
public int Height { get; set; } = 600;
/// <summary>
/// ( if y is used) Window's left offset from screen. Default is to center the
/// window.
/// </summary>
public int X { get; set; }
public int X { get; set; } = -1;
/// <summary>
/// ( if x is used) Window's top offset from screen. Default is to center the
/// window.
/// </summary>
public int Y { get; set; }
public int Y { get; set; } = -1;
/// <summary>
/// The width and height would be used as web page's size, which means the actual
@@ -258,5 +258,17 @@ namespace ElectronNET.API.Entities
/// Settings of web page's features.
/// </summary>
public WebPreferences WebPreferences { get; set; }
/// <summary>
/// A proxy to set on creation in the format host:port.
/// The proxy can be alternatively set using the BrowserWindow.WebContents.SetProxyAsync function.
/// </summary>
public string Proxy { get; set; }
/// <summary>
/// The credentials of the Proxy in the format username:password.
/// These will only be used if the Proxy field is also set.
/// </summary>
public string ProxyCredentials { get; set; }
}
}

View File

@@ -5,15 +5,15 @@
/// </summary>
public class CPUUsage
{
/// <summary>
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
/// </summary>
public int PercentCPUUsage { get; set; }
/// <summary>
/// The number of average idle cpu wakeups per second since the last call to
/// getCPUUsage.First call returns 0.
/// </summary>
public int IdleWakeupsPerSecond { get; set; }
/// <summary>
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
/// </summary>
public int PercentCPUUsage { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Provide metadata about the current loaded Chrome extension
/// </summary>
public class ChromeExtensionInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="ChromeExtensionInfo"/> class.
/// </summary>
/// <param name="name">The name of the Chrome extension.</param>
/// <param name="version">The version of the Chrome extension.</param>
public ChromeExtensionInfo(string name, string version)
{
Name = name;
Version = version;
}
/// <summary>
/// Name of the Chrome extension
/// </summary>
public string Name { get; set; }
/// <summary>
/// Version of the Chrome extension
/// </summary>
public string Version { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ClearStorageDataOptions
{
/// <summary>
/// Should follow window.location.origins representation scheme://host:port.
/// </summary>
public string Origin { get; set; }
/// <summary>
/// The types of storages to clear, can contain: appcache, cookies, filesystem,
/// indexdb, localstorage, shadercache, websql, serviceworkers, cachestorage.
/// </summary>
public string[] Storages { get; set; }
/// <summary>
/// The types of quotas to clear, can contain: temporary, persistent, syncable.
/// </summary>
public string[] Quotas { get; set; }
}
}

View File

@@ -0,0 +1,51 @@
namespace ElectronNET.API.Entities {
/// <summary>
///
/// </summary>
public class Cookie {
/// <summary>
/// The name of the cookie.
/// </summary>
public string Name { get; set;}
/// <summary>
/// The value of the cookie.
/// </summary>
public string Value { get; set; }
/// <summary>
/// (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains.
/// </summary>
public string Domain { get; set; }
/// <summary>
/// (optional) - Whether the cookie is a host-only cookie; this will only be true if no domain was passed.
/// </summary>
public bool HostOnly { get; set; }
/// <summary>
/// (optional) - The path of the cookie.
/// </summary>
public string Path { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as secure.
/// </summary>
public bool Secure { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as HTTP only.
/// </summary>
public bool HttpOnly { get; set; }
/// <summary>
/// (optional) - Whether the cookie is a session cookie or a persistent cookie with an expiration date.
/// </summary>
public bool Session { get; set; }
/// <summary>
/// (optional) - The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.
/// </summary>
public long ExpirationDate { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities {
/// <summary>
/// The cause of the change
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum CookieChangedCause
{
/// <summary>
///The cookie was changed directly by a consumer's action.
/// </summary>
[JsonProperty("explicit")]
@explicit,
/// <summary>
/// The cookie was automatically removed due to an insert operation that overwrote it.
/// </summary>
overwrite,
/// <summary>
/// The cookie was automatically removed as it expired.
/// </summary>
expired,
/// <summary>
/// The cookie was automatically evicted during garbage collection.
/// </summary>
evicted,
/// <summary>
/// The cookie was overwritten with an already-expired expiration date.
/// </summary>
[JsonProperty("expired_overwrite")]
expiredOverwrite
}
}

View File

@@ -0,0 +1,56 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities {
/// <summary>
///
/// </summary>
public class CookieDetails {
/// <summary>
/// The URL to associate the cookie with. The callback will be rejected if the URL is invalid.
/// </summary>
public string Url { get; set; }
/// <summary>
/// (optional) - The name of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Name { get; set; }
/// <summary>
/// (optional) - The value of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Value { get; set; }
/// <summary>
/// (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Domain { get; set; }
/// <summary>
/// (optional) - The path of the cookie. Empty by default if omitted.
/// </summary>
[DefaultValue("")]
public string Path { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as secure. Defaults to false.
/// </summary>
[DefaultValue(false)]
public bool Secure { get; set; }
/// <summary>
/// (optional) - Whether the cookie is marked as HTTP only. Defaults to false.
/// </summary>
[DefaultValue(false)]
public bool HttpOnly { get; set; }
/// <summary>
/// (optional) - The expiration date of the cookie as the number of seconds since the UNIX epoch.
/// If omitted then the cookie becomes a session cookie and will not be retained between sessions.
/// </summary>
[DefaultValue(0)]
public long ExpirationDate { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CookieFilter
{
/// <summary>
/// (optional) - Retrieves cookies which are associated with url.Empty implies retrieving cookies of all URLs.
/// </summary>
public string Url { get; set; }
/// <summary>
/// (optional) - Filters cookies by name.
/// </summary>
public string Name { get; set; }
/// <summary>
/// (optional) - Retrieves cookies whose domains match or are subdomains of domains.
/// </summary>
public string Domain { get; set; }
/// <summary>
/// (optional) - Retrieves cookies whose path matches path.
/// </summary>
public string Path { get; set; }
/// <summary>
/// (optional) - Filters cookies by their Secure property.
/// </summary>
public bool Secure { get; set; }
/// <summary>
/// (optional) - Filters out session or persistent cookies.
/// </summary>
public bool Session { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateFromBitmapOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateFromBufferOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,67 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class CreateInterruptedDownloadOptions
{
/// <summary>
/// Absolute path of the download.
/// </summary>
public string Path { get; set; }
/// <summary>
/// Complete URL chain for the download.
/// </summary>
public string[] UrlChain { get; set; }
/// <summary>
///
/// </summary>
public string MimeType { get; set; }
/// <summary>
/// Start range for the download.
/// </summary>
public int Offset { get; set; }
/// <summary>
/// Total length of the download.
/// </summary>
public int Length { get; set; }
/// <summary>
/// Last-Modified header value.
/// </summary>
public string LastModified { get; set; }
/// <summary>
/// ETag header value.
/// </summary>
public string ETag { get; set; }
/// <summary>
/// Time when download was started in number of seconds since UNIX epoch.
/// </summary>
public int StartTime { get; set; }
/// <summary>
///
/// </summary>
/// <param name="path">Absolute path of the download.</param>
/// <param name="urlChain">Complete URL chain for the download.</param>
/// <param name="offset">Start range for the download.</param>
/// <param name="length">Total length of the download.</param>
/// <param name="lastModified">Last-Modified header value.</param>
/// <param name="eTag">ETag header value.</param>
public CreateInterruptedDownloadOptions(string path, string[] urlChain, int offset, int length, string lastModified, string eTag)
{
Path = path;
UrlChain = urlChain;
Offset = offset;
Length = length;
LastModified = lastModified;
ETag = eTag;
}
}
}

View File

@@ -1,18 +1,22 @@
namespace ElectronNET.API
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// Defines the DockBounceType enumeration.
/// </summary>
public enum DockBounceType
{
/// <summary>
/// The critical
/// Dock icon will bounce until either the application becomes active or the request is canceled.
/// </summary>
critical,
[Description("critical")]
Critical,
/// <summary>
/// The informational
/// The dock icon will bounce for one second.
/// </summary>
informational
[Description("informational")]
Informational
}
}

View File

@@ -0,0 +1,28 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class EnableNetworkEmulationOptions
{
/// <summary>
/// Whether to emulate network outage. Defaults to false.
/// </summary>
public bool Offline { get; set; } = false;
/// <summary>
/// RTT in ms. Defaults to 0 which will disable latency throttling.
/// </summary>
public int Latency { get; set; }
/// <summary>
/// Download rate in Bps. Defaults to 0 which will disable download throttling.
/// </summary>
public int DownloadThroughput { get; set; }
/// <summary>
/// Upload rate in Bps. Defaults to 0 which will disable upload throttling.
/// </summary>
public int UploadThroughput { get; set; }
}
}

View File

@@ -1,16 +0,0 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Error
{
/// <summary>
/// Gets or sets the stack.
/// </summary>
/// <value>
/// The stack.
/// </value>
public string Stack { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Docs: https://electronjs.org/docs/api/structures/extension
/// </summary>
public class Extension
{
/// <summary>
///
/// </summary>
public string Id { get; set; }
/// <summary>
/// Copy of the extension's manifest data.
/// </summary>
public dynamic Manifest { get; set; }
/// <summary>
///
/// </summary>
public string Name { get; set; }
/// <summary>
/// The extension's file path.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The extension's `chrome-extension://` URL.
/// </summary>
public string Url { get; set; }
/// <summary>
///
/// </summary>
public string Version { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Controls the behavior of <see cref="App.Focus(FocusOptions)"/>.
/// </summary>
public class FocusOptions
{
/// <summary>
/// Make the receiver the active app even if another app is currently active.
/// <para/>
/// You should seek to use the <see cref="Steal"/> option as sparingly as possible.
/// </summary>
public bool Steal { get; set; }
}
}

View File

@@ -8,77 +8,77 @@ namespace ElectronNET.API.Entities
public class GPUFeatureStatus
{
/// <summary>
/// Canvas
/// Canvas.
/// </summary>
[JsonProperty("2d_canvas")]
public string Canvas { get; set; }
/// <summary>
/// Flash
/// Flash.
/// </summary>
[JsonProperty("flash_3d")]
public string Flash3D { get; set; }
/// <summary>
/// Flash Stage3D
/// Flash Stage3D.
/// </summary>
[JsonProperty("flash_stage3d")]
public string FlashStage3D { get; set; }
/// <summary>
/// Flash Stage3D Baseline profile
/// Flash Stage3D Baseline profile.
/// </summary>
[JsonProperty("flash_stage3d_baseline")]
public string FlashStage3dBaseline { get; set; }
/// <summary>
/// Compositing
/// Compositing.
/// </summary>
[JsonProperty("gpu_compositing")]
public string GpuCompositing { get; set; }
/// <summary>
/// Multiple Raster Threads
/// Multiple Raster Threads.
/// </summary>
[JsonProperty("multiple_raster_threads")]
public string MultipleRasterThreads { get; set; }
/// <summary>
/// Native GpuMemoryBuffers
/// Native GpuMemoryBuffers.
/// </summary>
[JsonProperty("native_gpu_memory_buffers")]
public string NativeGpuMemoryBuffers { get; set; }
/// <summary>
/// Rasterization
/// Rasterization.
/// </summary>
public string Rasterization { get; set; }
/// <summary>
/// Video Decode
/// Video Decode.
/// </summary>
[JsonProperty("video_decode")]
public string VideoDecode { get; set; }
/// <summary>
/// Video Encode
/// Video Encode.
/// </summary>
[JsonProperty("video_encode")]
public string VideoEncode { get; set; }
/// <summary>
/// VPx Video Decode
/// VPx Video Decode.
/// </summary>
[JsonProperty("vpx_decode")]
public string VpxDecode { get; set; }
/// <summary>
/// WebGL
/// WebGL.
/// </summary>
public string Webgl { get; set; }
/// <summary>
/// WebGL2
/// WebGL2.
/// </summary>
public string Webgl2 { get; set; }
}

View File

@@ -1,23 +0,0 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
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
}
}

View File

@@ -0,0 +1,16 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Interface to use Electrons PostData Object
/// </summary>
public interface IPostData
{
/// <summary>
/// One of the following:
/// rawData - <see cref="UploadRawData"/> The data is available as a Buffer, in the rawData field.
/// file - <see cref="UploadFile"/> The object represents a file. The filePath, offset, length and modificationTime fields will be used to describe the file.
/// blob - <see cref="Blob"/> The object represents a Blob. The blobUUID field will be used to describe the Blob.
/// </summary>
public string Type { get; }
}
}

View File

@@ -1,8 +1,7 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API
namespace ElectronNET.API.Entities
{
/// <summary>
///
@@ -25,4 +24,4 @@ namespace ElectronNET.API
[JsonConverter(typeof(StringEnumConverter))]
public JumpListCategoryType Type { get; set; }
}
}
}

View File

@@ -1,4 +1,4 @@
namespace ElectronNET.API
namespace ElectronNET.API.Entities
{
/// <summary>
///

View File

@@ -6,13 +6,16 @@
public class JumpListSettings
{
/// <summary>
/// The minimum number of items that will be shown in the Jump List (for a more detailed description of this value see the MSDN docs).
/// The minimum number of items that will be shown in the Jump List (for a more detailed description of this value see the
/// <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx">MSDN</see> docs).
/// </summary>
public int MinItems { get; set; } = 0;
/// <summary>
/// Array of JumpListItem objects that correspond to items that the user has explicitly removed from custom categories in the Jump List. These items must not be re-added to the Jump List in the next call to app.setJumpList(), Windows will not display any custom category that contains any of the removed items.
/// Array of JumpListItem objects that correspond to items that the user has explicitly removed from custom categories
/// in the Jump List. These items must not be re-added to the Jump List in the next call to <see cref="App.SetJumpList"/>, Windows will
/// not display any custom category that contains any of the removed items.
/// </summary>
public JumpListItem[] RemovedItems { get; set; } = new JumpListItem[0];
}
}
}

View File

@@ -21,5 +21,16 @@
/// files.
/// </summary>
public string BaseURLForDataURL { get; set; }
/// <summary>
/// Extra headers for the request.
/// </summary>
public string ExtraHeaders { get; set; }
/// <summary>
/// PostData Object for the request.
/// Can be <see cref="UploadRawData"/>, <see cref="UploadFile"/> or <see cref="Blob"/>
/// </summary>
public IPostData[] PostData { get; set; }
}
}

View File

@@ -6,33 +6,33 @@
public class LoginItemSettings
{
/// <summary>
/// true if the app is set to open at login.
/// <see langword="true"/> if the app is set to open at login.
/// </summary>
public bool OpenAtLogin { get; set; }
/// <summary>
/// true if the app is set to open as hidden at login. This setting is only
/// supported on macOS.
/// <see langword="true"/> if the app is set to open as hidden at login. This setting is not available
/// on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool OpenAsHidden { get; set; }
/// <summary>
/// true if the app was opened at login automatically. This setting is only
/// supported on macOS.
/// <see langword="true"/> if the app was opened at login automatically. This setting is not available
/// on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool WasOpenedAtLogin { get; set; }
/// <summary>
/// true if the app was opened as a hidden login item. This indicates that the app
/// should not open any windows at startup.This setting is only supported on macOS.
/// <see langword="true"/> if the app was opened as a hidden login item. This indicates that the app should not
/// open any windows at startup. This setting is not available on
/// <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool WasOpenedAsHidden { get; set; }
/// <summary>
/// true if the app was opened as a login item that should restore the state from
/// the previous session.This indicates that the app should restore the windows
/// that were open the last time the app was closed.This setting is only supported
/// on macOS.
/// <see langword="true"/> if the app was opened as a login item that should restore the state from the previous
/// session. This indicates that the app should restore the windows that were open the last time the app was closed.
/// This setting is not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool RestoreState { get; set; }
}

View File

@@ -6,16 +6,15 @@
public class LoginSettings
{
/// <summary>
/// true to open the app at login, false to remove the app as a login item. Defaults
/// to false.
/// <see langword="true"/> to open the app at login, <see langword="false"/> to remove the app as a login item.
/// Defaults to <see langword="false"/>.
/// </summary>
public bool OpenAtLogin { get; set; }
/// <summary>
/// true to open the app as hidden. Defaults to false. The user can edit this
/// setting from the System Preferences so
/// app.getLoginItemStatus().wasOpenedAsHidden should be checked when the app is
/// opened to know the current value.This setting is only supported on macOS.
/// <see langword="true"/> to open the app as hidden. Defaults to <see langword="false"/>. The user can edit this
/// setting from the System Preferences so app.getLoginItemSettings().wasOpenedAsHidden should be checked when the app is
/// opened to know the current value. This setting is not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
/// </summary>
public bool OpenAsHidden { get; set; }

View File

@@ -6,31 +6,19 @@
public class MemoryInfo
{
/// <summary>
/// The maximum amount of memory that has ever been pinned to actual physical RAM.
/// On macOS its value will always be 0.
/// The amount of memory currently pinned to actual physical RAM.
/// </summary>
public int PeakWorkingSetSize { get; set; }
public int WorkingSetSize { get; set; }
/// <summary>
/// Process id of the process.
/// The maximum amount of memory that has ever been pinned to actual physical RAM.
/// </summary>
public int Pid { get; set; }
public int PeakWorkingSetSize { get; set; }
/// <summary>
/// The amount of memory not shared by other processes, such as JS heap or HTML
/// content.
/// </summary>
public int PrivateBytes { get; set; }
/// <summary>
/// The amount of memory shared between processes, typically memory consumed by the
/// Electron code itself
/// </summary>
public int SharedBytes { get; set; }
/// <summary>
/// The amount of memory currently pinned to actual physical RAM.
/// </summary>
public int WorkingSetSize {get; set; }
}
}
}

View File

@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
@@ -68,12 +69,12 @@ namespace ElectronNET.API.Entities
/// <summary>
/// If false, the menu item will be greyed out and unclickable.
/// </summary>
public bool Enabled { get; set; }
public bool Enabled { get; set; } = true;
/// <summary>
/// If false, the menu item will be entirely hidden.
/// </summary>
public bool Visible { get; set; }
public bool Visible { get; set; } = true;
/// <summary>
/// Should only be specified for checkbox or radio type menu items.

View File

@@ -8,7 +8,7 @@
/// <summary>
/// The undo
/// </summary>
undo,
undo = 1,
/// <summary>
/// The redo

View File

@@ -1,109 +1,453 @@
namespace ElectronNET.API.Entities
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
// TODO: Need some of real code :)
/// <summary>
///
/// Native Image handler for Electron.NET
/// </summary>
[JsonConverter(typeof(NativeImageJsonConverter))]
public class NativeImage
{
// public static NativeImage CreateEmpty()
// {
// throw new NotImplementedException();
// }
private readonly Dictionary<float, Image> _images = new Dictionary<float, Image>();
private bool _isTemplateImage;
// public static NativeImage CreateFromBuffer(byte[] buffer)
// {
// throw new NotImplementedException();
// }
private static readonly Dictionary<string, float> ScaleFactorPairs = new Dictionary<string, float>
{
{"@2x", 2.0f}, {"@3x", 3.0f}, {"@1x", 1.0f}, {"@4x", 4.0f},
{"@5x", 5.0f}, {"@1.25x", 1.25f}, {"@1.33x", 1.33f}, {"@1.4x", 1.4f},
{"@1.5x", 1.5f}, {"@1.8x", 1.8f}, {"@2.5x", 2.5f}
};
// public static NativeImage CreateFromBuffer(byte[] buffer, CreateFromBufferOptions options)
// {
// throw new NotImplementedException();
// }
private static float? ExtractDpiFromFilePath(string filePath)
{
var withoutExtension = Path.GetFileNameWithoutExtension(filePath);
return ScaleFactorPairs
.Where(p => withoutExtension.EndsWith(p.Key))
.Select(p => p.Value)
.FirstOrDefault();
}
private static Image BytesToImage(byte[] bytes)
{
var ms = new MemoryStream(bytes);
return Image.FromStream(ms);
}
// public static NativeImage CreateFromDataURL(string dataURL)
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Creates an empty NativeImage
/// </summary>
public static NativeImage CreateEmpty()
{
return new NativeImage();
}
// public static NativeImage CreateFromPath(string path)
// {
// throw new NotImplementedException();
// }
/// <summary>
///
/// </summary>
public static NativeImage CreateFromBitmap(Bitmap bitmap, CreateFromBitmapOptions options = null)
{
if (options is null)
{
options = new CreateFromBitmapOptions();
}
// public void AddRepresentation(AddRepresentationOptions options)
// {
// throw new NotImplementedException();
// }
return new NativeImage(bitmap, options.ScaleFactor);
}
// public NativeImage Crop(Rectangle rect)
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Creates a NativeImage from a byte array.
/// </summary>
public static NativeImage CreateFromBuffer(byte[] buffer, CreateFromBufferOptions options = null)
{
if (options is null)
{
options = new CreateFromBufferOptions();
}
// public int GetAspectRatio()
// {
// throw new NotImplementedException();
// }
var ms = new MemoryStream(buffer);
var image = Image.FromStream(ms);
// public byte[] GetBitmap()
// {
// throw new NotImplementedException();
// }
return new NativeImage(image, options.ScaleFactor);
}
// public byte[] GetBitmap(BitmapOptions options)
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Creates a NativeImage from a base64 encoded data URL.
/// </summary>
/// <param name="dataUrl">A data URL with a base64 encoded image.</param>
public static NativeImage CreateFromDataURL(string dataUrl)
{
var images = new Dictionary<float,Image>();
var parsedDataUrl = Regex.Match(dataUrl, @"data:image/(?<type>.+?),(?<data>.+)");
var actualData = parsedDataUrl.Groups["data"].Value;
var binData = Convert.FromBase64String(actualData);
// public byte[] GetNativeHandle()
// {
// throw new NotImplementedException();
// }
var image = BytesToImage(binData);
// public Size GetSize()
// {
// throw new NotImplementedException();
// }
images.Add(1.0f, image);
// public bool IsEmpty()
// {
// throw new NotImplementedException();
// }
return new NativeImage(images);
}
// public bool IsTemplateImage()
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Creates a NativeImage from an image on the disk.
/// </summary>
/// <param name="path">The path of the image</param>
public static NativeImage CreateFromPath(string path)
{
var images = new Dictionary<float,Image>();
if (Regex.IsMatch(path, "(@.+?x)"))
{
var dpi = ExtractDpiFromFilePath(path);
if (dpi == null)
{
throw new Exception($"Invalid scaling factor for '{path}'.");
}
// public NativeImage Resize(ResizeOptions options)
// {
// throw new NotImplementedException();
// }
images[dpi.Value] = Image.FromFile(path);
}
else
{
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
var extension = Path.GetExtension(path);
// Load as 1x dpi
images[1.0f] = Image.FromFile(path);
// public void SetTemplateImage(bool option)
// {
// throw new NotImplementedException();
// }
foreach (var scale in ScaleFactorPairs)
{
var fileName = $"{fileNameWithoutExtension}{scale}.{extension}";
if (File.Exists(fileName))
{
var dpi = ExtractDpiFromFilePath(fileName);
if (dpi != null)
{
images[dpi.Value] = Image.FromFile(fileName);
}
}
}
}
// public byte[] ToBitmap(ToBitmapOptions options)
// {
// throw new NotImplementedException();
// }
return new NativeImage(images);
}
// public string ToDataURL(ToDataURLOptions options)
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Creates an empty NativeImage
/// </summary>
public NativeImage()
{
}
// public byte[] ToJPEG(int quality)
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Creates a NativeImage from a bitmap and scale factor
/// </summary>
public NativeImage(Image bitmap, float scaleFactor = 1.0f)
{
_images.Add(scaleFactor, bitmap);
}
// public byte[] ToPNG(ToPNGOptions options)
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Creates a NativeImage from a dictionary of scales and images.
/// </summary>
public NativeImage(Dictionary<float, Image> imageDictionary)
{
_images = imageDictionary;
}
/// <summary>
/// Crops the image specified by the input rectangle and computes scale factor
/// </summary>
public NativeImage Crop(Rectangle rect)
{
var images = new Dictionary<float,Image>();
foreach (var image in _images)
{
images.Add(image.Key, Crop(rect.X, rect.Y, rect.Width, rect.Height, image.Key));
}
return new NativeImage(images);
}
/// <summary>
/// Resizes the image and computes scale factor
/// </summary>
public NativeImage Resize(ResizeOptions options)
{
var images = new Dictionary<float, Image>();
foreach (var image in _images)
{
images.Add(image.Key, Resize(options.Width, options.Height, image.Key));
}
return new NativeImage(images);
}
/// <summary>
/// Add an image representation for a specific scale factor.
/// </summary>
/// <param name="options"></param>
public void AddRepresentation(AddRepresentationOptions options)
{
if (options.Buffer.Length > 0)
{
_images[options.ScaleFactor] =
CreateFromBuffer(options.Buffer, new CreateFromBufferOptions {ScaleFactor = options.ScaleFactor})
.GetScale(options.ScaleFactor);
}
else if (!string.IsNullOrEmpty(options.DataUrl))
{
_images[options.ScaleFactor] = CreateFromDataURL(options.DataUrl).GetScale(options.ScaleFactor);
}
}
/// <summary>
/// Gets the aspect ratio for the image based on scale factor
/// </summary>
/// <param name="scaleFactor">Optional</param>
public float GetAspectRatio(float scaleFactor = 1.0f)
{
var image = GetScale(scaleFactor);
if (image != null)
{
return image.Width / image.Height;
}
return 0f;
}
/// <summary>
/// Returns a byte array that contains the image's raw bitmap pixel data.
/// </summary>
public byte[] GetBitmap(BitmapOptions options)
{
return ToBitmap(new ToBitmapOptions{ ScaleFactor = options.ScaleFactor });
}
/// <summary>
/// Returns a byte array that contains the image's raw bitmap pixel data.
/// </summary>
public byte[] GetNativeHandle()
{
return ToBitmap(new ToBitmapOptions());
}
/// <summary>
/// Gets the size of the specified image based on scale factor
/// </summary>
public Size GetSize(float scaleFactor = 1.0f)
{
if (_images.ContainsKey(scaleFactor))
{
var image = _images[scaleFactor];
return new Size
{
Width = image.Width,
Height = image.Height
};
}
return null;
}
/// <summary>
/// Checks to see if the NativeImage instance is empty.
/// </summary>
public bool IsEmpty()
{
return _images.Count <= 0;
}
/// <summary>
/// Deprecated. Whether the image is a template image.
/// </summary>
public bool IsTemplateImage => _isTemplateImage;
/// <summary>
/// Deprecated. Marks the image as a template image.
/// </summary>
public void SetTemplateImage(bool option)
{
_isTemplateImage = option;
}
/// <summary>
/// Outputs a bitmap based on the scale factor
/// </summary>
public byte[] ToBitmap(ToBitmapOptions options)
{
return ImageToBytes(ImageFormat.Bmp, options.ScaleFactor);
}
/// <summary>
/// Outputs a data URL based on the scale factor
/// </summary>
public string ToDataURL(ToDataUrlOptions options)
{
if (!_images.ContainsKey(options.ScaleFactor))
{
return null;
}
var image = _images[options.ScaleFactor];
var mimeType = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == image.RawFormat.Guid)?.MimeType;
if (mimeType is null)
{
mimeType = "image/png";
}
var bytes = ImageToBytes(image.RawFormat, options.ScaleFactor);
var base64 = Convert.ToBase64String(bytes);
return $"data:{mimeType};base64,{base64}";
}
/// <summary>
/// Outputs a JPEG for the default scale factor
/// </summary>
public byte[] ToJPEG(int quality)
{
return ImageToBytes(ImageFormat.Jpeg, 1.0f, quality);
}
/// <summary>
/// Outputs a PNG for the specified scale factor
/// </summary>
public byte[] ToPNG(ToPNGOptions options)
{
return ImageToBytes(ImageFormat.Png, options.ScaleFactor);
}
private byte[] ImageToBytes(ImageFormat imageFormat = null, float scaleFactor = 1.0f, int quality = 100)
{
using var ms = new MemoryStream();
if (_images.ContainsKey(scaleFactor))
{
var image = _images[scaleFactor];
var encoderCodecInfo = GetEncoder(imageFormat ?? image.RawFormat);
var encoder = Encoder.Quality;
var encoderParameters = new EncoderParameters(1)
{
Param = new[]
{
new EncoderParameter(encoder, quality)
}
};
image.Save(ms, encoderCodecInfo, encoderParameters);
return ms.ToArray();
}
return null;
}
private Image Resize(int? width, int? height, float scaleFactor = 1.0f)
{
if (!_images.ContainsKey(scaleFactor) || (width is null && height is null))
{
return null;
}
var image = _images[scaleFactor];
using (var g = Graphics.FromImage(image))
{
g.CompositingQuality = CompositingQuality.HighQuality;
var aspect = GetAspectRatio(scaleFactor);
width ??= Convert.ToInt32(image.Width * aspect);
height ??= Convert.ToInt32(image.Height * aspect);
width = Convert.ToInt32(width * scaleFactor);
height = Convert.ToInt32(height * scaleFactor);
var bmp = new Bitmap(width.Value, height.Value);
g.DrawImage(bmp,
new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
GraphicsUnit.Pixel);
return bmp;
}
}
private Image Crop(int? x, int? y, int? width, int? height, float scaleFactor = 1.0f)
{
if (!_images.ContainsKey(scaleFactor))
{
return null;
}
var image = _images[scaleFactor];
using (var g = Graphics.FromImage(image))
{
g.CompositingQuality = CompositingQuality.HighQuality;
x ??= 0;
y ??= 0;
x = Convert.ToInt32(x * scaleFactor);
y = Convert.ToInt32(y * scaleFactor);
width ??= image.Width;
height ??= image.Height;
width = Convert.ToInt32(width * scaleFactor);
height = Convert.ToInt32(height * scaleFactor);
var bmp = new Bitmap(width.Value, height.Value);
g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, image.Width, image.Height), new System.Drawing.Rectangle(x.Value, y.Value, width.Value, height.Value), GraphicsUnit.Pixel);
return bmp;
}
}
private ImageCodecInfo GetEncoder(ImageFormat format)
{
var codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
internal Dictionary<float,string> GetAllScaledImages()
{
var dict = new Dictionary<float,string>();
try
{
foreach (var (scale, image) in _images)
{
dict.Add(scale, Convert.ToBase64String(ImageToBytes(null, scale)));
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
return dict;
}
internal Image GetScale(float scaleFactor)
{
if (_images.ContainsKey(scaleFactor))
{
return _images[scaleFactor];
}
return null;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
internal class NativeImageJsonConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value is NativeImage nativeImage)
{
var scaledImages = nativeImage.GetAllScaledImages();
serializer.Serialize(writer, scaledImages);
}
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var dict = serializer.Deserialize<Dictionary<float, string>>(reader);
var newDictionary = new Dictionary<float, Image>();
foreach (var item in dict)
{
var bytes = Convert.FromBase64String(item.Value);
newDictionary.Add(item.Key, Image.FromStream(new MemoryStream(bytes)));
}
return new NativeImage(newDictionary);
}
public override bool CanConvert(Type objectType) => objectType == typeof(NativeImage);
}
}

View File

@@ -10,28 +10,28 @@ namespace ElectronNET.API.Entities
{
/// <summary>
/// A title for the notification, which will be shown at the top of the notification
/// window when it is shown
/// window when it is shown.
/// </summary>
public string Title { get; set; }
/// <summary>
/// A subtitle for the notification, which will be displayed below the title.
/// </summary>
public string SubTitle { get; set; }
/// <summary>
/// The body text of the notification, which will be displayed below the title or
/// subtitle
/// subtitle.
/// </summary>
public string Body { get; set; }
/// <summary>
/// A subtitle for the notification, which will be displayed below the title.
/// </summary>
public string Subtitle { get; set; }
/// <summary>
/// Whether or not to emit an OS notification noise when showing the notification
/// Whether or not to emit an OS notification noise when showing the notification.
/// </summary>
public bool Silent { get; set; }
/// <summary>
/// An icon to use in the notification
/// An icon to use in the notification.
/// </summary>
public string Icon { get; set; }
@@ -40,6 +40,11 @@ namespace ElectronNET.API.Entities
/// </summary>
public bool HasReply { get; set; }
/// <summary>
/// The timeout duration of the notification. Can be 'default' or 'never'.
/// </summary>
public string TimeoutType { get; set; }
/// <summary>
/// The placeholder to write in the inline reply input field.
/// </summary>
@@ -50,16 +55,27 @@ namespace ElectronNET.API.Entities
/// </summary>
public string Sound { get; set; }
/// <summary>
/// The urgency level of the notification. Can be 'normal', 'critical', or 'low'.
/// </summary>
public string Urgency { get; set; }
/// <summary>
/// Actions to add to the notification. Please read the available actions and
/// limitations in the NotificationAction documentation
/// 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.
/// A custom title for the close button of an alert. An empty string will cause the
/// default localized text to be used.
/// </summary>
public string CloseButtonText { 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; }
@@ -148,4 +164,4 @@ namespace ElectronNET.API.Entities
Body = body;
}
}
}
}

View File

@@ -1,16 +1,22 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// Controls the behavior of OpenExternal.
/// </summary>
public class OpenExternalOptions
{
/// <summary>
/// true to bring the opened application to the foreground. The default is true.
/// <see langword="true"/> to bring the opened application to the foreground. The default is <see langword="true"/>.
/// </summary>
[DefaultValue(true)]
public bool Activate { get; set; } = true;
/// <summary>
/// The working directory.
/// </summary>
public string WorkingDirectory { get; set; }
}
}

View File

@@ -1,79 +1,95 @@
namespace ElectronNET.API.Entities
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// Defines the PathName enumeration.
/// </summary>
public enum PathName
{
/// <summary>
/// Users home directory.
/// </summary>
home,
[Description("home")]
Home,
/// <summary>
/// Per-user application data directory.
/// </summary>
appData,
[Description("appData")]
AppData,
/// <summary>
/// The directory for storing your apps configuration files,
/// which by default it is the appData directory appended with your apps name.
/// </summary>
userData,
[Description("userData")]
UserData,
/// <summary>
/// Temporary directory.
/// </summary>
temp,
[Description("temp")]
Temp,
/// <summary>
/// The current executable file.
/// </summary>
exe,
[Description("exe")]
Exe,
/// <summary>
/// The libchromiumcontent library.
/// </summary>
module,
[Description("Module")]
Module,
/// <summary>
/// The current users Desktop directory.
/// </summary>
desktop,
[Description("desktop")]
Desktop,
/// <summary>
/// Directory for a users “My Documents”.
/// </summary>
documents,
[Description("documents")]
Documents,
/// <summary>
/// Directory for a users downloads.
/// </summary>
downloads,
[Description("downloads")]
Downloads,
/// <summary>
/// Directory for a users music.
/// </summary>
music,
[Description("music")]
Music,
/// <summary>
/// Directory for a users pictures.
/// </summary>
pictures,
[Description("pictures")]
Pictures,
/// <summary>
/// Directory for a users videos.
/// </summary>
videos,
[Description("videos")]
Videos,
/// <summary>
/// The logs
/// The logs.
/// </summary>
logs,
[Description("logs")]
Logs,
/// <summary>
/// Full path to the system version of the Pepper Flash plugin.
/// </summary>
pepperFlashSystemPlugin
[Description("PepperFlashSystemPlugin")]
PepperFlashSystemPlugin
}
}

View File

@@ -0,0 +1,107 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Print dpi
/// </summary>
public class PrintDpi
{
/// <summary>
/// The horizontal dpi
/// </summary>
public float Horizontal { get; set; }
/// <summary>
/// The vertical dpi
/// </summary>
public float Vertical { get; set; }
}
/// <summary>
/// The page range to print
/// </summary>
public class PrintPageRange
{
/// <summary>
/// From
/// </summary>
public int From { get; set; }
/// <summary>
/// To
/// </summary>
public int To { get; set; }
}
/// <summary>
/// Print options
/// </summary>
public class PrintOptions
{
/// <summary>
/// Don't ask user for print settings
/// </summary>
public bool Silent { get; set; }
/// <summary>
/// Prints the background color and image of the web page
/// </summary>
public bool PrintBackground { get; set; }
/// <summary>
/// Set the printer device name to use
/// </summary>
public string DeviceName { get; set; }
/// <summary>
/// Set whether the printed web page will be in color or grayscale
/// </summary>
public bool Color { get; set; }
/// <summary>
/// Specifies the type of margins to use. Uses 0 for default margin, 1 for no
/// margin, and 2 for minimum margin.
/// </summary>
public int MarginsType { get; set; }
/// <summary>
/// true for landscape, false for portrait.
/// </summary>
public bool Landscape { get; set; }
/// <summary>
/// The scale factor of the web page
/// </summary>
public float ScaleFactor { get; set; }
/// <summary>
/// The number of pages to print per page sheet
/// </summary>
public int PagesPerSheet { get; set; }
/// <summary>
/// The number of copies of the web page to print
/// </summary>
public bool Copies { get; set; }
/// <summary>
/// Whether the web page should be collated
/// </summary>
public bool Collate { get; set; }
/// <summary>
/// The page range to print
/// </summary>
public PrintPageRange PageRanges { get; set; }
/// <summary>
/// Set the duplex mode of the printed web page. Can be simplex, shortEdge, or longEdge.
/// </summary>
public string DuplexMode { get; set; }
/// <summary>
/// Dpi
/// </summary>
public PrintDpi Dpi { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Printer info
/// </summary>
public class PrinterInfo
{
/// <summary>
/// Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Name
/// </summary>
public string Description { get; set; }
/// <summary>
/// Status
/// </summary>
public int Status { get; set; }
/// <summary>
/// Is default
/// </summary>
public bool IsDefault { get; set; }
}
}

View File

@@ -5,24 +5,42 @@
/// </summary>
public class ProcessMetric
{
/// <summary>
/// CPU usage of the process.
/// </summary>
public CPUUsage Cpu { get; set; }
/// <summary>
/// Process id of the process.
/// </summary>
public int PId { get; set; }
/// <summary>
/// Memory information for the process.
/// </summary>
public MemoryInfo Memory {get; set;}
/// <summary>
/// Process type (Browser or Tab or GPU etc).
/// </summary>
public string Type { get; set; }
/// <summary>
/// Process id of the process.
/// </summary>
public int Pid { get; set; }
/// <summary>
/// CPU usage of the process.
/// </summary>
public CPUUsage Cpu { get; set; }
/// <summary>
/// Process type (Browser or Tab or GPU etc).
/// </summary>
public string Type { get; set; }
/// <summary>
/// Creation time for this process. The time is represented as number of milliseconds since epoch.
/// Since the <see cref="PId"/> can be reused after a process dies, it is useful to use both the <see cref="PId"/>
/// and the <see cref="CreationTime"/> to uniquely identify a process.
/// </summary>
public int CreationTime { get; set; }
/// <summary>
/// Memory information for the process.
/// </summary>
public MemoryInfo Memory { get; set; }
/// <summary>
/// Whether the process is sandboxed on OS level.
/// </summary>
public bool Sandboxed { get; set; }
/// <summary>
/// One of the following values:
/// untrusted | low | medium | high | unknown
/// </summary>
public string IntegrityLevel { get; set; }
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ProgressInfo
{
/// <summary>
///
/// </summary>
public string Progress { get; set; }
/// <summary>
///
/// </summary>
public string BytesPerSecond { get; set; }
/// <summary>
///
/// </summary>
public string Percent { get; set; }
/// <summary>
///
/// </summary>
public string Total { get; set; }
/// <summary>
///
/// </summary>
public string Transferred { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ProxyConfig
{
/// <summary>
/// The URL associated with the PAC file.
/// </summary>
public string PacScript { get; set; }
/// <summary>
/// Rules indicating which proxies to use.
/// </summary>
public string ProxyRules { get; set; }
/// <summary>
/// Rules indicating which URLs should bypass the proxy settings.
/// </summary>
public string ProxyBypassRules { get; set; }
/// <summary>
///
/// </summary>
/// <param name="pacScript">The URL associated with the PAC file.</param>
/// <param name="proxyRules">Rules indicating which proxies to use.</param>
/// <param name="proxyBypassRules">Rules indicating which URLs should bypass the proxy settings.</param>
public ProxyConfig(string pacScript, string proxyRules, string proxyBypassRules)
{
PacScript = pacScript;
ProxyRules = proxyRules;
ProxyBypassRules = proxyBypassRules;
}
}
}

View File

@@ -1,7 +1,7 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// Controls the behavior of <see cref="App.Relaunch(RelaunchOptions)"/>.
/// </summary>
public class RelaunchOptions
{
@@ -21,4 +21,4 @@
/// </value>
public string ExecPath { get; set; }
}
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ReleaseNoteInfo
{
/// <summary>
/// The version.
/// </summary>
public string Version { get; set; }
/// <summary>
/// The note.
/// </summary>
public string Note { get; set; }
}
}

View File

@@ -0,0 +1,53 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class RemovePassword
{
/// <summary>
/// When provided, the authentication info related to the origin will only be
/// removed otherwise the entire cache will be cleared.
/// </summary>
public string Origin { get; set; }
/// <summary>
/// Credentials of the authentication. Must be provided if removing by origin.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Realm of the authentication. Must be provided if removing by origin.
/// </summary>
public string Realm { get; set; }
/// <summary>
/// Scheme of the authentication. Can be basic, digest, ntlm, negotiate.
/// Must be provided if removing by origin.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public Scheme Scheme { get; set; }
/// <summary>
/// password.
/// </summary>
public string Type { get; set; }
/// <summary>
/// Credentials of the authentication. Must be provided if removing by origin.
/// </summary>
public string Username { get; set; }
/// <summary>
///
/// </summary>
/// <param name="type">password.</param>
public RemovePassword(string type)
{
Type = type;
}
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ResizeOptions
{
/// <summary>
/// Gets or sets the width
/// </summary>
public int? Width { get; set; }
/// <summary>
/// Gets or sets the height
/// </summary>
public int? Height { get; set; }
/// <summary>
/// good, better, or best. Default is "best";
/// </summary>
public string Quality { get; set; } = "best";
}
}

View File

@@ -0,0 +1,28 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public enum Scheme
{
/// <summary>
///
/// </summary>
basic,
/// <summary>
///
/// </summary>
digest,
/// <summary>
///
/// </summary>
ntlm,
/// <summary>
///
/// </summary>
negotiate
}
}

View File

@@ -0,0 +1,59 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class SemVer
{
/// <summary>
///
/// </summary>
public string Raw { get; set; }
/// <summary>
///
/// </summary>
public bool Loose { get; set; }
/// <summary>
///
/// </summary>
public SemVerOptions Options { get; set; }
/// <summary>
///
/// </summary>
public int Major { get; set; }
/// <summary>
///
/// </summary>
public int Minor { get; set; }
/// <summary>
///
/// </summary>
public int Patch { get; set; }
/// <summary>
///
/// </summary>
public string Version { get; set; }
/// <summary>
///
/// </summary>
public string[] Build { get; set; }
/// <summary>
///
/// </summary>
public string[] Prerelease { get; set; }
}
/// <summary>
///
/// </summary>
public class SemVerOptions {
/// <summary>
///
/// </summary>
public bool? Loose { get; set; }
/// <summary>
///
/// </summary>
public bool? IncludePrerelease { get; set; }
}
}

View File

@@ -1,38 +1,38 @@
namespace ElectronNET.API
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// Structure of a shortcut.
/// </summary>
public class ShortcutDetails
{
/// <summary>
/// The Application User Model ID. Default is empty.
/// The Application User Model ID. Default is <see cref="string.Empty"/>.
/// </summary>
public string AppUserModelId { get; set; }
/// <summary>
/// The arguments to be applied to target when launching from this shortcut. Default is empty.
/// The arguments to be applied to <see cref="Target"/> when launching from this shortcut. Default is <see cref="string.Empty"/>.
/// </summary>
public string Args { get; set; }
/// <summary>
/// The working directory. Default is empty.
/// The working directory. Default is <see cref="string.Empty"/>.
/// </summary>
public string Cwd { get; set; }
/// <summary>
/// The description of the shortcut. Default is empty.
/// The description of the shortcut. Default is <see cref="string.Empty"/>.
/// </summary>
public string Description { get; set; }
/// <summary>
/// The path to the icon, can be a DLL or EXE. icon and iconIndex have to be set
/// together.Default is empty, which uses the target's icon.
/// The path to the icon, can be a DLL or EXE. <see cref="Icon"/> and <see cref="IconIndex"/> have to be set
/// together. Default is <see cref="string.Empty"/>, which uses the target's icon.
/// </summary>
public string Icon { get; set; }
/// <summary>
/// The resource ID of icon when icon is a DLL or EXE. Default is 0.
/// The resource ID of icon when <see cref="Icon"/> is a DLL or EXE. Default is 0.
/// </summary>
public int IconIndex { get; set; }

View File

@@ -1,23 +1,28 @@
namespace ElectronNET.API
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// Defines the ShortcutLinkOperation enumeration.
/// </summary>
public enum ShortcutLinkOperation
{
/// <summary>
/// Creates a new shortcut, overwriting if necessary.
/// </summary>
create,
[Description("create")]
Create,
/// <summary>
/// Updates specified properties only on an existing shortcut.
/// </summary>
update,
[Description("update")]
Update,
/// <summary>
/// Overwrites an existing shortcut, fails if the shortcut doesnt exist.
/// Overwrites an existing shortcut, fails if the shortcut doesn't exist.
/// </summary>
replace
[Description("replace")]
Replace
}
}
}

View File

@@ -0,0 +1,28 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Defines the ThemeSourceMode enumeration.
/// </summary>
public enum ThemeSourceMode
{
/// <summary>
/// Operating system default.
/// </summary>
[Description("system")]
System,
/// <summary>
/// Light theme.
/// </summary>
[Description("light")]
Light,
/// <summary>
/// Dark theme.
/// </summary>
[Description("dark")]
Dark
}
}

View File

@@ -0,0 +1,13 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ToBitmapOptions
{
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,13 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ToDataUrlOptions
{
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,13 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class ToPNGOptions
{
/// <summary>
/// Gets or sets the scalefactor
/// </summary>
public float ScaleFactor { get; set; } = 1.0f;
}
}

View File

@@ -0,0 +1,29 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UpdateCancellationToken
{
/// <summary>
///
/// </summary>
public bool Cancelled { get; set; }
/// <summary>
///
/// </summary>
public void Cancel()
{
}
/// <summary>
///
/// </summary>
public void Dispose()
{
}
}
}

View File

@@ -0,0 +1,23 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UpdateCheckResult
{
/// <summary>
///
/// </summary>
public UpdateInfo UpdateInfo { get; set; } = new UpdateInfo();
/// <summary>
///
/// </summary>
public string[] Download { get; set; }
/// <summary>
///
/// </summary>
public UpdateCancellationToken CancellationToken { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UpdateFileInfo : BlockMapDataHolder
{
/// <summary>
///
/// </summary>
public string Url { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UpdateInfo
{
/// <summary>
/// The version.
/// </summary>
public string Version { get; set; }
/// <summary>
///
/// </summary>
public UpdateFileInfo[] Files { get; set; } = new UpdateFileInfo[0];
/// <summary>
/// The release name.
/// </summary>
public string ReleaseName { get; set; }
/// <summary>
/// The release notes.
/// </summary>
public ReleaseNoteInfo[] ReleaseNotes { get; set; } = new ReleaseNoteInfo[0];
/// <summary>
///
/// </summary>
public string ReleaseDate { get; set; }
/// <summary>
/// The staged rollout percentage, 0-100.
/// </summary>
public int StagingPercentage { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UploadFile : IPostData
{
/// <summary>
/// The object represents a file.
/// </summary>
public string Type { get; } = "file";
/// <summary>
/// The path of the file being uploaded.
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// The offset from the beginning of the file being uploaded, in bytes. Defaults to 0.
/// </summary>
public long Offset { get; set; } = 0;
/// <summary>
/// The length of the file being uploaded, <see cref="Offset"/>. Defaults to 0.
/// If set to -1, the whole file will be uploaded.
/// </summary>
public long Length { get; set; } = 0;
/// <summary>
/// The modification time of the file represented by a double, which is the number of seconds since the UNIX Epoch (Jan 1, 1970)
/// </summary>
public double ModificationTime { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UploadRawData : IPostData
{
/// <summary>
/// The data is available as a Buffer, in the rawData field.
/// </summary>
public string Type { get; } = "rawData";
/// <summary>
/// The raw bytes of the post data in a Buffer.
/// </summary>
public byte[] Bytes { get; set; }
}
}

View File

@@ -52,5 +52,10 @@
/// The title.
/// </value>
public string Title { get; set; }
/// <summary>
/// The working directory. Default is <see cref="string.Empty"/>.
/// </summary>
public string WorkingDirectory { get; set; }
}
}
}

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace ElectronNET.API.Entities
{
@@ -10,7 +10,7 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The appearance based
/// </summary>
[JsonProperty("appearance-based")]
[EnumMember(Value = "appearance-based")]
appearanceBased,
/// <summary>
@@ -51,13 +51,13 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The medium light
/// </summary>
[JsonProperty("medium-light")]
[EnumMember(Value = "medium-light")]
mediumLight,
/// <summary>
/// The ultra dark
/// </summary>
[JsonProperty("ultra-dark")]
[EnumMember(Value = "ultra-dark")]
ultraDark
}
}

View File

@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
@@ -15,7 +15,7 @@ namespace ElectronNET.API.Entities
public bool DevTools { get; set; } = true;
/// <summary>
/// Whether node integration is enabled. Default is true.
/// Whether node integration is enabled. Required to enable IPC. Default is true.
/// </summary>
[DefaultValue(true)]
public bool NodeIntegration { get; set; } = true;
@@ -126,7 +126,7 @@ namespace ElectronNET.API.Entities
/// A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
/// enable.The full list of supported feature strings can be found in the file.
/// </summary>
public string BlinkFeatures { get; set; }
public string EnableBlinkFeatures { get; set; }
/// <summary>
/// A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
@@ -142,7 +142,7 @@ namespace ElectronNET.API.Entities
/// <summary>
/// Defaults to 16.
/// </summary>
public int DefaultFontSize { get; set; }
public int DefaultFontSize { get; set; } = 16;
/// <summary>
/// Defaults to 13.
@@ -173,7 +173,7 @@ namespace ElectronNET.API.Entities
/// <summary>
/// Whether to run Electron APIs and the specified preload script in a separate
/// JavaScript context.Defaults to false. The context that the preload script runs
/// JavaScript context. Defaults to false. The context that the preload script runs
/// in will still have full access to the document and window globals but it will
/// use its own set of JavaScript builtins (Array, Object, JSON, etc.) and will be
/// isolated from any changes made to the global environment by the loaded page.The
@@ -185,7 +185,8 @@ namespace ElectronNET.API.Entities
/// Context' entry in the combo box at the top of the Console tab. This option is
/// currently experimental and may change or be removed in future Electron releases.
/// </summary>
public bool ContextIsolation { get; set; }
[DefaultValue(false)]
public bool ContextIsolation { get; set; } = false;
/// <summary>
/// Whether to use native window.open(). Defaults to false. This option is currently experimental.
@@ -203,6 +204,13 @@ namespace ElectronNET.API.Entities
/// <value>
/// <c>true</c> if [webview tag]; otherwise, <c>false</c>.
/// </value>
public bool WebviewTag { get; set; }
[DefaultValue(false)]
public bool WebviewTag { get; set; } = false;
/// <summary>
/// Whether to enable the remote module. Defaults to false.
/// </summary>
[DefaultValue(false)]
public bool EnableRemoteModule { get; set; } = false;
}
}

105
ElectronNET.API/Events.cs Normal file
View File

@@ -0,0 +1,105 @@
using System;
using System.Globalization;
using Quobject.EngineIoClientDotNet.ComponentEmitter;
namespace ElectronNET.API
{
/// <summary>
/// Generic Event Consumers for Electron Modules
/// </summary>
internal class Events
{
private static Events _events;
private static object _syncRoot = new object();
private TextInfo _ti = new CultureInfo("en-US", false).TextInfo;
private Events()
{
}
public static Events Instance
{
get
{
if (_events == null)
{
lock (_syncRoot)
{
if (_events == null)
{
_events = new Events();
}
}
}
return _events;
}
}
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="fn">The event handler</param>
public void On(string moduleName, string eventName, Action fn)
=> On(moduleName, eventName, new ListenerImpl(fn));
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="fn">The event handler</param>
public void On(string moduleName, string eventName, Action<object> fn)
=> On(moduleName, eventName, new ListenerImpl(fn));
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="fn">The event handler</param>
private void On(string moduleName, string eventName, IListener fn)
{
var listener = $"{moduleName}{_ti.ToTitleCase(eventName)}Completed";
var subscriber = $"register-{moduleName}-on-event";
BridgeConnector.Socket.On(listener, fn);
BridgeConnector.Socket.Emit(subscriber, eventName, listener);
}
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="fn">The event handler</param>
public void Once(string moduleName, string eventName, Action fn)
=> Once(moduleName, eventName, new ListenerImpl(fn));
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="fn">The event handler</param>
public void Once(string moduleName, string eventName, Action<object> fn)
=> Once(moduleName, eventName, new ListenerImpl(fn));
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="fn">The event handler</param>
private void Once(string moduleName, string eventName, IListener fn)
{
var listener = $"{moduleName}{_ti.ToTitleCase(eventName)}Completed";
var subscriber = $"register-{moduleName}-once-event";
BridgeConnector.Socket.Once(listener, fn);
BridgeConnector.Socket.Emit(subscriber, eventName, listener);
}
}
}

View File

@@ -48,5 +48,24 @@ namespace ElectronNET.API.Extensions
return result;
}
public static MenuItem[] AddSubmenuTypes(this MenuItem[] menuItems)
{
for (int index = 0; index < menuItems.Length; index++)
{
var menuItem = menuItems[index];
if (menuItem?.Submenu?.Length > 0)
{
if(menuItem.Type == MenuType.normal)
{
menuItem.Type = MenuType.submenu;
}
AddSubmenuTypes(menuItem.Submenu);
}
}
return menuItems;
}
}
}

View File

@@ -10,7 +10,7 @@ namespace ElectronNET.API
public sealed class GlobalShortcut
{
private static GlobalShortcut _globalShortcut;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
internal GlobalShortcut() { }

128
ElectronNET.API/HostHook.cs Normal file
View File

@@ -0,0 +1,128 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Allows you to execute native JavaScript/TypeScript code from the host process.
///
/// It is only possible if the Electron.NET CLI has previously added an
/// ElectronHostHook directory:
/// <c>electronize add HostHook</c>
/// </summary>
public sealed class HostHook
{
private static HostHook _electronHostHook;
private static object _syncRoot = new object();
string oneCallguid = Guid.NewGuid().ToString();
internal HostHook() { }
internal static HostHook Instance
{
get
{
if (_electronHostHook == null)
{
lock (_syncRoot)
{
if (_electronHostHook == null)
{
_electronHostHook = new HostHook();
}
}
}
return _electronHostHook;
}
}
/// <summary>
/// Execute native JavaScript/TypeScript code.
/// </summary>
/// <param name="socketEventName">Socket name registered on the host.</param>
/// <param name="arguments">Optional parameters.</param>
public void Call(string socketEventName, params dynamic[] arguments)
{
BridgeConnector.Socket.On(socketEventName + "Error" + oneCallguid, (result) =>
{
BridgeConnector.Socket.Off(socketEventName + "Error" + oneCallguid);
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
});
BridgeConnector.Socket.Emit(socketEventName, arguments, oneCallguid);
}
/// <summary>
/// Execute native JavaScript/TypeScript code.
/// </summary>
/// <typeparam name="T">Results from the executed host code.</typeparam>
/// <param name="socketEventName">Socket name registered on the host.</param>
/// <param name="arguments">Optional parameters.</param>
/// <returns></returns>
public Task<T> CallAsync<T>(string socketEventName, params dynamic[] arguments)
{
var taskCompletionSource = new TaskCompletionSource<T>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On(socketEventName + "Error" + guid, (result) =>
{
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
taskCompletionSource.SetException(new Exception($"Host Hook Exception {result}"));
});
BridgeConnector.Socket.On(socketEventName + "Complete" + guid, (result) =>
{
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
BridgeConnector.Socket.Off(socketEventName + "Complete" + guid);
T data = default;
try
{
if (result.GetType().IsValueType || result is string)
{
data = (T)result;
}
else
{
var token = JToken.Parse(result.ToString());
if (token is JArray)
{
data = token.ToObject<T>();
}
else if (token is JObject)
{
data = token.ToObject<T>();
}
else
{
data = (T)result;
}
}
}
catch (Exception exception)
{
taskCompletionSource.SetException(exception);
//throw new InvalidCastException("Return value does not match with the generic type.", exception);
}
taskCompletionSource.SetResult(data);
});
BridgeConnector.Socket.Emit(socketEventName, arguments, guid);
return taskCompletionSource.Task;
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
}

View File

@@ -14,7 +14,7 @@ namespace ElectronNET.API
public sealed class IpcMain
{
private static IpcMain _ipcMain;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
internal IpcMain() { }
@@ -46,6 +46,7 @@ namespace ElectronNET.API
public void On(string channel, Action<object> listener)
{
BridgeConnector.Socket.Emit("registerIpcMainChannel", channel);
BridgeConnector.Socket.Off(channel);
BridgeConnector.Socket.On(channel, (args) =>
{
List<object> objectArray = FormatArguments(args);
@@ -152,7 +153,7 @@ namespace ElectronNET.API
{
List<JObject> jobjects = new List<JObject>();
List<JArray> jarrays = new List<JArray>();
List<Object> objects = new List<Object>();
List<object> objects = new List<object>();
foreach (var parameterObject in data)
{
@@ -178,6 +179,45 @@ namespace ElectronNET.API
}
}
/// <summary>
/// Send a message to the BrowserView renderer process asynchronously via channel, you can also send
/// arbitrary arguments. Arguments will be serialized in JSON internally and hence
/// no functions or prototype chain will be included. The renderer process handles it by
/// listening for channel with ipcRenderer module.
/// </summary>
/// <param name="browserView">BrowserView with channel.</param>
/// <param name="channel">Channelname.</param>
/// <param name="data">Arguments data.</param>
public void Send(BrowserView browserView, string channel, params object[] data)
{
List<JObject> jobjects = new List<JObject>();
List<JArray> jarrays = new List<JArray>();
List<object> objects = new List<object>();
foreach (var parameterObject in data)
{
if(parameterObject.GetType().IsArray || parameterObject.GetType().IsGenericType && parameterObject is IEnumerable)
{
jarrays.Add(JArray.FromObject(parameterObject, _jsonSerializer));
} else if(parameterObject.GetType().IsClass && !parameterObject.GetType().IsPrimitive && !(parameterObject is string))
{
jobjects.Add(JObject.FromObject(parameterObject, _jsonSerializer));
} else if(parameterObject.GetType().IsPrimitive || (parameterObject is string))
{
objects.Add(parameterObject);
}
}
if(jobjects.Count > 0 || jarrays.Count > 0)
{
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, jarrays.ToArray(), jobjects.ToArray(), objects.ToArray());
}
else
{
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, data);
}
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),

View File

@@ -0,0 +1,41 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace ElectronNET.API
{
/// <summary>
/// Base class that reports if ASP.NET Core has fully started.
/// </summary>
internal class LifetimeServiceHost : IHostedService
{
public LifetimeServiceHost(IHostApplicationLifetime lifetime)
{
lifetime.ApplicationStarted.Register(() =>
{
App.Instance.IsReady = true;
Console.WriteLine("ASP.NET Core host has fully started.");
});
}
/// <summary>
/// Triggered when the application host is ready to start the service.
/// </summary>
/// <param name="cancellationToken">Indicates that the start process has been aborted.</param>
public Task StartAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
/// <summary>
/// Triggered when the application host is performing a graceful shutdown.
/// </summary>
/// <param name="cancellationToken">Indicates that the shutdown process should no longer be graceful.</param>
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
}

View File

@@ -6,7 +6,6 @@ using System.Collections.Generic;
using ElectronNET.API.Extensions;
using System.Linq;
using System.Collections.ObjectModel;
using System;
namespace ElectronNET.API
{
@@ -16,7 +15,7 @@ namespace ElectronNET.API
public sealed class Menu
{
private static Menu _menu;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
internal Menu() { }
@@ -57,6 +56,8 @@ namespace ElectronNET.API
_menuItems.Clear();
menuItems.AddMenuItemsId();
menuItems.AddSubmenuTypes();
BridgeConnector.Socket.Emit("menu-setApplicationMenu", JArray.FromObject(menuItems, _jsonSerializer));
_menuItems.AddRange(menuItems);
@@ -83,25 +84,27 @@ namespace ElectronNET.API
/// <param name="menuItems">The menu items.</param>
public void SetContextMenu(BrowserWindow browserWindow, MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
menuItems.AddSubmenuTypes();
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
if (!_contextMenuItems.ContainsKey(browserWindow.Id))
{
menuItems.AddMenuItemsId();
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
_contextMenuItems.Add(browserWindow.Id, menuItems.ToList());
var x = _contextMenuItems.ToDictionary(kv => kv.Key, kv => kv.Value.AsReadOnly());
ContextMenuItems = new ReadOnlyDictionary<int, ReadOnlyCollection<MenuItem>>(x);
BridgeConnector.Socket.Off("contextMenuItemClicked");
BridgeConnector.Socket.On("contextMenuItemClicked", (results) =>
{
var id = ((JArray)results).First.ToString();
var browserWindowId = (int)((JArray)results).Last;
MenuItem menuItem = _contextMenuItems[browserWindowId].GetMenuItem(id);
menuItem.Click?.Invoke();
});
}
BridgeConnector.Socket.Off("contextMenuItemClicked");
BridgeConnector.Socket.On("contextMenuItemClicked", (results) =>
{
var id = ((JArray)results).First.ToString();
var browserWindowId = (int)((JArray)results).Last;
MenuItem menuItem = _contextMenuItems[browserWindowId].GetMenuItem(id);
menuItem.Click?.Invoke();
});
}
/// <summary>
@@ -116,8 +119,7 @@ namespace ElectronNET.API
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
NullValueHandling = NullValueHandling.Ignore
};
}
}

View File

@@ -0,0 +1,212 @@
using System;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
namespace ElectronNET.API
{
/// <summary>
/// Read and respond to changes in Chromium's native color theme.
/// </summary>
public sealed class NativeTheme
{
private static NativeTheme _nativeTheme;
private static object _syncRoot = new object();
internal NativeTheme() { }
internal static NativeTheme Instance
{
get
{
if (_nativeTheme == null)
{
lock (_syncRoot)
{
if (_nativeTheme == null)
{
_nativeTheme = new NativeTheme();
}
}
}
return _nativeTheme;
}
}
/// <summary>
/// Setting this property to <see cref="ThemeSourceMode.System"/> will remove the override and everything will be reset to the OS default. By default 'ThemeSource' is <see cref="ThemeSourceMode.System"/>.
/// <para/>
/// Settings this property to <see cref="ThemeSourceMode.Dark"/> will have the following effects:
/// <list type="bullet">
/// <item>
/// <description><see cref="ShouldUseDarkColorsAsync"/> will be <see langword="true"/> when accessed</description>
/// </item>
/// <item>
/// <description>Any UI Electron renders on Linux and Windows including context menus, devtools, etc. will use the dark UI.</description>
/// </item>
/// <item>
/// <description>Any UI the OS renders on macOS including menus, window frames, etc. will use the dark UI.</description>
/// </item>
/// <item>
/// <description>The 'prefers-color-scheme' CSS query will match 'dark' mode.</description>
/// </item>
/// <item>
/// <description>The 'updated' event will be emitted</description>
/// </item>
/// </list>
/// <para/>
/// Settings this property to <see cref="ThemeSourceMode.Light"/> will have the following effects:
/// <list type="bullet">
/// <item>
/// <description><see cref="ShouldUseDarkColorsAsync"/> will be <see langword="false"/> when accessed</description>
/// </item>
/// <item>
/// <description>Any UI Electron renders on Linux and Windows including context menus, devtools, etc. will use the light UI.</description>
/// </item>
/// <item>
/// <description>Any UI the OS renders on macOS including menus, window frames, etc. will use the light UI.</description>
/// </item>
/// <item>
/// <description>The 'prefers-color-scheme' CSS query will match 'light' mode.</description>
/// </item>
/// <item>
/// <description>The 'updated' event will be emitted</description>
/// </item>
/// </list>
/// The usage of this property should align with a classic "dark mode" state machine in your application where the user has three options.
/// <para/>
/// <list type="bullet">
/// <item>
/// <description>Follow OS: SetThemeSource(ThemeSourceMode.System);</description>
/// </item>
/// <item>
/// <description>Dark Mode: SetThemeSource(ThemeSourceMode.Dark);</description>
/// </item>
/// <item>
/// <description>Light Mode: SetThemeSource(ThemeSourceMode.Light);</description>
/// </item>
/// </list>
/// Your application should then always use <see cref="ShouldUseDarkColorsAsync"/> to determine what CSS to apply.
/// </summary>
/// <param name="themeSourceMode">The new ThemeSource.</param>
public void SetThemeSource(ThemeSourceMode themeSourceMode)
{
var themeSource = themeSourceMode.GetDescription();
BridgeConnector.Socket.Emit("nativeTheme-themeSource", themeSource);
}
/// <summary>
/// A <see cref="ThemeSourceMode"/> property that can be <see cref="ThemeSourceMode.System"/>, <see cref="ThemeSourceMode.Light"/> or <see cref="ThemeSourceMode.Dark"/>. It is used to override (<seealso cref="SetThemeSource"/>) and
/// supercede the value that Chromium has chosen to use internally.
/// </summary>
public Task<ThemeSourceMode> GetThemeSourceAsync()
{
var taskCompletionSource = new TaskCompletionSource<ThemeSourceMode>();
BridgeConnector.Socket.On("nativeTheme-themeSource-getCompleted", (themeSource) =>
{
BridgeConnector.Socket.Off("nativeTheme-themeSource-getCompleted");
var themeSourceValue = (ThemeSourceMode)Enum.Parse(typeof(ThemeSourceMode), (string)themeSource, true);
taskCompletionSource.SetResult(themeSourceValue);
});
BridgeConnector.Socket.Emit("nativeTheme-themeSource-get");
return taskCompletionSource.Task;
}
/// <summary>
/// A <see cref="bool"/> for if the OS / Chromium currently has a dark mode enabled or is
/// being instructed to show a dark-style UI. If you want to modify this value you
/// should use <see cref="SetThemeSource"/>.
/// </summary>
public Task<bool> ShouldUseDarkColorsAsync()
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("nativeTheme-shouldUseDarkColors-completed", (shouldUseDarkColors) => {
BridgeConnector.Socket.Off("nativeTheme-shouldUseDarkColors-completed");
taskCompletionSource.SetResult((bool)shouldUseDarkColors);
});
BridgeConnector.Socket.Emit("nativeTheme-shouldUseDarkColors");
return taskCompletionSource.Task;
}
/// <summary>
/// A <see cref="bool"/> for if the OS / Chromium currently has high-contrast mode enabled or is
/// being instructed to show a high-contrast UI.
/// </summary>
public Task<bool> ShouldUseHighContrastColorsAsync()
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("nativeTheme-shouldUseHighContrastColors-completed", (shouldUseHighContrastColors) => {
BridgeConnector.Socket.Off("nativeTheme-shouldUseHighContrastColors-completed");
taskCompletionSource.SetResult((bool)shouldUseHighContrastColors);
});
BridgeConnector.Socket.Emit("nativeTheme-shouldUseHighContrastColors");
return taskCompletionSource.Task;
}
/// <summary>
/// A <see cref="bool"/> for if the OS / Chromium currently has an inverted color scheme or is
/// being instructed to use an inverted color scheme.
/// </summary>
public Task<bool> ShouldUseInvertedColorSchemeAsync()
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("nativeTheme-shouldUseInvertedColorScheme-completed", (shouldUseInvertedColorScheme) => {
BridgeConnector.Socket.Off("nativeTheme-shouldUseInvertedColorScheme-completed");
taskCompletionSource.SetResult((bool)shouldUseInvertedColorScheme);
});
BridgeConnector.Socket.Emit("nativeTheme-shouldUseInvertedColorScheme");
return taskCompletionSource.Task;
}
/// <summary>
/// Emitted when something in the underlying NativeTheme has changed. This normally means that either the value of <see cref="ShouldUseDarkColorsAsync"/>,
/// <see cref="ShouldUseHighContrastColorsAsync"/> or <see cref="ShouldUseInvertedColorSchemeAsync"/> has changed. You will have to check them to determine which one has changed.
/// </summary>
public event Action Updated
{
add
{
if (_updated == null)
{
BridgeConnector.Socket.On("nativeTheme-updated" + GetHashCode(), () =>
{
_updated();
});
BridgeConnector.Socket.Emit("register-nativeTheme-updated-event", GetHashCode());
}
_updated += value;
}
remove
{
_updated -= value;
if (_updated == null)
{
BridgeConnector.Socket.Off("nativeTheme-updated" + GetHashCode());
}
}
}
private event Action _updated;
}
}

View File

@@ -15,7 +15,7 @@ namespace ElectronNET.API
public sealed class Notification
{
private static Notification _notification;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
internal Notification() { }

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,242 @@
using System;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Monitor power state changes..
/// </summary>
public sealed class PowerMonitor
{
/// <summary>
/// Emitted when the system is about to lock the screen.
/// </summary>
public event Action OnLockScreen
{
add
{
if (_lockScreen == null)
{
BridgeConnector.Socket.On("pm-lock-screen" , () =>
{
_lockScreen();
});
BridgeConnector.Socket.Emit("register-pm-lock-screen");
}
_lockScreen += value;
}
remove
{
_lockScreen -= value;
if (_lockScreen == null)
BridgeConnector.Socket.Off("pm-lock-screen");
}
}
private event Action _lockScreen;
/// <summary>
/// Emitted when the system is about to unlock the screen.
/// </summary>
public event Action OnUnLockScreen
{
add
{
if (_unlockScreen == null)
{
BridgeConnector.Socket.On("pm-unlock-screen", () =>
{
_unlockScreen();
});
BridgeConnector.Socket.Emit("register-pm-unlock-screen");
}
_unlockScreen += value;
}
remove
{
_unlockScreen -= value;
if (_unlockScreen == null)
BridgeConnector.Socket.Off("pm-unlock-screen");
}
}
private event Action _unlockScreen;
/// <summary>
/// Emitted when the system is suspending.
/// </summary>
public event Action OnSuspend
{
add
{
if (_suspend == null)
{
BridgeConnector.Socket.On("pm-suspend", () =>
{
_suspend();
});
BridgeConnector.Socket.Emit("register-pm-suspend");
}
_suspend += value;
}
remove
{
_suspend -= value;
if (_suspend == null)
BridgeConnector.Socket.Off("pm-suspend");
}
}
private event Action _suspend;
/// <summary>
/// Emitted when system is resuming.
/// </summary>
public event Action OnResume
{
add
{
if (_resume == null)
{
BridgeConnector.Socket.On("pm-resume", () =>
{
_resume();
});
BridgeConnector.Socket.Emit("register-pm-resume");
}
_resume += value;
}
remove
{
_resume -= value;
if (_resume == null)
BridgeConnector.Socket.Off("pm-resume");
}
}
private event Action _resume;
/// <summary>
/// Emitted when the system changes to AC power.
/// </summary>
public event Action OnAC
{
add
{
if (_onAC == null)
{
BridgeConnector.Socket.On("pm-on-ac", () =>
{
_onAC();
});
BridgeConnector.Socket.Emit("register-pm-on-ac");
}
_onAC += value;
}
remove
{
_onAC -= value;
if (_onAC == null)
BridgeConnector.Socket.Off("pm-on-ac");
}
}
private event Action _onAC;
/// <summary>
/// Emitted when system changes to battery power.
/// </summary>
public event Action OnBattery
{
add
{
if (_onBattery == null)
{
BridgeConnector.Socket.On("pm-on-battery", () =>
{
_onBattery();
});
BridgeConnector.Socket.Emit("register-pm-on-battery");
}
_onBattery += value;
}
remove
{
_onBattery -= value;
if (_onBattery == null)
BridgeConnector.Socket.Off("pm-on-battery");
}
}
private event Action _onBattery;
/// <summary>
/// Emitted when the system is about to reboot or shut down. If the event handler
/// invokes `e.preventDefault()`, Electron will attempt to delay system shutdown in
/// order for the app to exit cleanly.If `e.preventDefault()` is called, the app
/// should exit as soon as possible by calling something like `app.quit()`.
/// </summary>
public event Action OnShutdown
{
add
{
if (_shutdown == null)
{
BridgeConnector.Socket.On("pm-shutdown", () =>
{
_shutdown();
});
BridgeConnector.Socket.Emit("register-pm-shutdown");
}
_shutdown += value;
}
remove
{
_shutdown -= value;
if (_shutdown == null)
BridgeConnector.Socket.Off("pm-on-shutdown");
}
}
private event Action _shutdown;
private static PowerMonitor _powerMonitor;
private static object _syncRoot = new object();
internal PowerMonitor() { }
internal static PowerMonitor Instance
{
get
{
if (_powerMonitor == null)
{
lock (_syncRoot)
{
if (_powerMonitor == null)
{
_powerMonitor = new PowerMonitor();
}
}
}
return _powerMonitor;
}
}
}
}

View File

@@ -1,7 +1,7 @@
namespace ElectronNET.API
{
/// <summary>
///
/// Event arguments for the <see cref="App.BeforeQuit"/> / <see cref="App.WillQuit"/> event.
/// </summary>
public sealed class QuitEventArgs
{
@@ -13,4 +13,4 @@
Electron.App.PreventQuit();
}
}
}
}

View File

@@ -105,7 +105,7 @@ namespace ElectronNET.API
private event Action<Display, string[]> _onDisplayMetricsChanged;
private static Screen _screen;
private static object _syncRoot = new Object();
private static object _syncRoot = new object();
internal Screen() { }

View File

@@ -0,0 +1,33 @@
using Microsoft.Extensions.DependencyInjection;
namespace ElectronNET.API
{
/// <summary>
///
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds the <see cref="Electron"/> Members to the Service Collection
/// </summary>
public static IServiceCollection AddElectron(this IServiceCollection services)
=> services
// adding in this manner to ensure late binding.
.AddSingleton(provider => IpcMain.Instance)
.AddSingleton(provider => App.Instance)
.AddSingleton(provider => AutoUpdater.Instance)
.AddSingleton(provider => WindowManager.Instance)
.AddSingleton(provider => Menu.Instance)
.AddSingleton(provider => Dialog.Instance)
.AddSingleton(provider => Notification.Instance)
.AddSingleton(provider => Tray.Instance)
.AddSingleton(provider => GlobalShortcut.Instance)
.AddSingleton(provider => Shell.Instance)
.AddSingleton(provider => Screen.Instance)
.AddSingleton(provider => Clipboard.Instance)
.AddSingleton(provider => HostHook.Instance)
.AddSingleton(provider => PowerMonitor.Instance)
.AddSingleton(provider => NativeTheme.Instance)
.AddSingleton(provider => Dock.Instance);
}
}

460
ElectronNET.API/Session.cs Normal file
View File

@@ -0,0 +1,460 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Manage browser sessions, cookies, cache, proxy settings, etc.
/// </summary>
public class Session
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; private set; }
/// <summary>
/// Query and modify a session's cookies.
/// </summary>
public Cookies Cookies { get; }
internal Session(int id)
{
Id = id;
Cookies = new Cookies(id);
}
/// <summary>
/// Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication.
/// </summary>
/// <param name="domains">A comma-separated list of servers for which integrated authentication is enabled.</param>
public void AllowNTLMCredentialsForDomains(string domains)
{
BridgeConnector.Socket.Emit("webContents-session-allowNTLMCredentialsForDomains", Id, domains);
}
/// <summary>
/// Clears the sessions HTTP authentication cache.
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public Task ClearAuthCacheAsync(RemovePassword options)
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-clearAuthCache-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-clearAuthCache-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, JObject.FromObject(options, _jsonSerializer), guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Clears the sessions HTTP authentication cache.
/// </summary>
public Task ClearAuthCacheAsync()
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-clearAuthCache-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-clearAuthCache-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Clears the sessions HTTP cache.
/// </summary>
/// <returns></returns>
public Task ClearCacheAsync()
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-clearCache-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-clearCache-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-clearCache", Id, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Clears the host resolver cache.
/// </summary>
/// <returns></returns>
public Task ClearHostResolverCacheAsync()
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-clearHostResolverCache-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-clearHostResolverCache-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-clearHostResolverCache", Id, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Clears the data of web storages.
/// </summary>
/// <returns></returns>
public Task ClearStorageDataAsync()
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-clearStorageData-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-clearStorageData-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-clearStorageData", Id, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Clears the data of web storages.
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public Task ClearStorageDataAsync(ClearStorageDataOptions options)
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-clearStorageData-options-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-clearStorageData-options-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-clearStorageData-options", Id, JObject.FromObject(options, _jsonSerializer), guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Allows resuming cancelled or interrupted downloads from previous Session. The
/// API will generate a DownloadItem that can be accessed with the will-download
/// event. The DownloadItem will not have any WebContents associated with it and the
/// initial state will be interrupted. The download will start only when the resume
/// API is called on the DownloadItem.
/// </summary>
/// <param name="options"></param>
public void CreateInterruptedDownload(CreateInterruptedDownloadOptions options)
{
BridgeConnector.Socket.Emit("webContents-session-createInterruptedDownload", Id, JObject.FromObject(options, _jsonSerializer));
}
/// <summary>
/// Disables any network emulation already active for the session. Resets to the
/// original network configuration.
/// </summary>
public void DisableNetworkEmulation()
{
BridgeConnector.Socket.Emit("webContents-session-disableNetworkEmulation", Id);
}
/// <summary>
/// Emulates network with the given configuration for the session.
/// </summary>
/// <param name="options"></param>
public void EnableNetworkEmulation(EnableNetworkEmulationOptions options)
{
BridgeConnector.Socket.Emit("webContents-session-enableNetworkEmulation", Id, JObject.FromObject(options, _jsonSerializer));
}
/// <summary>
/// Writes any unwritten DOMStorage data to disk.
/// </summary>
public void FlushStorageData()
{
BridgeConnector.Socket.Emit("webContents-session-flushStorageData", Id);
}
/// <summary>
///
/// </summary>
/// <param name="identifier"></param>
/// <returns></returns>
public Task<int[]> GetBlobDataAsync(string identifier)
{
var taskCompletionSource = new TaskCompletionSource<int[]>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-getBlobData-completed" + guid, (buffer) =>
{
var result = ((JArray)buffer).ToObject<int[]>();
BridgeConnector.Socket.Off("webContents-session-getBlobData-completed" + guid);
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("webContents-session-getBlobData", Id, identifier, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Get session's current cache size.
/// </summary>
/// <returns>Callback is invoked with the session's current cache size.</returns>
public Task<int> GetCacheSizeAsync()
{
var taskCompletionSource = new TaskCompletionSource<int>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-getCacheSize-completed" + guid, (size) =>
{
BridgeConnector.Socket.Off("webContents-session-getCacheSize-completed" + guid);
taskCompletionSource.SetResult((int)size);
});
BridgeConnector.Socket.Emit("webContents-session-getCacheSize", Id, guid);
return taskCompletionSource.Task;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public Task<string[]> GetPreloadsAsync()
{
var taskCompletionSource = new TaskCompletionSource<string[]>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-getPreloads-completed" + guid, (preloads) =>
{
var result = ((JArray)preloads).ToObject<string[]>();
BridgeConnector.Socket.Off("webContents-session-getPreloads-completed" + guid);
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("webContents-session-getPreloads", Id, guid);
return taskCompletionSource.Task;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public Task<string> GetUserAgent()
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-getUserAgent-completed" + guid, (userAgent) =>
{
BridgeConnector.Socket.Off("webContents-session-getUserAgent-completed" + guid);
taskCompletionSource.SetResult(userAgent.ToString());
});
BridgeConnector.Socket.Emit("webContents-session-getUserAgent", Id, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Resolves the proxy information for url. The callback will be called with
/// callback(proxy) when the request is performed.
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public Task<string> ResolveProxyAsync(string url)
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-resolveProxy-completed" + guid, (proxy) =>
{
BridgeConnector.Socket.Off("webContents-session-resolveProxy-completed" + guid);
taskCompletionSource.SetResult(proxy.ToString());
});
BridgeConnector.Socket.Emit("webContents-session-resolveProxy", Id, url, guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Sets download saving directory. By default, the download directory will be the
/// Downloads under the respective app folder.
/// </summary>
/// <param name="path"></param>
public void SetDownloadPath(string path)
{
BridgeConnector.Socket.Emit("webContents-session-setDownloadPath", Id, path);
}
/// <summary>
/// Adds scripts that will be executed on ALL web contents that are associated with
/// this session just before normal preload scripts run.
/// </summary>
/// <param name="preloads"></param>
public void SetPreloads(string[] preloads)
{
BridgeConnector.Socket.Emit("webContents-session-setPreloads", Id, preloads);
}
/// <summary>
/// Sets the proxy settings. When pacScript and proxyRules are provided together,
/// the proxyRules option is ignored and pacScript configuration is applied.
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
public Task SetProxyAsync(ProxyConfig config)
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("webContents-session-setProxy-completed" + guid, () =>
{
BridgeConnector.Socket.Off("webContents-session-setProxy-completed" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-setProxy", Id, JObject.FromObject(config, _jsonSerializer), guid);
return taskCompletionSource.Task;
}
/// <summary>
/// Overrides the userAgent for this session. This doesn't affect existing WebContents, and
/// each WebContents can use webContents.setUserAgent to override the session-wide
/// user agent.
/// </summary>
/// <param name="userAgent"></param>
public void SetUserAgent(string userAgent)
{
BridgeConnector.Socket.Emit("webContents-session-setUserAgent", Id, userAgent);
}
/// <summary>
/// Overrides the userAgent and acceptLanguages for this session. The
/// acceptLanguages must a comma separated ordered list of language codes, for
/// example "en-US,fr,de,ko,zh-CN,ja". This doesn't affect existing WebContents, and
/// each WebContents can use webContents.setUserAgent to override the session-wide
/// user agent.
/// </summary>
/// <param name="userAgent"></param>
/// <param name="acceptLanguages">The
/// acceptLanguages must a comma separated ordered list of language codes, for
/// example "en-US,fr,de,ko,zh-CN,ja".</param>
public void SetUserAgent(string userAgent, string acceptLanguages)
{
BridgeConnector.Socket.Emit("webContents-session-setUserAgent", Id, userAgent, acceptLanguages);
}
/// <summary>
/// The keys are the extension names and each value is an object containing name and version properties.
/// Note: This API cannot be called before the ready event of the app module is emitted.
/// </summary>
/// <returns></returns>
public Task<ChromeExtensionInfo[]> GetAllExtensionsAsync()
{
var taskCompletionSource = new TaskCompletionSource<ChromeExtensionInfo[]>();
BridgeConnector.Socket.On("webContents-session-getAllExtensions-completed", (extensionslist) =>
{
BridgeConnector.Socket.Off("webContents-session-getAllExtensions-completed");
var chromeExtensionInfos = ((JArray)extensionslist).ToObject<ChromeExtensionInfo[]>();
taskCompletionSource.SetResult(chromeExtensionInfos);
});
BridgeConnector.Socket.Emit("webContents-session-getAllExtensions", Id);
return taskCompletionSource.Task;
}
/// <summary>
/// Remove Chrome extension with the specified name.
/// Note: This API cannot be called before the ready event of the app module is emitted.
/// </summary>
/// <param name="name">Name of the Chrome extension to remove</param>
public void RemoveExtension(string name)
{
BridgeConnector.Socket.Emit("webContents-session-removeExtension", Id, name);
}
/// <summary>
/// resolves when the extension is loaded.
///
/// This method will raise an exception if the extension could not be loaded.If
/// there are warnings when installing the extension (e.g. if the extension requests
/// an API that Electron does not support) then they will be logged to the console.
///
/// Note that Electron does not support the full range of Chrome extensions APIs.
/// See Supported Extensions APIs for more details on what is supported.
///
/// Note that in previous versions of Electron, extensions that were loaded would be
/// remembered for future runs of the application.This is no longer the case:
/// `loadExtension` must be called on every boot of your app if you want the
/// extension to be loaded.
///
/// This API does not support loading packed (.crx) extensions.
///
///** Note:** This API cannot be called before the `ready` event of the `app` module
/// is emitted.
///
///** Note:** Loading extensions into in-memory(non-persistent) sessions is not supported and will throw an error.
/// </summary>
/// <param name="path">Path to the Chrome extension</param>
/// <param name="allowFileAccess">Whether to allow the extension to read local files over `file://` protocol and
/// inject content scripts into `file://` pages. This is required e.g. for loading
/// devtools extensions on `file://` URLs. Defaults to false.</param>
/// <returns></returns>
public Task<Extension> LoadExtensionAsync(string path, bool allowFileAccess = false)
{
var taskCompletionSource = new TaskCompletionSource<Extension>();
BridgeConnector.Socket.On("webContents-session-loadExtension-completed", (extension) =>
{
BridgeConnector.Socket.Off("webContents-session-loadExtension-completed");
taskCompletionSource.SetResult(((JObject)extension).ToObject<Extension>());
});
BridgeConnector.Socket.Emit("webContents-session-loadExtension", Id, path, allowFileAccess);
return taskCompletionSource.Task;
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
}

Some files were not shown because too many files have changed in this diff Show More