private void Button_Click(object sender, RoutedEventArgs e) { try { int nFramesToCapture = Convert.ToInt32(nFramesToCaptureText.Text); _framesToCapture = nFramesToCapture; int nMemoryFrames = Convert.ToInt32(nMemoryFramesText.Text); SerializationFlags serializationFlags = new SerializationFlags(ColorBox.IsChecked == true, DepthBox.IsChecked == true, InfraredBox.IsChecked == true, SkeletonBox.IsChecked == true, DepthMappingBox.IsChecked == true, BodyIndexBox.IsChecked == true); _captureController.StartCapture(serializationFlags, nMemoryFrames, nFramesToCapture); } catch (Exception ex) { // Catch those Exceptions we know can happen if (ex is FormatException || ex is ArgumentException || ex is ArgumentOutOfRangeException || ex is OverflowException || ex is InvalidOperationException) { Console.WriteLine("Exception thrown"); MessageBox.Show(ex.Message); return; } // Other type of Exception, so rethrow it throw; } }
private void Button_Click(object sender, RoutedEventArgs e) { try { _captureController.StartCapture(); } catch (InvalidOperationException ex) { MessageBox.Show(ex.Message); } }