private async void DiscardButton_Click(object sender, RoutedEventArgs e) { _captureTimer.Stop(); FrameRate.Stop(); FrameCount = 0; Stage = Stage.Discarding; await _capture.Stop(); OutterGrid.IsEnabled = false; Cursor = Cursors.AppStarting; _discardFramesDel = Discard; _discardFramesDel.BeginInvoke(DiscardCallback, null); }
internal virtual async Task StopCapture() { FrameRate.Stop(); StopInternalCapture(); if (Capture != null) { await Capture.Stop(); } GarbageTimer.Stop(); }
/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private async void Stop() { try { StopButton.IsEnabled = false; _captureTimer.Stop(); FrameRate.Stop(); _capture?.Stop(); if (Stage != Stage.Stopped && Stage != Stage.PreStarting && Project.Any) { #region Stop if (UserSettings.All.AsyncRecording) { _stopRequested = true; } await Task.Delay(100); Close(); #endregion } else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !Project.Any) { #region if Pre-Starting or in Snapmode and no Frames, Stops if (Stage == Stage.PreStarting) { //Stop the pre-start timer to kill pre-start warming up _preStartTimer.Stop(); } //Only returns to the stopped stage if it was recording. Stage = Stage == Stage.Snapping ? Stage.Snapping : Stage.Stopped; //Enables the controls that are disabled while recording; FpsIntegerUpDown.IsEnabled = true; RecordPauseButton.IsEnabled = true; HeightIntegerBox.IsEnabled = true; WidthIntegerBox.IsEnabled = true; IsRecording = false; Topmost = true; Title = "ScreenToGif"; AutoFitButtons(); #endregion } } catch (NullReferenceException nll) { LogWriter.Log(nll, "NullPointer on the Stop function"); ErrorDialog.Ok("ScreenToGif", "Error while stopping", nll.Message, nll); } catch (Exception ex) { LogWriter.Log(ex, "Error on the Stop function"); ErrorDialog.Ok("ScreenToGif", "Error while stopping", ex.Message, ex); } finally { if (IsLoaded) { StopButton.IsEnabled = true; } } }