Пример #1
0
        private void SetWindow()
        {
            var captureDevice = VideoSettings.CaptureDevice;

            var item = windowsComboBox.SelectedItem;

            if (item != null)
            {
                var tag = ((ComboBoxItem)item).Tag;
                if (tag != null)
                {
                    WindowDescription window = tag as WindowDescription;
                    if (window != null)
                    {
                        var windowCapture = (WindowCaptureDevice)captureDevice;
                        windowCapture.ClientRect = window.clientRect;
                        windowCapture.Resolution = window.clientRect.Size;

                        windowCapture.hWnd        = window.hWnd;
                        windowCapture.ProcName    = window.processName;
                        windowCapture.WindowClass = window.windowClass;
                        windowCapture.WindowTitle = window.windowTitle;

                        if (windowForm == null)
                        {
                            windowForm = new SelectAreaForm(true, false)
                            {
                                StartPosition = FormStartPosition.Manual,
                                Locked        = true,
                            };
                        }

                        windowForm.Visible = false;

                        if (windowHook != null)
                        {
                            windowHook.Close();
                        }

                        windowHook = new WindowHook();


                        windowHook.LocationChanged += WindowHook_LocationChanged;
                        windowHook.WindowClosed    += WindowHook_WindowClosed;
                        windowHook.VisibleChanged  += WindowHook_VisibleChanged;

                        windowHook.Setup(windowCapture.hWnd);

                        var rect = windowHook.GetCurrentWindowRect();

                        SetWindowsPosition(rect);

                        windowForm.Visible = true;
                    }
                }
            }
        }
Пример #2
0
        public void Dispose()
        {
            if (selectAreaForm != null)
            {
                selectAreaForm.AreaChanged -= SelectAreaForm_AreaChanged;
                selectAreaForm.Close();
                selectAreaForm = null;
            }

            viewRect = null;
        }
Пример #3
0
        public void Init(IViewRect rect)
        {
            if (selectAreaForm == null)
            {
                selectAreaForm = new SelectAreaForm
                {
                    StartPosition = System.Windows.Forms.FormStartPosition.Manual,
                };

                selectAreaForm.AreaChanged += SelectAreaForm_AreaChanged;
            }

            this.viewRect = rect;
        }
Пример #4
0
        private void videoSourceComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            logger.Debug("videoSourceComboBox_SelectedValueChanged(...)");

            bool isCustomRegion = false;

            Rectangle displayRect = Rectangle.Empty;

            VideoCaptureDevice captureParams = null;

            var obj = videoSourceComboBox.SelectedItem;

            if (obj != null)
            {
                var item = obj as ComboBoxItem;
                if (item != null)
                {
                    var tag = item.Tag;
                    if (tag != null)
                    {
                        if (tag is ScreenCaptureDevice)
                        {
                            var captureDevice = ((ScreenCaptureDevice)tag);
                            isCustomRegion = captureDevice.DisplayRegion.IsEmpty;
                            captureParams  = captureDevice;
                        }
                        else if (tag is UvcDevice)
                        {
                            captureParams = (UvcDevice)tag;
                            //videoSettings.EncodingParams.Resolution = captDevice.Resolution;
                        }
                        else if (tag is WindowCaptureDevice)
                        {
                            captureParams = (WindowCaptureDevice)tag;
                            //videoSettings.EncodingParams.Resolution = captDevice.Resolution;
                        }
                    }
                    else
                    {
                    }
                }


                if (isCustomRegion)
                {
                    if (selectAreaForm == null)
                    {
                        var customRegion = Config.Data.SelectAreaRectangle;
                        selectAreaForm = new SelectAreaForm
                        {
                            StartPosition = FormStartPosition.Manual,
                            Location      = customRegion.Location,
                            Size          = customRegion.Size,
                        };

                        selectAreaForm.AreaChanged += SelectAreaForm_AreaChanged;
                    }

                    selectAreaForm.Tag = captureParams;

                    selectAreaForm.Visible = true;
                }
                else
                {
                    if (selectAreaForm != null)
                    {
                        selectAreaForm.Visible = false;
                    }
                }
            }

            //videoSettings.CaptureDescription.Name = displayName;
            currentSession.VideoSettings.CaptureDevice = captureParams;

            videoSourceDetailsButton.Enabled = true;
        }