/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Create the gesture recognizer. this.activeRecognizer = this.CreateRecognizer(); // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.imageSource = new DrawingImage(this.drawingGroup); // Display the drawing using our image control Image.Source = this.imageSource; // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } if (null != this.sensor) { // Turn on the skeleton stream to receive skeleton frames this.sensor.SkeletonStream.Enable(); // Add an event handler to be called whenever there is new color frame data this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } } if (null == this.sensor) { this.txtStatus.Text = "No kinect has detected."; } // Show screen window to draw pen or laser wndScreen = new ScreenWindow(); wndScreen.Show(); InitializeWindowInfo(); hwndPresentation = FindPresentationHandle((IntPtr)null, this.windowInfo); if (hwndPresentation == (IntPtr)null) { this.txtStatus.Text = "No presentation application has detected."; } // Find windows handle to send message hwndScreen = new WindowInteropHelper(this.wndScreen).Handle; }