Recover Browser Information with BrowserInfo

When using VirtualUI, it is often necessary to be aware of some features and capabilities of the device from which end users are accessing our application.

The VirtualUI class has a property called BrowserInfo, which contains data about the browser being used. This information can assist us in delivering the best possible user experience.

In the list below we will find a detailed reference of the information that BrowserInfo will deliver:

An important value to consider is the UserAgent property. When establishing a connection, the browser sends VirtualUI a data string indicating its brand and version, which OS it is running on, and the brand and model of the device that is being used. This value is known as the userAgent. Using this value we can infer, for example, if the user is connecting from a mobile device and then modify some specific feature, layout or functionality of our application to better suit that device.

Information relative to the available screen space:

It is also worth mentioning that when using VirtualUI, the desktop size is dynamic. This means that the space available to display the application is correlated to the available space in the browser screen and it is not limited to a fixed desktop size space —as it would happen, for example, in an RDP connection, where the desktop size is defined when the connection is established.

The following C# example shows how to center a window of our application on this virtual desktop as needed, previously controlling its size if it exceeds the available space:

using Cybele.Thinfinity;...

...

...

private VirtualUI vui;

public Form1()

{

InitializeComponent();

vui = new VirtualUI();}

private void CenterThisWindow(object sender, EventArgs e)

{

this.WindowState = FormWindowState.Normal;

if (vui.BrowserInfo.ViewHeight < (this.Height + 20)) {

this.Height = vui.BrowserInfo.ViewHeight - 20;

}

if (vui.BrowserInfo.ViewWidth < (this.Width + 20))

{

this.Width = vui.BrowserInfo.ViewWidth - 20;

}

this.Top = (vui.BrowserInfo.ViewHeight - this.Height) / 2;

this.Left = (vui.BrowserInfo.ViewWidth - this.Width) / 2;

}

Last updated