public List <PresetParams> parse(Dictionary <string, PresetParams> PresetName2Preset) { List <PresetParams> cams = new List <PresetParams>(); XmlTextReader reader = new XmlTextReader(fileName); XmlDocument doc = new XmlDocument(); doc.Load(fileName); XmlNodeList nodes = doc.DocumentElement.SelectNodes("/Cameras/Preset"); foreach (XmlNode node in nodes) { PresetParams cam = new PresetParams(); try { cam.presettingId = node.Attributes["Name"].Value.ToString(); cam.CameraName = node.SelectSingleNode("CameraID").InnerText; cam.pan = Convert.ToDouble(node.SelectSingleNode("Pan").InnerText); cam.tilt = Convert.ToDouble(node.SelectSingleNode("Tilt").InnerText); cam.zoom = Convert.ToDouble(node.SelectSingleNode("Zoom").InnerText); //node.Attributes["Zoom"].Value; cams.Add(cam); PresetName2Preset[cam.presettingId] = cam; } catch { Debug.WriteLine("Invalide Format."); } } return(cams); }
private void saveAsNew(CameraInfo camInfo) { if (CurrentCamera != null) { CurrentSetting = new PresetParams("", CurrentCamera.CameraName, CurrentCamera.Pan, CurrentCamera.Tilt, CurrentCamera.Zoom); _ea.GetEvent <SaveSettingAsNewEvent>().Publish(CurrentSetting); } }
public void set(object input) { int index = _selectedIndex; if (index < camList.Count && index >= 0) { // Debug.WriteLine("set preset: " + camList[index].toString()); PresetParamsExtend toSet = camList[index]; PresetParams preset = new PresetParams(toSet.PresettingId, toSet.Camera.CameraName, toSet.Pan, toSet.Tilt, toSet.Zoom); _ea.GetEvent <SetPresetEvent>().Publish(preset); } }
private void saveSetting(PresetParams setting) { foreach (PresetParamsExtend item in CamList) { if (item.PresettingId == setting.presettingId) { item.Pan = setting.pan; item.Tilt = setting.tilt; item.Zoom = setting.zoom; return; } } saveAsNewSetting(setting); }
public void acceptPreset(PresetParams preset) { if (CurrentCamera == null || preset.CameraName != CurrentCamera.CameraName || preset.presettingId == null) { MessageBox.Show("Preset cannot be applied to this camera."); } else { CurrentSetting = preset; SliderPan = Convert.ToInt32(preset.pan); SliderTilt = Convert.ToInt32(preset.tilt); UndoRedoManager.clear(); SliderZoom = Convert.ToInt32(preset.zoom); } }
public void delete(object input) { int index = _selectedIndex; if (index < camList.Count && index >= 0) { PresetParamsExtend toDelete = camList[index]; if (camList2camListForDisk.ContainsKey(toDelete)) { PresetParams itemInCamListForDisk = camList2camListForDisk[toDelete]; camListForDisk.Remove(itemInCamListForDisk); } camList.Remove(toDelete); } saveCamListToDisk(); _ea.GetEvent <PresettingDeleteEvent>().Publish(index); }
private void saveSetting(CameraInfo camInfo) { if (CurrentCamera != null) { if (CurrentSetting != null) { CurrentSetting.CameraName = camInfo.CameraName; CurrentSetting.pan = camInfo.Pan; CurrentSetting.tilt = camInfo.Tilt; CurrentSetting.zoom = camInfo.Zoom; } else { CurrentSetting = new PresetParams("", CurrentCamera.CameraName, CurrentCamera.Pan, CurrentCamera.Tilt, CurrentCamera.Zoom); } _ea.GetEvent <SaveSettingEvent>().Publish(CurrentSetting); } }
private void saveAsNewSetting(PresetParams setting) { PresetParamsExtend newItem = new PresetParamsExtend(CameraNameList); newItem.Camera = new CameraNameWrapper(setting.CameraName); newItem.Pan = setting.pan; newItem.Tilt = setting.tilt; newItem.Zoom = setting.zoom; newItem.CanSave = true; foreach (CameraNameWrapper item in CameraNameList) { if (item.CameraName == setting.CameraName) { newItem.Camera = item; break; } } camList.Add(newItem); }
private void saveToDiskListAtIndex(int index) { if (index < camList.Count && index >= 0) { PresetParamsExtend toSave = camList[index]; foreach (PresetParams preset in camListForDisk) { if (preset.presettingId == toSave.PresettingId) { if (!camList2camListForDisk.ContainsKey(toSave) || (camList2camListForDisk.ContainsKey(toSave) && camList2camListForDisk[toSave] != preset)) { MessageBox.Show("Cannot assian duplicate preset name", "Warning"); return; } } } if (toSave.Camera == null || toSave.PresettingId == null) { MessageBox.Show("Missing data", "Warning"); return; } if (camList2camListForDisk.ContainsKey(toSave)) { PresetParams itemInCamListForDisk = camList2camListForDisk[toSave]; itemInCamListForDisk.update(toSave.PresettingId, toSave.Camera.CameraName, toSave.Pan, toSave.Tilt, toSave.Zoom); if (presetName2Preset.ContainsKey(camList2camListForDisk[toSave].presettingId)) { presetName2Preset.Remove(camList2camListForDisk[toSave].presettingId); } } else { PresetParams savedItem = new PresetParams(toSave.PresettingId, toSave.Camera.CameraName, toSave.Pan, toSave.Tilt, toSave.Zoom); camListForDisk.Add(savedItem); camList2camListForDisk[toSave] = savedItem; } presetName2Preset[toSave.PresettingId] = camList2camListForDisk[toSave]; toSave.CanSave = false; } }
public PreviewVM() { currentSetting = null; PreviewIsForbidden = false; _ea = Notification.Instance; modeColors = ModeColors.Singleton(_ea); _ea.GetEvent <CameraSelectEvent>().Subscribe(acceptCamera); _ea.GetEvent <SetPresetEvent>().Subscribe(acceptPreset); _ea.GetEvent <CameraDiscoverEvent>().Subscribe(clearBeforeDiscover); _ea.GetEvent <PreviewPauseEvent>().Subscribe(pausePreview); _ea.GetEvent <PreviewResumeEvent>().Subscribe(resumePreview); _ea.GetEvent <MenuBarToPreviewEvent>().Subscribe(processMenuBarCommand); UndoRedoManager = new UndoRedo <ptz>(Constant.UNDO_BUFFER_SIZE); Idle = Visibility.Visible; Active = Visibility.Hidden; Forbidden = Visibility.Hidden; SliderPan = 0; SliderTilt = 0; UndoRedoManager.clear(); SliderZoom = 1; }