Skip to main content

How many fingers point can be tracked by Windows 8

Windows 8 brought to us a native support for touch screens. This is a great feature that opens the tablets world for us.
For touch support, we have a lot of gestures that are built in. We need only to subscribe to the event that we want to listen. This can be very useful, because we don’t need any more to implement our custom gestures.
  • Tap - one finger touches the screen and lifts up.
  • Press and hold - one finger touches the screen and stays in place.
  • Slide - one or more fingers touch the screen and move in the same direction.
  • Swipe - one or more fingers touch the screen and move a short distance in the same direction.
  • Turn - two or more fingers touch the screen and move in a clockwise or counter-clockwise arc.
  • Pinch - two or more fingers touch the screen and move closer together.
  • Stretch - two or more fingers touch the screen and move farther apart.
If we need a custom gesture we can implement it without any kind of problem. This is not recommended because the user will need to learn new gestures for each application.
I received some question about how many fingers can be tracked in the same time by Windows 8. It seems that this is direct dependent to the hardware. WinRT API gives as the possibility to track each touch point separately with a unique id when the track point enters in our component. We can store these items in a collection (dictionary with the pointer ID as key). When a new pointer appears in our component we can add it to our collection and when the pointer exits our control we will need to remove it from our collection. In this way we will know how many finger points are in our controller.
The event that we need to use to track these actions is PointerMoved event of a container. The event will contains a method named “GetCurrentPoint”, that will return the current point that was moved. Each object of this type contains two properties that are very useful for us:
  • PointerId – The unique id of the pointer (each time when we touch the screen a new point with a new id will be generated).
  • IsInContact – Will tell us if the current pointer is still in contact (eq. when you remove the finger from the screen this method will be called with this property set to false – at this step we need to remove the pointer id from the collection).
Our code should look like something like this:
private void container_PointerMoved(object sender, PointerRoutedEventArgs e)
{
    PointerPoint currentPointerPoint = e.GetCurrentPoint(myContainer);
    var pointerId = currentPointerPoint.PointerId;
    if (!currentPointerPoint.IsInContact 
           && collection.Contains(pointerId))
    {
      collection.Remove(pointerId);
        return;
    }
    if (currentPointerPoint.IsInContact) 
    {
  // Check the pointer location - Position.X and Position.X properties
  collection[pointerId] = ...;
    }
}
It seems that the number of maxim fingers that are supported by Windows 8 is directly dependent by the hardware.

Comments

Popular posts from this blog

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Run native .NET application in Docker (.NET Framework 4.6.2)

Scope
The main scope of this post is to see how we can run a legacy application written in .NET Framework in Docker.

Context
First of all, let’s define what is a legacy application in our context. By a legacy application we understand an application that runs .NET Framework 3.5 or higher in a production environment where we don’t have any more the people or documentation that would help us to understand what is happening behind the scene.
In this scenarios, you might want to migrate the current solution from a standard environment to Docker. There are many advantages for such a migration, like:

Continuous DeploymentTestingIsolationSecurity at container levelVersioning ControlEnvironment Standardization
Until now, we didn’t had the possibility to run a .NET application in Docker. With .NET Core, there was support for .NET Core in Docker, but migration from a full .NET framework to .NET Core can be costly and even impossible. Not only because of lack of features, but also because once you…