Ejemplo n.º 1
0
        /// <summary>
        /// Função que recebe um array de bytes contendo as informações do frame e monta o frame com estes dados.
        /// Após a montagem deste frame, o mesmo é armazenado na lista de pacotes recebidos.
        /// </summary>
        /// <param name="byteData"></param>
        /// <param name="nReceived"></param>
        private void ParseData(byte[] byteData, int nReceived)
        {
            //Since all protocol packets are encapsulated in the IP datagram
            //so we start by parsing the IP header and see what protocol data
            //is being carried by it
            IPHeader ipHeader = new IPHeader(byteData, nReceived);

            ipHeader.ListIndex = ListaPacotesRecebidos.Count;
            ListaPacotesRecebidos.Add(ipHeader);

            AddFrame addFrame = new AddFrame(OnAddFrame);

            //Thread safe adding of the nodes
            panel1.Invoke(addFrame, new object[] { ipHeader });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts rendering in a thread. Each StartAsync() call *must* be balanced
        /// by a Dispose() call or bad things will happen.
        /// </summary>
        public void StartAsync()
        {
            System.Diagnostics.Debug.Assert(mAviWriter == null);
            System.Diagnostics.Debug.Assert(mThread == null);
            if (mThread != null)
            {
                return;                   // for sanity
            }
            mAddFrameFunc = doAddFrame;
            if (mDestFilename != null)
            {
                mAviWriter = new AviWriter();
                mAviBmp    = mAviWriter.Open(mDestFilename, (uint)mFps, mMovieSx, mMovieSy);
            }
            else
            {
                mAviBmp = new Bitmap(mMovieSx, mMovieSy);
            }

            mThreadMustStop = false;

            mThread = new Thread(threadEntryPoint);
            mThread.Start();
        }
Ejemplo n.º 3
0
        private void RecordPauseButton_Click(object sender, RoutedEventArgs e)
        {
            Extras.CreateTemp(_pathTemp);

            _capture.PrepareCapture();

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

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

                ListFrames = new List<FrameInfo>();

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

                _addDel = AddFrames;
                _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;
                    RecordPauseButton.Text = Properties.Resources.Pause;
                    RecordPauseButton.Content = (Canvas)FindResource("Vector.Pause");

                    #endregion
                }
                else
                {
                    #region SnapShot Recording

                    Stage = Stage.Snapping;
                    RecordPauseButton.Content = (Canvas)FindResource("Vector.Camera");
                    RecordPauseButton.Text = Properties.Resources.btnSnap;
                    Title = "Screen To Gif - " + Properties.Resources.Con_SnapshotMode;

                    Normal_Elapsed(null, null);

                    #endregion
                }

                #endregion

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

                Stage = Stage.Paused;
                RecordPauseButton.Text = Properties.Resources.btnRecordPause_Continue;
                RecordPauseButton.Content = (Canvas)FindResource("Vector.Record.Dark");
                Title = Properties.Resources.TitlePaused;

                _timer.Stop();

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

                Stage = Stage.Recording;
                RecordPauseButton.Text = Properties.Resources.Pause;
                RecordPauseButton.Content = (Canvas)FindResource("Vector.Pause");
                Title = Properties.Resources.TitleRecording;

                _timer.Start();

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

                Normal_Elapsed(null, null);

                #endregion
            }
        }
Ejemplo n.º 4
0
        private void RecordPauseButton_Click(object sender, RoutedEventArgs e)
        {
            WebcamControl.Capture.PrepareCapture();

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

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

                Project = new ProjectInfo().CreateProjectFolder();

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

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

                #region Start - Normal or Snap

                if (!UserSettings.All.SnapshotMode)
                {
                    #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
            }
        }
