Example #1
0
        private void btnAddTextOverlay_Click(object sender, EventArgs e)
        {
            try
            {
                frmNewOverlay frm = new frmNewOverlay(true);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    TextOverlay textOverlay = frm.GetOverlay() as TextOverlay;
                    if (_capturer.IsRunning)
                    {
                        //_capturer.AddTextOverlay(overlay.Left, overlay.Top, overlay.Text, overlay.Font.Name, (int)overlay.Font.Size,
                        //                        overlay.Font.Bold, overlay.Font.Italic, overlay.Font.Underline, (uint)ColorTranslator.ToOle(overlay.Color));
                        _capturer.AddTextOverlayWithBackground2(textOverlay.Left, textOverlay.Top, textOverlay.Text, textOverlay.Font.Name,
                                                                (int)textOverlay.Font.Size, textOverlay.Font.Bold, textOverlay.Font.Italic,
                                                                textOverlay.Font.Underline,
                                                                textOverlay.Color.R, textOverlay.Color.G, textOverlay.Color.B, textOverlay.Color.A,
                                                                textOverlay.BackColor.R, textOverlay.BackColor.G, textOverlay.BackColor.B, textOverlay.BackColor.A);
                    }

                    ListViewItem item = new ListViewItem();
                    item.Text = textOverlay.ToString();
                    item.Tag  = textOverlay;
                    lstOverlays.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        public ctrlTextOverlay(TextOverlay textOverlay, int index, ICapturer capturer)
        {
            InitializeComponent();

            _textOverlay = textOverlay;
            _index       = index;
            _capturer    = capturer;

            nmLeft.Value       = _textOverlay.Left;
            nmTop.Value        = _textOverlay.Top;
            txtText.Text       = _textOverlay.Text;
            txtFont.Text       = _textOverlay.Font.Name;
            txtFont.Font       = _textOverlay.Font;
            pnlColor.BackColor = _textOverlay.Color;
            chkVisible.Checked = _textOverlay.Visible;
            btnUpdate.Visible  = true;

            chkBackColor.Checked   = _textOverlay.BackColor != Color.Transparent;
            btnBackColor.Enabled   = _textOverlay.BackColor != Color.Transparent;
            pnlBackColor.BackColor = _textOverlay.BackColor;

            txtFont.Enabled      = false;
            btnFont.Enabled      = false;
            pnlColor.Enabled     = false;
            btnColor.Enabled     = false;
            chkBackColor.Enabled = false;
            btnBackColor.Enabled = false;
            pnlBackColor.Enabled = false;

            _isLoaded = true;
        }
Example #3
0
        public TextOverlay GetTextOverlay()
        {
            if (_textOverlay == null)
            {
                _textOverlay = new TextOverlay();

                _textOverlay.Left      = (int)nmLeft.Value;
                _textOverlay.Top       = (int)nmTop.Value;
                _textOverlay.Text      = txtText.Text;
                _textOverlay.Font      = txtFont.Font;
                _textOverlay.Color     = pnlColor.BackColor;
                _textOverlay.Visible   = chkVisible.Checked;
                _textOverlay.BackColor = pnlBackColor.BackColor;
            }

            return(_textOverlay);
        }
Example #4
0
        private void btnRecord_Click(object sender, EventArgs e)
        {
            try
            {
                if (_capturer.IsRunning)
                {
                    _capturer.Stop();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(_capturer);
                    _capturer = null;
                    InitCapturer();

                    lstOverlays.Items.Clear();
                    btnRecord.Text        = "Record";
                    grpProperties.Enabled = true;
                    lblStatus.Text        = "Stopped";
                }
                else
                {
                    _capturer.AudioEnabled = chkEnableAudio.Checked;
                    if (chkEnableAudio.Checked)
                    {
                        _capturer.CurrentAudioDeviceName = cmbAudioDevices.SelectedItem.ToString();
                        //_capturer.CurrentAudioCodecName = cmbAudioCodecs.SelectedItem.ToString();
                    }

                    _capturer.AddWebCamVideo = chkEnableWebcam.Checked;
                    if (chkEnableWebcam.Checked)
                    {
                        _capturer.SetWebCamVideoRectangle((int)nmWebCamLeft.Value, (int)nmWebCamTop.Value, (int)nmWebCamWidth.Value, (int)nmWebCamHeight.Value);
                        _capturer.CurrentWebCamName = cmbWebCam.SelectedItem.ToString();
                    }

                    //_capturer.CurrentVideoCodecName = cmbVideoCodec.SelectedItem.ToString();

                    if (!string.IsNullOrEmpty(txtLogFile.Text))
                    {
                        _capturer.SetLogFile(txtLogFile.Text);
                    }

                    _capturer.OutputFileName = txtOutputFile.Text;

                    _capturer.CapturingType = (CaptureAreaType)cmbCaptureAreaType.SelectedItem;

                    _previewGraphics = pnlPreview.CreateGraphics();
                    _previewHdc      = _previewGraphics.GetHdc().ToInt32();
                    _capturer.SetFullPreviewContext(_previewHdc, 0, 0, pnlPreview.Width, pnlPreview.Height, 5);

                    _capturer.CaptureRectLeft   = (int)nmCaptureLeft.Value;
                    _capturer.CaptureRectTop    = (int)nmCaptureTop.Value;
                    _capturer.CaptureRectWidth  = (int)nmCaptureWidth.Value;
                    _capturer.CaptureRectHeight = (int)nmCaptureHeight.Value;

                    _capturer.OutputWidth  = (int)nmOutputWidth.Value;
                    _capturer.OutputHeight = (int)nmOutputHeight.Value;


                    foreach (ListViewItem item in lstOverlays.Items)
                    {
                        Overlay overlay = item.Tag as Overlay;
                        if (overlay is TextOverlay)
                        {
                            TextOverlay textOverlay = overlay as TextOverlay;

                            int a = (int)textOverlay.BackColor.A;
                            //_capturer.AddTextOverlay(textOverlay.Left, textOverlay.Top, textOverlay.Text, textOverlay.Font.Name,
                            //                        (int)textOverlay.Font.Size,textOverlay.Font.Bold, textOverlay.Font.Italic,
                            //                        textOverlay.Font.Underline, (uint)ColorTranslator.ToOle(textOverlay.Color));
                            _capturer.AddTextOverlayWithBackground2(textOverlay.Left, textOverlay.Top, textOverlay.Text, textOverlay.Font.Name,
                                                                    (int)textOverlay.Font.Size, textOverlay.Font.Bold, textOverlay.Font.Italic,
                                                                    textOverlay.Font.Underline,
                                                                    textOverlay.Color.R, textOverlay.Color.G, textOverlay.Color.B, textOverlay.Color.A,
                                                                    textOverlay.BackColor.R, textOverlay.BackColor.G, textOverlay.BackColor.B, textOverlay.BackColor.A);
                        }
                        else if (overlay is ImageOverlay)
                        {
                            ImageOverlay imageOverlay = overlay as ImageOverlay;
                            _capturer.AddImageOverlay(imageOverlay.Left, imageOverlay.Top, imageOverlay.FileName);
                        }
                    }


                    _capturer.Run();

                    //' IMPORTANT: if you want to check for some code if need to stop the recording then make sure you are
                    //' using Thread.Sleep(1) inside the checking loop, so you have the loop like
                    //' Do {
                    //' Thread.Sleep(1)
                    //' }
                    //' While(StopButtonNotClicked);


                    btnRecord.Text        = "Stop";
                    grpProperties.Enabled = false;
                    lblStatus.Text        = "Running";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnRecord_Click(object sender, EventArgs e)
        {
            try
            {
                if (_capturer.IsRunning)
                {
                    _capturer.Stop();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(_capturer);
                    _capturer = null;
                    InitCapturer();

                    // lstOverlays.Items.Clear();
                    btnRecord.Text      = "Record";
                    tabControl1.Enabled = true;
                    lblStatus.Text      = "Stopped";
                    timer1.Stop();
                    _captureStarted = false;

                    btnPause.Enabled = false;
                    _isPaused        = false;
                }
                else
                {
                    if (!_isPaused)
                    {
                        _capturer.AudioEnabled = chkEnableAudio.Checked;
                        if (chkEnableAudio.Checked)
                        {
                            _capturer.CurrentAudioDeviceName = cmbAudioDevices.SelectedItem.ToString();
                            //_capturer.CurrentAudioCodecName = cmbAudioCodecs.SelectedItem.ToString();
                        }

                        _capturer.AddWebCamVideo = chkEnableWebcam.Checked;
                        if (chkEnableWebcam.Checked)
                        {
                            _capturer.SetWebCamVideoRectangle((int)nmWebCamLeft.Value, (int)nmWebCamTop.Value, (int)nmWebCamWidth.Value, (int)nmWebCamHeight.Value);
                            _capturer.CurrentWebCamName = cmbWebCam.SelectedItem.ToString();
                        }

                        //_capturer.CurrentVideoCodecName = cmbVideoCodec.SelectedItem.ToString();

                        if (!string.IsNullOrEmpty(txtLogFile.Text) && cbWriteLog.Checked)
                        {
                            _capturer.SetLogFile(txtLogFile.Text);
                        }

                        _capturer.OutputFileName = txtOutputFile.Text;

                        _capturer.CapturingType = (CaptureAreaType)cmbCaptureAreaType.SelectedItem;

                        _previewGraphics = pnlPreview.CreateGraphics();
                        _previewHdc      = _previewGraphics.GetHdc().ToInt32();
                        _capturer.SetFullPreviewContext(_previewHdc, 0, 0, pnlPreview.Width, pnlPreview.Height, 5);

                        _capturer.CaptureRectLeft   = (int)nmCaptureLeft.Value;
                        _capturer.CaptureRectTop    = (int)nmCaptureTop.Value;
                        _capturer.CaptureRectWidth  = (int)nmCaptureWidth.Value;
                        _capturer.CaptureRectHeight = (int)nmCaptureHeight.Value;

                        _capturer.OutputWidth  = (int)nmOutputWidth.Value;
                        _capturer.OutputHeight = (int)nmOutputHeight.Value;


                        foreach (ListViewItem item in lstOverlays.Items)
                        {
                            Overlay overlay = item.Tag as Overlay;
                            if (overlay is TextOverlay)
                            {
                                TextOverlay textOverlay = overlay as TextOverlay;

                                int a = (int)textOverlay.BackColor.A;
                                //_capturer.AddTextOverlay(textOverlay.Left, textOverlay.Top, textOverlay.Text, textOverlay.Font.Name,
                                //                        (int)textOverlay.Font.Size,textOverlay.Font.Bold, textOverlay.Font.Italic,
                                //                        textOverlay.Font.Underline, (uint)ColorTranslator.ToOle(textOverlay.Color));
                                _capturer.AddTextOverlayWithBackground2(textOverlay.Left, textOverlay.Top, textOverlay.Text, textOverlay.Font.Name,
                                                                        (int)textOverlay.Font.Size, textOverlay.Font.Bold, textOverlay.Font.Italic,
                                                                        textOverlay.Font.Underline,
                                                                        textOverlay.Color.R, textOverlay.Color.G, textOverlay.Color.B, textOverlay.Color.A,
                                                                        textOverlay.BackColor.R, textOverlay.BackColor.G, textOverlay.BackColor.B, textOverlay.BackColor.A);
                            }
                            else if (overlay is ImageOverlay)
                            {
                                ImageOverlay imageOverlay = overlay as ImageOverlay;
                                _capturer.AddImageOverlay(imageOverlay.Left, imageOverlay.Top, imageOverlay.FileName);
                            }
                        }

                        _capturer.RecordingMode = (RecordingModeType)cmbMotionDetection.SelectedItem;
                        _capturer.NoMotionDetectedActionInterval    = (int)nmMotionInterval.Value;
                        _capturer.NoMotionDetectedActionSensitivity = (double)nmMotionSensitivity.Value;

                        _capturer.MonitorIndex = (int)cmbCurrentMonitor.SelectedItem;
                    }

                    _capturer.Run();


                    btnRecord.Text      = "Stop";
                    tabControl1.Enabled = false;
                    lblStatus.Text      = "Running";
                    _captureStarted     = true;
                    timer1.Start();

                    _isPaused        = false;
                    btnPause.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }