/// <summary> /// Execute shutdown tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void MainWindow_Closing(object sender, CancelEventArgs e) { if (this.kinectIRView != null) { this.kinectIRView.Dispose(); this.kinectIRView = null; } if (this.kinectDepthView != null) { this.kinectDepthView.Dispose(); this.kinectDepthView = null; } if (this.kinectBodyIndexView != null) { this.kinectBodyIndexView.Dispose(); this.kinectBodyIndexView = null; } if (this.kinectBodyView != null) { this.kinectBodyView.Dispose(); this.kinectBodyView = null; } if (this.kinectSensor != null) { this.kinectSensor.Close(); this.kinectSensor = null; } }
/// <summary> /// Disposes all unmanaged resources for the class /// </summary> public void Dispose() { if (this.kinectIRView != null) { this.kinectIRView.Dispose(); this.kinectIRView = null; } if (this.kinectDepthView != null) { this.kinectDepthView.Dispose(); this.kinectDepthView = null; } if (this.kinectBodyIndexView != null) { this.kinectBodyIndexView.Dispose(); this.kinectBodyIndexView = null; } if (this.kinectBodyView != null) { this.kinectBodyView.Dispose(); this.kinectBodyView = null; } }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { // initialize the components (controls) of the window this.InitializeComponent(); // get the kinectSensor object this.kinectSensor = KinectSensor.GetDefault(); // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // set the status text this.KinectStatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; // create the IR visualizer this.kinectIRView = new KinectIRView(this.kinectSensor); // create the Depth visualizer this.kinectDepthView = new KinectDepthView(this.kinectSensor); // create the BodyIndex visualizer this.kinectBodyIndexView = new KinectBodyIndexView(this.kinectSensor); // create the Body visualizer this.kinectBodyView = new KinectBodyView(this.kinectSensor); // set data context for display in UI this.DataContext = this; this.kinectIRViewbox.DataContext = this.kinectIRView; this.kinectDepthViewbox.DataContext = this.kinectDepthView; this.kinectBodyIndexViewbox.DataContext = this.kinectBodyIndexView; this.kinectBodyViewbox.DataContext = this.kinectBodyView; }