Пример #1
0
        private void ReadKeySettingFromIni(string fileName)
        {
            var keyConfig = new KeyConfig();
            var sr        = new StreamReader(fileName);
            var s         = sr.ReadToEnd().Replace("\r\n", "\n").Replace("\r", "\n");

            sr.Close();
            var sp = s.Split('\n');

            for (int i = 0; i < Math.Min(sp.Length, ButtonUtility.Array.Length); i++)
            {
                var secondsp = sp[i].Split(':');
                if (secondsp.Length >= 2)
                {
                    keyConfig.SetKeyMap(ButtonUtility.Array[i], (Key)int.Parse(secondsp[0]));
                    keyConfig.SetButtonMap(ButtonUtility.Array[i], int.Parse(secondsp[1]));
                }
            }
            keyConfigs.Add(keyConfig);
        }
Пример #2
0
 private void ReadKeySetting(XmlReader reader, KeyConfig keyConfig)
 {
     while (reader.Read())
     {
         if (reader.IsStartElement())
         {
             switch (reader.LocalName)
             {
             case "Config":
                 var key = (Key)int.Parse(reader.GetAttribute("Key"));
                 int button = int.Parse(reader.GetAttribute("Button")), index = FindIndex(reader.GetAttribute("Type"));
                 if (index >= 0)
                 {
                     keyConfig.SetKeyMap(ButtonUtility.Array[index], key);
                     keyConfig.SetButtonMap(ButtonUtility.Array[index], button);
                 }
                 break;
             }
         }
     }
     reader.Close();
 }