Ejemplo n.º 5
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;
                    RecordPauseButton.Text    = Properties.Resources.Pause;
                    RecordPauseButton.Content = (Canvas)FindResource("Vector.Pause");

                    #endregion
                }
                else
                {
                    #region SnapShot Recording

                    Stage = Stage.Snapping;
                    RecordPauseButton.Content = (Canvas)FindResource("Vector.Camera.Add");
                    RecordPauseButton.Text    = Properties.Resources.btnSnap;
                    Title = "Screen To Gif - " + Properties.Resources.Con_SnapshotMode;

                    Normal_Elapsed(null, null);

                    #endregion
                }

                #endregion

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

                Stage = Stage.Paused;
                RecordPauseButton.Text    = Properties.Resources.btnRecordPause_Continue;
                RecordPauseButton.Content = (Canvas)FindResource("Vector.Record.Dark");
                Title = Properties.Resources.TitlePaused;

                _timer.Stop();

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

                Stage = Stage.Recording;
                RecordPauseButton.Text    = Properties.Resources.Pause;
                RecordPauseButton.Content = (Canvas)FindResource("Vector.Pause");
                Title = Properties.Resources.TitleRecording;

                _timer.Start();

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

                Normal_Elapsed(null, null);

                #endregion
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Method that starts or pauses the recording
        /// </summary>
        private void RecordPause()
        {
            CreateTemp();

            if (_stage == Stage.Stopped) //if stoped, starts recording
            {
                #region To Record

                #region Remove all pages

                panelTransparent.BackColor = Color.LimeGreen;
                this.TransparencyKey = Color.LimeGreen;
                panelTransparent.Controls.Clear(); //Removes all pages from the top

                btnConfig.Checked = false;
                btnGifConfig.Checked = false;
                btnInfo.Checked = false;

                #endregion

                timerCapture.Interval =
                timerCaptureFull.Interval =
                timerCapWithCursor.Interval =
                timerCapWithCursorFull.Interval = 1000 / Convert.ToInt32(numMaxFps.Value);

                _listFrames = new List<string>(); //List that contains the path of all frames.
                _listCursor = new List<CursorInfo>(); //List that contains all the icon information

                if (Settings.Default.fullscreen)
                {
                    _sizeResolution = new Size(_sizeScreen);
                    _bt = new Bitmap(_sizeResolution.Width, _sizeResolution.Height);

                    HideWindowAndShowTrayIcon();
                }
                else
                {
                    _bt = new Bitmap(panelTransparent.Width, panelTransparent.Height);
                }
                _gr = Graphics.FromImage(_bt);

                tbHeight.Enabled = false;
                tbWidth.Enabled = false;
                numMaxFps.Enabled = false;
                this.TopMost = true;

                _addDel = AddFrames;

                if (Settings.Default.preStart) //if should show the pre start countdown
                {
                    this.Text = "Screen To Gif (2" + Resources.TitleSecondsToGo;
                    btnRecordPause.Enabled = false;

                    _stage = Stage.PreStarting;
                    _preStartCount = 1; //Reset timer to 2 seconds, 1 second to trigger the timer so 1 + 1 = 2

                    timerPreStart.Start();
                }
                else
                {
                    btnRecordPause.Enabled = true;
                    btnMaximize.Enabled = false;

                    if (Settings.Default.showCursor) //if show cursor
                    {
                        #region If show cursor

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

                            _actHook.OnMouseActivity += MouseHookTarget;

                            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.
                                btnMinimize.Enabled = false;

                                timerCapWithCursor_Tick(null, null);
                                timerCapWithCursor.Start();
                            }
                            else
                            {
                                this.MinimizeBox = false;
                                timerCapWithCursorFull_Tick(null, null);
                                timerCapWithCursorFull.Start();
                            }

                            _stage = Stage.Recording;
                            btnRecordPause.Text = Resources.Pause;
                            btnRecordPause.Image = Resources.Pause_17Blue;
                            btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;

                            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;
                            btnRecordPause.Image = Properties.Resources.Snap16x;
                            btnRecordPause.Text = Resources.btnSnap;
                            btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;
                            this.Text = "Screen To Gif - " + Resources.Con_SnapshotMode;

                            AutoFitButtons();

                            #endregion
                        }

                        #endregion
                    }
                    else
                    {
                        #region If not

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

                            if (!Settings.Default.fullscreen)
                            {
                                btnMaximize.Enabled = false;
                                timerCapture_Tick(null, null);
                                timerCapture.Start();
                            }
                            else
                            {
                                timerCaptureFull_Tick(null, null);
                                timerCaptureFull.Start();
                            }

                            _stage = Stage.Recording;
                            btnRecordPause.Text = Resources.Pause;
                            btnRecordPause.Image = Resources.Pause_17Blue;
                            btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;

                            AutoFitButtons();

                            #endregion
                        }
                        else
                        {
                            #region SnapShot Recording

                            _stage = Stage.Snapping;
                            btnRecordPause.Image = Resources.Snap16x;
                            btnRecordPause.Text = Resources.btnSnap;
                            btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;
                            this.Text = "Screen To Gif - " + Resources.Con_SnapshotMode;

                            AutoFitButtons();

                            #endregion
                        }

                        #endregion
                    }
                }

                this.Invalidate();

                #endregion
            }
            else if (_stage == Stage.Recording) //if recording, pauses
            {
                #region To Pause

                this.Text = Resources.TitlePaused;
                btnRecordPause.Text = Resources.btnRecordPause_Continue;
                btnRecordPause.Image = Resources.Record;
                btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;
                _stage = Stage.Paused;

                AutoFitButtons();

                ModifyCaptureTimerAndChangeTrayIconVisibility(false);

                #endregion
            }
            else if (_stage == Stage.Paused) //if paused, starts recording again
            {
                #region To Record Again

                this.Text = Resources.TitleRecording;
                btnRecordPause.Text = Resources.Pause;
                btnRecordPause.Image = Resources.Pause_17Blue;
                btnRecordPause.ImageAlign = ContentAlignment.MiddleLeft;
                _stage = Stage.Recording;

                AutoFitButtons();

                ModifyCaptureTimerAndChangeTrayIconVisibility(true);

                #endregion
            }
            else if (_stage == Stage.Snapping)
            {
                #region Take Screenshot (All possibles types)

                if (Settings.Default.showCursor)
                {
                    if (Settings.Default.fullscreen)
                    {
                        timerCapWithCursorFull_Tick(null, null);
                    }
                    else
                    {
                        timerCapWithCursor_Tick(null, null);
                    }
                }
                else
                {
                    if (Settings.Default.fullscreen)
                    {
                        timerCaptureFull_Tick(null, null);
                    }
                    else
                    {
                        timerCapture_Tick(null, null);
                    }
                }

                #endregion
            }
        }
Ejemplo n.º 7
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 - " + Properties.Resources.Con_SnapshotMode;

                    Normal_Elapsed(null, null);

                    #endregion
                }

                #endregion

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

                Stage = Stage.Paused;
                Title = Properties.Resources.TitlePaused;

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

                _timer.Stop();

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

                Stage = Stage.Recording;
                Title = Properties.Resources.TitleRecording;

                _timer.Start();

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

                Normal_Elapsed(null, null);

                #endregion
            }
        }