发布日期 2022年01月14日

DotNetBrowser 2.11

What’s new

Chromium 96

Chromium has been upgraded to version 96.0.4664.110.

This Chromium version includes 5 security fixes, so we recommend that you upgrade to this version.

Intercepting touch events

It is now possible to handle touch events using the following handlers: Touch.Started.Handler, Touch.Moved.Handler, Touch.Canceled.Handler and Touch.Ended.Handler. See example below:

private void Subscribe(IBrowser browser)
{
    // Subscribe touch started event
    browser.Touch.Started.Handler = new Handler<ITouchEventArgs, InputEventResponse>(e =>
    {
        ITouchPoint point = e.TouchPoints.First(p => p.TouchState == TouchState.Started);
        Console.WriteLine($@"Touch {point.Id} started at -         ({point.LocationOnWidget.X} : {point.LocationOnWidget.X})");
        return InputEventResponse.Proceed;
    });

    // Subscribe touch moved event
    browser.Touch.Moved.Handler = new Handler<ITouchEventArgs, InputEventResponse>(e =>
    {
        ITouchPoint point = e.TouchPoints.First(p => p.TouchState == TouchState.Moved);
        Console.WriteLine($@"Touch {point.Id} moved to -         ({point.LocationOnWidget.X} : {point.LocationOnWidget.X})");
        return InputEventResponse.Proceed;
    });

    // Subscribe touch canceled event
    browser.Touch.Canceled.Handler = new Handler<ITouchEventArgs, InputEventResponse>(e =>
    {
        ITouchPoint point = e.TouchPoints.First(p => p.TouchState == TouchState.Canceled);
        Console.WriteLine($@"Touch {point.Id} canceled at -         ({point.LocationOnWidget.X} : {point.LocationOnWidget.X})");
        return InputEventResponse.Proceed;
    });

    // Subscribe touch ended event
    browser.Touch.Ended.Handler = new Handler<ITouchEventArgs, InputEventResponse>(e =>
    {
        ITouchPoint point = e.TouchPoints.First(p => p.TouchState == TouchState.Ended);
        Console.WriteLine($@"Touch {point.Id} ended at -         ({point.LocationOnWidget.X} : {point.LocationOnWidget.X})");
        return InputEventResponse.Proceed;
    });
}

Simulating touch events

The touch event can be simulated with the help of browser.Touch.Started, browser.Touch.Moved and browser.Touch.Ended input events:

private void SimulateTouches(IBrowser browser)
{
    browser.Focus();

    // Start touch with ID = 0 at location (10, 10)
    browser.Touch.Started.Raise(
        new TouchStartedEventArgs(
            new TouchPoint(0, TouchState.Started, new Point(10, 10))));
    Thread.Sleep(500);
    // Shifting touch with ID = 0 on 5 pixels along x axis
    browser.Touch.Moved.Raise(
        new TouchMovedEventArgs(
            new TouchPoint(0, TouchState.Moved, new Point(15, 10))));
    Thread.Sleep(500);
    // End touch with ID = 0 at location (10, 10)
    browser.Touch.Ended.Raise(
        new TouchEndedEventArgs(
            new TouchPoint(0, TouchState.Ended, new Point(15, 10))));
    Thread.Sleep(500);

    // Start touch with ID = 1 at location (10, 10)
    browser.Touch.Started.Raise(
        new TouchStartedEventArgs(
            new TouchPoint(1, TouchState.Started, new Point(10, 10))));
    Thread.Sleep(500);
    // Shifting touch with ID = 1 on 5 pixels along x axis
    browser.Touch.Moved.Raise(
        new TouchMovedEventArgs(
            new TouchPoint(1, TouchState.Moved, new Point(15, 10))));
    Thread.Sleep(500);
    // Cancel touch with ID = 1 at location (10, 10)
    browser.Touch.Canceled.Raise(
        new TouchCanceledEventArgs(
            new TouchPoint(1, TouchState.Canceled, new Point(10, 10))));
    Thread.Sleep(500);
}

System.Guid

The JS-.NET bridge functionality has been extended. Now you can inject the System.Guid structure into JavaScript and obtain it as an object from JavaScript.

DOM Image Element

DOM API has been extended with the IImageElement interface. It allows fetching image contents from the IMG tag:

IImageElement element = document.GetElementByTagName("img") as IImageElement;
Bitmap contents = element.Contents;

Improvements

  • The VS 2022 VSIX package compatibility has been added.

Fixed issues

  • AlertHandler causing the entire application to freeze.

Request evaluation license
Download DotNetBrowser 2.11 (.NET Framework)
Download DotNetBrowser 2.11 (.NET Core)

Go Top