Table of Contents

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

InfiniFrameNativeParameters

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

string

CachedPreFullScreenBounds

public Rectangle CachedPreFullScreenBounds { get; set; }

Property Value

Rectangle

CachedPreMaximizedBounds

public Rectangle CachedPreMaximizedBounds { get; set; }

Property Value

Rectangle

Chromeless

Gets the value indicating whether the native window is chromeless.

public bool Chromeless { get; }

Property Value

bool

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

bool

CustomSchemes

public required Dictionary<string, NetCustomSchemeDelegate?> CustomSchemes { get; init; }

Property Value

Dictionary<string, NetCustomSchemeDelegate>

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

bool

Events

public required IInfiniFrameWindowEvents Events { get; init; }

Property Value

IInfiniFrameWindowEvents

FileSystemAccessEnabled

public bool FileSystemAccessEnabled { get; }

Property Value

bool

Focused

Gets whether the native window is currently within focus

public bool Focused { get; }

Property Value

bool

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

bool

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

bool

Height

Gets or Sets the Height property of the native window in pixels. The default value is 0.

public int Height { get; }

Property Value

int

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

string

Id

Gets a unique GUID to identify the native window.

public Guid Id { get; }

Property Value

Guid

Remarks

This property is not currently used by the InfiniFrame framework.

IgnoreCertificateErrorsEnabled

public bool IgnoreCertificateErrorsEnabled { get; }

Property Value

bool

InstanceHandle

public nint InstanceHandle { get; }

Property Value

nint

JavascriptClipboardAccessEnabled

public bool JavascriptClipboardAccessEnabled { get; }

Property Value

bool

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

int

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

Point

Logger

public required ILogger<IInfiniFrameWindow> Logger { get; init; }

Property Value

ILogger<IInfiniFrameWindow>

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

int

MaxHeight

Gets or sets the native window maximum height in pixels.

public int MaxHeight { get; set; }

Property Value

int

MaxSize

Gets or set the maximum size of the native window in pixels.

public Size MaxSize { get; set; }

Property Value

Size

MaxWidth

Gets or sets the native window maximum width in pixels.

public int MaxWidth { get; set; }

Property Value

int

Maximized

Gets or sets whether the native window is maximized. Default is false.

public bool Maximized { get; }

Property Value

bool

MediaAutoplayEnabled

public bool MediaAutoplayEnabled { get; }

Property Value

bool

MediaStreamEnabled

public bool MediaStreamEnabled { get; }

Property Value

bool

MessageHandlers

public required IInfiniFrameWindowMessageHandlers MessageHandlers { get; init; }

Property Value

IInfiniFrameWindowMessageHandlers

MinHeight

Gets or sets the native window minimum height in pixels.

public int MinHeight { get; set; }

Property Value

int

MinSize

Gets or set the minimum size of the native window in pixels.

public Size MinSize { get; set; }

Property Value

Size

MinWidth

Gets or sets the native window minimum width in pixels.

public int MinWidth { get; set; }

Property Value

int

Minimized

Gets or sets whether the native window is minimized (hidden). Default is false.

public bool Minimized { get; }

Property Value

bool

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

nint

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

string

Remarks

Only available on Windows.

Exceptions

ApplicationException

Thrown if a platform is not Windows.

NotificationsEnabled

public bool NotificationsEnabled { get; }

Property Value

bool

Parent

public required IInfiniFrameWindow? Parent { get; init; }

Property Value

IInfiniFrameWindow

Resizable

Gets or sets whether the user can resize the native window. Default is true.

public bool Resizable { get; }

Property Value

bool

ScreenDpi

Gets the dots per inch (DPI) for the primary display from the native window.

public uint ScreenDpi { get; }

Property Value

uint

Exceptions

ApplicationException

An ApplicationException is thrown if the window hasn't been initialized yet.

ServiceProvider

public required IServiceProvider? ServiceProvider { get; init; }

Property Value

IServiceProvider

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

Size

SmoothScrollingEnabled

public bool SmoothScrollingEnabled { get; }

Property Value

bool

StartString

Gets or sets an HTML string that the browser control will render when initialized. Default is none.

public string? StartString { get; }

Property Value

string

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

string

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

string

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

string

Top

Gets or sets the native window Top (Y) coordinate in pixels. Default is 0.

public int Top { get; }

Property Value

int

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

bool

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

bool

Exceptions

ApplicationException

On Windows, thrown if trying to set a value after a native window is initialized.

UserAgent

public string? UserAgent { get; }

Property Value

string

WebSecurityEnabled

public bool WebSecurityEnabled { get; }

Property Value

bool

Width

Gets or Sets the native window width in pixels. Default is 0.

public int Width { get; }

Property Value

int

WindowHandle

Represents a property that gets the handle of the native window on a Windows platform.

public nint WindowHandle { get; }

Property Value

nint

The handle of the native window. The value is of type nint.

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

int

Examples

100 = 100%, 50 = 50%

ZoomEnabled

public bool ZoomEnabled { get; }

Property Value

bool

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

workItem Action

The 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

url string

URL of the Scheme

numBytes int

Number of bytes of the response

contentType string

Content type of the response

Returns

nint

nint

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

scheme string

The custom scheme

handler NetCustomSchemeDelegate

EventHandler

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

title string

The title of the notification

body string

The text of the notification

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

message string

Message 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

message string

Returns

Task

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

title string

Title of the dialog

text string

Text of the dialog

buttons InfiniFrameDialogButtons

Available interaction buttons InfiniFrameDialogButtons

icon InfiniFrameDialogIcon

Icon of the dialog InfiniFrameDialogButtons

Returns

InfiniFrameDialogResult

InfiniFrameDialogResult

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

title string

Title of the dialog

defaultPath string

Default path. Defaults to MyDocuments

multiSelect bool

Whether 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

title string

Title of the dialog

defaultPath string

Default path. Defaults to MyDocuments

multiSelect bool

Whether multiple selections are allowed

filters (string Name, string[] Extensions)[]

Array of Extensions for filtering.

Returns

Task<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.

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

title string

Title of the dialog

defaultPath string

Default path. Defaults to MyDocuments

multiSelect bool

Whether 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

title string

Title of the dialog

defaultPath string

Default path. Defaults to MyDocuments

multiSelect bool

Whether multiple selections are allowed

Returns

Task<string[]>

Array of folder paths as strings

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

title string

Title of the dialog

defaultPath string

Default path. Defaults to MyDocuments

filters (string Name, string[] Extensions)[]

Array of Extensions for filtering.

Returns

string

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

title string

Title of the dialog

defaultPath string

Default path. Defaults to MyDocuments

filters (string Name, string[] Extensions)[]

Array of Extensions for filtering.

Returns

Task<string>

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()

Returns

Task