I am creating a WPF/C# app that uses the kinect for moving objects but it also runs with using the mouse. Currently I comment out the kinect code for it work using the mouse. I need way to recognize whether the kinect is connected or not so I don't have to comment out code for it to use the mouse when it's not (without throwing an exception as it currently does) and use kinect when it does. How may I do that?? info: I am using official Microsoft Kinect SDKs (Downloaded about a week ago)
Edit-- I am using these
using System;
using System.ComponentModel;
using System.Threading;
using System.Windows;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows.Media.Media3D;
using System.Windows.Media.Animation;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using GridAnimationDemo;
using System.Windows.Threading;
using HtmlAgilityPack;
using System.Xml.Linq;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Net;
using Microsoft.Research.Kinect.Nui;
using Microsoft.Research.Kinect.Audio;
using Microsoft.Research.Kinect;
using Microsoft.Office.Interop.PowerPoint;
using System.Windows.Data;
using Microsoft.Research.Kinect.Samples.CursorControl;
using Coding4Fun.Kinect.Wpf;
using Coding4Fun;
using System.Speech.Synthesis;
Cannot add reference and use Microsoft.Kinect as it creates conflicts with some of these
EDIT--
Device dvc = new Device();
if (dvc.Count.Equals(0))
MessageBox.Show("apoellin");
I tried the above code and the app crashes with the same error it crashes if I use any Kinect code with Kinect not connected
You are using a very out of date version of the Kinect for Windows SDK. The Microsoft.Research.Kinect
namespace is from the beta.
The latest SDK can be downloaded here:
http://www.microsoft.com/en-us/kinectforwindows/develop/developer-downloads.aspx
After you do that, download the Developer Toolkit, also available from the link above. It contains multiple examples of how to do many tasks.
I strongly suggest looking at the Kinect Explorer example. This will show you how to use a data container called KinectSensorManager. This class is a data wrapper and not part of the SDK -- it helps manage the Kinect sensor. It is included in several of the Toolkit examples.
The class, among other things, fires events when the Kinect sensor state changes. So you can set your program up to initialize and uninitialized the Kinect in the appropriate event handlers.