Пример #1
0
        public static KeyStoreInfoCollection ReadStore(XmlElement xmlElement)
        {
            KeyStoreInfoCollection storeCollection = new KeyStoreInfoCollection();

            foreach (XmlElement childElement in xmlElement.ChildNodes.OfType <XmlElement>())
            {
                if (childElement.Name == KEY_STORE_INFO)
                {
                    try
                    {
                        KeyStoreInfo keyStore = new KeyStoreInfo();
                        switch ((KEY_TYPE)int.Parse(childElement.GetAttribute(KEY_STORE_TYPE)))
                        {
                        case KEY_TYPE.KEYBOARD:
                            keyStore.SetStoreValue((Keys)int.Parse(childElement.GetAttribute(KEY_STORE_VALUE)));
                            break;

                        case KEY_TYPE.JOYSTICK:
                            keyStore.SetStoreValue((JoystickButtons)int.Parse(childElement.GetAttribute(KEY_STORE_VALUE)));
                            break;
                        }
                        storeCollection.Add(keyStore);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            return(storeCollection);
        }
Пример #2
0
 public static void WriteStore(KeyStoreInfoCollection storeCollection, ref XmlDocument xmlDoc, ref XmlElement xmlItem)
 {
     foreach (KeyStoreInfo keyStore in storeCollection)
     {
         XmlElement xmlStore = xmlDoc.CreateElement(KEY_STORE_INFO);
         if (keyStore.IsJoystick() && keyStore._Joystick != JoystickButtons.None)
         {
             xmlStore.SetAttribute(KEY_STORE_TYPE, ((int)KEY_TYPE.JOYSTICK).ToString());
             xmlStore.SetAttribute(KEY_STORE_VALUE, ((int)keyStore._Joystick).ToString());
         }
         else if (keyStore._Keyboard != Keys.NoName)
         {
             xmlStore.SetAttribute(KEY_STORE_TYPE, ((int)KEY_TYPE.KEYBOARD).ToString());
             xmlStore.SetAttribute(KEY_STORE_VALUE, ((int)keyStore._Keyboard).ToString());
         }
         xmlItem.AppendChild(xmlStore);
     }
 }