private void ToggleButton_Checked(object sender, RoutedEventArgs e) { if (_selectedWindow != null) { SaveFileDialog sfd = new SaveFileDialog(); sfd.AddExtension = true; sfd.DefaultExt = ".avi"; if (sfd.ShowDialog().Value) { _state = State.Recording; _capture = new CaptureThread(sfd.FileName); _capture.UsePrintWindow = UsePrintWindow.IsChecked.Value; _capture.Start((IntPtr)_selectedWindow["handle"]); Dispatcher.BeginInvoke(_updateUI, UpdateType.ChangeRecordToStopRecording); Dispatcher.BeginInvoke(_updateUI, UpdateType.DisableSelecting); } else { RecordButton.IsChecked = false; } } else { RecordButton.IsChecked = false; } }