Beispiel #1
0
        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);
        }
        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);
        }
        void ConnectModel_DeviceAdded(object sender, DeviceAddedEventArgs e)
        {
            // add webcam
            if (e.Info.WebCameraInfo != null)
            {
                var createdCamera = new WebCameraEngine(e.Info.WebCameraInfo);
                AddCamera(createdCamera);
                //CurrentModel = createdCamera;
            }
            else if (e.Info.IpCameraInfo != null)
            {
                // add IP camera
                if (e.Info.IpCameraInfo.Uri == null)
                    return;

                var ipCamera = new IpCameraEngine(e.Info.IpCameraInfo.Uri.ToString(), UserName, Password);

                if (CurrentModel != null && CurrentModel.CameraInfo.Equals(ipCamera.CameraInfo))
                    CurrentModel = null;

                AddCamera(ipCamera);
                // CurrentModel = ipCamera;
            }
        }