Exemplo n.º 1
0
        private void DiscardCallback(IAsyncResult ar)
        {
            _discardFramesDel.EndInvoke(ar);

            Dispatcher.Invoke(() =>
            {
                //Enables the controls that are disabled while recording;
                FpsIntegerUpDown.IsEnabled = true;
                HeightIntegerBox.IsEnabled = true;
                WidthIntegerBox.IsEnabled  = true;
                OutterGrid.IsEnabled       = true;

                Cursor      = Cursors.Arrow;
                IsRecording = false;

                DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                if (!UserSettings.All.SnapshotMode)
                {
                    //Only display the Record text when not in snapshot mode.
                    Title = "Screen To Gif";
                }
                else
                {
                    Stage = Stage.Snapping;
                    EnableSnapshot_Executed(null, null);
                }

                AutoFitButtons();
            });

            GC.Collect();
        }
Exemplo n.º 2
0
        private void DiscardCallback(IAsyncResult ar)
        {
            _discardFramesDel.EndInvoke(ar);

            Dispatcher.Invoke(() =>
            {
                //Enables the controls that are disabled while recording;
                FpsNumericUpDown.IsEnabled     = true;
                RefreshButton.IsEnabled        = true;
                VideoDevicesComboBox.IsEnabled = true;
                LowerGrid.IsEnabled            = true;

                DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                Cursor = Cursors.Arrow;

                //if (!UserSettings.All.SnapshotMode)
                {
                    //Only display the Record text when not in snapshot mode.
                    Title = "ScreenToGif";
                    Stage = Stage.Stopped;
                }
                //else
                {
                    //Stage = Stage.Snapping;
                    //EnableSnapshot_Executed(null, null);
                }

                GC.Collect();
            });

            GC.Collect();
        }
Exemplo n.º 3
0
        private void DiscardCallback(IAsyncResult ar)
        {
            _discardFramesDel.EndInvoke(ar);

            Dispatcher.Invoke(() =>
            {
                //Enables the controls that are disabled while recording;
                FpsIntegerUpDown.IsEnabled = true;
                HeightIntegerBox.IsEnabled = true;
                WidthIntegerBox.IsEnabled  = true;
                OuterGrid.IsEnabled        = true;

                Cursor      = Cursors.Arrow;
                IsRecording = false;

                DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                Title = "ScreenToGif";
                Stage = Stage.Stopped;

                AutoFitButtons();
            });

            GC.Collect();
        }
Exemplo n.º 4
0
        private void MainInkCanvas_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            if ((Stage == Stage.Stopped || Stage == Stage.Paused) && AutoRecordToggleButton.IsChecked == true)
            {
                RecordPause();
            }

            if (DiscardButton.Visibility == Visibility.Collapsed)
            {
                DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);
            }
        }
Exemplo n.º 5
0
        private async Task Snap()
        {
            if (Project == null || Project.Frames.Count == 0)
            {
                try
                {
                    DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                    Project = new ProjectInfo().CreateProjectFolder(ProjectByType.ScreenRecorder);

                    await PrepareNewCapture();

                    IsRecording = true;
                }
                catch (Exception ex)
                {
                    LogWriter.Log(ex, "Impossible to start the screencasting.");
                    ErrorDialog.Ok(Title, LocalizationHelper.Get("S.Recorder.Warning.CaptureNotPossible"), ex.Message, ex);
                    return;
                }
            }

            if (_capture != null)
            {
                _capture.SnapDelay = UserSettings.All.SnapshotDefaultDelay;
            }

            #region Take the screenshot

            var limit = 0;
            do
            {
                if (UserSettings.All.ShowCursor)
                {
                    Cursor_Elapsed(null, null);
                }
                else
                {
                    Normal_Elapsed(null, null);
                }

                if (limit > 10)
                {
                    ErrorDialog.Ok(Title, LocalizationHelper.Get("S.Recorder.Warning.CaptureNotPossible"), LocalizationHelper.Get("S.Recorder.Warning.CaptureNotPossible.Info"), null);
                    return;
                }

                limit++;
            }while (FrameCount == 0);

            #endregion
        }
Exemplo n.º 6
0
    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();
    }
