예제 #1
0
        public void Load(String xmlFile)
        {
            var     reader  = new XmlTextReader(xmlFile);
            Gesture gesture = null;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name == "gestures")
                    {
                        var timeout = reader.GetAttribute("gestureResetTimeout");
                        gestureResetTimeout = timeout != null?Convert.ToInt32(timeout) : gestureResetTimeout;
                    }
                    if (reader.Name == "gesture")
                    {
                        gesture = Gesture.Parse(reader);
                        gestures.Add(gesture);
                        WSRConfig.GetInstance().logInfo("GESTURE", "Loading: " + gesture.Description);
                    }
                    if (reader.Name == "component" && gesture != null)
                    {
                        GestureComponent component = GestureComponent.Parse(reader);
                        gesture.Components.Add(component);
                        WSRConfig.GetInstance().logDebug("GESTURE", "Component: " + component.Log(gesture.Description));
                    }
                    break;
                }
            }
        }
예제 #2
0
        // ------------------------------------------
        //  Parser
        // ------------------------------------------

        public static GestureComponent Parse(XmlTextReader reader)
        {
            GestureComponent component = new GestureComponent();

            var j1 = reader.GetAttribute("firstJoint");

            if (j1 != null)
            {
                JointType join = (JointType)(Enum.Parse(typeof(JointType), j1));
                component.Joint1 = join;
            }

            var j2 = reader.GetAttribute("secondJoint");

            if (j2 != null)
            {
                JointType join = (JointType)(Enum.Parse(typeof(JointType), j2));
                component.Joint2 = join;
            }

            var begin = reader.GetAttribute("beginningRelationship");

            if (begin != null)
            {
                JointRelationship rs = (JointRelationship)(Enum.Parse(typeof(JointRelationship), begin));
                component.Begin = rs;
            }

            var end = reader.GetAttribute("endingRelationship");

            if (end != null)
            {
                JointRelationship rs = (JointRelationship)(Enum.Parse(typeof(JointRelationship), end));
                component.Ending = rs;
            }

            return(component);
        }
예제 #3
0
 public GestureComponentState(GestureComponent component)
 {
     this.component = component;
     Reset();
 }
예제 #4
0
 public GestureComponentState(GestureComponent component)
 {
     this.component = component;
       Reset();
 }
예제 #5
0
        // ------------------------------------------
        //  Parser
        // ------------------------------------------
        public static GestureComponent Parse(XmlTextReader reader)
        {
            GestureComponent component = new GestureComponent();

              var j1  = reader.GetAttribute("firstJoint");
              if (j1 != null) {
            JointType join = (JointType)(Enum.Parse(typeof(JointType), j1));
            component.Joint1 = join;
              }

              var j2 = reader.GetAttribute("secondJoint");
              if (j2 != null) {
            JointType join = (JointType)(Enum.Parse(typeof(JointType), j2));
            component.Joint2 = join;
              }

              var begin = reader.GetAttribute("beginningRelationship");
              if (begin != null) {
            JointRelationship rs = (JointRelationship)(Enum.Parse(typeof(JointRelationship), begin));
            component.Begin = rs;
              }

              var end = reader.GetAttribute("endingRelationship");
              if (end != null) {
            JointRelationship rs = (JointRelationship)(Enum.Parse(typeof(JointRelationship), end));
            component.Ending = rs;
              }

              return component;
        }