Exemple #1
0
        /// <summary>
        /// Stops the recording or stops the pre-start timer.
        /// </summary>
        private void Stop()
        {
            try
            {
                _frameCount = 0; //put this in other location

                timerCapture.Stop();
                timerCaptureFull.Stop();
                timerCapWithCursor.Stop();
                timerCapWithCursorFull.Stop();

                if (_stage != Stage.Stopped && _stage != Stage.PreStarting && _listFrames.Any()) //if not already stoped or pre starting, stops
                {
                    #region To Stop and Save

                    try
                    {
                        _actHook.Stop(); //Stops the hook.
                    }
                    catch (Exception ex) { }

                    _stopDel = StopAsync;
                    _stopDel.BeginInvoke(CallBackStop, null);

                    this.Cursor = Cursors.AppStarting;
                    panelBottom.Enabled = false;

                    return;

                    #endregion
                }
                else if ((_stage == Stage.PreStarting || _stage == Stage.Snapping) && !_listFrames.Any()) // if Pre-Starting or in Snapmode and no frames, stops.
                {
                    #region To Stop

                    timerPreStart.Stop();
                    _stage = Stage.Stopped;

                    //Enables the controls that are disabled while recording;
                    numMaxFps.Enabled = true;
                    btnRecordPause.Enabled = true;
                    tbHeight.Enabled = true;
                    tbWidth.Enabled = true;

                    btnMaximize.Enabled = true;
                    btnMinimize.Enabled = true;

                    btnRecordPause.Text = Resources.btnRecordPause_Record;
                    btnRecordPause.Image = Resources.Record;
                    btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;
                    this.Text = Resources.TitleStoped;

                    AutoFitButtons();
                    this.Invalidate();

                    try
                    {
                        //Re-starts the keyboard hook.
                        _actHook.OnMouseActivity += null;
                        _actHook.Start(false, true);
                    }
                    catch (Exception) { }

                    #endregion
                }
            }
            catch (NullReferenceException nll)
            {
                MessageBox.Show(nll.Message, "NullReference", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogWriter.Log(nll, "NullPointer in the Stop function");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogWriter.Log(ex, "Error in the Stop function");
            }
        }