Example #1
0
 public st_XML_Keyboard(st_XML_Keyboard that)
 {
     this.KLID = that.KLID;
       this.Name = that.Name;
       this.KeyData = new List<st_XML_Scancode>(that.KeyData);
 }
Example #2
0
        private void ProcessUserKeyboards(bool bValidate, string XMLPath)
        {
            this.Reader = new XmlTextReader(XMLPath);
              StreamReader SR = new StreamReader(this.XSDPath);

              XmlReaderSettings ReaderSettings = new XmlReaderSettings();

              if (bValidate) {
            XmlSchema Schema = new XmlSchema();
            Schema = XmlSchema.Read(SR,
                  new ValidationEventHandler(ReaderSettings_ValidationEventHandler));

            ReaderSettings.ValidationType = ValidationType.Schema;
            ReaderSettings.Schemas.Add(Schema);

            ReaderSettings.ValidationEventHandler +=
                new ValidationEventHandler(ReaderSettings_ValidationEventHandler);
              }
              XmlReader objXmlReader = XmlReader.Create(Reader, ReaderSettings);

              st_XML_Keyboard stkb = new st_XML_Keyboard();
              stkb.KeyData = new List<st_XML_Scancode>();
              st_XML_Scancode stsc = new st_XML_Scancode();

              while (objXmlReader.Read()) {
            switch (objXmlReader.NodeType) {
              case XmlNodeType.Element:
            if (bValidate)
              break;
            if (objXmlReader.Name == "keyboard") {
              stkb.KLID = objXmlReader.GetAttribute("klid");
              stkb.Name = objXmlReader.GetAttribute("kname");
            }
            if (objXmlReader.Name == "key") {
              stsc.sc  = objXmlReader.GetAttribute("scancode");
              string c1, c2, c3, c4;
              c1 = objXmlReader.GetAttribute("b");
              c2 = objXmlReader.GetAttribute("bC");
              c3 = objXmlReader.GetAttribute("sb");
              c4 = objXmlReader.GetAttribute("sbC");
              stsc.chars1 = " 0x" + c1 + ", 0x" + c2 + ", 0x" + c3 + ", 0x" + c4;
              c1 = objXmlReader.GetAttribute("l");
              c2 = objXmlReader.GetAttribute("lC");
              c3 = objXmlReader.GetAttribute("sl");
              c4 = objXmlReader.GetAttribute("slC");
              stsc.chars2 = " 0x" + c1 + ", 0x" + c2 + ", 0x" + c3 + ", 0x" + c4;
              c1 = objXmlReader.GetAttribute("g");
              c2 = objXmlReader.GetAttribute("gC");
              c3 = objXmlReader.GetAttribute("sg");
              c4 = objXmlReader.GetAttribute("sgC");
              stsc.chars3 = " 0x" + c1 + ", 0x" + c2 + ", 0x" + c3 + ", 0x" + c4;
              c1 = objXmlReader.GetAttribute("r");
              c2 = objXmlReader.GetAttribute("rC");
              c3 = objXmlReader.GetAttribute("sr");
              c4 = objXmlReader.GetAttribute("srC");
              stsc.chars4 = " 0x" + c1 + ", 0x" + c2 + ", 0x" + c3 + ", 0x" + c4;
              stkb.KeyData.Add(stsc);
            }
            break;
              case XmlNodeType.EndElement:
            if (bValidate)
              break;

            if (objXmlReader.Name == "keyboard") {
              XMLKeyboards.Add(new st_XML_Keyboard(stkb));
              stkb.KeyData.Clear();
            }
            break;
            }
              }
              objXmlReader.Close();
        }