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; } } }
// ------------------------------------------ // 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); }
public GestureComponentState(GestureComponent component) { this.component = component; Reset(); }
// ------------------------------------------ // 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; }