Exemple #1
0
        private async void PrepareWindowToWork()
        {
            var cameras = await _camerasService.GetCameras();

            MonitoringImages.Clear();

            foreach (var camera in cameras)
            {
                var monitoringImage = new MonitoringImage
                {
                    CameraName        = camera.Name,
                    CameraId          = camera.Id.ToString(),
                    Url               = camera.Url,
                    GridWidth         = HalfWidth - 20,
                    GridHeight        = HalfHeight,
                    IsRecordSetupNeed = true,
                    IsRecording       = true
                };

                MonitoringImages.Add(monitoringImage);
            }

            RaisePropertyChanged("MonitoringImages");

            StartAllCameras();
        }
Exemple #2
0
        public async void AddNewCamera()
        {
            var newCameraView = new NewCameraView();

            newCameraView.ShowDialog();
            var viewModel = ((NewCameraViewModel)newCameraView.DataContext);

            var url        = viewModel.IpCameraUrl;
            var cameraName = viewModel.CameraName;

            if (url != null)
            {
                if (await _camerasService.IsCameraExists(url))
                {
                    MessageBox.Show("Url that you are trying to add is already exists.", "Exception", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                IpCameraUrls.Add(new CameraScreen {
                    ImageSourcePath = url
                });
                RaisePropertyChanged("IpCameraUrls");

                var monitoringImage = new MonitoringImage(url, HalfWidth - 20, HalfHeight);

                monitoringImage.VideoRecordingService = new VideoRecordingService();
                monitoringImage.CameraName            = cameraName;
                monitoringImage.IsRecording           = true;

                MonitoringImages.Add(monitoringImage);

                var camera = new Camera
                {
                    Url  = url,
                    Name = cameraName
                };

                _camerasService.SaveNewCamera(camera);

                monitoringImage.CameraId = camera.Id.ToString();

                StartLastAddedCamera();
            }
        }