public override void PromptDeviceSelector() { // Ask the user which device he wants to use. formDevicePicker fdp = new formDevicePicker(ListDevices(), m_CurrentVideoDevice); if(fdp.ShowDialog() == DialogResult.OK) { DeviceIdentifier selected = fdp.SelectedDevice; if(selected != null) { m_CurrentVideoDevice = selected; ConnectToDevice(m_CurrentVideoDevice); m_Container.Connected(); } } fdp.Dispose(); }
public override void PromptDeviceSelector() { DelegatesPool dp = DelegatesPool.Instance(); if (dp.DeactivateKeyboardHandler != null) { dp.DeactivateKeyboardHandler(); } bool reconnected = false; // Ask the user which device he wants to use or which size/framerate. formDevicePicker fdp = new formDevicePicker(ListDevices(), m_CurrentVideoDevice, DisplayDevicePropertyPage); if(fdp.ShowDialog() == DialogResult.OK) { DeviceDescriptor dev = fdp.SelectedDevice; if(dev == null || dev.Empty) { log.DebugFormat("Selected device is null or empty."); if(m_CurrentVideoDevice != null) { // From something to empty. Disconnect(); } } else if(dev.Network) { if(m_CurrentVideoDevice == null || !m_CurrentVideoDevice.Network) { // From empty or non-network to network. log.DebugFormat("Selected network camera - connect with default parameters"); reconnected = ConnectToDevice(dev); } else { // From network to network. log.DebugFormat("Network camera - parameters changed - connect with new parameters"); // Parameters were set on the dialog. We don't care if the parameters were actually changed. DeviceDescriptor netDevice = new DeviceDescriptor(ScreenManagerLang.Capture_NetworkCamera, fdp.SelectedUrl, fdp.SelectedFormat); reconnected = ConnectToDevice(netDevice); } } else { if(m_CurrentVideoDevice == null || m_CurrentVideoDevice.Network || dev.Identification != m_CurrentVideoDevice.Identification) { // From network or different capture device to capture device. log.DebugFormat("Selected capture device"); reconnected = ConnectToDevice(dev); } else { // From same capture device - caps changed. DeviceCapability cap = fdp.SelectedCapability; if(cap != null && !cap.Equals(m_CurrentVideoDevice.SelectedCapability)) { log.DebugFormat("Capture device, capability changed."); m_CurrentVideoDevice.SelectedCapability = cap; //PreferencesManager.CapturePreferences.UpdateDeviceConfiguration(m_CurrentVideoDevice.Identification, cap); //PreferencesManager.Save(); if(m_bIsGrabbing) { m_VideoSource.Stop(); } ((VideoCaptureDevice)m_VideoSource).DesiredFrameSize = cap.FrameSize; ((VideoCaptureDevice)m_VideoSource).DesiredFrameRate = cap.Framerate; m_FrameSize = cap.FrameSize; m_FramesInterval = 1000 / (double)cap.Framerate; log.Debug(String.Format("New capability: {0}", cap.ToString())); m_bSizeChanged = true; if(m_bIsGrabbing) { m_VideoSource.Start(); } } } } if(reconnected) m_Container.Connected(); } fdp.Dispose(); if(dp.ActivateKeyboardHandler != null) { dp.ActivateKeyboardHandler(); } }