/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private async void Stop() { try { _capture.Stop(); FrameRate.Stop(); if (Stage != Stage.Stopped && Project.AnyFrames) { await Task.Delay(100); Close(); } } 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); } }
/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private async void Stop() { try { _capture.Stop(); FrameRate.Stop(); if (Stage != Stage.Stopped && Stage != Stage.PreStarting && Project.Any) { #region Stop if (UserSettings.All.AsyncRecording) { _stopRequested = true; } await Task.Delay(100); ExitArg = ExitAction.Recorded; //DialogResult = false; Close(); #endregion } else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !Project.Any) { #region if Pre-Starting or in Snapmode and no Frames, Stops //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 = "Screen To Gif"; 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); } }
public void RunLoop() { if (Control == null) { throw new ArgumentException("Control cannot be null on loop start"); } if (frameRate == null) { frameRate = new FrameRate(); } frameRate.Start(); while (NextFrame()) { frameRate.StartFrame(); if (PreProcess != null) { PreProcess(this, new EventArgs()); } if (ProcessFrame != null) { ProcessFrame(this, new EventArgs()); } if (PostProcess != null) { PostProcess(this, new EventArgs()); } frameRate.EndFrame(); } frameRate.Stop(); }
/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private void Stop() { try { FrameCount = 0; _capture.Stop(); FrameRate.Stop(); if (Stage != Stage.Stopped && Stage != Stage.PreStarting && Project.Any) { #region Stop ExitArg = ExitAction.Recorded; if (IsDialog) { DialogResult = false; } else { Close(); } #endregion } else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !Project.Any) { #region if Pre-Starting or in Snapmode and no Frames, Stops Stage = Stage.Stopped; //Enables the controls that are disabled while recording; FpsNumericUpDown.IsEnabled = true; HeightIntegerBox.IsEnabled = true; WidthIntegerBox.IsEnabled = true; IsRecording = false; Topmost = true; Title = FindResource("Board.Title") as string + " ■"; AutoFitButtons(); #endregion } } catch (NullReferenceException nll) { ErrorDialog.Ok(FindResource("Board.Title") as string, "Error while stopping", nll.Message, nll); LogWriter.Log(nll, "NullPointer on the Stop function"); } catch (Exception ex) { ErrorDialog.Ok(FindResource("Board.Title") as string, "Error while stopping", ex.Message, ex); LogWriter.Log(ex, "Error on the Stop function"); } }
/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private void Stop() { try { _frameCount = 0; _capture.Stop(); FrameRate.Stop(); if (Stage != Stage.Stopped && Stage != Stage.PreStarting && ListFrames.Any()) { #region Stop ExitArg = ExitAction.Recorded; DialogResult = false; #endregion } else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !ListFrames.Any()) { #region if Pre-Starting or in Snapmode and no Frames, Stops Stage = Stage.Stopped; //Enables the controls that are disabled while recording; FpsNumericUpDown.IsEnabled = true; RecordPauseButton.IsEnabled = true; HeightTextBox.IsEnabled = true; WidthTextBox.IsEnabled = true; IsRecording(false); Topmost = true; RecordPauseButton.Text = Properties.Resources.btnRecordPause_Record; RecordPauseButton.Content = (Canvas)FindResource("Vector.Record.Dark"); RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left; Title = Properties.Resources.TitleStoped; AutoFitButtons(); #endregion } } catch (NullReferenceException nll) { var errorViewer = new ExceptionViewer(nll); errorViewer.ShowDialog(); LogWriter.Log(nll, "NullPointer on the Stop function"); } catch (Exception ex) { var errorViewer = new ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Error on the Stop function"); } }
/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private async void Stop() { try { _capture.Stop(); FrameRate.Stop(); await Task.Delay(100); FrameCount = 0; if (Stage != Stage.Stopped && Stage != Stage.PreStarting && ListFrames.Any()) { #region Stop ExitArg = ExitAction.Recorded; DialogResult = false; #endregion } else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !ListFrames.Any()) { #region if Pre-Starting or in Snapmode and no Frames, Stops Stage = Stage.Stopped; //Enables the controls that are disabled while recording; FpsNumericUpDown.IsEnabled = true; RecordPauseButton.IsEnabled = true; HeightIntegerBox.IsEnabled = true; WidthIntegerBox.IsEnabled = true; IsRecording = false; Topmost = true; Title = "Screen To Gif"; AutoFitButtons(); #endregion } } catch (NullReferenceException nll) { var errorViewer = new Other.ExceptionViewer(nll); errorViewer.ShowDialog(); LogWriter.Log(nll, "NullPointer on the Stop function"); } catch (Exception ex) { var errorViewer = new Other.ExceptionViewer(ex); errorViewer.ShowDialog(); LogWriter.Log(ex, "Error on the Stop function"); } }
internal virtual async Task StopCapture() { FrameRate.Stop(); StopInternalCapture(); if (Capture != null) { await Capture.Stop(); } GarbageTimer.Stop(); }
private void DiscardButton_Click(object sender, RoutedEventArgs e) { _capture.Stop(); FrameRate.Stop(); FrameCount = 0; Stage = Stage.Stopped; OutterGrid.IsEnabled = false; Cursor = Cursors.AppStarting; _discardFramesDel = Discard; _discardFramesDel.BeginInvoke(DiscardCallback, null); }
private async void DiscardButton_Click(object sender, RoutedEventArgs e) { if (UserSettings.All.NotifyRecordingDiscard && !Dialog.Ask(LocalizationHelper.Get("S.Recorder.Discard.Title"), LocalizationHelper.Get("S.Recorder.Discard.Instruction"), LocalizationHelper.Get("S.Recorder.Discard.Message"), false)) { return; } _capture.Stop(); FrameRate.Stop(); FrameCount = 0; Stage = RecorderStages.Stopped; MainGrid.IsEnabled = false; Cursor = Cursors.AppStarting; await Task.Run(Discard); //Enables the controls that are disabled while recording; FpsNumericUpDown.IsEnabled = true; HeightIntegerBox.IsEnabled = true; WidthIntegerBox.IsEnabled = true; MainGrid.IsEnabled = true; Cursor = Cursors.Arrow; IsRecording = false; DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); //Removes the current drawings. MainInkCanvas.Strokes.Clear(); //if (!Settings.Default.Snapshot) //{ //Only display the Record text when not in snapshot mode. Title = LocalizationHelper.Get("S.Board.Title"); //} //else //{ // Stage = Stage.Snapping; // EnableSnapshot_Executed(null, null); //} AutoFitButtons(); }
/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private void Stop() { try { FrameCount = 0; _capture.Stop(); FrameRate.Stop(); if (Stage != RecorderStages.Stopped && Stage != RecorderStages.PreStarting && Project.Any) { Close(); } else if ((Stage == RecorderStages.PreStarting || Stage == RecorderStages.Snapping) && !Project.Any) { #region if Pre-Starting or in Snapmode and no Frames, Stops Stage = RecorderStages.Stopped; //Enables the controls that are disabled while recording; FpsNumericUpDown.IsEnabled = true; HeightIntegerBox.IsEnabled = true; WidthIntegerBox.IsEnabled = true; IsRecording = false; Topmost = true; Title = LocalizationHelper.Get("S.Board.Title") + " ■"; AutoFitButtons(); #endregion } } catch (NullReferenceException nll) { ErrorDialog.Ok(LocalizationHelper.Get("S.Board.Title"), "Error while stopping", nll.Message, nll); LogWriter.Log(nll, "NullPointer on the Stop function"); } catch (Exception ex) { ErrorDialog.Ok(LocalizationHelper.Get("S.Board.Title"), "Error while stopping", ex.Message, ex); LogWriter.Log(ex, "Error on the Stop function"); } }
private void DiscardButton_Click(object sender, RoutedEventArgs e) { if (UserSettings.All.NotifyRecordingDiscard && !Dialog.Ask(LocalizationHelper.Get("S.Recorder.Discard.Title"), LocalizationHelper.Get("S.Recorder.Discard.Instruction"), LocalizationHelper.Get("S.Recorder.Discard.Message"), false)) { return; } _capture.Stop(); FrameRate.Stop(); FrameCount = 0; Stage = Stage.Stopped; MainGrid.IsEnabled = false; Cursor = Cursors.AppStarting; _discardFramesDel = Discard; _discardFramesDel.BeginInvoke(DiscardCallback, null); }
/// <summary> /// Method that starts or pauses the recording /// </summary> private async void RecordPause() { switch (Stage) { case Stage.Stopped: #region To Record _capture = new Timer { Interval = 1000 / FpsIntegerUpDown.Value }; _snapDelay = null; Project = new ProjectInfo().CreateProjectFolder(); _keyList.Clear(); FrameCount = 0; await Task.Factory.StartNew(UpdateScreenDpi); #region Sizing if (UserSettings.All.FullScreenMode) { _size = new Size((int)_sizeScreen.X, (int)_sizeScreen.Y); } else { _size = new Size((int)Math.Round((Width - Constants.HorizontalOffset) * _scale), (int)Math.Round((Height - Constants.VerticalOffset) * _scale)); } #endregion HeightIntegerBox.IsEnabled = false; WidthIntegerBox.IsEnabled = false; FpsIntegerUpDown.IsEnabled = false; IsRecording = true; Topmost = true; FrameRate.Start(_capture.Interval); UnregisterEvents(); #region Start if (UserSettings.All.UsePreStart) { Title = $"Screen To Gif ({FindResource("Recorder.PreStart")} {UserSettings.All.PreStartValue}s)"; RecordPauseButton.IsEnabled = false; Stage = Stage.PreStarting; _preStartCount = UserSettings.All.PreStartValue - 1; _preStartTimer.Start(); } else { if (UserSettings.All.ShowCursor) { #region If Show Cursor if (!UserSettings.All.FullScreenMode) { if (UserSettings.All.AsyncRecording) { _capture.Tick += CursorAsync_Elapsed; } else { _capture.Tick += Cursor_Elapsed; } _capture.Start(); } else { _capture.Tick += FullCursor_Elapsed; _capture.Start(); } Stage = Stage.Recording; AutoFitButtons(); #endregion } else { #region If Not if (!UserSettings.All.FullScreenMode) { if (UserSettings.All.AsyncRecording) { _capture.Tick += NormalAsync_Elapsed; } else { _capture.Tick += Normal_Elapsed; } _capture.Start(); } else { _capture.Tick += Full_Elapsed; _capture.Start(); } Stage = Stage.Recording; AutoFitButtons(); #endregion } } break; #endregion #endregion case Stage.Recording: #region To Pause Stage = Stage.Paused; Title = FindResource("Recorder.Paused").ToString(); DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); _capture.Stop(); FrameRate.Stop(); break; #endregion case Stage.Paused: #region To Record Again Stage = Stage.Recording; Title = "Screen To Gif"; DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); FrameRate.Start(_capture.Interval); _capture.Start(); break; #endregion } }
private void EnableSnapshot_Executed(object sender, ExecutedRoutedEventArgs e) { if (UserSettings.All.SnapshotMode) { #region SnapShot Recording //Set to Snapshot Mode, change the text of the record button to "Snap" and //every press of the button, takes a screenshot Stage = Stage.Snapping; Title = "Screen To Gif - " + FindResource("Recorder.Snapshot"); AutoFitButtons(); if (Project == null || Project.Frames.Count == 0) { Project = new ProjectInfo().CreateProjectFolder(); } #endregion } else { #region Normal Recording _snapDelay = null; if (Project.Frames.Count > 0) { Stage = Stage.Paused; Title = FindResource("Recorder.Paused").ToString(); DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); } else { Stage = Stage.Stopped; Title = "Screen To Gif"; } AutoFitButtons(); FrameRate.Stop(); #region Register the events UnregisterEvents(); if (UserSettings.All.ShowCursor) { if (!UserSettings.All.FullScreenMode) { if (UserSettings.All.AsyncRecording) { _capture.Tick += CursorAsync_Elapsed; } else { _capture.Tick += Cursor_Elapsed; } } else { _capture.Tick += FullCursor_Elapsed; } } else { if (!UserSettings.All.FullScreenMode) { if (UserSettings.All.AsyncRecording) { _capture.Tick += NormalAsync_Elapsed; } else { _capture.Tick += Normal_Elapsed; } } else { _capture.Tick += Full_Elapsed; } } #endregion #endregion } }
/// <summary> /// Method that starts or pauses the recording /// </summary> internal async void RecordPause() { switch (Stage) { case Stage.Stopped: _capture = new Timer { Interval = 1000 / FpsIntegerUpDown.Value }; _keyList.Clear(); FrameCount = 0; await Task.Factory.StartNew(UpdateScreenDpi); //Sizing. _size = new Size((int)Math.Round((Width - Constants.HorizontalOffset) * _scale), (int)Math.Round((Height - Constants.VerticalOffset) * _scale)); Project = new ProjectInfo(new Int32Rect { Height = (int)_size.Height, Width = (int)_size.Width }); HeightIntegerBox.IsEnabled = false; WidthIntegerBox.IsEnabled = false; FpsIntegerUpDown.IsEnabled = false; IsRecording = true; Topmost = true; FrameRate.Start(_capture.Interval); UnregisterEvents(); _capture.Tick += Normal_Elapsed; _capture.Start(); Stage = Stage.Recording; AutoFitButtons(); break; case Stage.Recording: Stage = Stage.Paused; Title = FindResource("Recorder.Paused").ToString(); DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); _capture.Stop(); FrameRate.Stop(); break; case Stage.Paused: Stage = Stage.Recording; Title = "Screen To Gif"; DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); FrameRate.Start(_capture.Interval); _capture.Start(); break; } }
/// <summary> /// Method that starts or pauses the recording /// </summary> private void RecordPause() { Extras.CreateTemp(_pathTemp); switch (Stage) { case Stage.Stopped: #region To Record _capture = new Timer { Interval = 1000 / (int)FpsNumericUpDown.Value }; _snapDelay = null; ListFrames = new List <FrameInfo>(); HeightTextBox.IsEnabled = false; WidthTextBox.IsEnabled = false; FpsNumericUpDown.IsEnabled = false; IsRecording = true; Topmost = true; FrameRate.Start(_capture.Interval); #region Start if (!Settings.Default.Snapshot) { #region Normal Recording _capture.Tick += Normal_Elapsed; //Normal_Elapsed(null, null); _capture.Start(); Stage = Stage.Recording; AutoFitButtons(); #endregion } else { #region SnapShot Recording Stage = Stage.Snapping; //Title = "Board Recorder - " + Properties.Resources.Con_SnapshotMode; AutoFitButtons(); #endregion } break; #endregion #endregion case Stage.Recording: #region To Pause Stage = Stage.Paused; Title = FindResource("Recorder.Paused").ToString(); AutoFitButtons(); _capture.Stop(); FrameRate.Stop(); break; #endregion case Stage.Paused: #region To Record Again Stage = Stage.Recording; Title = "Board Recorder"; AutoFitButtons(); FrameRate.Start(_capture.Interval); _capture.Start(); break; #endregion case Stage.Snapping: #region Take Screenshot (All possibles types) _snapDelay = Settings.Default.SnapshotDefaultDelay; Normal_Elapsed(null, null); break; #endregion } }
/// <summary> /// Method that starts or pauses the recording /// </summary> private void RecordPause() { switch (Stage) { case Stage.Stopped: #region To Record _capture = new Timer { Interval = 1000 / FpsNumericUpDown.Value }; _snapDelay = null; Project = new ProjectInfo().CreateProjectFolder(); HeightIntegerBox.IsEnabled = false; WidthIntegerBox.IsEnabled = false; FpsNumericUpDown.IsEnabled = false; IsRecording = true; Topmost = true; FrameRate.Start(_capture.Interval); #region Start //if (!Settings.Default.Snapshot) //{ #region Normal Recording _capture.Tick += Normal_Elapsed; //Normal_Elapsed(null, null); _capture.Start(); Stage = Stage.Recording; AutoFitButtons(); #endregion //} //else //{ // #region SnapShot Recording // Stage = Stage.Snapping; // //Title = "Board Recorder - " + Properties.Resources.Con_SnapshotMode; // AutoFitButtons(); // #endregion //} break; #endregion #endregion case Stage.Recording: #region To Pause Stage = Stage.Paused; Title = FindResource("Recorder.Paused").ToString(); AutoFitButtons(); _capture.Stop(); FrameRate.Stop(); break; #endregion case Stage.Paused: #region To Record Again Stage = Stage.Recording; Title = FindResource("Board.Title") as string; AutoFitButtons(); FrameRate.Start(_capture.Interval); _capture.Start(); break; #endregion case Stage.Snapping: #region Take Screenshot (All possibles types) _snapDelay = UserSettings.All.SnapshotDefaultDelay; Normal_Elapsed(null, null); break; #endregion } }
/// <summary> /// Method that starts or pauses the recording /// </summary> internal async void RecordPause() { try { switch (Stage) { case Stage.Stopped: #region To Record _captureTimer = new Timer { Interval = 1000 / FpsIntegerUpDown.Value }; Project = new ProjectInfo().CreateProjectFolder(ProjectByType.ScreenRecorder); _keyList.Clear(); FrameCount = 0; await Task.Factory.StartNew(UpdateScreenDpi); PrepareNewCapture(); HeightIntegerBox.IsEnabled = false; WidthIntegerBox.IsEnabled = false; FpsIntegerUpDown.IsEnabled = false; IsRecording = true; Topmost = true; FrameRate.Start(_captureTimer.Interval); UnregisterEvents(); #region Start if (UserSettings.All.UsePreStart) { Title = $"ScreenToGif ({LocalizationHelper.Get("Recorder.PreStart")} {UserSettings.All.PreStartValue}s)"; RecordPauseButton.IsEnabled = false; Stage = Stage.PreStarting; _preStartCount = UserSettings.All.PreStartValue - 1; _preStartTimer.Start(); } else { if (UserSettings.All.ShowCursor) { #region If Show Cursor if (UserSettings.All.AsyncRecording) { _captureTimer.Tick += CursorAsync_Elapsed; } else { _captureTimer.Tick += Cursor_Elapsed; } _captureTimer.Start(); Stage = Stage.Recording; AutoFitButtons(); #endregion } else { #region If Not if (UserSettings.All.AsyncRecording) { _captureTimer.Tick += NormalAsync_Elapsed; } else { _captureTimer.Tick += Normal_Elapsed; } _captureTimer.Start(); Stage = Stage.Recording; AutoFitButtons(); #endregion } } break; #endregion #endregion case Stage.Recording: #region To Pause _captureTimer.Stop(); FrameRate.Stop(); Stage = Stage.Paused; Title = LocalizationHelper.Get("Recorder.Paused"); DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); break; #endregion case Stage.Paused: #region To Record Again Stage = Stage.Recording; Title = "ScreenToGif"; DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); FrameRate.Start(_captureTimer.Interval); _captureTimer.Start(); break; #endregion } } catch (Exception e) { LogWriter.Log(e, "Impossible to start the recording."); ErrorDialog.Ok(Title, LocalizationHelper.Get("S.Recorder.Warning.StartPauseNotPossible"), e.Message, e); } }
private void EnableSnapshot_Executed(object sender, ExecutedRoutedEventArgs e) { if (UserSettings.All.SnapshotMode) { #region SnapShot Recording //Set to Snapshot Mode, change the text of the record button to "Snap" and //every press of the button, takes a screenshot Stage = Stage.Snapping; Title = "ScreenToGif - " + LocalizationHelper.Get("Recorder.Snapshot"); AutoFitButtons(); #endregion } else { #region Normal Recording if (_capture != null) { _capture.SnapDelay = null; } if (Project?.Frames.Count > 0) { Stage = Stage.Paused; Title = LocalizationHelper.Get("Recorder.Paused"); DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); } else { Stage = Stage.Stopped; Title = "ScreenToGif"; } AutoFitButtons(); FrameRate.Stop(); #region Register the events UnregisterEvents(); if (UserSettings.All.ShowCursor) { if (UserSettings.All.AsyncRecording) { _captureTimer.Tick += CursorAsync_Elapsed; } else { _captureTimer.Tick += Cursor_Elapsed; } } else { if (UserSettings.All.AsyncRecording) { _captureTimer.Tick += NormalAsync_Elapsed; } else { _captureTimer.Tick += Normal_Elapsed; } } #endregion #endregion } }
private void EnableSnapshot_Executed(object sender, ExecutedRoutedEventArgs e) { Extras.CreateTemp(_pathTemp); if (Settings.Default.Snapshot) { #region SnapShot Recording FpsNumericUpDown.IsEnabled = false; Topmost = true; //Set to Snapshot Mode, change the text of the record button to "Snap" and //every press of the button, takes a screenshot Stage = Stage.Snapping; Title = "Screen To Gif - " + FindResource("Recorder.Snapshot"); AutoFitButtons(); #endregion } else { #region Normal Recording _snapDelay = null; if (ListFrames.Count > 0) { Stage = Stage.Paused; Title = FindResource("Recorder.Paused").ToString(); DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); } else { Stage = Stage.Stopped; Title = "Screen To Gif"; } AutoFitButtons(); FrameRate.Stop(); #region Register the events UnregisterEvents(); if (Settings.Default.ShowCursor) { if (!Settings.Default.FullScreen) { if (Settings.Default.AsyncRecording) { _capture.Tick += CursorAsync_Elapsed; } else { _capture.Tick += Cursor_Elapsed; } } else { _capture.Tick += FullCursor_Elapsed; } } else { if (!Settings.Default.FullScreen) { if (Settings.Default.AsyncRecording) { _capture.Tick += NormalAsync_Elapsed; } else { _capture.Tick += Normal_Elapsed; } } else { _capture.Tick += Full_Elapsed; } } #endregion #endregion } }
internal virtual void PauseCapture() { FrameRate.Stop(); StopInternalCapture(); }
/// <summary> /// Method that starts or pauses the recording /// </summary> private async void RecordPause() { Extras.CreateTemp(_pathTemp); switch (Stage) { case Stage.Stopped: #region To Record _capture = new Timer { Interval = 1000 / FpsIntegerUpDown.Value }; _snapDelay = null; ListFrames = new List <FrameInfo>(); FrameCount = 0; await Task.Factory.StartNew(UpdateScreenDpi); #region If Fullscreen if (Settings.Default.FullScreen) { _size = new Size((int)_sizeScreen.X, (int)_sizeScreen.Y); //TODO: Hide the top of the window, add a little drag component, position this window at the bottom. } else { _size = new Size((int)((Width - Constants.HorizontalOffset) * _scale), (int)((Height - Constants.VerticalOffset) * _scale)); } #endregion HeightIntegerBox.IsEnabled = false; WidthIntegerBox.IsEnabled = false; FpsIntegerUpDown.IsEnabled = false; IsRecording = true; Topmost = true; FrameRate.Start(_capture.Interval); UnregisterEvents(); #region Start if (Settings.Default.PreStart) { Title = $"Screen To Gif ({FindResource("Recorder.PreStart")} 2s)"; RecordPauseButton.IsEnabled = false; Stage = Stage.PreStarting; _preStartCount = 1; //Reset timer to 2 seconds, 1 second to trigger the timer so 1 + 1 = 2 _preStartTimer.Start(); } else { if (Settings.Default.ShowCursor) { #region If Show Cursor if (!Settings.Default.FullScreen) { if (Settings.Default.AsyncRecording) { _capture.Tick += CursorAsync_Elapsed; } else { _capture.Tick += Cursor_Elapsed; } _capture.Start(); } else { _capture.Tick += FullCursor_Elapsed; _capture.Start(); } Stage = Stage.Recording; AutoFitButtons(); #endregion } else { #region If Not if (!Settings.Default.FullScreen) { if (Settings.Default.AsyncRecording) { _capture.Tick += NormalAsync_Elapsed; } else { _capture.Tick += Normal_Elapsed; } _capture.Start(); } else { _capture.Tick += Full_Elapsed; _capture.Start(); } Stage = Stage.Recording; AutoFitButtons(); #endregion } } break; #endregion #endregion case Stage.Recording: #region To Pause Stage = Stage.Paused; Title = FindResource("Recorder.Paused").ToString(); DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); _capture.Stop(); FrameRate.Stop(); break; #endregion case Stage.Paused: #region To Record Again Stage = Stage.Recording; Title = "Screen To Gif"; DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose); AutoFitButtons(); FrameRate.Start(_capture.Interval); _capture.Start(); break; #endregion } }
/// <summary> /// Stops the recording or the Pre-Start countdown. /// </summary> private async Task Stop() { try { StopButton.IsEnabled = false; RecordPauseButton.IsEnabled = false; DiscardButton.IsEnabled = false; Title = "ScreenToGif - " + LocalizationHelper.Get("S.Recorder.Stopping"); Cursor = Cursors.AppStarting; _captureTimer.Stop(); FrameRate.Stop(); if (_capture != null) { await _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; 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) { Title = "ScreenToGif"; Cursor = Cursors.Arrow; StopButton.IsEnabled = true; RecordPauseButton.IsEnabled = true; DiscardButton.IsEnabled = true; } } }
/// <summary> /// Method that starts or pauses the recording /// </summary> private void RecordPause() { Extras.CreateTemp(_pathTemp); switch (Stage) { case Stage.Stopped: #region To Record _capture = new Timer { Interval = 1000 / FpsNumericUpDown.Value }; _snapDelay = null; ListFrames = new List <FrameInfo>(); #region If Fullscreen if (Settings.Default.FullScreen) { _bt = new Bitmap((int)_sizeScreen.X, (int)_sizeScreen.Y); HideWindowAndShowTrayIcon(); } else { _bt = new Bitmap((int)((Width - 18) * _dpi), (int)((Height - 69) * _dpi)); } #endregion _gr = Graphics.FromImage(_bt); HeightTextBox.IsEnabled = false; WidthTextBox.IsEnabled = false; FpsNumericUpDown.IsEnabled = false; IsRecording(true); Topmost = true; _size = new System.Drawing.Size(_bt.Size.Width, _bt.Size.Height); FrameRate.Start(_capture.Interval); #region Start if (Settings.Default.PreStart) { Title = "Screen To Gif (2 " + Properties.Resources.TitleSecondsToGo; RecordPauseButton.IsEnabled = false; Stage = Stage.PreStarting; _preStartCount = 1; //Reset timer to 2 seconds, 1 second to trigger the timer so 1 + 1 = 2 _preStartTimer.Start(); } else { if (Settings.Default.ShowCursor) { #region If Show Cursor if (!Settings.Default.Snapshot) { #region Normal Recording if (!Settings.Default.FullScreen) { //To start recording right away, I call the tick before starting the timer, //because the first tick will only occur after the delay. _capture.Tick += Cursor_Elapsed; //Cursor_Elapsed(null, null); _capture.Start(); } else { _capture.Tick += FullCursor_Elapsed; //FullCursor_Elapsed(null, null); _capture.Start(); } Stage = Stage.Recording; RecordPauseButton.Text = Properties.Resources.Pause; RecordPauseButton.Content = (Canvas)FindResource("Vector.Pause"); RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left; AutoFitButtons(); #endregion } else { #region SnapShot Recording //Set to Snapshot Mode, change the text of the record button to "Snap" and //every press of the button, takes a screenshot Stage = Stage.Snapping; RecordPauseButton.Content = (Canvas)FindResource("Vector.Camera.Old"); RecordPauseButton.Text = Properties.Resources.btnSnap; RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left; Title = "Screen To Gif - " + Properties.Resources.Con_SnapshotMode; AutoFitButtons(); #endregion } #endregion } else { #region If Not if (!Settings.Default.Snapshot) { #region Normal Recording _actHook.OnMouseActivity += MouseHookTarget; if (!Settings.Default.FullScreen) { _capture.Tick += Normal_Elapsed; //Normal_Elapsed(null, null); _capture.Start(); } else { _capture.Tick += Full_Elapsed; //Full_Elapsed(null, null); _capture.Start(); } Stage = Stage.Recording; RecordPauseButton.Text = Properties.Resources.Pause; RecordPauseButton.Content = (Canvas)FindResource("Vector.Pause"); RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left; AutoFitButtons(); #endregion } else { #region SnapShot Recording Stage = Stage.Snapping; RecordPauseButton.Content = (Canvas)FindResource("Vector.Camera.Old"); RecordPauseButton.Text = Properties.Resources.btnSnap; RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left; Title = "Screen To Gif - " + Properties.Resources.Con_SnapshotMode; AutoFitButtons(); #endregion } #endregion } } break; #endregion #endregion case Stage.Recording: #region To Pause Stage = Stage.Paused; RecordPauseButton.Text = Properties.Resources.btnRecordPause_Continue; RecordPauseButton.Content = (Canvas)FindResource("Vector.Record.Dark"); RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left; Title = Properties.Resources.TitlePaused; AutoFitButtons(); _capture.Stop(); //ModifyCaptureTimerAndChangeTrayIconVisibility(false); FrameRate.Stop(); break; #endregion case Stage.Paused: #region To Record Again Stage = Stage.Recording; RecordPauseButton.Text = Properties.Resources.Pause; RecordPauseButton.Content = (Canvas)FindResource("Vector.Pause"); RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left; Title = Properties.Resources.TitleRecording; AutoFitButtons(); FrameRate.Start(_capture.Interval); _capture.Start(); break; //ModifyCaptureTimerAndChangeTrayIconVisibility(true); #endregion case Stage.Snapping: #region Take Screenshot (All possibles types) _snapDelay = Settings.Default.SnapshotDefaultDelay; if (Settings.Default.ShowCursor) { if (Settings.Default.FullScreen) { FullCursor_Elapsed(null, null); } else { Cursor_Elapsed(null, null); } } else { if (Settings.Default.FullScreen) { Full_Elapsed(null, null); } else { Normal_Elapsed(null, null); } } break; #endregion } }