Example #1
0
        /// <summary>
        /// Add a new item to a command set (command set will be created if it doesn't exist)
        /// </summary>
        /// <param name="commandSetName">The name of the command set</param>
        /// <param name="command">The actual command</param>
        public void Add(string commandSetName, LauncherCommand command)
        {
            if (string.IsNullOrEmpty(commandSetName))
            {
                throw new ArgumentNullException(Resources.CommandSetNameEmpty);
            }

            if (command == null)
            {
                throw new ArgumentNullException(Resources.CommandEmpty);
            }

            if (!dict.ContainsKey(commandSetName))
            {
                dict.Add(commandSetName, new List <LauncherCommand>());
            }

            dict[commandSetName].Add(command);
        }
        /// <summary>
        /// Runs a LauncherCommand
        /// </summary>
        /// <param name="command">The command to run</param>
        public async Task RunCommand(LauncherCommand command)
        {
            if (!IsReady)
            {
                throw new InvalidOperationException(Resources.DeviceIsNotReady);
            }

            switch (command.Command)
            {
            case Command.Up:
                await Up(command.Value);

                break;

            case Command.Down:
                await Down(command.Value);

                break;

            case Command.Left:
                await Left(command.Value);

                break;

            case Command.Right:
                await Right(command.Value);

                break;

            case Command.Reset:
                await Reset();

                break;

            case Command.Fire:
                await Fire(command.Value);

                break;
            }
        }