internal void SetAnnotationLibraries(IEnumerable <string> librarynames) { AnnotationLibraries.Clear(); foreach (string lib in librarynames) { AnnotationLibraries.Add(lib); } //if (AnnotationLibraries.Count > 0) // AnnotationLibComboBox.SelectedIndex = 0; }
public void SetProperties(Tree node, Tree root, Bitmap wholeScreenshot, string ptypeLib, PrefabInterpretationLogic interpLogic, Bitmap image = null, IEnumerable <string> annotationLibs = null) { Annotations.Clear(); AnnotationLibraries.Clear(); List <string> keys = new List <string>(node.GetTags().Select(kvp => kvp.Key)); foreach (string key in keys) { if (!key.Equals("ptype") && !key.Equals("invalidated")) { object attribute = node[key]; if (attribute == null) { attribute = ""; } AnnotationKeyValuePair annotation = new AnnotationKeyValuePair(key, attribute.ToString()); annotation.IsEditingChanged += new DependencyPropertyChangedEventHandler(annotation_IsEditingChanged); Annotations.Add(annotation); } } Node = node; if (node.HasTag("type")) { switch (node["type"].ToString()) { case "ptype": Ptype ptype = (Ptype)node["ptype"]; var exs = PtypeSerializationUtility.GetTrainingExamples(ptypeLib, ptype.Id); Prototype = new ViewablePrototypeItem(ptype, ptypeLib, exs.Positives, exs.Negatives, image); break; case "content": case "feature": Prototype = new ViewablePrototypeItem(null, ptypeLib, new List <ImageAnnotation>(), new List <ImageAnnotation>(), image); break; default: break; } } SetAnnotationLibraries(annotationLibs); StaticMetadata = "x=" + node.Left + ", y=" + node.Top + ", width=" + node.Width + ", height=" + node.Height; NodePath = PathDescriptor.GetPath(node, root); if (image != null) { //string bitmapid = wholeScreenshot.GetHashCode().ToString(); //var annotations = interpLogic.GetAnnotationsMatchingNode(node, root, bitmapid); //string annotationsStr = "[\n"; //foreach (string lib in annotations.Keys) //{ // foreach (IAnnotation ia in annotations[lib]) // { // annotationsStr += "{\"library\" : \"" + lib + "\"\n"; // annotationsStr += "\"id\" : \"" + ia.Id + "\"\n"; // annotationsStr += ", \"data\"" + JsonConvert.SerializeObject(ia.Data) + "\n"; // annotationsStr += "}"; // annotationsStr += ","; // } //} //annotationsStr.Remove(annotationsStr.Length - 1); //annotationsStr += "\n]"; //AnnotationValueBox.Text = annotationsStr; } }