void _bodyReader_FrameArrived(BodyFrameReader sender, BodyFrameArrivedEventArgs e) { bool shouldRecord = _recorder != null && _recorder.IsStarted && BodyCheckBox.IsChecked.GetValueOrDefault(); bool shouldDisplay = _displayType == FrameTypes.Body; if (shouldRecord || shouldDisplay) { IEnumerable <IBody> bodies = null; // to make the RecordFrame & GetBitmap calls a little cleaner using (var frame = e.FrameReference.AcquireFrame()) { if (frame != null) { if (SmoothingCombo.SelectedIndex == 0) { frame.GetAndRefreshBodyData(_bodies); bodies = _bodies; } else if (SmoothingCombo.SelectedIndex == 1) { frame.GetAndRefreshBodyData(_kalmanBodies); bodies = _kalmanBodies; } else { frame.GetAndRefreshBodyData(_exponentialBodies); bodies = _exponentialBodies; } if (shouldRecord) { _recorder.RecordFrame(frame, bodies.Cast <CustomBody>().ToList()); } } else { shouldDisplay = false; System.Diagnostics.Debug.WriteLine("!!! FRAME SKIPPED (Body in MainPage)"); } } if (shouldDisplay) { if (bodies != null) { OutputImage.Source = bodies.GetBitmap(Colors.LightGreen, Colors.Yellow); } else { OutputImage.Source = null; } } } }