private void LoadAnnotations() { if (Directory.Exists(ImageFolder)) { string annXml = Path.Combine(ImageFolder, "Annotations.xml"); if (File.Exists(annXml)) { _annList = AnnotationList.FromFile(annXml); } else { _annList = new AnnotationList(); } if (_files != null) { foreach (string file in _files) { if (!_annList.ContainsKey(file)) { _annList.Add(file); } } } } }
private void SaveAnnotations(string fileName) { SaveImageRectangles(CurrenIndex); if (Directory.Exists(ImageFolder)) { if (_annList == null) { _annList = new AnnotationList(); } _annList.Save(fileName); } }
public static AnnotationList FromFile(string fileName) { TextReader tr = new StreamReader(fileName); XmlSerializer xs = new XmlSerializer(typeof(AnnotationEntry[]), new XmlRootAttribute() { ElementName = "Entries" }); AnnotationEntry[] aentry = (AnnotationEntry[])xs.Deserialize(tr); tr.Close(); AnnotationList result = new AnnotationList(); foreach (AnnotationEntry en in aentry) { result.Add(en.File, en.Rectangles); } return(result); }