Screen
How to use the Screen class of the bit Butil?
Usage
To use the browser screen features you need to inject the Bit.Butil.Screen class and use it like this:
@inject Bit.Butil.Screen screen @code { var screenWidth = await screen.GetWidth(); }
Methods
GetAvailableHeight:
Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows (MDN).
@inject Bit.Butil.Screen screen <BitButton OnClick="@GetAvailableHeight">GetAvailableHeight</BitButton> <div>Available height: @availableHeight</div> @code { private string? availableHeight; private async Task GetAvailableHeight() { var result = await screen.GetAvailableHeight(); availableHeight = result.ToString(); } }
GetAvailableWidth:
Returns the amount of horizontal space in pixels available to the window (MDN).
@inject Bit.Butil.Screen screen <BitButton OnClick="@GetAvailableWidth">GetAvailableWidth</BitButton> <div>Available width: @availableWidth</div> @code { private string? availableWidth; private async Task GetAvailableWidth() { var result = await screen.GetAvailableWidth(); availableWidth = result.ToString(); } }
GetColorDepth:
Returns the color depth of the screen (MDN).
@inject Bit.Butil.Screen screen <BitButton OnClick="@GetColorDepth">GetColorDepth</BitButton> <div>Color depth: @colorDepth</div> @code { private string? colorDepth; private async Task GetColorDepth() { var result = await screen.GetColorDepth(); colorDepth = result.ToString(); } }
GetHeight:
Returns the height of the screen in pixels (MDN).
@inject Bit.Butil.Screen screen <BitButton OnClick="@GetHeight">GetHeight</BitButton> <div>Height: @height</div> @code { private string? height; private async Task GetHeight() { var result = await screen.GetHeight(); height = result.ToString(); } }
IsExtended:
Returns true if the user's device has multiple screens, and false if not (MDN).
@inject Bit.Butil.Screen screen <BitButton OnClick="@GetIsExtended">GetIsExtended</BitButton> <div>Is extended: @IsExtended</div> @code { private string? isExtended; private async Task GetIsExtended() { var result = await screen.IsExtended(); isExtended = result.ToString(); } }
GetPixelDepth:
Gets the bit depth of the screen (MDN).
@inject Bit.Butil.Screen screen <BitButton OnClick="@GetPixelDepth">GetPixelDepth</BitButton> <div>Pixel depth: @PixelDepth</div> @code { private string? pixelDepth; private async Task GetPixelDepth() { var result = await screen.GetPixelDepth(); pixelDepth = result.ToString(); } }
GetWidth:
Returns the width of the screen (MDN).
@inject Bit.Butil.Screen screen <BitButton OnClick="@GetWidth">GetWidth</BitButton> <div>Width: @width</div> @code { private string? width; private async Task GetWidth() { var result = await screen.GetWidth(); width = result.ToString(); } }
AddChange, RemoveChange:
Fired on a specific screen when it changes in some way — width or height, available width or height, color depth, or orientation (MDN).