void DiscoverUsbDevices()
 {
     var webCameras = WebCamera.GetDevices();
     foreach (var camera in webCameras)
     {
         var deviceInfo = new CameraDeviceInfo { WebCameraInfo = camera };
         AddDeviceToList(deviceInfo);
     }
 }
        void AddCamera()
        {
            if (String.IsNullOrEmpty(CameraUrl))
                return;

            var ipCamera = new IpCameraEngine(CameraUrl, UserName, Password);

            if (!(CameraUrl.Trim().ToUpper().StartsWith("HTTP://") || CameraUrl.Trim().ToUpper().StartsWith("RTSP://")))
                CameraUrl = String.Format("http://{0}", CameraUrl);

            var ipCameraInfo = new IPVideoDeviceInfo
            {
                Uri = new Uri(CameraUrl)
            };

            var savedCamera = new SavedCamera
            {
                DeviceInfo = new CameraDeviceInfo
                {
                    IpCameraInfo = ipCameraInfo
                },
                Camera = ipCamera,
                UserName = UserName,
                Password = Password
            };

            var deviceInfo = new CameraDeviceInfo
            {
                IpCameraInfo = ipCameraInfo
            };

            ConnectModel.CameraList.Add(ipCamera);
            ConnectModel.SavedCameras.Add(savedCamera);
            ConnectModel.DeviceList.Add(deviceInfo);

            OnCameraAdded(ipCamera);
        }
 internal DeviceAddedEventArgs(CameraDeviceInfo info)
 {
     Info = info;
 }
        Camera GetCurrentModel(CameraDeviceInfo cameraInfo)
        {
            if (cameraInfo.IpCameraInfo != null)
            {
                foreach (var camInfo in ConnectModel.CameraList)
                {
                    if (camInfo.CameraInfo != null)
                        if (camInfo.CameraInfo.Equals(cameraInfo.IpCameraInfo.Uri.ToString()) ||
                            String.Format("{0}/", camInfo.CameraInfo).Equals(cameraInfo.IpCameraInfo.Uri.ToString()) ||
                            String.Format("http://{0}/", camInfo.CameraInfo).Equals(cameraInfo.IpCameraInfo.Uri.ToString()))
                            return camInfo;
                }
            }
            else if (cameraInfo.WebCameraInfo != null)
            {
                foreach (var camInfo in ConnectModel.CameraList)
                {
                    if (camInfo.DeviceInfo != null)
                        if (camInfo.CameraInfo.Equals(cameraInfo.WebCameraInfo.Name))
                            return camInfo;
                }
            }

            return null;
        }
 void IPCamera_DeviceDiscovered(object sender, DiscoveryEventArgs e)
 {
     var deviceInfo = new CameraDeviceInfo { IpCameraInfo = new IPVideoDeviceInfo(e.Device) };
     AddDeviceToList(deviceInfo);
 }
 void OnDeviceAdded(CameraDeviceInfo info)
 {
     var handler = DeviceAdded;
     if (handler != null)
         handler(this, new DeviceAddedEventArgs(info));
 }
        void AddDeviceToList(CameraDeviceInfo info)
        {
            if (SelectedDevice == null)
            {
                SelectedDevice = info;
                OnPropertyChanged("SelectedDevice");
            }

            if (info.IpCameraInfo != null)
            {
                foreach (var cameraDeviceInfo in SavedCameras)
                {
                    if (String.IsNullOrEmpty(cameraDeviceInfo.Camera.DeviceInfo))
                        continue;

                    if (cameraDeviceInfo.DeviceInfo == null || cameraDeviceInfo.DeviceInfo.IpCameraInfo == null || info.IpCameraInfo.Uri == null)
                        continue;

                    if (cameraDeviceInfo.DeviceInfo.IpCameraInfo.Uri.ToString().Equals(info.IpCameraInfo.Uri.ToString()))
                        return;
                }
            }
            else
            {
                foreach (var cameraDeviceInfo in SavedCameras)
                {
                    if (String.IsNullOrEmpty(cameraDeviceInfo.Camera.DeviceInfo))
                        continue;

                    if (cameraDeviceInfo.DeviceInfo == null || cameraDeviceInfo.DeviceInfo.WebCameraInfo == null)
                        continue;

                    if (cameraDeviceInfo.DeviceInfo.WebCameraInfo.Name.Equals(info.WebCameraInfo.Name))
                        return;
                }
            }

            DeviceList.Add(info);

            try
            {
                OnDeviceAdded(info);
            }
            catch (Exception ex)
            {
            }

            OnPropertyChanged("DeviceList");
        }
 internal DeviceAddedEventArgs(CameraDeviceInfo info)
 {
     Info = info;
 }