Ejemplo n.º 1
0
 public GestureState(Gesture gesture)
 {
     _gesture = gesture;
     ComponentStates = new List<GestureComponentState>();
     InitializeComponents();
     IsExecuting = false;
     HasError = false;
 }
Ejemplo n.º 2
0
        public override GestureMap GetGestureMap()
        {
            GestureMap map = new GestureMap();

            Gesture moving = new Gesture("moving", 1000, (int)ViCharGesture.Moving);
            moving.Components.Add(new GestureComponent(JointType.HandRight, JointType.ElbowRight,
                JointRelationship.AboveAndLeft, JointRelationship.AboveAndRight));
            map.Items.Add(moving);

            Gesture jumping = new Gesture("jumping", 1000, (int)ViCharGesture.Jumping);
            jumping.Components.Add(new GestureComponent(JointType.HandRight, JointType.ShoulderRight,
                JointRelationship.Below, JointRelationship.Above));
            jumping.Components.Add(new GestureComponent(JointType.HandLeft, JointType.ShoulderLeft,
                JointRelationship.Below, JointRelationship.Above));
            map.Items.Add(jumping);

            return map;
        }
Ejemplo n.º 3
0
        public override GestureMap GetGestureMap()
        {
            GestureMap map = new GestureMap();

            Gesture jumping = new Gesture("jumping", 1000, (int)ViCharGesture.Jumping);
            jumping.Components.Add(new GestureComponent(JointType.HandRight, JointType.ShoulderRight,
                JointRelationship.Below, JointRelationship.Above));
            jumping.Components.Add(new GestureComponent(JointType.HandLeft, JointType.ShoulderLeft,
                JointRelationship.Below, JointRelationship.Above));
            map.Items.Add(jumping);

            Gesture turningLeft = new Gesture("turningLeft", 1000, (int)ViCharGesture.TurningLeft);
            turningLeft.Components.Add(new GestureComponent(JointType.KneeRight, JointType.KneeLeft,
                JointRelationship.AboveAndLeft));
            map.Items.Add(turningLeft);

            Gesture turningRight = new Gesture("turningRight", 1000, (int)ViCharGesture.TurningRight);
            turningRight.Components.Add(new GestureComponent(JointType.KneeLeft, JointType.KneeRight,
                JointRelationship.AboveAndRight));
            map.Items.Add(turningRight);

            return map;
        }
Ejemplo n.º 4
0
 public GestureState(Gesture gesture)
 {
     _gesture = gesture;
     _keycode = gesture.MappedKeycode;
     ComponentStates = new List<GestureComponentState>();
     InitializeComponents();
     Messages = new List<string>();
     MessageWaiting = false;
     IsExecuting = false;
     HasError = false;
 }
Ejemplo n.º 5
0
        public Gesture ParseGestureFromXml(XmlTextReader reader)
        {
            var name = reader.GetAttribute("Description");
            var maxexecutiontime = reader.GetAttribute("MaxExecutionTime") ?? "0";
            var keycode = reader.GetAttribute("MappedKeyCode") ?? "NONAME";

            Messages.Add("Gesture Name: " + name);
            Messages.Add("Maximum Gesture Execution Time: " + maxexecutiontime);
            Messages.Add("KeyCode Mapping: " + keycode);
            MessagesWaiting = true;

            var gesture = new Gesture(name, Convert.ToInt32(maxexecutiontime));
            gesture.MappedKeycode = (VirtualKeyCode)(Enum.Parse(typeof(VirtualKeyCode), keycode));
            gesture.MaximumExecutionTime = Convert.ToInt32(maxexecutiontime);

            return gesture;
        }
Ejemplo n.º 6
0
        public Gesture ParseGestureComponentsFromXml(XmlReader reader, Gesture gesture)
        {
            var firstjoint = reader.GetAttribute("FirstJoint");
            var secondjoint = reader.GetAttribute("SecondJoint");
            JointType firstjointtype;
            JointType secondjointtype;
            GestureComponent component;

            if (firstjoint != null)
            {
                firstjointtype = (JointType)(Enum.Parse(typeof(JointType), firstjoint));
                Messages.Add("First Joint: " + firstjoint);
            }
            else
            {
                return gesture;
            }

            if (secondjoint != null)
            {
                secondjointtype = (JointType)(Enum.Parse(typeof(JointType), secondjoint));
                Messages.Add("Second Joint: " + secondjoint);
            }
            else
            {
                return gesture;
            }

            var beginningrelationship = reader.GetAttribute("BeginningRelationship");
            var endingrelationship = reader.GetAttribute("EndingRelationship");

            var endingrelationshippos = JointRelationship.None;
            var beginningrelationshippos = JointRelationship.None;

            if (endingrelationship != null)
            {
                endingrelationshippos = (JointRelationship)(Enum.Parse(typeof(JointRelationship), endingrelationship));
                Messages.Add("Ending Relationship: " + endingrelationship);
            }

            if (beginningrelationship != null)
            {
                beginningrelationshippos = (JointRelationship)(Enum.Parse(typeof(JointRelationship), beginningrelationship));
                Messages.Add("Beginning Relationship: " + beginningrelationship);
            }

            if (beginningrelationshippos != JointRelationship.None)
            {
                component = new GestureComponent(firstjointtype, secondjointtype, endingrelationshippos,
                                                     beginningrelationshippos);
            }
            else
            {
                component = new GestureComponent(firstjointtype, secondjointtype, endingrelationshippos);
            }

            gesture.Components.Add(component);
            Messages.Add("Component added to gesture:" + gesture.Description);

            return gesture;
        }
