Class InfiniFrameWindow
- Namespace
- InfiniFrame
- Assembly
- InfiniFrame.dll
public sealed class InfiniFrameWindow : IInfiniFrameWindow, IHasInfiniFrameProperties, IHasInfiniFrameEvents
- Inheritance
-
InfiniFrameWindow
- Implements
- Inherited Members
Fields
StartupParameters
public InfiniFrameNativeParameters StartupParameters
Field Value
Properties
BrowserControlInitParameters
Gets or sets platform-specific initialization parameters for the native browser control on startup. Default is none. WINDOWS: WebView2 specific string. Space separated. https://peter.sh/experiments/chromium-command-line-switches/ https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2environmentoptions.additionalbrowserarguments?view=webview2-dotnet-1.0.1938.49 viewFallbackFrom=webview2-dotnet-1.0.1901.177view%3Dwebview2-1.0.1901.177 https://www.chromium.org/developers/how-tos/run-chromium-with-flags/ LINUX: Webkit2Gtk specific string. Enter parameter names and values as JSON string. E.g. { "set_enable_encrypted_media": true } https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitSettings.html https://lazka.github.io/pgi-docs/WebKit2-4.0/classes/Settings.html Mac: Webkit specific string. Enter parameter names and values as JSON string. E.g. { "minimumFontSize": 8 } https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc https://developer.apple.com/documentation/webkit/wkpreferences?language=objc
public string? BrowserControlInitParameters { get; }
Property Value
CachedPreFullScreenBounds
public Rectangle CachedPreFullScreenBounds { get; set; }
Property Value
CachedPreMaximizedBounds
public Rectangle CachedPreMaximizedBounds { get; set; }
Property Value
Chromeless
Gets the value indicating whether the native window is chromeless.
public bool Chromeless { get; }
Property Value
Remarks
The user has to supply titlebar, border, dragging and resizing manually.
ContextMenuEnabled
When true, the user can access the browser control's context menu. By default, this is set to true.
public bool ContextMenuEnabled { get; }
Property Value
CustomSchemes
public required Dictionary<string, NetCustomSchemeDelegate?> CustomSchemes { get; init; }
Property Value
DevToolsEnabled
When true, the user can access the browser control's developer tools. By default, this is set to true.
public bool DevToolsEnabled { get; }
Property Value
Events
public required IInfiniFrameWindowEvents Events { get; init; }
Property Value
FileSystemAccessEnabled
public bool FileSystemAccessEnabled { get; }
Property Value
Focused
Gets whether the native window is currently within focus
public bool Focused { get; }
Property Value
FullScreen
This property returns or sets the fullscreen status of the window. When set to true, the native window will cover the entire screen, similar to kiosk mode. By default, this is set to false.
public bool FullScreen { get; }
Property Value
GrantBrowserPermissions
Gets whether the native browser control grants all requests for access to local resources such as the user's camera and microphone. By default, this is set to true.
public bool GrantBrowserPermissions { get; }
Property Value
Height
Gets or Sets the Height property of the native window in pixels. The default value is 0.
public int Height { get; }
Property Value
IconFilePath
Gets or sets the icon file for the native window title bar. The file must be located on the local machine and cannot be a URL. The default is none.
public string IconFilePath { get; }
Property Value
Id
Gets a unique GUID to identify the native window.
public Guid Id { get; }
Property Value
Remarks
This property is not currently used by the InfiniFrame framework.
IgnoreCertificateErrorsEnabled
public bool IgnoreCertificateErrorsEnabled { get; }
Property Value
InstanceHandle
public nint InstanceHandle { get; }
Property Value
JavascriptClipboardAccessEnabled
public bool JavascriptClipboardAccessEnabled { get; }
Property Value
Left
Gets or sets the native window Left (X) coordinate in pixels. This represents the horizontal position of the window relative to the screen. The default value is 0, which means the window will be aligned to the left edge of the screen.
public int Left { get; }
Property Value
Location
Gets or sets the native window Left (X) and Top coordinates (Y) in pixels. Default is 0,0 that means the window will be aligned to the top-left edge of the screen.
public Point Location { get; }
Property Value
Logger
public required ILogger<IInfiniFrameWindow> Logger { get; init; }
Property Value
MainMonitor
Retrieves the primary monitor information from the native window instance.
public InfiniMonitor MainMonitor { get; }
Property Value
- InfiniMonitor
Returns a Monitor object representing the main monitor. The main monitor is the first monitor in the list of available monitors.
Exceptions
- ApplicationException
Thrown when the window hasn't been initialized yet.
ManagedThreadId
public int ManagedThreadId { get; }
Property Value
MaxHeight
Gets or sets the native window maximum height in pixels.
public int MaxHeight { get; set; }
Property Value
MaxSize
Gets or set the maximum size of the native window in pixels.
public Size MaxSize { get; set; }
Property Value
MaxWidth
Gets or sets the native window maximum width in pixels.
public int MaxWidth { get; set; }
Property Value
Maximized
Gets or sets whether the native window is maximized. Default is false.
public bool Maximized { get; }
Property Value
MediaAutoplayEnabled
public bool MediaAutoplayEnabled { get; }
Property Value
MediaStreamEnabled
public bool MediaStreamEnabled { get; }
Property Value
MessageHandlers
public required IInfiniFrameWindowMessageHandlers MessageHandlers { get; init; }
Property Value
MinHeight
Gets or sets the native window minimum height in pixels.
public int MinHeight { get; set; }
Property Value
MinSize
Gets or set the minimum size of the native window in pixels.
public Size MinSize { get; set; }
Property Value
MinWidth
Gets or sets the native window minimum width in pixels.
public int MinWidth { get; set; }
Property Value
Minimized
Gets or sets whether the native window is minimized (hidden). Default is false.
public bool Minimized { get; }
Property Value
Monitors
Gets a list of information for each monitor from the native window. This property represents a list of Monitor objects associated with each display monitor.
public ImmutableArray<InfiniMonitor> Monitors { get; }
Property Value
- ImmutableArray<InfiniMonitor>
A read-only list of Monitor objects representing information about each display monitor.
Remarks
If called when the native instance of the window is not initialized, it will throw an ApplicationException.
Exceptions
- ApplicationException
Thrown when the native instance of the window is not initialized.
NativeType
public nint NativeType { get; }
Property Value
NotificationRegistrationId
Gets or sets the registration id for doing toast notifications. The default is to use the window title.
public string? NotificationRegistrationId { get; }
Property Value
Remarks
Only available on Windows.
Exceptions
- ApplicationException
Thrown if a platform is not Windows.
NotificationsEnabled
public bool NotificationsEnabled { get; }
Property Value
Parent
public required IInfiniFrameWindow? Parent { get; init; }
Property Value
Resizable
Gets or sets whether the user can resize the native window. Default is true.
public bool Resizable { get; }
Property Value
ScreenDpi
Gets the dots per inch (DPI) for the primary display from the native window.
public uint ScreenDpi { get; }
Property Value
Exceptions
- ApplicationException
An ApplicationException is thrown if the window hasn't been initialized yet.
ServiceProvider
public required IServiceProvider? ServiceProvider { get; init; }
Property Value
Size
Gets or sets the native window Size. This represents the width and the height of the window in pixels. The default Size is 0,0.
public Size Size { get; }
Property Value
SmoothScrollingEnabled
public bool SmoothScrollingEnabled { get; }
Property Value
StartString
Gets or sets an HTML string that the browser control will render when initialized. Default is none.
public string? StartString { get; }
Property Value
Remarks
Either StartString or StartUrl must be specified.
Exceptions
- ApplicationException
Thrown if trying to set a value after a native window is initialized.
- See Also
StartUrl
Gets or sets a URL that the browser control will navigate to when initialized. Default is none.
public string? StartUrl { get; }
Property Value
Remarks
Either StartString or StartUrl must be specified.
Exceptions
- ApplicationException
Thrown if trying to set a value after a native window is initialized.
- See Also
TemporaryFilesPath
Gets or sets the local path to store temp files for browser control. Default is the user's AppDataLocal folder.
public string? TemporaryFilesPath { get; }
Property Value
Remarks
Only available on Windows.
Exceptions
- ApplicationException
Thrown if a platform is not Windows.
Title
Gets or sets the native window title. Default is "InfiniFrame".
public string Title { get; }
Property Value
Top
Gets or sets the native window Top (Y) coordinate in pixels. Default is 0.
public int Top { get; }
Property Value
TopMost
Gets or sets whether the native window is always at the top of the z-order. Default is false.
public bool TopMost { get; }
Property Value
Transparent
When true, the native window and browser control can be displayed with a transparent background. HTML document's body background must have alpha-based value. WebView2 on Windows can only be fully transparent or fully opaque. By default, this is set to false.
public bool Transparent { get; }
Property Value
Exceptions
- ApplicationException
On Windows, thrown if trying to set a value after a native window is initialized.
UserAgent
public string? UserAgent { get; }
Property Value
WebSecurityEnabled
public bool WebSecurityEnabled { get; }
Property Value
Width
Gets or Sets the native window width in pixels. Default is 0.
public int Width { get; }
Property Value
WindowHandle
Represents a property that gets the handle of the native window on a Windows platform.
public nint WindowHandle { get; }
Property Value
Remarks
Only available on the Windows platform. If this property is accessed from a non-Windows platform, a PlatformNotSupportedException will be thrown. If this property is accessed before the window is initialized, an ApplicationException will be thrown.
Exceptions
- ApplicationException
Thrown when the window is not initialized yet.
- PlatformNotSupportedException
Thrown when accessed from a non-Windows platform.
Zoom
Gets or sets the native browser control Zoom. Default is 100.
public int Zoom { get; }
Property Value
Examples
100 = 100%, 50 = 50%
ZoomEnabled
public bool ZoomEnabled { get; }
Property Value
Methods
Close()
Closes the native window.
public void Close()
Exceptions
- ApplicationException
Thrown when the window is not initialized.
Initialize()
public void Initialize()
Invoke(Action)
Dispatches an Action to the UI thread if called from another thread.
public void Invoke(Action workItem)
Parameters
workItemActionThe delegate encapsulating a method / action to be executed in the UI thread.
OnCustomScheme(string, out int, out string?)
Invokes registered user-defined handler methods for user-defined custom schemes (other than 'http','https', and 'file') when the native browser control encounters them.
public nint OnCustomScheme(string url, out int numBytes, out string? contentType)
Parameters
urlstringURL of the Scheme
numBytesintNumber of bytes of the response
contentTypestringContent type of the response
Returns
Exceptions
- ApplicationException
Thrown when the URL does not contain a colon.
- ApplicationException
Thrown when no handler is registered.
RegisterCustomSchemeHandler(string, NetCustomSchemeDelegate)
Registers user-defined custom schemes (other than 'http', 'https' and 'file') and handler methods to receive callbacks when the native browser control encounters them.
public IInfiniFrameWindow RegisterCustomSchemeHandler(string scheme, NetCustomSchemeDelegate handler)
Parameters
schemestringThe custom scheme
handlerNetCustomSchemeDelegate
Returns
- IInfiniFrameWindow
Returns the current InfiniFrameWindow instance.
Exceptions
- ArgumentException
Thrown if no scheme or handler was provided
SendNotification(string, string)
Sends a native notification to the OS. Sometimes referred to as Toast notifications.
public void SendNotification(string title, string body)
Parameters
Exceptions
- ApplicationException
Thrown when the window is not initialized.
SendWebMessage(string)
Send a message to the native window's native browser control's JavaScript context.
public void SendWebMessage(string message)
Parameters
messagestringMessage as string
Remarks
In JavaScript, messages can be received via
window.external.receiveMessage(message)
Exceptions
- ApplicationException
Thrown when the window is not initialized.
SendWebMessageAsync(string)
public Task SendWebMessageAsync(string message)
Parameters
messagestring
Returns
ShowMessage(string, string?, InfiniFrameDialogButtons, InfiniFrameDialogIcon)
Show a message dialog native to the OS.
public InfiniFrameDialogResult ShowMessage(string title, string? text, InfiniFrameDialogButtons buttons = InfiniFrameDialogButtons.Ok, InfiniFrameDialogIcon icon = InfiniFrameDialogIcon.Info)
Parameters
titlestringTitle of the dialog
textstringText of the dialog
buttonsInfiniFrameDialogButtonsAvailable interaction buttons InfiniFrameDialogButtons
iconInfiniFrameDialogIconIcon of the dialog InfiniFrameDialogButtons
Returns
Exceptions
- ApplicationException
Thrown when the window is not initialized.
ShowOpenFile(string, string?, bool, (string Name, string[] Extensions)[]?)
Show an open file dialog native to the OS.
public string?[] ShowOpenFile(string title = "Choose file", string? defaultPath = null, bool multiSelect = false, (string Name, string[] Extensions)[]? filters = null)
Parameters
titlestringTitle of the dialog
defaultPathstringDefault path. Defaults to MyDocuments
multiSelectboolWhether multiple selections are allowed
filters(string Name, string[] Extensions)[]Array of Extensions for filtering.
Returns
- string[]
Array of file paths as strings
Remarks
Filter names are not used on macOS. Use async version for InfiniFrame.Blazor as the synchronous version crashes.
Exceptions
- ApplicationException
Thrown when the window is not initialized.
ShowOpenFileAsync(string, string?, bool, (string Name, string[] Extensions)[]?)
Async version is required for InfiniFrame.Blazor
public Task<string?[]> ShowOpenFileAsync(string title = "Choose file", string? defaultPath = null, bool multiSelect = false, (string Name, string[] Extensions)[]? filters = null)
Parameters
titlestringTitle of the dialog
defaultPathstringDefault path. Defaults to MyDocuments
multiSelectboolWhether multiple selections are allowed
filters(string Name, string[] Extensions)[]Array of Extensions for filtering.
Returns
Remarks
Filter names are not used on macOS. Use async version for InfiniFrame.Blazor as the synchronous version crashes.
Exceptions
- ApplicationException
Thrown when the window is not initialized.
ShowOpenFolder(string, string?, bool)
Show an open folder dialog native to the OS.
public string?[] ShowOpenFolder(string title = "Select folder", string? defaultPath = null, bool multiSelect = false)
Parameters
titlestringTitle of the dialog
defaultPathstringDefault path. Defaults to MyDocuments
multiSelectboolWhether multiple selections are allowed
Returns
- string[]
Array of folder paths as strings
Exceptions
- ApplicationException
Thrown when the window is not initialized.
ShowOpenFolderAsync(string, string?, bool)
Async version is required for InfiniFrame.Blazor
public Task<string?[]> ShowOpenFolderAsync(string title = "Choose file", string? defaultPath = null, bool multiSelect = false)
Parameters
titlestringTitle of the dialog
defaultPathstringDefault path. Defaults to MyDocuments
multiSelectboolWhether multiple selections are allowed
Returns
Exceptions
- ApplicationException
Thrown when the window is not initialized.
ShowSaveFile(string, string?, (string Name, string[] Extensions)[]?)
Show a save folder dialog native to the OS.
public string? ShowSaveFile(string title = "Save file", string? defaultPath = null, (string Name, string[] Extensions)[]? filters = null)
Parameters
titlestringTitle of the dialog
defaultPathstringDefault path. Defaults to MyDocuments
filters(string Name, string[] Extensions)[]Array of Extensions for filtering.
Returns
Remarks
Filter names are not used on macOS.
Exceptions
- ApplicationException
Thrown when the window is not initialized.
ShowSaveFileAsync(string, string?, (string Name, string[] Extensions)[]?)
Async version is required for InfiniFrame.Blazor
public Task<string?> ShowSaveFileAsync(string title = "Choose file", string? defaultPath = null, (string Name, string[] Extensions)[]? filters = null)
Parameters
titlestringTitle of the dialog
defaultPathstringDefault path. Defaults to MyDocuments
filters(string Name, string[] Extensions)[]Array of Extensions for filtering.
Returns
Remarks
Filter names are not used on macOS.
Exceptions
- ApplicationException
Thrown when the window is not initialized.
WaitForClose()
Responsible for the initialization of the primary native window and remains in operation until the window is closed. This method is also applicable for initializing child windows, but in this case, it does not inhibit operation.
public void WaitForClose()
Remarks
The operation of the message loop is exclusive to the main native window only.
WaitForCloseAsync()
public Task WaitForCloseAsync()