コード例 #1
0
        public void LoadKeys()
        {
            XmlDocument doc = new XmlDocument ();
            doc.Load ("Data/Keys.xml");

            XmlNodeList nodes = doc.GetElementsByTagName ("Key");

            for (int n = 0; n < nodes.Count; n++)
            {
                KeyDef key = new KeyDef ();

                XmlNodeList innerNodes = nodes[n].ChildNodes;

                for (int i = 0; i < innerNodes.Count; i++)
                {

                    if (innerNodes[i].Name == "KeyPressed")
                    {
                        key.Key = (Keys)Convert.ToInt32 (innerNodes[i].InnerText);

                    }
                    else if (innerNodes[i].Name == "Action")
                    {
                        key.Action = innerNodes[i].InnerText;
                    }
                    else if (innerNodes[i].Name == "Control")
                    {
                        key.Control = Convert.ToBoolean (Convert.ToInt32 (innerNodes[i].InnerText));
                    }
                    else if (innerNodes[i].Name == "Alt")
                    {
                        key.Alt = Convert.ToBoolean (Convert.ToInt32 (innerNodes[i].InnerText));
                    }
                    else if (innerNodes[i].Name == "Shift")
                    {
                        key.Shift = Convert.ToBoolean (Convert.ToInt32 (innerNodes[i].InnerText));
                    }

                }
                KeyDefCollection.Add (key.Key, key);
            }
        }
コード例 #2
0
 public void AddKey(Keys key, string Action, bool Control, bool Alt, bool Shift)
 {
     var keyDef = new KeyDef (Action, key, Control, Alt, Shift);
     this.KeyDefCollection.Add (key, keyDef);
 }