/// <summary> /// All camera data is stored in separate files. /// It is binary serialized due to the fact that the /// dictionary can't be XML serialized. /// </summary> /// <returns></returns> public static CameraCollection Load() { CameraCollection all = Storage.GetAllCameras(); /*CameraCollection all = new CameraCollection(); * string path = Storage.GetFilePath("CameraData.bin"); * * if (File.Exists(path)) * { * BinaryFormatter serializer = new BinaryFormatter(); * if (File.Exists(path)) * { * using (Stream reader = new FileStream(path, FileMode.Open)) * { * all = (CameraCollection)serializer.Deserialize(reader); * } * * } * }*/ foreach (var cam in all.CameraDictionary.Values) { cam.Init(); } return(all); }
public static CameraCollection GetAllCameras() { CameraCollection cameras = new CameraCollection(); // TODO: ? cameras.CurrentCameraPath = (string)s_cameras.GetValue("CurrentCamera"); foreach (var camKeyName in s_cameras.GetSubKeyNames()) { using (RegistryKey camKey = s_cameras.OpenSubKey(camKeyName)) { string cameraPrefix = GetCameraPrefix(camKey); string cameraPath = GetCameraPath(camKey, camKeyName); // contains path + prefix CameraData cam = new CameraData(cameraPrefix, cameraPath); // GetCamera( cam.RegistrationX = (int)camKey.GetValue("RegistrationX"); cam.RegistrationY = (int)camKey.GetValue("RegistrationY"); cam.RegistrationXResolution = (int)camKey.GetValue("RegistrationXResolution"); cam.RegistrationYResolution = (int)camKey.GetValue("RegistrationYResolution"); cam.Monitoring = bool.Parse((string)camKey.GetValue("Monitoring")); cam.LiveContactData = GetContactData(camKey); cameras.AddCamera(cam); } } return(cameras); }
public static CameraCollection GetAllCameras() { CameraCollection cameras = new CameraCollection { CurrentCameraPath = (string)s_cameras.GetValue("CurrentCamera") }; foreach (var camKeyName in s_cameras.GetSubKeyNames()) { using (RegistryKey camKey = s_cameras.OpenSubKey(camKeyName, true)) { string cameraPrefix = GetCameraPrefix(camKey); string cameraPath = GetCameraPath(camKey); // contains path + prefix int registrationX = (int)camKey.GetValue("RegistrationX", 500); int registrationY = (int)camKey.GetValue("RegistrationY", 500); CameraData cam = new CameraData(Guid.Parse(camKeyName), cameraPrefix, cameraPath); cam.RegistrationX = registrationX; cam.RegistrationY = registrationY; cam.RegistrationXResolution = (int)camKey.GetValue("RegistrationXResolution", 1280); cam.RegistrationYResolution = (int)camKey.GetValue("RegistrationYResolution", 1024); cam.Monitoring = bool.Parse((string)camKey.GetValue("Monitoring", "true")); cam.NoMotionTimeout = (int)camKey.GetValue("MotionStoppedTimeout", 90); cam.LiveContactData = GetContactData(camKey); cameras.AddCamera(cam); } } return(cameras); }
public CleanupDialog(CameraCollection theCams, string path, string prefix) { _allCameras = theCams; _path = path; _prefix = prefix; InitializeComponent(); }
public static void Save(CameraCollection allCameras) { Storage.SaveCameras(allCameras); /*BinaryFormatter serializer = new BinaryFormatter(); * using (Stream stream = new FileStream(Storage.GetFilePath("CameraData.bin"), FileMode.Create)) * { * serializer.Serialize(stream, allCameras); * }*/ }
/// <summary> /// All camera data is stored in separate files. /// It is binary serialized due to the fact that the /// dictionary can't be XML serialized. /// </summary> /// <returns></returns> public static CameraCollection Load() { CameraCollection all = Storage.GetAllCameras(); foreach (var cam in all.CameraDictionary.Values) { cam.Init(); } return(all); }
public CameraCollection(CameraCollection src) { CameraDictionary = new Dictionary <string, CameraData>(); if (null != src && null != src.CameraDictionary && null != src.CameraDictionary.Values) { foreach (var cam in src.CameraDictionary.Values) { CameraData newCam = new CameraData(cam); CameraDictionary.Add(CameraData.PathAndPrefix(newCam), newCam); newCam.Init(); } CurrentCameraPath = src.CurrentCameraPath; } }
public static void SaveCameras(CameraCollection allCameras) { // Since we are saving everything we need to get rid of the old data foreach (string keyName in s_cameras.GetSubKeyNames()) { s_cameras.DeleteSubKeyTree(keyName, false); } // Now we can save the new data s_cameras.SetValue("CurrentCamera", allCameras.CurrentCameraPath, RegistryValueKind.String); foreach (CameraData camera in allCameras.CameraDictionary.Values) { using (RegistryKey camKey = s_cameras.CreateSubKey(camera.ID.ToString(), true)) { SaveCamera(camKey, camera); } } }
public CameraConfigurationDialog(CameraCollection allCameras) { InitializeComponent(); AllCameraData = new CameraCollection(allCameras); // we need a deep copy so we can avoid makinge changes to the current camera data in case the dialog is canceled foreach (var page in configurationTabControl.TabPages.Cast <TabPage>()) { page.CausesValidation = true; page.Validating += new CancelEventHandler(OnTabPageValidating); } if (AllCameraData.CameraDictionary.Count > 0) { removeCameraButton.Enabled = true; } SelectedCamera = AllCameraData.CurrentCamera; // just a reference to the item in the new list. May be null. It is a very convenient shortcut PopulateControls(); }
public static void Save(CameraCollection allCameras) { Storage.SaveCameras(allCameras); }