Last reviewed: 7/27/2024 9:13:16 AM

.NET Windows Forms Applications

Develop .NET Windows Forms applications that manage grammars using your favorite .NET Windows Forms development tools. This includes development environments such as Microsoft Visual C# .NET and Microsoft Visual Basic .NET.

The following sections describe the steps for integrating KinesicsKit with .NET Windows Forms applications.

KinesicsKit Assemblies

KinesicsKit includes Windows Forms compatible .NET assemblies for .NET Framework and .NET to support most applications' target framework. If you need a specific target framework, then contact Chant Product Support.

To access KinesicsKit .NET classes within a Windows Forms application, add project references to the following nuget package:

  • Select the application project in the Solution Explorer
  • Right-click the mouse and select the Manage Nuget Packages… menu item.
  • Enter Chant in the search bar.
  • Select the Chant.KinesicsKit.Windows package and press the Install button.
  • Chant GrammarKit Windows package

To access the KinesicsKit .NET classes within your application, add references to the Chant shared and KinesicsKit assemblies in your code.


using System;
...
using Chant.KinesicsKit.Windows;
using Chant.Shared.Windows;

Imports Chant.KinesicsKit.Windows
Imports Chant.Shared.Windows
Class MainWindow
...

Platform Target

Set the project Platform target to either x86 for 32-bit application or x64 for 64-bit application as follows:

Within your C# project

  1. Select the Build tab under project properties.
  2. Select x86 or x64 in the Platform target dropdown list.

Within your VB .NET Project

  1. Select the Compile tab under project properties.
  2. Press the Advanced Compile Options... button.
  3. Select x86 or x64 in the Target CPU dropdown list.

Object Instantiation

Declare a global variable for the KinesicsKit class, instantiate an instance, add the event handler, and set the credentials.


private NKinesicsKit _KinesicsKit;
private NChantKinectSensor _Sensor;
public MainWindow()
{
    InitializeComponent();
    // Instantiate KinesicsKit object
    _KinesicsKit = new NKinesicsKit();
    if (_KinesicsKit != null)
    {
        // Set credentials
        _KinesicsKit.SetCredentials("Credentials");
        // Create KinectSensor
        _Sensor = _KinesicsKit.CreateKinectSensor();
        if (_Sensor != null)
        {
            // Setup event callback handler
            _Sensor.MultiSourceFrameArrived += this.NKinectSensor_MultiSourceFrameArrived;
        }
    }
}

Dim WithEvents _Sensor As NChantKinectSensor
Dim _KinesicsKit As NKinesicsKit
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    ' Instantiate KinesicsKit object
    _KinesicsKit = New NKinesicsKit()
    If (_KinesicsKit IsNot Nothing) Then
        ' Set credentials
        _KinesicsKit.SetCredentials("Credentials")
        ' Create KinectSensor
        _Sensor = _KinesicsKit.CreateKinectSensor()
    End If
End Sub

These applications require the applicable KinesicsKit API library in the same directory as the application .exe.

Speech API KinesicsKit Speech API class KinesicsKit Speech API library
Microsoft Kinect 2.0NKinectSensorCKinesicsKit.Kinect.dll or CKinesicsKitX64.Kinect.dll

Event Callbacks

Event callbacks are the mechanism in which the class object sends information back to the application such as compilation is complete or there was an error.


private void NKinectSensor_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
{
    MultiSourceFrameReference multiSourceFrameReference = e.FrameReference;
    if (multiSourceFrameReference != null)
    {
        MultiSourceFrame multiSourceFrame = multiSourceFrameReference.AcquireFrame();
        if (multiSourceFrame != null)
        {
            ...
            multiSourceFrame.Dispose();
        }
        multiSourceFrameReference.Dispose();
    }
}

Public Sub NKinectSensor_MultiSourceFrameArrived(ByVal sender As System.Object, ByVal e As MultiSourceFrameArrivedEventArgs) Handles _Sensor.MultiSourceFrameArrived
    Dim multiSourceFrameReference As MultiSourceFrameReference = e.FrameReference
    If Not (multiSourceFrameReference Is Nothing) Then
        Dim multiSourceFrame As MultiSourceFrame = multiSourceFrameReference.AcquireFrame()
        If Not (multiSourceFrame Is Nothing) Then
            ...
            multiSourceFrame.Dispose()
        End If
        multiSourceFrameReference.Dispose()
    End If
End Sub

Development and Deployment Checklist

When developing and deploying .NET applications, ensure you have a valid license, bundle the correct Chant class libraries, and configure your installation properly on the target system.

Review the following checklist before developing and deploying applications that require the applicable KinesicsKit API library:

  • Develop and deploy .NET applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
  • Copy Chant.KinesicsKit.Windows.dll and Chant.Shared.Windows.dll assemblies to the target system or merge them with your application using an obfuscator like .NET Reactor by Eziriz.
  • Copy CKinesicsKit.Kinect.dll to the target system.
  • Copy NKinesicsKit.dll to the target system,
    • register as a COM library on the target system, or
    • place in the same directory with .NET application and include an App.manifest with a dependent assembly declaration:
      
          <dependency>
              <dependentAssembly>
                      <assemblyIdentity type="win32" name="Chant.KinesicsKit.Windows" version="8.0.0.0" publicKeyToken="14b829eb51f0f386" />
              </dependentAssembly>
          </dependency>
          
  • Develop and deploy .NET applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
  • Copy Chant.KinesicsKit.Windows.dll and Chant.Shared.Windows.dll assemblies to the target system or merge them with your application using an obfuscator like .NET Reactor by Eziriz.
  • Copy CKinesicsKitX64.Kinect.dll to the target system.
  • Copy NKinesicsKitX64.dll to the target system,
    • register as a COM library on the target system, or
    • place in the same directory with .NET application and include an App.manifest with a dependent assembly declaration:
      
      <dependency>
          <dependentAssembly>
                  <assemblyIdentity type="win32" name="Chant.KinesicsKit.Windows" version="8.0.0.0" publicKeyToken="14b829eb51f0f386" />
          </dependentAssembly>
      </dependency>