public XmlElement AddElementWithAttribute(string name, string attribute, string value) { XmlElement result = Doc.CreateElement(name); result.SetAttribute(attribute, value); return(result); }
//Template public void Initialization(string xsdFile, string namespaceurl = null) { //File- { XmlElement module = Doc.CreateElement("File"); Root.AppendChild(module); //IN-- module.AppendChild(FormFile.InitialTemplate()); //OS-- module.AppendChild(FormBasicFunction.InitialTemplate()); } //Method- Root.AppendChild(FormMethod.InitialTemplate()); //EMCParameters- Root.AppendChild(FormFrequency.InitialTemplate()); //Excitation- Root.AppendChild(FormExcitation.InitialTemplate()); //Solution- Root.AppendChild(FormSolution.InitialTemplate()); //Request- Root.AppendChild(FormRequest.InitialTemplate()); _settings.Schemas.Add(namespaceurl, xsdFile); _settings.ValidationEventHandler += ErrorEventHanlde; Doc.Schemas = _settings.Schemas; }
//Help API public XmlElement AddElementWithText(string name, string text) { XmlElement result = Doc.CreateElement(name); result.InnerText = text; return(result); }
/// <summary> /// 添加节点 /// </summary> /// <param name="nodeName">节点名称</param> /// <param name="nodeValue">节点内容</param> /// <param name="fatherNodeXPath">父节点Path</param> /// <param name="attrs">属性集合</param> /// <returns>返回新建的节点</returns> public XmlNode InsertNode(string nodeName, string nodeValue, string fatherNodeXPath, Dictionary <string, string> attrs) { try { XmlNode root = Doc.SelectSingleNode(fatherNodeXPath); if (root != null) { var xmlelem = Doc.CreateElement(nodeName); if (!string.IsNullOrEmpty(nodeValue)) { xmlelem.InnerText = nodeValue; } if (attrs != null) { attrs.ForEach(p => SetAttributeValue(xmlelem, p.Key, p.Value)); } root.AppendChild(xmlelem); SaveXmlDocument(); return(xmlelem); } return(null); } catch (Exception e) { throw new Exception(e.Message); } }
protected override void generateXML() { if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } if (Options.SelectedJoints.Count == 1) { var jointNode = Doc.CreateElement(UseHand ? "HandJoint" : "Joint", NamespaceUri); appendStringAttribute(jointNode, "name", getJointName(Options.SelectedJoints[0].Main)); RecognizerNode.AppendChild(jointNode); } var fingerCountNode = Doc.CreateElement("FingerCount", NamespaceUri); if (Options.ToleranceCountType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(fingerCountNode, "min", Math.Max(0, m_avgFingerCount - Options.ToleranceCount)); } if (Options.ToleranceCountType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(fingerCountNode, "max", Math.Min(5, m_avgFingerCount + Options.ToleranceCount)); } if (Options.MedianWindowSize > 0) { appendStringAttribute(fingerCountNode, "useMedianCalculation", "true"); appendNumericAttribute(fingerCountNode, "medianWindowSize", Options.MedianWindowSize, 0); } RecognizerNode.AppendChild(fingerCountNode); }
protected override void generateXML() { for (var i = 0; i < CombOptions.States.Count; i++) { if (CombOptions.States[i].Recognizers.Count > 0) // Skip emtpy states { var stateNode = Doc.CreateElement("State", NamespaceUri); foreach (var recognizer in CombOptions.States[i].Recognizers) { var recNode = Doc.CreateElement("Recognizer", NamespaceUri); appendStringAttribute(recNode, "name", recognizer); stateNode.AppendChild(recNode); } var minDuration = CombOptions.States[i].MinDuration - CombOptions.TimeTolerance; if (minDuration > 0 && CombOptions.TimeToleranceType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(stateNode, "minDuration", minDuration, 3); } if (CombOptions.States[i].MaxDuration >= 0 && CombOptions.TimeToleranceType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(stateNode, "maxDuration", CombOptions.States[i].MaxDuration + CombOptions.TimeTolerance, 3); } if (i != CombOptions.States.Count - 1 && CombOptions.States[i].TimeForTransition >= 0) { appendNumericAttribute(stateNode, "timeForTransition", CombOptions.States[i].TimeForTransition + CombOptions.TransitionTolerance, 3); } RecognizerNode.AppendChild(stateNode); } } }
public override void CreateElement() { var xmlImage = Doc.CreateElement(string.Empty, "image", string.Empty); foreach (var attributeKeyPair in Attributes) { xmlImage.Attributes.Append(attributeKeyPair.Value); } Parent.AppendChild(xmlImage); base.CreateElement(); }
public override void CreateElement() { var xmlLinkView = Doc.CreateElement(string.Empty, "linkview", string.Empty); foreach (var attributeKeyPair in Attributes) { xmlLinkView.Attributes.Append(attributeKeyPair.Value); } Parent.AppendChild(xmlLinkView); base.CreateElement(); }
public void WriteString(string key, string value) { XmlElement ele = Doc.DocumentElement.SelectSingleNode(string.Format("config[@key=\"{0}\"]", key)) as XmlElement; if (ele == null) { ele = Doc.CreateElement("config"); Doc.DocumentElement.AppendChild(ele); ele.SetAttribute("key", key); } ele.SetAttribute("value", value); Doc.Save(ConfigPath); }
// Gets a `String` state value. public string GetCharState(uint charIdx, string settingName) { var charNode = CharNode(charIdx); var charSettingNode = charNode.SelectSingleNode(settingName); if (charSettingNode == null) { charSettingNode = charNode.AppendChild(Doc.CreateElement(settingName)); } return(charSettingNode.InnerText); }
public XmlElement CharTasksNode(uint charIdx) { var charNodeName = Global.Default.CharLabelPrefix + charIdx.ToString(); var charNode = GetOrCreateSettingNode(charNodeName, CharactersNodeName); var charTasksNode = charNode.SelectSingleNode(TasksNodeName); if (charTasksNode == null) { charTasksNode = charNode.AppendChild(Doc.CreateElement(TasksNodeName)); } return((XmlElement)charTasksNode); }
// Saves a `String` state value. public void SaveCharState(string settingVal, uint charIdx, string settingName) { var charNode = CharNode(charIdx); var charSettingNode = charNode.SelectSingleNode(settingName); if (charSettingNode == null) { charSettingNode = charNode.AppendChild(Doc.CreateElement(settingName)); } charSettingNode.InnerText = settingVal; SaveFile(); }
public string GetCharSetting(uint charIdx, string settingName) { var charNodeName = Global.Default.CharLabelPrefix + charIdx.ToString(); var charNode = GetOrCreateSettingNode(charNodeName, CharactersNodeName); var charSettingNode = charNode.SelectSingleNode(settingName); if (charSettingNode == null) { charSettingNode = Doc.CreateElement(settingName); charNode.AppendChild(charSettingNode); } return(charSettingNode.InnerText); }
public void SaveCharSetting(string settingVal, uint charIdx, string settingName) { var charNodeName = Global.Default.CharLabelPrefix + charIdx.ToString(); var charNode = GetOrCreateSettingNode(charNodeName, CharactersNodeName); var charSettingNode = charNode.SelectSingleNode(settingName); if (charSettingNode == null) { charSettingNode = Doc.CreateElement(settingName); charNode.AppendChild(charSettingNode); } charSettingNode.InnerText = settingVal; SaveFile(); }
public override void CreateElement() { var xmlPage = Doc.CreateElement(string.Empty, "page", string.Empty); foreach (var attributeKeyPair in Attributes) { xmlPage.Attributes.Append(attributeKeyPair.Value); } if (!string.IsNullOrEmpty(_content)) { var cdata = _doc.CreateCDataSection(_content); xmlPage.AppendChild(cdata); } Parent.AppendChild(xmlPage); base.CreateElement(); }
public override void CreateElement() { var xmlLink = Doc.CreateElement(string.Empty, "link", string.Empty); foreach (var attributeKeyPair in Attributes) { xmlLink.Attributes.Append(attributeKeyPair.Value); } var xmlLinkViews = Doc.CreateElement(string.Empty, "linkviews", string.Empty); var linkView = new LinkView(_mapId, _originNode, Doc, xmlLinkViews, this.LinkType); linkView.CreateElement(); xmlLink.AppendChild(xmlLinkViews); Parent.AppendChild(xmlLink); base.CreateElement(); }
/// <summary> /// 新增說明tag /// </summary> /// <param name="dr"></param> /// <param name="abbrName">商品中說明</param> protected virtual void MakeDescElement(DataRow dr, string abbrName) { DateTime beginYmd = dr["issue_begin_ymd"].AsDateTime("yyyyMMdd"); string issueBeginYmd = beginYmd.AsTaiwanDateTime("{0}年{1}月{2}日", 3); DateTime endYmd = dr["issue_end_ymd"].AsDateTime("yyyyMMdd"); string issueEndYmd = endYmd.AsTaiwanDateTime("{0}年{1}月{2}日", 3); XmlElement element = Doc.CreateElement("文字"); element.InnerText = DescTxt; ReplaceXmlInnterText(element, "#kind_name_llist#", abbrName); ReplaceXmlInnterText(element, "#issue_begin_ymd#", issueBeginYmd); ReplaceXmlInnterText(element, "#issue_end_ymd#", issueEndYmd); XmlElement element_Tmp = Doc.CreateElement("條列"); element_Tmp.AppendChild(element); Doc.GetElementsByTagName("段落")[0].AppendChild(element_Tmp); }
public GlymaXmlMap(Guid mapId) { var doctype = Doc.CreateDocumentType("model", null, "Compendium.dtd", null); Doc.AppendChild(doctype); var model = Doc.CreateElement(string.Empty, "model", string.Empty); var attr = Doc.CreateAttribute("rootview"); attr.Value = mapId.ToLongString(); model.Attributes.Append(attr); Doc.AppendChild(model); //_xmlElementViews = Doc.CreateElement(string.Empty, "views", string.Empty); //model.AppendChild(_xmlElementViews); //_xmlElementNodes = Doc.CreateElement(string.Empty, "nodes", string.Empty); //model.AppendChild(_xmlElementNodes); //_xmlElementLinks = Doc.CreateElement(string.Empty, "links", string.Empty); //model.AppendChild(_xmlElementLinks); }
public void AddInputNode(string nameId, string type, string value) { var inputNode = Doc.CreateElement("input"); if (!string.IsNullOrEmpty(nameId)) { var nameAttribute = Doc.CreateAttribute("name", nameId); inputNode.Attributes.Add(nameAttribute); var idAttribute = Doc.CreateAttribute("id", nameId); inputNode.Attributes.Add(idAttribute); } var hiddenAttribute = Doc.CreateAttribute("type", type); inputNode.Attributes.Add(hiddenAttribute); var valueAttribute = Doc.CreateAttribute("value", value); inputNode.Attributes.Add(valueAttribute); FormNode.AppendChild(inputNode); }
protected override void generateXML() { if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { appendStringAttribute(RecognizerNode, "measuringUnit", FubiUtils.getBodyMeasureName(Options.MeasuringUnit)); } if (Options.Local) { appendStringAttribute(RecognizerNode, "useLocalTransformations", "true"); } if (Options.MaxAngleDifference >= 0) { appendNumericAttribute(RecognizerNode, "maxRotation", Options.MaxAngleDifference, 3); } appendNumericAttribute(RecognizerNode, "maxDistance", Options.MaxDistance, 3); appendStringAttribute(RecognizerNode, "distanceMeasure", Options.DistanceMeasure.ToString().ToLower()); if (Options.UseOrientations) { appendStringAttribute(RecognizerNode, "useOrientations", "true"); } if (Options.AspectInvariant) { appendStringAttribute(RecognizerNode, "aspectInvariant", "true"); } foreach (XMLGenerator.RelativeJoint j in Options.SelectedJoints) { var jointNode = Doc.CreateElement(UseHand ? "HandJoints" : "Joints", NamespaceUri); appendStringAttribute(jointNode, "main", getJointName(j.Main)); if (j.Relative != FubiUtils.SkeletonJoint.NUM_JOINTS) { appendStringAttribute(jointNode, "relative", getJointName(j.Relative)); } RecognizerNode.AppendChild(jointNode); } var trainingNode = Doc.CreateElement("TrainingData", NamespaceUri); appendStringAttribute(trainingNode, "file", Options.PlaybackFile); appendNumericAttribute(trainingNode, "start", Options.PlaybackStart, 0); appendNumericAttribute(trainingNode, "end", Options.PlaybackEnd, 0); RecognizerNode.AppendChild(trainingNode); if (Options.IgnoreAxes != 0) { var ignoreAxesNode = Doc.CreateElement("IgnoreAxes", NamespaceUri); if ((Options.IgnoreAxes & (uint)FubiUtils.CoordinateAxis.X) != 0) { appendStringAttribute(ignoreAxesNode, "x", "true"); } if ((Options.IgnoreAxes & (uint)FubiUtils.CoordinateAxis.Y) != 0) { appendStringAttribute(ignoreAxesNode, "y", "true"); } if ((Options.IgnoreAxes & (uint)FubiUtils.CoordinateAxis.Z) != 0) { appendStringAttribute(ignoreAxesNode, "z", "true"); } RecognizerNode.AppendChild(ignoreAxesNode); } }
public override void CreateElement() { var xmlNode = Doc.CreateElement(string.Empty, "node", string.Empty); foreach (var attributeKeyPair in Attributes) { xmlNode.Attributes.Append(attributeKeyPair.Value); } var details = Doc.CreateElement(string.Empty, "details", string.Empty); var pageNum = 1; if (!string.IsNullOrEmpty(_node.Description)) { var page = new Page(_node.Description, _node, Doc, details, pageNum); page.CreateElement(); pageNum++; } if (!string.IsNullOrEmpty(_node.ExtraMetadata)) { var page2 = new Page(_node.ExtraMetadata, _node, Doc, details, pageNum); page2.CreateElement(); pageNum++; } if (pageNum == 1) { var page = new Page(_node.Description, _node, Doc, details, pageNum); page.CreateElement(); } xmlNode.AppendChild(details); var source = Doc.CreateElement(string.Empty, "source", string.Empty); if (!string.IsNullOrEmpty(_node.Source)) { var sourceCdata = Doc.CreateCDataSection(_node.Source); source.AppendChild(sourceCdata); } xmlNode.AppendChild(source); var image = new Image(Doc, xmlNode); image.CreateElement(); var background = Doc.CreateElement(string.Empty, "background", string.Empty); xmlNode.AppendChild(background); var coderefs = Doc.CreateElement(string.Empty, "coderefs", string.Empty); xmlNode.AppendChild(coderefs); var shortcutrefs = Doc.CreateElement(string.Empty, "shortcutrefs", string.Empty); xmlNode.AppendChild(shortcutrefs); var movies = Doc.CreateElement(string.Empty, "movies", string.Empty); xmlNode.AppendChild(movies); Parent.AppendChild(xmlNode); base.CreateElement(); }
/// <summary> /// Helper method for serializing a simple or complex type and /// formating the data into an xml element. /// </summary> /// <param name="name"></param> /// <param name="obj"></param> /// <returns></returns> protected XmlElement SerializeCore(string name, object obj) { //if we are serializing a null object, we have already created the element for it //so now we need to let it know there is no data to be found. if (IsReferenceNull(obj)) { XmlElement e = Doc.CreateElement(name); e.SetAttribute("value", "null"); return(e); } //we want Unity objects to be identified by their type Type objType = obj.GetType(); XmlElement element = null; if (obj is UnityEngine.Object && name == null) { element = Doc.CreateElement(objType.Name); } else { element = Doc.CreateElement(name); } //WARNING: I'm guessing 'AnsiClass' means 'struct'. Not entirely sure though. //And I have no idea what an 'AutoClass' or 'UnicodeClass' is at all. //we are serializing a complex object of some kind if (objType.IsClass && objType != typeof(string)) { //This object is a Unity component that had its serialization previously defered. //We now need to know what that defered element used as an id and store that //when we serialize this object. if (DeferedCache != null && DeferedCache.ContainsKey(obj)) { element.SetAttribute("id", GetCacheId(objType, obj).ToString()); //element.SetAttribute("DeferedId", DeferedCache[obj].ToString()); //tj //SetAsDeferedComponent((Component)obj, element); //continue serialization as normal from here... } //if this is not a unity object we still need to check the object cache and see //if we already serialized it once. else if (Options.UseGraphSerialization && !AddObjToCache(objType, obj, element)) { return(element); } // the object has just been added SetTypeInfo(objType, element); //TODO: For general-surrogate support we'll need to implement it here. if (CheckForcedSerialization(objType)) { // serialize as complex type SerializeComplexType(obj, ref element); return(element); } IXmlSerializable xmlSer = obj as IXmlSerializable; if (xmlSer == null) { //HACK ALERT: Hard-coding logic tied to specific datatypes!! //We need to intercept Unity built-in types here because some of //them expose the IEnumerable interface and will cause inifite loops //(namely, the Transform component). if (objType.IsSubclassOf(typeof(Component))) { SerializeComplexType(obj as Component, ref element); return(element); } // does not know about automatic serialization IEnumerable enumerable = obj as IEnumerable; if (enumerable == null) { SerializeComplexType(obj, ref element); } else { //This gets a little poo-poo here. We can't simply serialize //as a list of enumerables if this is a multi-dimensional array //since we'll need to know the individual ranks and rank lengths //when we deserialize. So we'll try casting to see what we do next. var arr = obj as Array; if (arr != null && arr.Rank > 1) { element.SetAttribute("Ranks", ArrayRankCounter(arr)); SerializeMultiDimensionalArray(name, arr, 0, new int[arr.Rank], element); } else { //either a single-dimensional array or just an enumerable list of some kind foreach (object arrObj in enumerable) { XmlElement e = SerializeCore(name, arrObj); element.AppendChild(e); } } } } else { // can perform the serialization itself StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.Encoding = Encoding.UTF8; settings.OmitXmlDeclaration = true; XmlWriter wr = XmlWriter.Create(sb, settings); wr.WriteStartElement("value"); xmlSer.WriteXml(wr); wr.WriteEndElement(); wr.Close(); element.InnerXml = sb.ToString(); } } else { // the object has just been added SetTypeInfo(objType, element); if (CheckForcedSerialization(objType)) { // serialize as complex type SerializeComplexType(obj, ref element); return(element); } if (objType.IsEnum) { object val = Enum.Format(objType, obj, "d"); element.SetAttribute("value", val.ToString()); } else { if (objType.IsPrimitive || objType == typeof(string) || objType == typeof(DateTime) || objType == typeof(decimal)) { element.SetAttribute("value", obj.ToString()); } else { // this is most probably a struct (or autoclass or unicodeclass, whatever those are) SerializeComplexType(obj, ref element); } } } return(element); }
protected override void generateXML() { if (Options.Local) { appendStringAttribute(RecognizerNode, "useLocalPositions", "true"); } if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { appendStringAttribute(RecognizerNode, "measuringUnit", FubiUtils.getBodyMeasureName(Options.MeasuringUnit)); } var jointNode = Doc.CreateElement(UseHand ? "HandJoints" : "Joints", NamespaceUri); appendStringAttribute(jointNode, "main", getJointName(Options.SelectedJoints[0].Main)); if (Options.SelectedJoints[0].Relative != FubiUtils.SkeletonJoint.NUM_JOINTS) { appendStringAttribute(jointNode, "relative", getJointName(Options.SelectedJoints[0].Relative)); } RecognizerNode.AppendChild(jointNode); Vector3D direction = AvgValue; double length = AvgValue.Length; if (length > Double.Epsilon) { direction.Normalize(); } else // No valid direction recorded, so we arbitrarily chose up direction { direction = new Vector3D(0, 1, 0); } var directionNode = Doc.CreateElement("Direction", NamespaceUri); appendNumericAttribute(directionNode, "x", direction.X, 3); appendNumericAttribute(directionNode, "y", direction.Y, 3); appendNumericAttribute(directionNode, "z", direction.Z, 3); if (Options.MaxAngleDifference >= 0) { appendNumericAttribute(directionNode, "maxAngleDifference", Options.MaxAngleDifference, 3); } RecognizerNode.AppendChild(directionNode); if (Options.ToleranceDist >= 0) { if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { if (m_measureDist > 0) { AvgValue.X /= m_measureDist; AvgValue.Y /= m_measureDist; AvgValue.Z /= m_measureDist; length = AvgValue.Length; } } var lengthNode = Doc.CreateElement("Length", NamespaceUri); if (length - Options.ToleranceDist > 0 && Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(lengthNode, "min", length - Options.ToleranceDist, 3); } if (Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(lengthNode, "max", length + Options.ToleranceDist, 3); } if (lengthNode.HasAttributes) { RecognizerNode.AppendChild(lengthNode); } } if (Options.ToleranceSpeed >= 0) { var speedNode = Doc.CreateElement("Speed", NamespaceUri); if (m_speed - Options.ToleranceSpeed > 0 && Options.ToleranceSpeedType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(speedNode, "min", m_speed - Options.ToleranceSpeed, 3); } if (Options.ToleranceSpeedType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(speedNode, "max", m_speed + Options.ToleranceSpeed, 3); } if (speedNode.HasAttributes) { RecognizerNode.AppendChild(speedNode); } } }
/// <summary> /// Construit le patron /// </summary> /// <param name="Doc"></param> /// <param name="Code"></param> private void XmlBuild(ref XmlDocument Doc, XmlCode Code) { if (Doc == null) { Doc = new XmlDocument(); } else { Doc.RemoveAll(); } sVersion Actual = Outils.GetVersion(); //Déclaration de la norme utilisée XmlDeclaration xmlDeclaration = Doc.CreateXmlDeclaration("1.0", "UTF-8", null); XmlElement root = Doc.DocumentElement; Doc.InsertBefore(xmlDeclaration, root); //Création de la racine XmlElement xmlffs2play = Doc.CreateElement(string.Empty, "ffs2play", string.Empty); Doc.AppendChild(xmlffs2play); //Création de la version XmlElement xmlVersion = Doc.CreateElement(string.Empty, "version", string.Empty); xmlVersion.InnerText = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + "_" + Actual.Major.ToString() + "_" + Actual.Minor.ToString() + "_" + Actual.Build.ToString(); xmlffs2play.AppendChild(xmlVersion); //Activation du P2P; XmlElement xmlP2P = Doc.CreateElement(string.Empty, "P2P", string.Empty); xmlP2P.InnerText = Properties.Settings.Default.P2PEnable.ToString(); xmlffs2play.AppendChild(xmlP2P); //Création du switch XmlElement xmlSwitch = Doc.CreateElement(string.Empty, "switch", string.Empty); xmlffs2play.AppendChild(xmlSwitch); //Création du data XmlElement xmlData = Doc.CreateElement(string.Empty, "data", string.Empty); xmlData.InnerText = Code.ToString(); xmlSwitch.AppendChild(xmlData); //Création du key XmlElement xmlKey = Doc.CreateElement(string.Empty, "key", string.Empty); xmlKey.InnerText = Key; xmlSwitch.AppendChild(xmlKey); switch (Code) { case XmlCode.hello: XmlElement xmlHello = Doc.CreateElement(string.Empty, "hello", string.Empty); xmlffs2play.AppendChild(xmlHello); //Création de la balise pilotID XmlElement xmlLogin = Doc.CreateElement(string.Empty, "pilotID", string.Empty); xmlLogin.InnerText = User.Login; xmlHello.AppendChild(xmlLogin); break; case XmlCode.verify: //Création de la balise verify XmlElement xmlVerify = Doc.CreateElement(string.Empty, "verify", string.Empty); xmlffs2play.AppendChild(xmlVerify); //Création de la balise AES XmlElement xmlAES = Doc.CreateElement(string.Empty, "AES", string.Empty); xmlAES.InnerText = Crypted_AESKey; xmlVerify.AppendChild(xmlAES); //Création de la balise pilotID XmlElement xmlPilotID = Doc.CreateElement(string.Empty, "pilotID", string.Empty); xmlPilotID.InnerText = User.Login; xmlVerify.AppendChild(xmlPilotID); //Création de la balise password XmlElement xmlPassword = Doc.CreateElement(string.Empty, "password", string.Empty); xmlPassword.InnerText = Outils.EncryptMessage(Outils.Decrypt(User.Password), m_sAESKey); xmlVerify.AppendChild(xmlPassword); //Envoi du port en écoute XmlElement xmlPort = Doc.CreateElement(string.Empty, "port", string.Empty); xmlPort.InnerText = P2P.Port.ToString(); xmlVerify.AppendChild(xmlPort); //Envoi du port en écoute XmlElement xmlLocalIP = Doc.CreateElement(string.Empty, "local_ip", string.Empty); xmlLocalIP.InnerText = P2P.LocalIPSerialized; xmlVerify.AppendChild(xmlLocalIP); break; case XmlCode.liveupdate: //Création de la balise liveupdate XmlElement xmlLiveUpdate2 = Doc.CreateElement(string.Empty, "liveupdate", string.Empty); xmlffs2play.AppendChild(xmlLiveUpdate2); xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "registration", string.Empty)); //Création de la balise registration xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "latitude", string.Empty)); //Création de la balise latitude xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "longitude", string.Empty)); //Création de la balise longitude xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "heading", string.Empty)); //Création de la balise heading xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "altitude", string.Empty)); //Création de la balise altitude xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "groundSpeed", string.Empty)); //Création de la balise groundSpeed xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "iaspeed", string.Empty)); //Création de la balise iaspeed xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "squawk", string.Empty)); //Création de la balise squawk xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "onground", string.Empty)); //Création de la balise onground xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "sim", string.Empty)); //Création de la balise simulateur break; case XmlCode.atc: //Création de la balise liveupdate XmlElement xmlAtc = Doc.CreateElement(string.Empty, "atc", string.Empty); xmlffs2play.AppendChild(xmlAtc); xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "latitude", string.Empty)); //Création de la balise latitude xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "longitude", string.Empty)); //Création de la balise longitude xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "heading", string.Empty)); //Création de la balise heading xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "altitude", string.Empty)); //Création de la balise altitude xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "groundSpeed", string.Empty)); //Création de la balise groundSpeed xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "iaspeed", string.Empty)); //Création de la balise iaspeed xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "squawk", string.Empty)); //Création de la balise squawk break; case XmlCode.syncai: XmlElement xmlSyncAI = Doc.CreateElement(string.Empty, "syncai", string.Empty); xmlffs2play.AppendChild(xmlSyncAI); xmlSyncAI.AppendChild(Doc.CreateElement(string.Empty, "md5list", string.Empty)); break; case XmlCode.sendai: XmlElement xmlSendAI = Doc.CreateElement(string.Empty, "sendai", string.Empty); xmlffs2play.AppendChild(xmlSendAI); break; } }
protected override void generateXML() { if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } XmlElement maxNode, minNode; if (Type == XMLGenerator.RecognizerType.JointRelation) { if (Options.MeasuringUnit != FubiUtils.BodyMeasurement.NUM_MEASUREMENTS) { appendStringAttribute(RecognizerNode, "measuringUnit", FubiUtils.getBodyMeasureName(Options.MeasuringUnit)); } if (Options.Local) { appendStringAttribute(RecognizerNode, "useLocalPositions", "true"); } var jointNode = Doc.CreateElement(UseHand ? "HandJoints" : "Joints", NamespaceUri); appendStringAttribute(jointNode, "main", getJointName(Options.SelectedJoints[0].Main)); if (Options.SelectedJoints[0].Relative != FubiUtils.SkeletonJoint.NUM_JOINTS) { appendStringAttribute(jointNode, "relative", getJointName(Options.SelectedJoints[0].Relative)); } RecognizerNode.AppendChild(jointNode); maxNode = Doc.CreateElement("MaxValues", NamespaceUri); minNode = Doc.CreateElement("MinValues", NamespaceUri); } else { if (!Options.Local) { appendStringAttribute(RecognizerNode, "useLocalOrientations", "false"); } var jointNode = Doc.CreateElement(UseHand ? "HandJoint" : "Joint", NamespaceUri); appendStringAttribute(jointNode, "name", getJointName(Options.SelectedJoints[0].Main)); RecognizerNode.AppendChild(jointNode); if (Options.MaxAngleDifference >= 0) { var orientationNode = Doc.CreateElement("Orientation", NamespaceUri); appendNumericAttribute(orientationNode, "x", AvgValue.X); appendNumericAttribute(orientationNode, "y", AvgValue.Y); appendNumericAttribute(orientationNode, "z", AvgValue.Z); appendNumericAttribute(orientationNode, "maxAngleDifference", Options.MaxAngleDifference); RecognizerNode.AppendChild(orientationNode); return; } maxNode = Doc.CreateElement("MaxDegrees", NamespaceUri); minNode = Doc.CreateElement("MinDegrees", NamespaceUri); } if (Options.ToleranceX >= 0) { if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "x", AvgValue.X + Options.ToleranceX); } if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minNode, "x", AvgValue.X - Options.ToleranceX); } } if (Options.ToleranceY >= 0) { if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "y", AvgValue.Y + Options.ToleranceY); } if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minNode, "y", AvgValue.Y - Options.ToleranceY); } } if (Options.ToleranceZ >= 0) { if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "z", AvgValue.Z + Options.ToleranceZ); } if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minNode, "z", AvgValue.Z - Options.ToleranceZ); } } if (Type == XMLGenerator.RecognizerType.JointRelation && Options.ToleranceDist >= 0) { var dist = AvgValue.Length; if (Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxNode, "dist", dist + Options.ToleranceDist); } if (Options.ToleranceDistType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { var minDist = dist - Options.ToleranceDist; if (minDist > 0) { appendNumericAttribute(minNode, "dist", minDist); } } } if (maxNode.HasAttributes) { RecognizerNode.AppendChild(maxNode); } if (minNode.HasAttributes) { RecognizerNode.AppendChild(minNode); } }
protected override void generateXML() { if (!Options.Local) { appendStringAttribute(RecognizerNode, "useLocalOrientations", "false"); } if (Options.Filtered) { appendStringAttribute(RecognizerNode, "useFilteredData", "true"); } var jointNode = Doc.CreateElement(UseHand ? "HandJoint" : "Joint", NamespaceUri); appendStringAttribute(jointNode, "name", getJointName(Options.SelectedJoints[0].Main)); RecognizerNode.AppendChild(jointNode); var maxVelocity = Doc.CreateElement("MaxAngularVelocity", NamespaceUri); var minVelocity = Doc.CreateElement("MinAngularVelocity", NamespaceUri); if (Options.ToleranceX >= 0) { if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxVelocity, "x", (AvgValue.X + Options.ToleranceX)); } if (Options.ToleranceXType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minVelocity, "x", (AvgValue.X - Options.ToleranceX)); } } if (Options.ToleranceY >= 0) { if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxVelocity, "y", (AvgValue.Y + Options.ToleranceY)); } if (Options.ToleranceYType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minVelocity, "y", (AvgValue.Y - Options.ToleranceY)); } } if (Options.ToleranceZ >= 0) { if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Greater]) { appendNumericAttribute(maxVelocity, "z", (AvgValue.Z + Options.ToleranceZ)); } if (Options.ToleranceZType != XMLGenerator.ToleranceTypeString[(int)XMLGenerator.ToleranceType.Lesser]) { appendNumericAttribute(minVelocity, "z", (AvgValue.Z - Options.ToleranceZ)); } } if (maxVelocity.HasAttributes) { RecognizerNode.AppendChild(maxVelocity); } if (minVelocity.HasAttributes) { RecognizerNode.AppendChild(minVelocity); } }