Ejemplo n.º 7
0
        public void LoadGesturesFromXml(string xmlfilename)
        {
            Items.Clear();
            var gesture = new Gesture();
            var firstpass = true;
            var mappingdone = false;

            Messages.Add("Loading XML File " + xmlfilename + " from application directory");
            MessagesWaiting = true;

            try
            {
                var reader = new XmlTextReader(xmlfilename);

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            if (reader.Name == "Gestures")
                            {
                                Messages.Add("Reading Header Information from XML File");
                                MessagesWaiting = true;
                                ParseHeaderFromXml(reader);
                            }
                            if (reader.Name == "Gesture")
                            {
                                if (firstpass == false && mappingdone)
                                {
                                    Items.Add(gesture);
                                    mappingdone = false;
                                }

                                Messages.Add("Gesture Found in XML File");
                                MessagesWaiting = true;
                                gesture = ParseGestureFromXml(reader);
                                firstpass = false;
                            }
                            if (reader.Name == "GestureComponent")
                            {
                                Messages.Add("Gesture Component Found in XML File");
                                MessagesWaiting = true;
                                gesture = ParseGestureComponentsFromXml(reader, gesture);
                                mappingdone = true;
                            }
                            break;
                    }

                }

                if (firstpass == false && mappingdone)
                {
                    Items.Add(gesture);
                }

            }
            catch (Exception ex)
            {
                Messages.Add("Error Loading XML File: " + ex);
                MessagesWaiting = true;
            }

            Messages.Add("Completed XML File Load");
            MessagesWaiting = true;
        }
Ejemplo n.º 8
0
        public Gesture ParseGestureComponentsFromXml(XmlReader reader, Gesture gesture)
        {
            var              firstjoint  = reader.GetAttribute("FirstJoint");
            var              secondjoint = reader.GetAttribute("SecondJoint");
            JointType        firstjointtype;
            JointType        secondjointtype;
            GestureComponent component;

            if (firstjoint != null)
            {
                firstjointtype = (JointType)(Enum.Parse(typeof(JointType), firstjoint));
                Messages.Add("First Joint: " + firstjoint);
            }
            else
            {
                return(gesture);
            }

            if (secondjoint != null)
            {
                secondjointtype = (JointType)(Enum.Parse(typeof(JointType), secondjoint));
                Messages.Add("Second Joint: " + secondjoint);
            }
            else
            {
                return(gesture);
            }

            var beginningrelationship = reader.GetAttribute("BeginningRelationship");
            var endingrelationship    = reader.GetAttribute("EndingRelationship");


            var endingrelationshippos    = JointRelationship.None;
            var beginningrelationshippos = JointRelationship.None;


            if (endingrelationship != null)
            {
                endingrelationshippos = (JointRelationship)(Enum.Parse(typeof(JointRelationship), endingrelationship));
                Messages.Add("Ending Relationship: " + endingrelationship);
            }

            if (beginningrelationship != null)
            {
                beginningrelationshippos = (JointRelationship)(Enum.Parse(typeof(JointRelationship), beginningrelationship));
                Messages.Add("Beginning Relationship: " + beginningrelationship);
            }

            if (beginningrelationshippos != JointRelationship.None)
            {
                component = new GestureComponent(firstjointtype, secondjointtype, endingrelationshippos,
                                                 beginningrelationshippos);
            }
            else
            {
                component = new GestureComponent(firstjointtype, secondjointtype, endingrelationshippos);
            }

            gesture.Components.Add(component);
            Messages.Add("Component added to gesture:" + gesture.Description);

            return(gesture);
        }
Ejemplo n.º 9
0
        public void LoadGesturesFromXml(string xmlfilename)
        {
            Items.Clear();
            var gesture     = new Gesture();
            var firstpass   = true;
            var mappingdone = false;

            Messages.Add("Loading XML File " + xmlfilename + " from application directory");
            MessagesWaiting = true;

            try
            {
                var reader = new XmlTextReader(xmlfilename);

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (reader.Name == "Gestures")
                        {
                            Messages.Add("Reading Header Information from XML File");
                            MessagesWaiting = true;
                            ParseHeaderFromXml(reader);
                        }
                        if (reader.Name == "Gesture")
                        {
                            if (firstpass == false && mappingdone)
                            {
                                Items.Add(gesture);
                                mappingdone = false;
                            }

                            Messages.Add("Gesture Found in XML File");
                            MessagesWaiting = true;
                            gesture         = ParseGestureFromXml(reader);
                            firstpass       = false;
                        }
                        if (reader.Name == "GestureComponent")
                        {
                            Messages.Add("Gesture Component Found in XML File");
                            MessagesWaiting = true;
                            gesture         = ParseGestureComponentsFromXml(reader, gesture);
                            mappingdone     = true;
                        }
                        break;
                    }
                }

                if (firstpass == false && mappingdone)
                {
                    Items.Add(gesture);
                }
            }
            catch (Exception ex)
            {
                Messages.Add("Error Loading XML File: " + ex);
                MessagesWaiting = true;
            }

            Messages.Add("Completed XML File Load");
            MessagesWaiting = true;
        }