title: Need help updating old Kinect SDK code.
body: <p>We have been having trouble with finding up to date tutorials for the Kinect SDK 1.8. All of the tutorials that we have found online are for an older version of the SDK. If anyone could help, would someone please tell us what version of the Kinect SDK this code is written in and how to update the code to the latest SDK code(version 1.8). </p>
  
  <p><pre></p>
  
  <code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using Microsoft.Research.Kinect.Nui;
  
  namespace KinectSkeletonApplication3
  {
      public partial class MainWindow : Window
      {
          //Instantiate the Kinect runtime. Required to initialize the device.
          //IMPORTANT NOTE: You can pass the device ID here, in case more than one Kinect device is connected.
  
  
          Runtime runtime = Runtime.Kinects[0];
  
          public MainWindow()
          {
              InitializeComponent();
  
              //Runtime initialization is handled when the window is opened. When the window
              //is closed, the runtime MUST be unitialized.
              this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
              this.Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
  
              runtime.SkeletonFrameReady += new EventHandler&lt;SkeletonFrameReadyEventArgs&gt;(runtime_SkeletonFrameReady);
          }
  
          void runtime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
          {
              SkeletonFrame skeletonSet = e.SkeletonFrame;
  
              SkeletonData data = (from s in skeletonSet.Skeletons
                                   where s.TrackingState == SkeletonTrackingState.Tracked
                                   select s).FirstOrDefault();
              if (data != null)
              {
                  SetEllipsePosition(Head, data.Joints[JointID.Head]);
                  SetEllipsePosition(leftHand, data.Joints[JointID.HandLeft]);
                  SetEllipsePosition(rightHand, data.Joints[JointID.HandRight]);
                  ProcessGesture(data.Joints[JointID.Head], data.Joints[JointID.HandLeft], data.Joints[JointID.HandRight]);
              }     
  
          }
  
          private void ProcessGesture(Joint head, Joint handLeft, Joint handRight)
          {
              if ((handRight.position.Y &gt; head.position.Y) || (handLeft.position.Y &gt; head.position.Y))
              {
                  MessageBox.Show("Your hand is above your head, bitch.");
              }
              else if ((handRight.position.Y &lt; 0) || (handLeft.position.Y &lt; 0))
              {
                  MessageBox.Show("Your hand is below your waist, bitch.");
              }
              else if (handRight.position.X &lt; handLeft.position.X)
              {
                  MessageBox.Show("Your hands are crossed, bitch.");
              }
          }
  
  
          private void SetEllipsePosition(Ellipse ellipse, Joint joint)
          {
              Microsoft.Research.Kinect.Nui.Vector vector = new Microsoft.Research.Kinect.Nui.Vector();
              vector.X = ScaleVector(640, joint.Position.X);
              vector.Y = ScaleVector(480, -joint.Position.Y);
              vector.Z = joint.Position.Z;
  
              Joint updatedJoint = new Joint();
              updatedJoint.ID = joint.ID;
              updatedJoint.TrackingState = JointTrackingState.Tracked;
              updatedJoint.Position = vector;
  
              Canvas.SetLeft(ellipse, updatedJoint.Position.X);
              Canvas.SetTop(ellipse, updatedJoint.Position.Y);
  
  
          }
  
          private float ScaleVector(int length, float position)
          {
              float value = (((((float)length) / 1f) / 2f) * position) + (length / 2);
              if (value &gt; length)
              {
                  return (float)length;
              }
              if (value &lt; 0f)
              {
                  return 0f;
              }
              return value;
          }
  
          void MainWindow_Unloaded(object sender, RoutedEventArgs e)
          {
              runtime.Uninitialize();
          }
  
          void MainWindow_Loaded(object sender, RoutedEventArgs e)
          {
              //Since only a color video stream is needed, RuntimeOptions.UseColor is used.
              runtime.Initialize(Microsoft.Research.Kinect.Nui.RuntimeOptions.UseColor | RuntimeOptions.UseSkeletalTracking);
          }
  
  
      }
  }
  </code></pre>
  
  <p></p></p>