Ejemplo n.º 1
0
        /// <summary>
        /// Adds a gesture to the graph
        /// </summary>
        /// <param name="g">the gesture to add to the graph</param>
        public void AddGesture(Gesture g)
        {
            ReturnToRoot();
            //travel through tree, adding nodes as necessary
            int[] sequence = g.GetSequence();
            for (int i = 0; i < sequence.Length; i++)
            {
                if (!NextDirExists(sequence[i]))
                {
                    currentNode.leafNodes[sequence[i]] = new Node(null);
                    SelectNode(sequence[i]);
                }
                else
                {
                    SelectNode(sequence[i]);
                }
            }
            //will now be at the final node
            currentNode.gesture = g;

            //adds gesture to list of all gestures. Basically a lazy way of finding all gestures without traversing the tree
            if (g != null)
            {
                allGestures.Add(g);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a gesture from the graph
        /// </summary>
        /// <param name="g">the gesture to remove from the graph</param>
        public void RemoveGesture(Gesture g)
        {
            ReturnToRoot();
            //travel through tree, adding nodes as necessary
            int[] sequence = g.GetSequence();
            for (int i = 0; i < sequence.Length; i++)
            {
                SelectNode(sequence[i]);
            }
            //will now be at the final node
            //remove the gesture
            currentNode.gesture = null;

            //remove gesture from list
            if (g != null)
            {
                allGestures.Remove(g);
            }
        }