Kinect Hover Buttons Explained

Hover Buttons, totally cool.  Totally badly documented, I infer this from the search result for Hover Buttons.  Tess did a nice blog on create Hover buttons for one of the initial Betas.  Then nothing, ok, except for this blog, which is similar to nothing, except with the really cool null look that nothing has.

Also, the search return didn’t return the work of Ray Chambers using the Hover Button: http://raychambers.wordpress.com/2012/04/04/kinect-mix-and-match/ .  His source code is clearly based on his work with the KinectOrchestra. 

Usually I just show the code, but I just realized that the code really is “owned” by one of the instructors I am working with so you don’t get to see it.  I will have to sanitize it and then show it to you.

The best way to get started is to use the Skeletal Tracking sample, and please change the name of the project and sample.  Then to make your first HoverButton do the following:

Make sure you have a reference to the Coding4Fun.Kinect.Wpf.Controls:

image

Add to the XAML:

 xmlns:Controls="clr-namespace:Coding4Fun.Kinect.Wpf.Controls;assembly=Coding4Fun.Kinect.Wpf"
 Add this code to your project XAML in the Canvas, I have given it some color so you can see it, but normally you would have an image or similar for it to hit:
         <Controls:HoverButton Name="hoverButtonRight"                                Canvas.Left="385" Canvas.Top="303"                                Height="67" Width="97"                                ImageSize="78"                                TimeInterval="1000"                                BorderBrush="Yellow" Background="Yellow"                               FontFamily="Arial" FontSize="8" Opacity="0.1"/>

 

Then in the code behind, add the yellow highlighted code to the MainWindows:

        public MainWindow()         {             InitializeComponent();             hoverButtonRight.Click += new RoutedEventHandler(hoverButtonRight_Click);
 ….
 You will need an eventhandler, which can be added automatically:
              
         void hoverButtonRight_Click(object sender, RoutedEventArgs e)         {             //Add your code here                     }
 You will need a method to check the button in the GetCameraPoint method of the Skeletal Tracking, and that method would look like the following:
 The method would look like:
  private void CheckButtonForCamera()         {             /******************************************************              * CheckButton (Seriously fix this sloppy coding)              * The blog is tested for the FrameworkElement (image)              * And then this is passed for the Camera              *****************************************************/             if (blob == SideBarLeftHand)             {                 CheckButton(hoverButtonRight, SideBarLeftHand);             }
 Oh this isn’t working as well as I would like, so watch for a better blog tomorrow.