Пример #1
0
        public KeyConfig Clone()
        {
            var ret = new KeyConfig();

            foreach (ButtonType type in ButtonUtility.Array)
            {
                ret.SetKeyMap(type, GetKeyMap(type));
                ret.SetButtonMap(type, GetButtonMap(type));
            }
            return(ret);
        }
Пример #2
0
        private void ReadKeySettingFromIni()
        {
            var keyConfig = new KeyConfig();
            var sr        = new StreamReader(keyConfigFileName);
            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], int.Parse(secondsp[0]));
                    keyConfig.SetButtonMap(ButtonUtility.Array[i], int.Parse(secondsp[1]));
                }
            }
            AddKeyConfig(keyConfig);
        }
Пример #3
0
 private void ReadKeySetting(XmlReader reader, KeyConfig keyConfig)
 {
     while (reader.Read())
     {
         if (reader.IsStartElement())
         {
             switch (reader.LocalName)
             {
             case "Config":
                 int key = int.Parse(reader.GetAttribute("Key")), 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();
 }