Skip to content

Commit 2944e69

Browse files
committed
Added couple of enhancements
1 parent 8df9eff commit 2944e69

File tree

4 files changed

+64
-5
lines changed

4 files changed

+64
-5
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## ElectronNET.Core
44

55
- Updated `PrintToPDFOptions` to also allow specifying the `PageSize` with an object (#769)
6+
- Updated splashscreen image to have 0 margin (#622)
7+
- Added option to use `ElectronSplashScreen` with an HTML file (#799)
68
- Added option to provide floating point value as aspect ratios with `SetAspectRatio` (#793)
79

810
# 0.0.18

src/ElectronNET.API/API/BrowserWindow.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public event Action OnReadyToShow
4848
_readyToShow -= value;
4949

5050
if (_readyToShow == null)
51+
{
5152
BridgeConnector.Socket.Off("browserWindow-ready-to-show" + Id);
53+
}
5254
}
5355
}
5456

@@ -77,7 +79,9 @@ public event Action<string> OnPageTitleUpdated
7779
_pageTitleUpdated -= value;
7880

7981
if (_pageTitleUpdated == null)
82+
{
8083
BridgeConnector.Socket.Off("browserWindow-page-title-updated" + Id);
84+
}
8185
}
8286
}
8387

@@ -170,7 +174,9 @@ public event Action OnSessionEnd
170174
_sessionEnd -= value;
171175

172176
if (_sessionEnd == null)
177+
{
173178
BridgeConnector.Socket.Off("browserWindow-session-end" + Id);
179+
}
174180
}
175181
}
176182

@@ -199,7 +205,9 @@ public event Action OnUnresponsive
199205
_unresponsive -= value;
200206

201207
if (_unresponsive == null)
208+
{
202209
BridgeConnector.Socket.Off("browserWindow-unresponsive" + Id);
210+
}
203211
}
204212
}
205213

@@ -228,7 +236,9 @@ public event Action OnResponsive
228236
_responsive -= value;
229237

230238
if (_responsive == null)
239+
{
231240
BridgeConnector.Socket.Off("browserWindow-responsive" + Id);
241+
}
232242
}
233243
}
234244

@@ -257,7 +267,9 @@ public event Action OnBlur
257267
_blur -= value;
258268

259269
if (_blur == null)
270+
{
260271
BridgeConnector.Socket.Off("browserWindow-blur" + Id);
272+
}
261273
}
262274
}
263275

@@ -286,7 +298,9 @@ public event Action OnFocus
286298
_focus -= value;
287299

288300
if (_focus == null)
301+
{
289302
BridgeConnector.Socket.Off("browserWindow-focus" + Id);
303+
}
290304
}
291305
}
292306

@@ -315,7 +329,9 @@ public event Action OnShow
315329
_show -= value;
316330

317331
if (_show == null)
332+
{
318333
BridgeConnector.Socket.Off("browserWindow-show" + Id);
334+
}
319335
}
320336
}
321337

@@ -344,7 +360,9 @@ public event Action OnHide
344360
_hide -= value;
345361

346362
if (_hide == null)
363+
{
347364
BridgeConnector.Socket.Off("browserWindow-hide" + Id);
365+
}
348366
}
349367
}
350368

@@ -373,7 +391,9 @@ public event Action OnMaximize
373391
_maximize -= value;
374392

375393
if (_maximize == null)
394+
{
376395
BridgeConnector.Socket.Off("browserWindow-maximize" + Id);
396+
}
377397
}
378398
}
379399

@@ -402,7 +422,9 @@ public event Action OnUnmaximize
402422
_unmaximize -= value;
403423

404424
if (_unmaximize == null)
425+
{
405426
BridgeConnector.Socket.Off("browserWindow-unmaximize" + Id);
427+
}
406428
}
407429
}
408430

@@ -431,7 +453,9 @@ public event Action OnMinimize
431453
_minimize -= value;
432454

433455
if (_minimize == null)
456+
{
434457
BridgeConnector.Socket.Off("browserWindow-minimize" + Id);
458+
}
435459
}
436460
}
437461

@@ -460,7 +484,9 @@ public event Action OnRestore
460484
_restore -= value;
461485

462486
if (_restore == null)
487+
{
463488
BridgeConnector.Socket.Off("browserWindow-restore" + Id);
489+
}
464490
}
465491
}
466492

@@ -489,7 +515,9 @@ public event Action OnResize
489515
_resize -= value;
490516

491517
if (_resize == null)
518+
{
492519
BridgeConnector.Socket.Off("browserWindow-resize" + Id);
520+
}
493521
}
494522
}
495523

@@ -520,7 +548,9 @@ public event Action OnMove
520548
_move -= value;
521549

522550
if (_move == null)
551+
{
523552
BridgeConnector.Socket.Off("browserWindow-move" + Id);
553+
}
524554
}
525555
}
526556

@@ -549,7 +579,9 @@ public event Action OnMoved
549579
_moved -= value;
550580

551581
if (_moved == null)
582+
{
552583
BridgeConnector.Socket.Off("browserWindow-moved" + Id);
584+
}
553585
}
554586
}
555587

