示例#1
0
        // GET: Camera/Create
        public ActionResult Create()
        {
            var model = new CameraViewModels
            {
                _weekdaysList = new List <SelectListItem>
                {
                    new SelectListItem {
                        Value = "Sunday", Text = "Sunday"
                    },
                    new SelectListItem {
                        Value = "Monday", Text = "Monday"
                    },
                    new SelectListItem {
                        Value = "Tuesday", Text = "Tuesday"
                    },
                    new SelectListItem {
                        Value = "Wednesday", Text = "Wednesday"
                    },
                    new SelectListItem {
                        Value = "Thursday", Text = "Thursday"
                    },
                    new SelectListItem {
                        Value = "Friday", Text = "Friday"
                    },
                    new SelectListItem {
                        Value = "Saturday", Text = "Saturday"
                    },
                }
            };

            // the list of available values

            return(View(model));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            CameraViewModels cameraViewModels = db.CameraViewModels.Find(id);

            db.CameraViewModels.Remove(cameraViewModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "CameraId,Name,Make,Model,From,To,LiveView,ExtrernalLink,Status,VideoSpeed,ContinuousLoop")] CameraViewModels cameraViewModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cameraViewModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cameraViewModels));
 }
示例#4
0
        // GET: Camera/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CameraViewModels cameraViewModels = db.CameraViewModels.Find(id);

            if (cameraViewModels == null)
            {
                return(HttpNotFound());
            }
            return(View(cameraViewModels));
        }
示例#5
0
 public DTMainViewModel()
     : base()
 {
     CameraViewModels.Add(new DTCameraViewModel());
     SelectedCameraViewModel = CameraViewModels.FirstOrDefault();
 }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the AllCamerasViewModel class.
        /// </summary>
        public CamerasViewModel()
        {
            CamerasModel.Name = "all";
            CamerasModel.Cameras = new ObservableCollection<CameraModel>();
            CamerasModel.Controllers = new ObservableCollection<MotionControllerModel>();
            Refresh();
            MultipleViewsService = new MultipleViewsService();
            MultipleViewsService.Initialize(_camerasModel, CameraViewModels.Select(camera => camera.TrackerService).ToList());

            Messenger.Default.Register<AddCameraMessage>(this, message =>
            {
                CameraViewModel cvm = SimpleIoc.Default.GetInstance<CameraViewModel>(message.Camera.GUID);
                CameraViewModels.Add(cvm);
                CamerasModel.Cameras.Add(cvm.Camera);
                MultipleViewsService.TrackerServices.Add(cvm.TrackerService);
            });

            Messenger.Default.Register<RemoveCameraMessage>(this, message =>
            {
                if(SimpleIoc.Default.ContainsCreated<CameraViewModel>(message.Camera.GUID))
                {
                    CameraViewModel cvm = SimpleIoc.Default.GetInstance<CameraViewModel>(message.Camera.GUID);
                    CameraViewModels.Remove(cvm);
                    CamerasModel.Cameras.Remove(cvm.Camera);
                    MultipleViewsService.TrackerServices.Remove(cvm.TrackerService);
                }
            });

            Messenger.Default.Register<AddMotionControllerMessage>(this,
            message =>
            {
                CamerasModel.Controllers.Add(message.MotionController);
            });

            Messenger.Default.Register<RemoveMotionControllerMessage>(this,
            message =>
            {
                CamerasModel.Controllers.Remove(message.MotionController);
            });

            if(IsInDesignMode)
            {
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Controllers.Add(new MotionControllerModel());
                CamerasModel.Controllers.Add(new MotionControllerModel());
            }
            else
            {
                if (SimpleIoc.Default.GetInstance<SettingsViewModel>().Settings.LoadCamerasOnStartup)
                {
                    AddAvailableCameras();
                }
                if(SimpleIoc.Default.GetInstance<SettingsViewModel>().Settings.Debug)
                {
                    new CameraViewModel();
                    new CameraViewModel();
                    new CameraViewModel();
                    new CameraViewModel();
                }
            }
        }