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:
Attribute
Description
Username
Returns the logged-on username.
IPAddress
Returns the client's ip address.
Location
Returns the URL of the current application.
UniqueBrowserId
Identifies an instance of a browser. Each time an end-user opens the application from a different browser window, this identifier will be have a different value.
UserAgent
Returns the browser's User Agent string. This value is very important to identify which browser type is used, if the remote device is a mobile, etc.
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:
Attribute
Description
BrowserWidth
Returns the width of the HTML element containing the VirtualUI viewer, in pixels.
BrowserHeigth
Returns the height of the HTML element containing the VirtualUI viewer, in pixels.
ScreenWidth
Returns the width of the end-user's device screen, in pixels.
ScreenHeight
Returns the height of the end-user's device screen, in pixels.
ScreenResolution
Returns the application screen resolution defined in the application profile.
ViewWidth
Returns the width of the VirtualUI viewer, in pixels.
ViewHeight
Returns the height of the VirtualUI viewer, in pixels.
Orientation
Returns the browser's orientation.
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 modified 1yr ago
Export as PDF
Copy link