예제 #1
0
        public void ModifyCommandAt(int index, CommandControlMappingElement newCommand)
        {
            var newType = GetConfigType(newCommand);
            var oldType = GetConfigType(GetCommandAt(index));

            if (newType != oldType)
            {
                RemoveCommandAt(index);
                AddCommand(newCommand);

                return;
            }

            var i = 0;

            foreach (var type in bindings.Keys)
            {
                if (index - i < bindings[type].GetCommandControlMappings().Count)
                {
                    bindings[type].ModifyCommandAt(index - i, newCommand);
                    break;
                }

                i += bindings[type].GetCommandControlMappings().Count;
            }
        }
예제 #2
0
 public void AddCommand(CommandControlMappingElement command)
 {
     foreach (var type in bindings.Keys)
     {
         try
         {
             var config = Convert.ChangeType(command.hardwareConfiguration, type);
             bindings[type].AddCommand(command);
             break;
         }
         catch (InvalidCastException)
         {
         }
     }
 }
예제 #3
0
        public string GetConfigType(CommandControlMappingElement config)
        {
            foreach (var type in bindings.Keys)
            {
                try
                {
                    var c = Convert.ChangeType(config.hardwareConfiguration, type);
                    return(bindings[type].Name);
                }
                catch (InvalidCastException)
                {
                }
            }

            return("");
        }
예제 #4
0
 public abstract void ModifyCommandAt(int index, CommandControlMappingElement newCommand);
예제 #5
0
 public abstract void AddCommand(CommandControlMappingElement command);