Exemplo n.º 7
0
    private async void DiscardButton_Click(object sender, RoutedEventArgs e)
    {
        Pause();

        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;
        }

        _timer.Stop();
        _frameCount = 0;
        Stage       = RecorderStages.Stopped;

        Cursor = Cursors.AppStarting;
        LowerGrid.IsEnabled = false;

        await Task.Run(Discard);

        //Enables the controls that are disabled while recording;
        FpsNumericUpDown.IsEnabled     = true;
        RefreshButton.IsEnabled        = true;
        VideoDevicesComboBox.IsEnabled = true;
        LowerGrid.IsEnabled            = true;

        DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

        Cursor = Cursors.Arrow;

        //if (!UserSettings.All.SnapshotMode)
        {
            //Only display the Record text when not in snapshot mode.
            Title = "ScreenToGif";
            Stage = RecorderStages.Stopped;
        }
        //else
        {
            //Stage = Stage.Snapping;
            //EnableSnapshot_Executed(null, null);
        }

        GC.Collect();
    }
Exemplo n.º 8
0
        private void Snap()
        {
            if (Project == null || Project.Frames.Count == 0)
            {
                _size = new Size((int)Math.Round((Width - Constants.HorizontalOffset) * _scale), (int)Math.Round((Height - Constants.VerticalOffset) * _scale));

                DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                Project = new ProjectInfo().CreateProjectFolder(ProjectByType.ScreenRecorder);

                IsRecording = true;
            }

            _snapDelay = UserSettings.All.SnapshotDefaultDelay;

            #region Take Screenshot (All possibles types)

            if (UserSettings.All.ShowCursor)
            {
                if (UserSettings.All.AsyncRecording)
                {
                    CursorAsync_Elapsed(null, null);
                }
                else
                {
                    Cursor_Elapsed(null, null);
                }
            }
            else
            {
                if (UserSettings.All.AsyncRecording)
                {
                    NormalAsync_Elapsed(null, null);
                }
                else
                {
                    Normal_Elapsed(null, null);
                }
            }

            #endregion
        }
Exemplo n.º 9
0
        public void ChangesMade()
        {
            SaveButton.Visible    = true;
            DiscardButton.Visible = true;

            int height = MainSplit.Panel1.Height;

            PlanStructure.Height = height - PlanStructure.Top - SaveButton.Height - 8;


            if (GuiUtils.IsRunningOnMono())
            {
                // buttons aren't positioned when they aren't visible
                SaveButton.Location    = new Point(Width - 156, height - 22);
                DiscardButton.Location = new Point(Width - 86, height - 22);
            }

            SaveButton.BringToFront();
            DiscardButton.BringToFront();
        }
Exemplo n.º 10
0
        private void DiscardCallback(IAsyncResult ar)
        {
            _discardFramesDel.EndInvoke(ar);

            Dispatcher.Invoke(() =>
            {
                //Enables the controls that are disabled while recording;
                FpsNumericUpDown.IsEnabled     = true;
                RefreshButton.IsEnabled        = true;
                VideoDevicesComboBox.IsEnabled = true;
                LowerGrid.IsEnabled            = true;

                DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                Cursor = Cursors.Arrow;
                Title  = "Screen To Gif";

                GC.Collect();
            });

            GC.Collect();
        }
Exemplo n.º 11
0
    internal void Pause()
    {
        try
        {
            if (Stage != RecorderStages.Recording)
            {
                return;
            }

            Stage = RecorderStages.Paused;
            Stage = RecorderStages.Paused;
            Title = LocalizationHelper.Get("S.Recorder.Paused");

            DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

            _timer.Stop();
        }
        catch (Exception e)
        {
            LogWriter.Log(e, "Impossible to pause the recording.");
            ErrorDialog.Ok(Title, LocalizationHelper.Get("S.Recorder.Warning.StartPauseNotPossible"), e.Message, e);
        }
    }
Exemplo n.º 12
0
        private void DiscardCallback(IAsyncResult ar)
        {
            _discardFramesDel.EndInvoke(ar);

            Dispatcher.Invoke(() =>
            {
                //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 = FindResource("Board.Title") as string;
                //}
                //else
                //{
                //    Stage = Stage.Snapping;
                //    EnableSnapshot_Executed(null, null);
                //}

                AutoFitButtons();
            });

            GC.Collect();
        }
Exemplo n.º 13
0
        /// <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
            }
        }
Exemplo n.º 14
0
        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
            }
        }
Exemplo n.º 15
0
        private void Snap()
        {
            if (ListFrames.Count == 0)
            {
                #region If Fullscreen

                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

                DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                IsRecording = true;
            }

            _snapDelay = UserSettings.All.SnapshotDefaultDelay;

            #region Take Screenshot (All possibles types)

            if (UserSettings.All.ShowCursor)
            {
                if (UserSettings.All.FullScreenMode)
                {
                    FullCursor_Elapsed(null, null);
                }
                else
                {
                    if (UserSettings.All.AsyncRecording)
                    {
                        CursorAsync_Elapsed(null, null);
                    }
                    else
                    {
                        Cursor_Elapsed(null, null);
                    }
                }
            }
            else
            {
                if (UserSettings.All.FullScreenMode)
                {
                    Full_Elapsed(null, null);
                }
                else
                {
                    if (UserSettings.All.AsyncRecording)
                    {
                        NormalAsync_Elapsed(null, null);
                    }
                    else
                    {
                        Normal_Elapsed(null, null);
                    }
                }
            }

            #endregion
        }
