예제 #1
0
파일: Tree.cs 프로젝트: nunb/interpretation
		private Tree(Tree toCopy)
		{
			_tags = new Dictionary<string, object>();
			foreach (var item in toCopy.GetTags())
				_tags.Add (item.Key, item.Value);

			Occurrence = toCopy.Occurrence;

			List<Tree> children = new List<Tree>();
			foreach (Tree child in toCopy.GetChildren())
			{
				children.Add(new Tree(child));
			}

			_children = children;

		}
예제 #2
0
파일: MutableTree.cs 프로젝트: nunb/code
        public static MutableTree FromTree(Tree tree)
        {
            var tags = new Dictionary <string, object>();

            foreach (var pair in tree.GetTags())
            {
                tags[pair.Key] = pair.Value;
            }

            MutableTree node = MutableTree.FromBoundingBox(tree, tags);

            foreach (Tree child in tree.GetChildren())
            {
                node._children.Add(FromTree(child));
            }

            return(node);
        }
예제 #3
0
파일: Tree.cs 프로젝트: nunb/code
        private Tree(Tree toCopy)
        {
            _tags = new Dictionary <string, object>();
            foreach (var item in toCopy.GetTags())
            {
                _tags.Add(item.Key, item.Value);
            }

            Occurrence = toCopy.Occurrence;

            List <Tree> children = new List <Tree>();

            foreach (Tree child in toCopy.GetChildren())
            {
                children.Add(new Tree(child));
            }

            _children = children;
        }
예제 #4
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;
            }
           
        }
예제 #5
0
파일: Selector.cs 프로젝트: nunb/authoring
        private static bool NodeContainsAttributeIgnoreCase(Tree node, string attribute)
        {
            var attrs = node.GetTags();
            foreach (var attr in attrs)
            {
                if (attr.Key.ToLower().Contains(attribute.ToLower()))
                    return true;
            }

            return false;
        }
예제 #6
0
        public static MutableTree FromTree(Tree tree)
        {
            
            var tags = new Dictionary<string, object>();
            foreach (var pair in tree.GetTags())
            {
                tags[pair.Key] = pair.Value;
            }

            MutableTree node = MutableTree.FromBoundingBox(tree, tags);
            
            foreach (Tree child in tree.GetChildren())
                node._children.Add(FromTree(child));

            return node;
        }