/// <summary> /// Prevents a default instance of the <see cref="KinectCursorManager"/> class from being created. /// </summary> /// <param name="window">The window.</param> /// <param name="sensor">The sensor.</param> /// <param name="cursor">The cursor.</param> private KinectCursorManager(Window window, KinectSensor sensor, FrameworkElement cursor) { this._window = window; this._gesturePoints = new List <GesturePoint>(); // ensure kinects are present if (KinectSensor.KinectSensors.Count > 0) { _window.Unloaded += delegate { if (this._kinectSensor.SkeletonStream.IsEnabled) { this._kinectSensor.SkeletonStream.Disable(); } _kinectSensor.Stop(); }; _window.Loaded += delegate { if (cursor == null) { _cursorAdorner = new CursorAdorner((FrameworkElement)window.Content); } else { _cursorAdorner = new CursorAdorner((FrameworkElement)window.Content, cursor); } this._kinectSensor = sensor; this._kinectSensor.SkeletonFrameReady += SkeletonFrameReady; this._kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters() { Correction = 0.5f , JitterRadius = 0.05f , MaxDeviationRadius = 0.04f , Smoothing = 0.5f }); this._kinectSensor.Start(); }; } }
/// <summary> /// Prevents a default instance of the <see cref="KinectCursorManager"/> class from being created. /// </summary> /// <param name="window">The window.</param> /// <param name="sensor">The sensor.</param> /// <param name="cursor">The cursor.</param> private KinectCursorManager(Window window, KinectSensor sensor, FrameworkElement cursor) { this._window = window; this._gesturePoints = new List<GesturePoint>(); // ensure kinects are present if (KinectSensor.KinectSensors.Count > 0) { _window.Unloaded += delegate { if (this._kinectSensor.SkeletonStream.IsEnabled) this._kinectSensor.SkeletonStream.Disable(); _kinectSensor.Stop(); }; _window.Loaded += delegate { if (cursor == null) _cursorAdorner = new CursorAdorner((FrameworkElement)window.Content); else _cursorAdorner = new CursorAdorner((FrameworkElement)window.Content, cursor); this._kinectSensor = sensor; this._WaveGesture = new WaveDetection.WaveGesture(); this._WaveGesture.GestureDetected += new EventHandler(_WaveGesture_GestureDetected); this._XmlLogger = XMLLoggerSingleton.Instance; this._kinectSensor.SkeletonFrameReady += SkeletonFrameReady; this._kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters() { Correction = 0.5f , JitterRadius = 0.05f , MaxDeviationRadius = 0.04f , Smoothing = 0.5f }); this._kinectSensor.Start(); }; } }