public static ObjectDetectionZonesLayout loadObjectDetectionZoneLayout() { // filechooser System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.OBJECTDETECTIONZONES_DIR; dlg.Filter = "ozone files (*.ozone)|*.ozone"; dlg.FilterIndex = 2; dlg.RestoreDirectory = true; if (dlg.ShowDialog() == DialogResult.OK) { ObjectDetectionZonesLayout ret = null; bool isOkay = UtilitiesIO.GetObjectFromJson(ref ret, dlg.FileName); if (!isOkay) return null; else return ret; } return null; }
public void SetNewLayout(ObjectDetectionZonesLayout pLayout) { if (pLayout != null) { int highestID = 0; // workaround for databinding bug m_CurrentLayout.ObjectDetectionZones.Clear(); foreach (ObjectDetectionZone z in pLayout.ObjectDetectionZones) { m_CurrentLayout.ObjectDetectionZones.Add(z); if (z.Id > highestID) { highestID = z.Id; } } m_CurrentLayout.LayoutName = pLayout.LayoutName; m_IdCounter = highestID + 1; } }
public static void saveObjectDetectionZoneLayoutToFile(ObjectDetectionZonesLayout pCurrentLayout) { // check if scnes OBJECTDETECTIONZONES_DIR exists if (!Directory.Exists(ProjectConstants.OBJECTDETECTIONZONES_DIR)) { Directory.CreateDirectory(ProjectConstants.OBJECTDETECTIONZONES_DIR); } System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.OBJECTDETECTIONZONES_DIR; dlg.Filter = "ozone files (*.ozone)|*.ozone"; if (dlg.ShowDialog() != DialogResult.OK) return; string filename = dlg.FileName; if (!filename.EndsWith(ProjectConstants.OBJECTDETECTIONZONES_FILE_ENDING)) { filename = filename + ProjectConstants.OBJECTDETECTIONZONES_FILE_ENDING; } UtilitiesIO.SaveObjectToJson(pCurrentLayout, filename); }
/// <summary> /// constructor /// </summary> private ObjectDetectionManager() { m_CurrentLayout = new ObjectDetectionZonesLayout(); }
internal void saveObjectDetectionZoneLayoutToFile() { ObjectDetectionZonesLayout.saveObjectDetectionZoneLayoutToFile(m_CurrentLayout); }
public void loadObjectDetectionZoneLayoutFromFile() { SetNewLayout(ObjectDetectionZonesLayout.loadObjectDetectionZoneLayout()); }