@@ -578,7 +610,9 @@ public event Action OnEnterFullScreen
578610
_enterFullScreen -= value;
579611

580612
if (_enterFullScreen == null)
613+
{
581614
BridgeConnector.Socket.Off("browserWindow-enter-full-screen" + Id);
615+
}
582616
}
583617
}
584618

@@ -607,7 +641,9 @@ public event Action OnLeaveFullScreen
607641
_leaveFullScreen -= value;
608642

609643
if (_leaveFullScreen == null)
644+
{
610645
BridgeConnector.Socket.Off("browserWindow-leave-full-screen" + Id);
646+
}
611647
}
612648
}
613649

@@ -636,7 +672,9 @@ public event Action OnEnterHtmlFullScreen
636672
_enterHtmlFullScreen -= value;
637673

638674
if (_enterHtmlFullScreen == null)
675+
{
639676
BridgeConnector.Socket.Off("browserWindow-enter-html-full-screen" + Id);
677+
}
640678
}
641679
}
642680

@@ -665,7 +703,9 @@ public event Action OnLeaveHtmlFullScreen
665703
_leaveHtmlFullScreen -= value;
666704

667705
if (_leaveHtmlFullScreen == null)
706+
{
668707
BridgeConnector.Socket.Off("browserWindow-leave-html-full-screen" + Id);
708+
}
669709
}
670710
}
671711

@@ -700,7 +740,9 @@ public event Action<string> OnAppCommand
700740
_appCommand -= value;
701741

702742
if (_appCommand == null)
743+
{
703744
BridgeConnector.Socket.Off("browserWindow-app-command" + Id);
745+
}
704746
}
705747
}
706748

@@ -729,7 +771,9 @@ public event Action<string> OnSwipe
729771
_swipe -= value;
730772

731773
if (_swipe == null)
774+
{
732775
BridgeConnector.Socket.Off("browserWindow-swipe" + Id);
776+
}
733777
}
734778
}
735779

@@ -758,7 +802,9 @@ public event Action OnSheetBegin
758802
_sheetBegin -= value;
759803

760804
if (_sheetBegin == null)
805+
{
761806
BridgeConnector.Socket.Off("browserWindow-sheet-begin" + Id);
807+
}
762808
}
763809
}
764810

@@ -787,7 +833,9 @@ public event Action OnSheetEnd
787833
_sheetEnd -= value;
788834

789835
if (_sheetEnd == null)
836+
{
790837
BridgeConnector.Socket.Off("browserWindow-sheet-end" + Id);
838+
}
791839
}
792840
}
793841

@@ -816,7 +864,9 @@ public event Action OnNewWindowForTab
816864
_newWindowForTab -= value;
817865

818866
if (_newWindowForTab == null)
867+
{
819868
BridgeConnector.Socket.Off("browserWindow-new-window-for-tab" + Id);
869+
}
820870
}
821871
}
822872

src/ElectronNET.Host/main.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ function isSplashScreenEnabled() {
204204
}
205205

206206
function startSplashScreen() {
207-
let imageFile = path.join(currentPath, manifestJsonFile.splashscreen.imageFile);
207+
const imageFile = path.join(currentPath, manifestJsonFile.splashscreen.imageFile);
208+
const isHtml = imageFile.endsWith('.html') || imageFile.endsWith('.htm');
208209
const startWindow = (width, height) => {
209210
splashScreen = new BrowserWindow({
210211
width: width,
@@ -224,18 +225,24 @@ function startSplashScreen() {
224225
splashScreen.destroy();
225226
});
226227

227-
const loadSplashscreenUrl = path.join(currentPath, 'splashscreen', 'index.html') + '?imgPath=' + imageFile;
228+
const loadSplashscreenUrl = isHtml ? imageFile : path.join(currentPath, 'splashscreen', 'index.html') + '?imgPath=' + imageFile;
228229
splashScreen.loadURL('file://' + loadSplashscreenUrl);
229230
splashScreen.once('closed', () => {
230231
splashScreen = null;
231232
});
232233
};
233234

234235
if (manifestJsonFile.splashscreen.width && manifestJsonFile.splashscreen.height) {
235-
startWindow(manifestJsonFile.splashscreen.width, manifestJsonFile.splashscreen.height);
236-
return;
236+
// width and height are set explicitly
237+
return startWindow(manifestJsonFile.splashscreen.width, manifestJsonFile.splashscreen.height);
238+
}
239+
240+
if (isHtml) {
241+
// we cannot compute width and height => use default
242+
return startWindow(800, 600);
237243
}
238244

245+
// it's an image, so we can compute the desired splash screen size
239246
imageSize(imageFile, (error, dimensions) => {
240247
if (error) {
241248
console.log(`load splashscreen error:`);

src/ElectronNET.Host/splashscreen/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
</style>
1717

18-
<img draggable="false" alt="splashscreen" style="width: 100%; height: 100%;">
18+
<img draggable="false" alt="splashscreen" style="width: 100%; height: 100%; margin: 0">
1919

2020
<script>
2121
(() => {

0 commit comments

Comments
 (0)