Exemplo n.º 16
0
        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
            }
        }
Exemplo n.º 17
0
    private void RecordPauseButton_Click(object sender, RoutedEventArgs e)
    {
        WebcamControl.Capture.PrepareCapture();

        if (Stage == RecorderStages.Stopped)
        {
            #region To Record

            _timer = new Timer {
                Interval = 1000 / FpsNumericUpDown.Value
            };

            Project = new ProjectInfo().CreateProjectFolder(ProjectByType.WebcamRecorder);

            RefreshButton.IsEnabled        = false;
            VideoDevicesComboBox.IsEnabled = false;
            FpsNumericUpDown.IsEnabled     = false;
            Topmost = true;

            //WebcamControl.Capture.GetFrame();

            #region Start - Normal or Snap

            if (UserSettings.All.CaptureFrequency != CaptureFrequencies.Manual)
            {
                #region Normal Recording

                _timer.Tick += Normal_Elapsed;
                Normal_Elapsed(null, null);
                _timer.Start();

                Stage = RecorderStages.Recording;

                #endregion
            }
            else
            {
                #region SnapShot Recording

                Stage = RecorderStages.Snapping;
                Title = "ScreenToGif - " + LocalizationHelper.Get("S.Recorder.Snapshot");

                Normal_Elapsed(null, null);

                #endregion
            }

            #endregion

            #endregion
        }
        else if (Stage == RecorderStages.Recording)
        {
            #region To Pause

            Stage = RecorderStages.Paused;
            Title = LocalizationHelper.Get("S.Recorder.Paused");

            DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

            _timer.Stop();

            #endregion
        }
        else if (Stage == RecorderStages.Paused)
        {
            #region To Record Again

            Stage = RecorderStages.Recording;
            Title = "ScreenToGif";

            _timer.Start();

            #endregion
        }
        else if (Stage == RecorderStages.Snapping)
        {
            #region Take Screenshot

            Normal_Elapsed(null, null);

            #endregion
        }
    }
Exemplo n.º 18
0
        /// <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
            }
        }
Exemplo n.º 19
0
        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
            }
        }
Exemplo n.º 20
0
        /// <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;
            }
        }
Exemplo n.º 21
0
        private void RecordPauseButton_Click(object sender, RoutedEventArgs e)
        {
            Extras.CreateTemp(_pathTemp);

            WebcamControl.Capture.PrepareCapture();

            if (Stage == Stage.Stopped)
            {
                #region To Record

                _timer = new Timer {
                    Interval = 1000 / (int)FpsNumericUpDown.Value
                };

                ListFrames = new List <FrameInfo>();

                RefreshButton.IsEnabled        = false;
                VideoDevicesComboBox.IsEnabled = false;
                FpsNumericUpDown.IsEnabled     = false;
                Topmost = true;

                _addDel       = AddFrames;
                _addRenderDel = AddRenderFrames;
                //WebcamControl.Capture.GetFrame();

                #region Start - Normal or Snap

                if (!Settings.Default.Snapshot)
                {
                    #region Normal Recording

                    _timer.Tick += Normal_Elapsed;
                    Normal_Elapsed(null, null);
                    _timer.Start();

                    Stage = Stage.Recording;

                    #endregion
                }
                else
                {
                    #region SnapShot Recording

                    Stage = Stage.Snapping;
                    Title = "Screen To Gif - " + FindResource("Recorder.Snapshot");

                    Normal_Elapsed(null, null);

                    #endregion
                }

                #endregion

                #endregion
            }
            else if (Stage == Stage.Recording)
            {
                #region To Pause

                Stage = Stage.Paused;
                Title = FindResource("Recorder.Paused").ToString();

                DiscardButton.BeginStoryboard(FindResource("ShowDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

                _timer.Stop();

                #endregion
            }
            else if (Stage == Stage.Paused)
            {
                #region To Record Again

                Stage = Stage.Recording;
                Title = "Screen To Gif";

                _timer.Start();

                #endregion
            }
            else if (Stage == Stage.Snapping)
            {
                #region Take Screenshot

                Normal_Elapsed(null, null);

                #endregion
            }
        }
Exemplo n.º 22
0
        /// <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);
            }
        }