Files
Electron.NET/ElectronNET.API/BrowserWindow.cs

2101 lines
72 KiB
C#
Raw Normal View History

2017-10-15 21:39:52 +02:00
using ElectronNET.API.Entities;
2017-10-16 16:53:35 +02:00
using ElectronNET.API.Extensions;
2017-10-15 21:39:52 +02:00
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
2017-10-16 16:53:35 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
2021-08-26 14:22:54 +02:00
using System.Runtime.Versioning;
2017-10-15 21:39:52 +02:00
using System.Threading.Tasks;
2021-08-26 14:22:54 +02:00
//TODO: Add setTrafficLightPosition and getTrafficLightPosition: https://www.electronjs.org/docs/api/browser-window#winsettrafficlightpositionposition-macos
2017-10-15 21:39:52 +02:00
namespace ElectronNET.API
{
/// <summary>
/// Create and control browser windows.
/// </summary>
public class BrowserWindow
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; private set; }
/// <summary>
/// Emitted when the web page has been rendered (while not being shown) and
/// window can be displayed without a visual flash.
/// </summary>
public event Action OnReadyToShow
{
add
{
if (_readyToShow == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-ready-to-show" + Id, () =>
{
_readyToShow();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-ready-to-show", Id);
}
_readyToShow += value;
}
remove
{
_readyToShow -= value;
2017-10-25 21:28:43 +02:00
if (_readyToShow == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-ready-to-show" + Id);
}
}
private event Action _readyToShow;
/// <summary>
/// Emitted when the document changed its title.
/// </summary>
public event Action<string> OnPageTitleUpdated
{
add
{
if (_pageTitleUpdated == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On<string>("browserWindow-page-title-updated" + Id, (title) =>
{
2021-07-12 19:50:39 +02:00
_pageTitleUpdated(title);
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-page-title-updated", Id);
}
_pageTitleUpdated += value;
}
remove
{
_pageTitleUpdated -= value;
2017-10-25 21:28:43 +02:00
if (_pageTitleUpdated == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-page-title-updated" + Id);
}
}
private event Action<string> _pageTitleUpdated;
/// <summary>
/// Emitted when the window is going to be closed.
/// </summary>
public event Action OnClose
{
add
{
if (_close == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-close" + Id, () =>
{
_close();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-close", Id);
}
_close += value;
}
remove
{
_close -= value;
2017-10-25 21:28:43 +02:00
if (_close == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-close" + Id);
}
}
private event Action _close;
/// <summary>
/// Emitted when the window is closed.
/// After you have received this event you should remove the
/// reference to the window and avoid using it any more.
/// </summary>
public event Action OnClosed
{
add
{
if (_closed == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-closed" + Id, () =>
{
_closed();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-closed", Id);
}
_closed += value;
}
remove
{
_closed -= value;
2017-10-25 21:28:43 +02:00
if (_closed == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-closed" + Id);
}
}
private event Action _closed;
/// <summary>
/// Emitted when window session is going to end due to force shutdown or machine restart or session log off.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
public event Action OnSessionEnd
{
add
{
if (_sessionEnd == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-session-end" + Id, () =>
{
_sessionEnd();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-session-end", Id);
}
_sessionEnd += value;
}
remove
{
_sessionEnd -= value;
2017-10-25 21:28:43 +02:00
if (_sessionEnd == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-session-end" + Id);
}
}
private event Action _sessionEnd;
/// <summary>
/// Emitted when the web page becomes unresponsive.
/// </summary>
public event Action OnUnresponsive
{
add
{
if (_unresponsive == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-unresponsive" + Id, () =>
{
_unresponsive();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-unresponsive", Id);
}
_unresponsive += value;
}
remove
{
_unresponsive -= value;
2017-10-25 21:28:43 +02:00
if (_unresponsive == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-unresponsive" + Id);
}
}
private event Action _unresponsive;
/// <summary>
/// Emitted when the unresponsive web page becomes responsive again.
/// </summary>
public event Action OnResponsive
{
add
{
if (_responsive == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-responsive" + Id, () =>
{
_responsive();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-responsive", Id);
}
_responsive += value;
}
remove
{
_responsive -= value;
2017-10-25 21:28:43 +02:00
if (_responsive == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-responsive" + Id);
}
}
private event Action _responsive;
/// <summary>
/// Emitted when the window loses focus.
/// </summary>
public event Action OnBlur
{
add
{
if (_blur == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-blur" + Id, () =>
{
_blur();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-blur", Id);
}
_blur += value;
}
remove
{
_blur -= value;
2017-10-25 21:28:43 +02:00
if (_blur == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-blur" + Id);
}
}
private event Action _blur;
/// <summary>
/// Emitted when the window gains focus.
/// </summary>
public event Action OnFocus
{
add
{
if (_focus == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-focus" + Id, () =>
{
_focus();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-focus", Id);
}
_focus += value;
}
remove
{
_focus -= value;
2017-10-25 21:28:43 +02:00
if (_focus == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-focus" + Id);
}
}
private event Action _focus;
/// <summary>
/// Emitted when the window is shown.
/// </summary>
public event Action OnShow
{
add
{
if (_show == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-show" + Id, () =>
{
_show();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-show", Id);
}
_show += value;
}
remove
{
_show -= value;
2017-10-25 21:28:43 +02:00
if (_show == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-show" + Id);
}
}
private event Action _show;
/// <summary>
/// Emitted when the window is hidden.
/// </summary>
public event Action OnHide
{
add
{
if (_hide == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-hide" + Id, () =>
{
_hide();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-hide", Id);
}
_hide += value;
}
remove
{
_hide -= value;
2017-10-25 21:28:43 +02:00
if (_hide == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-hide" + Id);
}
}
private event Action _hide;
/// <summary>
/// Emitted when window is maximized.
/// </summary>
public event Action OnMaximize
{
add
{
if (_maximize == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-maximize" + Id, () =>
{
_maximize();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-maximize", Id);
}
_maximize += value;
}
remove
{
_maximize -= value;
2017-10-25 21:28:43 +02:00
if (_maximize == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-maximize" + Id);
}
}
private event Action _maximize;
/// <summary>
/// Emitted when the window exits from a maximized state.
/// </summary>
public event Action OnUnmaximize
{
add
{
if (_unmaximize == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-unmaximize" + Id, () =>
{
_unmaximize();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-unmaximize", Id);
}
_unmaximize += value;
}
remove
{
_unmaximize -= value;
2017-10-25 21:28:43 +02:00
if (_unmaximize == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-unmaximize" + Id);
}
}
private event Action _unmaximize;
/// <summary>
/// Emitted when the window is minimized.
/// </summary>
public event Action OnMinimize
{
add
{
if (_minimize == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-minimize" + Id, () =>
{
_minimize();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-minimize", Id);
}
_minimize += value;
}
remove
{
_minimize -= value;
2017-10-25 21:28:43 +02:00
if (_minimize == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-minimize" + Id);
}
}
private event Action _minimize;
/// <summary>
/// Emitted when the window is restored from a minimized state.
/// </summary>
public event Action OnRestore
{
add
{
if (_restore == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-restore" + Id, () =>
{
_restore();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-restore", Id);
}
_restore += value;
}
remove
{
_restore -= value;
2017-10-25 21:28:43 +02:00
if (_restore == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-restore" + Id);
}
}
private event Action _restore;
/// <summary>
/// Emitted when the window is being resized.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public event Action OnResize
{
add
{
if (_resize == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-resize" + Id, () =>
{
_resize();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-resize", Id);
}
_resize += value;
}
remove
{
_resize -= value;
2017-10-25 21:28:43 +02:00
if (_resize == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-resize" + Id);
}
}
private event Action _resize;
/// <summary>
/// Emitted when the window is being moved to a new position.
///
/// Note: On macOS this event is just an alias of moved.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public event Action OnMove
2017-10-16 16:53:35 +02:00
{
add
{
if (_move == null)
2017-10-16 16:53:35 +02:00
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-move" + Id, () =>
2017-10-16 16:53:35 +02:00
{
_move();
2017-10-16 16:53:35 +02:00
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-move", Id);
2017-10-16 16:53:35 +02:00
}
_move += value;
2017-10-16 16:53:35 +02:00
}
remove
{
_move -= value;
2017-10-25 21:28:43 +02:00
if (_move == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-move" + Id);
2017-10-16 16:53:35 +02:00
}
}
private event Action _move;
/// <summary>
2021-08-26 14:22:54 +02:00
/// Emitted once when the window is moved to a new position.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public event Action OnMoved
{
add
{
if (_moved == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-moved" + Id, () =>
{
_moved();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-moved", Id);
}
_moved += value;
}
remove
{
_moved -= value;
2017-10-25 21:28:43 +02:00
if (_moved == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-moved" + Id);
}
}
private event Action _moved;
/// <summary>
/// Emitted when the window enters a full-screen state.
/// </summary>
public event Action OnEnterFullScreen
{
add
{
if (_enterFullScreen == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-enter-full-screen" + Id, () =>
{
_enterFullScreen();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-enter-full-screen", Id);
}
_enterFullScreen += value;
}
remove
{
_enterFullScreen -= value;
2017-10-25 21:28:43 +02:00
if (_enterFullScreen == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-enter-full-screen" + Id);
}
}
private event Action _enterFullScreen;
/// <summary>
/// Emitted when the window leaves a full-screen state.
/// </summary>
public event Action OnLeaveFullScreen
{
add
{
if (_leaveFullScreen == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-leave-full-screen" + Id, () =>
{
_leaveFullScreen();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-leave-full-screen", Id);
}
_leaveFullScreen += value;
}
remove
{
_leaveFullScreen -= value;
2017-10-25 21:28:43 +02:00
if (_leaveFullScreen == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-leave-full-screen" + Id);
}
}
private event Action _leaveFullScreen;
/// <summary>
/// Emitted when the window enters a full-screen state triggered by HTML API.
/// </summary>
public event Action OnEnterHtmlFullScreen
{
add
{
if (_enterHtmlFullScreen == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-enter-html-full-screen" + Id, () =>
{
_enterHtmlFullScreen();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-enter-html-full-screen", Id);
}
_enterHtmlFullScreen += value;
}
remove
{
_enterHtmlFullScreen -= value;
2017-10-25 21:28:43 +02:00
if (_enterHtmlFullScreen == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-enter-html-full-screen" + Id);
}
}
private event Action _enterHtmlFullScreen;
/// <summary>
/// Emitted when the window leaves a full-screen state triggered by HTML API.
/// </summary>
public event Action OnLeaveHtmlFullScreen
{
add
{
if (_leaveHtmlFullScreen == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-leave-html-full-screen" + Id, () =>
{
_leaveHtmlFullScreen();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-leave-html-full-screen", Id);
}
_leaveHtmlFullScreen += value;
}
remove
{
_leaveHtmlFullScreen -= value;
2017-10-25 21:28:43 +02:00
if (_leaveHtmlFullScreen == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-leave-html-full-screen" + Id);
}
}
private event Action _leaveHtmlFullScreen;
/// <summary>
/// Emitted when an App Command is invoked. These are typically related to
/// keyboard media keys or browser commands, as well as the “Back” button
/// built into some mice on Windows.
///
/// Commands are lowercased, underscores are replaced with hyphens,
/// and the APPCOMMAND_ prefix is stripped off.e.g.APPCOMMAND_BROWSER_BACKWARD
/// is emitted as browser-backward.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows")]
public event Action<string> OnAppCommand
{
add
{
if (_appCommand == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On<string>("browserWindow-app-command" + Id, (command) =>
{
2021-07-12 19:50:39 +02:00
_appCommand(command);
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-app-command", Id);
}
_appCommand += value;
}
remove
{
_appCommand -= value;
2017-10-25 21:28:43 +02:00
if (_appCommand == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-app-command" + Id);
}
}
private event Action<string> _appCommand;
/// <summary>
/// Emitted when scroll wheel event phase has begun.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public event Action OnScrollTouchBegin
{
add
{
if (_scrollTouchBegin == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-scroll-touch-begin" + Id, () =>
{
_scrollTouchBegin();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-scroll-touch-begin", Id);
}
_scrollTouchBegin += value;
}
remove
{
_scrollTouchBegin -= value;
2017-10-25 21:28:43 +02:00
if (_scrollTouchBegin == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-scroll-touch-begin" + Id);
}
}
private event Action _scrollTouchBegin;
/// <summary>
/// Emitted when scroll wheel event phase has ended.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public event Action OnScrollTouchEnd
{
add
{
if (_scrollTouchEnd == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-scroll-touch-end" + Id, () =>
{
_scrollTouchEnd();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-scroll-touch-end", Id);
}
_scrollTouchEnd += value;
}
remove
{
_scrollTouchEnd -= value;
2017-10-25 21:28:43 +02:00
if (_scrollTouchEnd == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-scroll-touch-end" + Id);
}
}
private event Action _scrollTouchEnd;
/// <summary>
/// Emitted when scroll wheel event phase filed upon reaching the edge of element.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public event Action OnScrollTouchEdge
{
add
{
if (_scrollTouchEdge == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-scroll-touch-edge" + Id, () =>
{
_scrollTouchEdge();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-scroll-touch-edge", Id);
}
_scrollTouchEdge += value;
}
remove
{
_scrollTouchEdge -= value;
2017-10-25 21:28:43 +02:00
if (_scrollTouchEdge == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-scroll-touch-edge" + Id);
}
}
private event Action _scrollTouchEdge;
/// <summary>
/// Emitted on 3-finger swipe. Possible directions are up, right, down, left.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public event Action<string> OnSwipe
{
add
{
if (_swipe == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On<string>("browserWindow-swipe" + Id, (direction) =>
{
2021-07-12 19:50:39 +02:00
_swipe(direction);
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-swipe", Id);
}
_swipe += value;
}
remove
{
_swipe -= value;
2017-10-25 21:28:43 +02:00
if (_swipe == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-swipe" + Id);
}
}
private event Action<string> _swipe;
/// <summary>
/// Emitted when the window opens a sheet.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public event Action OnSheetBegin
{
add
{
if (_sheetBegin == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-sheet-begin" + Id, () =>
{
_sheetBegin();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-sheet-begin", Id);
}
_sheetBegin += value;
}
remove
{
_sheetBegin -= value;
2017-10-25 21:28:43 +02:00
if (_sheetBegin == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-sheet-begin" + Id);
}
}
private event Action _sheetBegin;
/// <summary>
/// Emitted when the window has closed a sheet.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public event Action OnSheetEnd
{
add
{
if (_sheetEnd == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-sheet-end" + Id, () =>
{
_sheetEnd();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-sheet-end", Id);
}
_sheetEnd += value;
}
remove
{
_sheetEnd -= value;
2017-10-25 21:28:43 +02:00
if (_sheetEnd == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-sheet-end" + Id);
}
}
private event Action _sheetEnd;
/// <summary>
/// Emitted when the native new tab button is clicked.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public event Action OnNewWindowForTab
{
add
{
if (_newWindowForTab == null)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.On("browserWindow-new-window-for-tab" + Id, () =>
{
_newWindowForTab();
});
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("register-browserWindow-new-window-for-tab", Id);
}
_newWindowForTab += value;
}
remove
{
_newWindowForTab -= value;
2017-10-25 21:28:43 +02:00
if (_newWindowForTab == null)
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("browserWindow-new-window-for-tab" + Id);
}
}
private event Action _newWindowForTab;
2017-10-16 16:53:35 +02:00
internal BrowserWindow(int id) {
Id = id;
WebContents = new WebContents(id);
}
2017-10-15 21:39:52 +02:00
/// <summary>
/// Force closing the window, the unload and beforeunload event wont be
/// emitted for the web page, and close event will also not be emitted
/// for this window, but it guarantees the closed event will be emitted.
/// </summary>
public void Destroy()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowDestroy", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Try to close the window. This has the same effect as a user manually
/// clicking the close button of the window. The web page may cancel the close though.
/// </summary>
public void Close()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowClose", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Focuses on the window.
/// </summary>
public void Focus()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowFocus", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Removes focus from the window.
/// </summary>
public void Blur()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowBlur", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window is focused.
/// </summary>
/// <returns></returns>
public Task<bool> IsFocusedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsFocused", "browserWindow-isFocused-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
/// <summary>
/// Whether the window is destroyed.
/// </summary>
/// <returns></returns>
public Task<bool> IsDestroyedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsDestroyed", "browserWindow-isDestroyed-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
/// <summary>
/// Shows and gives focus to the window.
/// </summary>
public void Show()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowShow", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Shows the window but doesnt focus on it.
/// </summary>
public void ShowInactive()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowShowInactive", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Hides the window.
/// </summary>
public void Hide()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowHide", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window is visible to the user.
/// </summary>
/// <returns></returns>
public Task<bool> IsVisibleAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsVisible", "browserWindow-isVisible-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether current window is a modal window.
/// </summary>
/// <returns></returns>
public Task<bool> IsModalAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsModal", "browserWindow-isModal-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Maximizes the window. This will also show (but not focus) the window if it isnt being displayed already.
/// </summary>
public void Maximize()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowMaximize", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Unmaximizes the window.
/// </summary>
public void Unmaximize()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowUnmaximize", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window is maximized.
/// </summary>
/// <returns></returns>
public Task<bool> IsMaximizedAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMaximized", "browserWindow-isMaximized-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Minimizes the window. On some platforms the minimized window will be shown in the Dock.
/// </summary>
public void Minimize()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowMinimize", Id);
}
2017-10-15 21:39:52 +02:00
/// <summary>
/// Restores the window from minimized state to its previous state.
/// </summary>
public void Restore()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowRestore", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window is minimized.
/// </summary>
/// <returns></returns>
public Task<bool> IsMinimizedAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMinimized", "browserWindow-isMinimized-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Sets whether the window should be in fullscreen mode.
/// </summary>
public void SetFullScreen(bool flag)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetFullScreen", Id, flag);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window is in fullscreen mode.
/// </summary>
/// <returns></returns>
public Task<bool> IsFullScreenAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreen", "browserWindow-isFullScreen-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// This will make a window maintain an aspect ratio. The extra size allows a developer to have space,
/// specified in pixels, not included within the aspect ratio calculations. This API already takes into
/// account the difference between a windows size and its content size.
///
/// Consider a normal window with an HD video player and associated controls.Perhaps there are 15 pixels
/// of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below
/// the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within
/// the player itself we would call this function with arguments of 16/9 and[40, 50]. The second argument
/// doesnt care where the extra width and height are within the content viewonly that they exist. Just
/// sum any extra width and height areas you have within the overall content view.
/// </summary>
/// <param name="aspectRatio">The aspect ratio to maintain for some portion of the content view.</param>
/// <param name="extraSize">The extra size not to be included while maintaining the aspect ratio.</param>
2021-08-26 14:22:54 +02:00
public void SetAspectRatio(int aspectRatio)
{
BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, new Size() { Height = 0, Width = 0 });
}
/// <summary>
/// This will make a window maintain an aspect ratio. The extra size allows a developer to have space,
/// specified in pixels, not included within the aspect ratio calculations. This API already takes into
/// account the difference between a windows size and its content size.
///
/// Consider a normal window with an HD video player and associated controls.Perhaps there are 15 pixels
/// of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below
/// the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within
/// the player itself we would call this function with arguments of 16/9 and[40, 50]. The second argument
/// doesnt care where the extra width and height are within the content viewonly that they exist. Just
/// sum any extra width and height areas you have within the overall content view.
/// </summary>
/// <param name="aspectRatio">The aspect ratio to maintain for some portion of the content view.</param>
/// <param name="extraSize">The extra size not to be included while maintaining the aspect ratio.</param>
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetAspectRatio(int aspectRatio, Size extraSize)
{
BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, extraSize);
2017-10-15 21:39:52 +02:00
}
2021-08-26 14:22:54 +02:00
2017-10-15 21:39:52 +02:00
/// <summary>
/// Uses Quick Look to preview a file at a given path.
/// </summary>
/// <param name="path">The absolute path to the file to preview with QuickLook. This is important as
/// Quick Look uses the file name and file extension on the path to determine the content type of the
/// file to open.</param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void PreviewFile(string path)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowPreviewFile", Id, path);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Uses Quick Look to preview a file at a given path.
/// </summary>
/// <param name="path">The absolute path to the file to preview with QuickLook. This is important as
/// Quick Look uses the file name and file extension on the path to determine the content type of the
/// file to open.</param>
/// <param name="displayname">The name of the file to display on the Quick Look modal view. This is
/// purely visual and does not affect the content type of the file. Defaults to path.</param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void PreviewFile(string path, string displayname)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowPreviewFile", Id, path, displayname);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Closes the currently open Quick Look panel.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void CloseFilePreview()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowCloseFilePreview", Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes and moves the window to the supplied bounds
/// </summary>
/// <param name="bounds"></param>
public void SetBounds(Rectangle bounds)
{
BridgeConnector.Emit("browserWindowSetBounds", Id, bounds);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes and moves the window to the supplied bounds
/// </summary>
/// <param name="bounds"></param>
/// <param name="animate"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetBounds(Rectangle bounds, bool animate)
{
BridgeConnector.Emit("browserWindowSetBounds", Id, bounds, animate);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Gets the bounds asynchronous.
/// </summary>
/// <returns></returns>
2017-10-15 21:39:52 +02:00
public Task<Rectangle> GetBoundsAsync()
{
return BridgeConnector.OnResult<Rectangle>("browserWindowGetBounds", "browserWindow-getBounds-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes and moves the windows client area (e.g. the web page) to the supplied bounds.
/// </summary>
/// <param name="bounds"></param>
public void SetContentBounds(Rectangle bounds)
{
BridgeConnector.Emit("browserWindowSetContentBounds", Id, bounds);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes and moves the windows client area (e.g. the web page) to the supplied bounds.
/// </summary>
/// <param name="bounds"></param>
/// <param name="animate"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetContentBounds(Rectangle bounds, bool animate)
{
BridgeConnector.Emit("browserWindowSetContentBounds", Id, bounds, animate);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Gets the content bounds asynchronous.
/// </summary>
/// <returns></returns>
2017-10-15 21:39:52 +02:00
public Task<Rectangle> GetContentBoundsAsync()
{
return BridgeConnector.OnResult<Rectangle>("browserWindowGetContentBounds", "browserWindow-getContentBounds-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes the window to width and height.
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void SetSize(int width, int height)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetSize", Id, width, height);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes the window to width and height.
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="animate"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetSize(int width, int height, bool animate)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetSize", Id, width, height, animate);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Contains the windows width and height.
/// </summary>
/// <returns></returns>
public Task<int[]> GetSizeAsync()
{
return BridgeConnector.OnResult<int[]>("browserWindowGetSize", "browserWindow-getSize-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes the windows client area (e.g. the web page) to width and height.
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void SetContentSize(int width, int height)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetContentSize", Id, width, height);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Resizes the windows client area (e.g. the web page) to width and height.
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="animate"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetContentSize(int width, int height, bool animate)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetContentSize", Id, width, height, animate);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Contains the windows client areas width and height.
/// </summary>
/// <returns></returns>
public Task<int[]> GetContentSizeAsync()
{
return BridgeConnector.OnResult<int[]>("browserWindowGetContentSize", "browserWindow-getContentSize-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Sets the minimum size of window to width and height.
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void SetMinimumSize(int width, int height)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetMinimumSize", Id, width, height);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Contains the windows minimum width and height.
/// </summary>
/// <returns></returns>
public Task<int[]> GetMinimumSizeAsync()
{
return BridgeConnector.OnResult<int[]>("browserWindowGetMinimumSize", "browserWindow-getMinimumSize-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Sets the maximum size of window to width and height.
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void SetMaximumSize(int width, int height)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetMaximumSize", Id, width, height);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Contains the windows maximum width and height.
/// </summary>
/// <returns></returns>
public Task<int[]> GetMaximumSizeAsync()
{
return BridgeConnector.OnResult<int[]>("browserWindowGetMaximumSize", "browserWindow-getMaximumSize-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Sets whether the window can be manually resized by user.
/// </summary>
/// <param name="resizable"></param>
public void SetResizable(bool resizable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetResizable", Id, resizable);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window can be manually resized by user.
/// </summary>
/// <returns></returns>
public Task<bool> IsResizableAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsResizable", "browserWindow-isResizable-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Sets whether the window can be moved by user. On Linux does nothing.
/// </summary>
/// <param name="movable"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetMovable(bool movable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetMovable", Id, movable);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window can be moved by user.
/// </summary>
/// <returns>On Linux always returns true.</returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public Task<bool> IsMovableAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMovable", "browserWindow-isMovable-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Sets whether the window can be manually minimized by user. On Linux does nothing.
/// </summary>
/// <param name="minimizable"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetMinimizable(bool minimizable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetMinimizable", Id, minimizable);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Whether the window can be manually minimized by user.
/// </summary>
/// <returns>On Linux always returns true.</returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public Task<bool> IsMinimizableAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMinimizable", "browserWindow-isMinimizable-completed" + Id, Id);
2017-10-15 21:39:52 +02:00
}
/// <summary>
/// Sets whether the window can be manually maximized by user. On Linux does nothing.
/// </summary>
/// <param name="maximizable"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-15 21:39:52 +02:00
public void SetMaximizable(bool maximizable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetMaximizable", Id, maximizable);
2017-10-15 21:39:52 +02:00
}
2017-10-16 16:53:35 +02:00
/// <summary>
/// Whether the window can be manually maximized by user.
/// </summary>
/// <returns>On Linux always returns true.</returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public Task<bool> IsMaximizableAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMaximizable", "browserWindow-isMaximizable-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
/// </summary>
/// <param name="fullscreenable"></param>
public void SetFullScreenable(bool fullscreenable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetFullScreenable", Id, fullscreenable);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
/// </summary>
/// <returns></returns>
public Task<bool> IsFullScreenableAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreenable", "browserWindow-isFullScreenable-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the window can be manually closed by user. On Linux does nothing.
/// </summary>
/// <param name="closable"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetClosable(bool closable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetClosable", Id, closable);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the window can be manually closed by user.
/// </summary>
/// <returns>On Linux always returns true.</returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public Task<bool> IsClosableAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsClosable", "browserWindow-isClosable-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the window should show always on top of other windows.
/// After setting this, the window is still a normal window, not a toolbox
/// window which can not be focused on.
/// </summary>
/// <param name="flag"></param>
public void SetAlwaysOnTop(bool flag)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetAlwaysOnTop", Id, flag);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the window should show always on top of other windows.
/// After setting this, the window is still a normal window, not a toolbox
/// window which can not be focused on.
/// </summary>
/// <param name="flag"></param>
/// <param name="level">Values include normal, floating, torn-off-menu, modal-panel, main-menu,
/// status, pop-up-menu and screen-saver. The default is floating.
/// See the macOS docs</param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
public void SetAlwaysOnTop(bool flag, OnTopLevel level)
2017-10-16 16:53:35 +02:00
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetAlwaysOnTop", Id, flag, level.GetDescription());
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the window should show always on top of other windows.
/// After setting this, the window is still a normal window, not a toolbox
/// window which can not be focused on.
/// </summary>
/// <param name="flag"></param>
/// <param name="level">Values include normal, floating, torn-off-menu, modal-panel, main-menu,
/// status, pop-up-menu and screen-saver. The default is floating.
/// See the macOS docs</param>
/// <param name="relativeLevel">The number of layers higher to set this window relative to the given level.
/// The default is 0. Note that Apple discourages setting levels higher than 1 above screen-saver.</param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public void SetAlwaysOnTop(bool flag, OnTopLevel level, int relativeLevel)
2017-10-16 16:53:35 +02:00
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetAlwaysOnTop", Id, flag, level.GetDescription(), relativeLevel);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the window is always on top of other windows.
/// </summary>
/// <returns></returns>
public Task<bool> IsAlwaysOnTopAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsAlwaysOnTop", "browserWindow-isAlwaysOnTop-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Moves window to the center of the screen.
/// </summary>
public void Center()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowCenter", Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Moves window to x and y.
/// </summary>
/// <param name="x"></param>
/// <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;
}
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetPosition", Id, x, y);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Moves window to x and y.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="animate"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
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;
}
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetPosition", Id, x, y, animate);
2017-10-16 16:53:35 +02:00
}
private bool isWindows10()
{
2021-08-26 14:22:54 +02:00
return OperatingSystem.IsWindowsVersionAtLeast(10);
}
2017-10-16 16:53:35 +02:00
/// <summary>
/// Contains the windows current position.
/// </summary>
/// <returns></returns>
public Task<int[]> GetPositionAsync()
{
return BridgeConnector.OnResult<int[]>("browserWindowGetPosition", "browserWindow-getPosition-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Changes the title of native window to title.
/// </summary>
/// <param name="title"></param>
public void SetTitle(string title)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetTitle", Id, title);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// The title of the native window.
///
/// Note: The title of web page can be different from the title of the native window.
/// </summary>
/// <returns></returns>
public Task<string> GetTitleAsync()
{
return BridgeConnector.OnResult<string>("browserWindowGetTitle", "browserWindow-getTitle-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Changes the attachment point for sheets on macOS.
/// By default, sheets are attached just below the window frame,
/// but you may want to display them beneath a HTML-rendered toolbar.
/// </summary>
/// <param name="offsetY"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetSheetOffset(float offsetY)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetSheetOffset", Id, offsetY);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Changes the attachment point for sheets on macOS.
/// By default, sheets are attached just below the window frame,
/// but you may want to display them beneath a HTML-rendered toolbar.
/// </summary>
/// <param name="offsetY"></param>
/// <param name="offsetX"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetSheetOffset(float offsetY, float offsetX)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetSheetOffset", Id, offsetY, offsetX);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Starts or stops flashing the window to attract users attention.
/// </summary>
/// <param name="flag"></param>
public void FlashFrame(bool flag)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowFlashFrame", Id, flag);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Makes the window not show in the taskbar.
/// </summary>
/// <param name="skip"></param>
public void SetSkipTaskbar(bool skip)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetSkipTaskbar", Id, skip);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Enters or leaves the kiosk mode.
/// </summary>
/// <param name="flag"></param>
public void SetKiosk(bool flag)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetKiosk", Id, flag);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the window is in kiosk mode.
/// </summary>
/// <returns></returns>
public Task<bool> IsKioskAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsKiosk", "browserWindow-isKiosk-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <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()
{
return BridgeConnector.OnResult<string>("browserWindowGetNativeWindowHandle", "browserWindow-getNativeWindowHandle-completed" + Id, Id);
}
2017-10-16 16:53:35 +02:00
/// <summary>
/// Sets the pathname of the file the window represents,
/// and the icon of the file will show in windows title bar.
/// </summary>
/// <param name="filename"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetRepresentedFilename(string filename)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetRepresentedFilename", Id, filename);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// The pathname of the file the window represents.
/// </summary>
/// <returns></returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public Task<string> GetRepresentedFilenameAsync()
{
return BridgeConnector.OnResult<string>("browserWindowGetRepresentedFilename", "browserWindow-getRepresentedFilename-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Specifies whether the windows document has been edited,
/// and the icon in title bar will become gray when set to true.
/// </summary>
/// <param name="edited"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetDocumentEdited(bool edited)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetDocumentEdited", Id, edited);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the windows document has been edited.
/// </summary>
/// <returns></returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public Task<bool> IsDocumentEditedAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsDocumentEdited", "browserWindow-isDocumentEdited-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Focuses the on web view.
/// </summary>
2017-10-16 16:53:35 +02:00
public void FocusOnWebView()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowFocusOnWebView", Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Blurs the web view.
/// </summary>
2017-10-16 16:53:35 +02:00
public void BlurWebView()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowBlurWebView", Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// The url can be a remote address (e.g. http://) or
/// a path to a local HTML file using the file:// protocol.
/// </summary>
/// <param name="url"></param>
public void LoadURL(string url)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowLoadURL", Id, url);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// The url can be a remote address (e.g. http://) or
/// a path to a local HTML file using the file:// protocol.
/// </summary>
/// <param name="url"></param>
/// <param name="options"></param>
public void LoadURL(string url, LoadURLOptions options)
{
BridgeConnector.Emit("browserWindowLoadURL", Id, url, options);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Same as webContents.reload.
/// </summary>
public void Reload()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowReload", Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Gets the menu items.
/// </summary>
/// <value>
/// The menu items.
/// </value>
public IReadOnlyCollection<MenuItem> MenuItems { get { return _items.AsReadOnly(); } }
2017-10-16 16:53:35 +02:00
private List<MenuItem> _items = new List<MenuItem>();
/// <summary>
/// Sets the menu as the windows menu bar,
/// setting it to null will remove the menu bar.
/// </summary>
/// <param name="menuItems"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
2017-10-16 16:53:35 +02:00
public void SetMenu(MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
2021-08-25 10:34:36 +02:00
BridgeConnector.Emit("browserWindowSetMenu", Id, JArray.FromObject(menuItems, _jsonSerializer));
2017-10-16 16:53:35 +02:00
_items.AddRange(menuItems);
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("windowMenuItemClicked");
BridgeConnector.On<string>("windowMenuItemClicked", (id) =>
{
2021-07-12 19:50:39 +02:00
MenuItem menuItem = _items.GetMenuItem(id);
2017-10-16 16:53:35 +02:00
menuItem?.Click();
});
}
2019-08-21 06:43:56 +03:00
/// <summary>
/// Remove the window's menu bar.
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
2019-08-21 06:43:56 +03:00
public void RemoveMenu()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowRemoveMenu", Id);
2019-08-21 06:43:56 +03:00
}
2017-10-16 16:53:35 +02:00
/// <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
2017-10-16 16:53:35 +02:00
/// platform, only supports Unity desktop environment, you need to specify the
/// .desktop file name to desktopName field in package.json.By default, it will
/// assume app.getName().desktop.On Windows, a mode can be passed.Accepted values
/// are none, normal, indeterminate, error, and paused. If you call setProgressBar
/// without a mode set (but with a value within the valid range), normal will be
/// assumed.
/// </summary>
/// <param name="progress"></param>
public void SetProgressBar(double progress)
2017-10-16 16:53:35 +02:00
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetProgressBar", Id, progress);
2017-10-16 16:53:35 +02:00
}
/// <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
2017-10-16 16:53:35 +02:00
/// platform, only supports Unity desktop environment, you need to specify the
/// .desktop file name to desktopName field in package.json.By default, it will
/// assume app.getName().desktop.On Windows, a mode can be passed.Accepted values
/// are none, normal, indeterminate, error, and paused. If you call setProgressBar
/// without a mode set (but with a value within the valid range), normal will be
/// assumed.
/// </summary>
/// <param name="progress"></param>
/// <param name="progressBarOptions"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
public void SetProgressBar(double progress, ProgressBarOptions progressBarOptions)
2017-10-16 16:53:35 +02:00
{
BridgeConnector.Emit("browserWindowSetProgressBar", Id, progress, progressBarOptions);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the window should have a shadow. On Windows and Linux does nothing.
/// </summary>
/// <param name="hasShadow"></param>
public void SetHasShadow(bool hasShadow)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetHasShadow", Id, hasShadow);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the window has a shadow.
///
/// On Windows and Linux always returns true.
/// </summary>
/// <returns></returns>
public Task<bool> HasShadowAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowHasShadow", "browserWindow-hasShadow-completed" + Id, Id);
}
/// <summary>
/// Gets the thumbar buttons.
/// </summary>
/// <value>
/// The thumbar buttons.
/// </value>
public IReadOnlyCollection<ThumbarButton> ThumbarButtons { get { return _thumbarButtons.AsReadOnly(); } }
private List<ThumbarButton> _thumbarButtons = new List<ThumbarButton>();
/// <summary>
/// Add a thumbnail toolbar with a specified set of buttons to the thumbnail
/// image of a window in a taskbar button layout. Returns a Boolean object
/// indicates whether the thumbnail has been added successfully.
///
/// The number of buttons in thumbnail toolbar should be no greater than 7 due
/// to the limited room.Once you setup the thumbnail toolbar, the toolbar cannot
/// be removed due to the platforms limitation.But you can call the API with an
/// empty array to clean the buttons.
/// </summary>
/// <param name="thumbarButtons"></param>
/// <returns>Whether the buttons were added successfully.</returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
public Task<bool> SetThumbarButtonsAsync(ThumbarButton[] thumbarButtons)
{
2021-08-17 16:28:07 +02:00
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
BridgeConnector.On<bool>("browserWindowSetThumbarButtons-completed" + Id, (success) =>
{
BridgeConnector.Off("browserWindowSetThumbarButtons-completed" + Id);
2021-07-12 21:33:35 +02:00
taskCompletionSource.SetResult(success);
});
thumbarButtons.AddThumbarButtonsId();
2021-08-25 10:34:36 +02:00
BridgeConnector.Emit("browserWindowSetThumbarButtons", Id, JArray.FromObject(thumbarButtons, _jsonSerializer));
_thumbarButtons.Clear();
_thumbarButtons.AddRange(thumbarButtons);
2021-07-12 19:50:39 +02:00
BridgeConnector.Off("thumbarButtonClicked");
BridgeConnector.On<string>("thumbarButtonClicked", (id) =>
{
2021-07-12 19:50:39 +02:00
ThumbarButton thumbarButton = _thumbarButtons.GetThumbarButton(id);
thumbarButton?.Click();
});
2017-10-16 16:53:35 +02:00
return taskCompletionSource.Task;
}
/// <summary>
/// Sets the region of the window to show as the thumbnail image displayed when hovering over
/// the window in the taskbar. You can reset the thumbnail to be the entire window by specifying
/// an empty region: {x: 0, y: 0, width: 0, height: 0}.
/// </summary>
/// <param name="rectangle"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
public void SetThumbnailClip(Rectangle rectangle)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetThumbnailClip", Id, rectangle);
}
/// <summary>
/// Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar.
/// </summary>
/// <param name="tooltip"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
public void SetThumbnailToolTip(string tooltip)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetThumbnailToolTip", Id, tooltip);
}
2017-10-16 16:53:35 +02:00
/// <summary>
/// Sets the properties for the windows taskbar button.
///
/// Note: relaunchCommand and relaunchDisplayName must always be set together.
/// If one of those properties is not set, then neither will be used.
/// </summary>
/// <param name="options"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
2017-10-16 16:53:35 +02:00
public void SetAppDetails(AppDetailsOptions options)
{
BridgeConnector.Emit("browserWindowSetAppDetails", Id, options);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Same as webContents.showDefinitionForSelection().
/// </summary>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void ShowDefinitionForSelection()
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowShowDefinitionForSelection", Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the window menu bar should hide itself automatically.
/// Once set the menu bar will only show when users press the single Alt key.
///
/// If the menu bar is already visible, calling setAutoHideMenuBar(true) wont hide it immediately.
/// </summary>
/// <param name="hide"></param>
public void SetAutoHideMenuBar(bool hide)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetAutoHideMenuBar", Id, hide);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether menu bar automatically hides itself.
/// </summary>
/// <returns></returns>
public Task<bool> IsMenuBarAutoHideAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarAutoHide", "browserWindow-isMenuBarAutoHide-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the menu bar should be visible. If the menu bar is auto-hide,
/// users can still bring up the menu bar by pressing the single Alt key.
/// </summary>
/// <param name="visible"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
2017-10-16 16:53:35 +02:00
public void SetMenuBarVisibility(bool visible)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetMenuBarVisibility", Id, visible);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the menu bar is visible.
/// </summary>
/// <returns></returns>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
2017-10-16 16:53:35 +02:00
public Task<bool> IsMenuBarVisibleAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarVisible", "browserWindow-isMenuBarVisible-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets whether the window should be visible on all workspaces.
///
/// Note: This API does nothing on Windows.
/// </summary>
/// <param name="visible"></param>
public void SetVisibleOnAllWorkspaces(bool visible)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetVisibleOnAllWorkspaces", Id, visible);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Whether the window is visible on all workspaces.
///
/// Note: This API always returns false on Windows.
/// </summary>
/// <returns></returns>
public Task<bool> IsVisibleOnAllWorkspacesAsync()
{
return BridgeConnector.OnResult<bool>("browserWindowIsVisibleOnAllWorkspaces", "browserWindow-isVisibleOnAllWorkspaces-completed" + Id, Id);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Makes the window ignore all mouse events.
///
/// All mouse events happened in this window will be passed to the window
/// below this window, but if this window has focus, it will still receive keyboard events.
/// </summary>
/// <param name="ignore"></param>
public void SetIgnoreMouseEvents(bool ignore)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetIgnoreMouseEvents", Id, ignore);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Prevents the window contents from being captured by other apps.
///
/// On macOS it sets the NSWindows sharingType to NSWindowSharingNone.
/// On Windows it calls SetWindowDisplayAffinity with WDA_MONITOR.
/// </summary>
/// <param name="enable"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetContentProtection(bool enable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetContentProtection", Id, enable);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Changes whether the window can be focused.
/// </summary>
/// <param name="focusable"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetFocusable(bool focusable)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetFocusable", Id, focusable);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Sets parent as current windows parent window,
/// passing null will turn current window into a top-level window.
/// </summary>
/// <param name="parent"></param>
2017-10-16 16:53:35 +02:00
public void SetParentWindow(BrowserWindow parent)
{
BridgeConnector.Emit("browserWindowSetParentWindow", Id, parent);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// The parent window.
/// </summary>
/// <returns></returns>
public async Task<BrowserWindow> GetParentWindowAsync()
2017-10-16 16:53:35 +02:00
{
var windowID = await BridgeConnector.OnResult<int>("browserWindowGetParentWindow", "browserWindow-getParentWindow-completed" + Id, Id);
return Electron.WindowManager.BrowserWindows.Where(w => w.Id == windowID).Single();
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// All child windows.
/// </summary>
/// <returns></returns>
public async Task<List<BrowserWindow>> GetChildWindowsAsync()
2017-10-16 16:53:35 +02:00
{
var windowIDs = new HashSet<int>(await BridgeConnector.OnResult<int[]>("browserWindowGetChildWindows", "browserWindow-getChildWindows-completed" + Id, Id));
return Electron.WindowManager.BrowserWindows.Where(w => windowIDs.Contains(w.Id)).ToList();
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Controls whether to hide cursor when typing.
/// </summary>
/// <param name="autoHide"></param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
2017-10-16 16:53:35 +02:00
public void SetAutoHideCursor(bool autoHide)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetAutoHideCursor", Id, autoHide);
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Adds a vibrancy effect to the browser window.
/// Passing null or an empty string will remove the vibrancy effect on the window.
/// </summary>
/// <param name="type">Can be appearance-based, light, dark, titlebar, selection,
/// menu, popover, sidebar, medium-light or ultra-dark.
/// See the macOS documentation for more details.</param>
2021-08-26 14:22:54 +02:00
[SupportedOSPlatform("macos")]
public void SetVibrancy(Vibrancy type)
2017-10-16 16:53:35 +02:00
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindowSetVibrancy", Id, type.GetDescription());
2017-10-16 16:53:35 +02:00
}
/// <summary>
/// Render and control web pages.
/// </summary>
public WebContents WebContents { get; internal set; }
2020-04-23 03:29:52 +02:00
/// <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)
{
2021-07-12 19:50:39 +02:00
BridgeConnector.Emit("browserWindow-setBrowserView", Id, browserView.Id);
2020-04-23 03:29:52 +02:00
}
2021-08-25 10:34:36 +02:00
private static readonly JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
}
}