Esempio n. 1
0
        private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Label label = sender as Label;
            AnnotationKeyValuePair kvp = label.DataContext as AnnotationKeyValuePair;

            kvp.IsEditing = true;
        }
Esempio n. 2
0
        private void EditableTextBlock_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            EditableTextBlock      tb  = sender as EditableTextBlock;
            AnnotationKeyValuePair kvp = tb.DataContext as AnnotationKeyValuePair;

            kvp.IsEditing = true;
        }
Esempio n. 3
0
        private void DeleteAnnotationClick(object sender, RoutedEventArgs e)
        {
            if (_annotationDeleted != null)
            {
                MenuItem item = sender as MenuItem;
                AnnotationKeyValuePair pair = item.DataContext as AnnotationKeyValuePair;

                _annotationDeleted(this, new AnnotationDeletedArgs(Node, pair));
            }
        }
Esempio n. 4
0
        private static void IsEditingChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            AnnotationKeyValuePair kvp = sender as AnnotationKeyValuePair;

            if (kvp.IsEditingChanged != null)
            {
                kvp.IsEditingChanged(kvp, args);
            }

            if ((bool)args.NewValue == false)
            {
                kvp.OldValue = kvp.Value;
            }
        }
Esempio n. 5
0
 public AnnotationDeletedArgs(Tree node, AnnotationKeyValuePair annotation)
 {
     Node       = node;
     Annotation = annotation;
 }
Esempio n. 6
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;
            }
        }
Esempio n. 7
0
 public AnnotationDeletedArgs(Tree node, AnnotationKeyValuePair annotation)
 {
     Node = node;
     Annotation = annotation;
 }
Esempio n. 8
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;
            }
           
        }