Exemplo n.º 1
0
        protected async Task Handle(MuteCommand message)
        {
            var cmd    = GetKodiCommand("Application.SetMute", new { mute = true });
            var result = await MessageBroker.QueryService <KodiCommand, JsonRpcResponse>(cmd).ConfigureAwait(false);

            _mute = await UpdateState(MuteState.StateName, _mute, true).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        protected async Task Handle(MuteCommand message)
        {
            var cmd = GetJsonCommand("audio", "setAudioMute", new SonyAudioMuteRequest(true));
            await MessageBroker.QueryJsonService <SonyJsonQuery, SonyAudioResult>(cmd);

            _mute = await UpdateState(MuteState.StateName, _mute, true);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Mutes the specified enabled.
 /// </summary>
 /// <param name="enabled">if set to <c>true</c> [enabled].</param>
 public void Mute(bool enabled)
 {
     if (MuteCommand?.CanExecute(enabled) == true)
     {
         MuteCommand?.Execute(enabled);
     }
 }
 private void Screencast2_VolumeChanged(object sender, EventArgs e)
 {
     if (_core.TryGetScreenCast(out IScreenCastPlayer screencast2))
     {
         Volume = screencast2.Volume;
         VolDownCommand.RaiseCanExecuteChanged();
         VolUpCommand.RaiseCanExecuteChanged();
         MuteCommand.RaiseCanExecuteChanged();
         UnmuteCommand.RaiseCanExecuteChanged();
     }
 }
Exemplo n.º 5
0
    public async Task ShouldReturnSuccessfulResult()
    {
        var command = new MuteCommand(ApplicationContext);
        var text    = command.Aliases[0];
        var message = GenerateMessage(DefaultUser.Id, DefaultUser.Id, text);

        var result = await command.Execute(message, DefaultUser);

        result.Should().BeOfType <SuccessfulResult>();
        result.Message.Should().NotBeNullOrEmpty();
        DefaultUser.IsErrorsEnabled.Should().BeFalse();
    }
Exemplo n.º 6
0
        protected async Task Handle(MuteCommand message)
        {
            var cmd = new ComputerCommand
            {
                Address = _hostname,
                Service = "Mute",
                Message = new MutePost {
                    Mute = true
                }
            };
            await MessageBroker.SendToService(cmd).ConfigureAwait(false);

            _mute = await UpdateState(MuteState.StateName, _mute, true).ConfigureAwait(false);
        }
Exemplo n.º 7
0
        public async Task MuteUser(MuteCommand command, Contexts contexts)
        {
            var userToMute = await this._usersService.GetUserByIdAsync(contexts.Server, command.User);

            if (userToMute == null || userToMute.Id == this._usersService.GetBot().Id)
            {
                throw new UserNotFoundException(command.User.GetUserMention());
            }
            var timeRange = TimeRange.FromNow(DateTime.UtcNow + command.Time); //todo: change DateTime.UtcNow to Contexts.SentAt
            var muteEvent = new MuteEvent(userToMute.Id, timeRange, command.Reason, contexts.Server.Id, contexts.Channel.Id);

            await this._mutingService.MuteUserOrOverwrite(contexts, muteEvent, userToMute);

            this._unmutingService.UnmuteInFuture(contexts, muteEvent, userToMute);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Mute the system volume
 /// </summary>
 public static void Mute(MuteCommand cmd)
 {
     switch (cmd)
     {
         case MuteCommand.Mute:
             systemVolume.AudioEndpointVolume.Mute = true;
             break;
         case MuteCommand.UnMute:
             systemVolume.AudioEndpointVolume.Mute = false;
             break;
         case MuteCommand.Toggle:
             systemVolume.AudioEndpointVolume.Mute = !systemVolume.AudioEndpointVolume.Mute;
             break;
     }
 }
Exemplo n.º 9
0
        protected async Task Handle(MuteCommand message)
        {
            var control = new DenonControlQuery
            {
                Command    = "MuteOn",
                Api        = "formiPhoneAppMute",
                ReturnNode = "Mute",
                Address    = _hostName,
                Zone       = _zone.ToString()
            };

            if (await MessageBroker.QueryServiceWithVerify <DenonControlQuery, string, object>(control, "on").ConfigureAwait(false))
            {
                _mute = await UpdateState(MuteState.StateName, _mute, true).ConfigureAwait(false);
            }
        }
Exemplo n.º 10
0
        public static void Run()
        {
            var simpleSoundBar = SimpleSoundBar.Singleton;

            var powerCommand          = new PowerCommand(simpleSoundBar);
            var muteCommand           = new MuteCommand(simpleSoundBar);
            var increaseVolumeCommand = new IncreaseVolumeCommand(simpleSoundBar);
            var decreaseVolumeCommand = new DecreaseVolumeCommand(simpleSoundBar);

            var controller = new SimpleSoundBarController(powerCommand, muteCommand, increaseVolumeCommand, decreaseVolumeCommand);

            controller.Mute(); // should result in message "Turn power on first."
            controller.Power();
            controller.IncreaseVolume();
            controller.IncreaseVolume();
            controller.Mute();
            controller.Mute();
            controller.DecreaseVolume();
            controller.Power();
        }
Exemplo n.º 11
0
        private static void InitializeCommands()
        {
            ChatCommand.AddCommand("/about", new AboutCommand());
            ChatCommand.AddCommand("/addfriend", new AddFriendCommand());
            AddAdminCommand command = new AddAdminCommand();

            command.AdminFlags = "CanAddAdmin";
            ChatCommand.AddCommand("/addadmin", command);
            AddFlagCommand command2 = new AddFlagCommand();

            command2.AdminFlags = "CanAddFlags";
            ChatCommand.AddCommand("/addflag", command2);
            AnnounceCommand command3 = new AnnounceCommand();

            command3.AdminFlags = "CanAnnounce";
            ChatCommand.AddCommand("/announce", command3);
            BanCommand command4 = new BanCommand();

            command4.AdminFlags = "CanBan";
            ChatCommand.AddCommand("/ban", command4);
            ChatCommand.AddCommand("/friends", new FriendsCommand());
            GetFlagsCommand command5 = new GetFlagsCommand();

            command5.AdminFlags = "CanGetFlags";
            ChatCommand.AddCommand("/getflags", command5);
            GiveItemCommand command6 = new GiveItemCommand();

            command6.AdminFlags = "CanGiveItem";
            ChatCommand.AddCommand("/give", command6);
            GodModeCommand command7 = new GodModeCommand();

            command7.AdminFlags = "CanGodMode";
            ChatCommand.AddCommand("/god", command7);
            ChatCommand.AddCommand("/help", new HelpCommand());
            ChatCommand.AddCommand("/history", new HistoryCommand());
            SpawnItemCommand command8 = new SpawnItemCommand();

            command8.AdminFlags = "CanSpawnItem";
            ChatCommand.AddCommand("/i", command8);
            InstaKOCommand command9 = new InstaKOCommand();

            command9.AdminFlags = "CanInstaKO";
            ChatCommand.AddCommand("/instako", command9);
            KickCommand command10 = new KickCommand();

            command10.AdminFlags = "CanKick";
            ChatCommand.AddCommand("/kick", command10);
            KillCommand command11 = new KillCommand();

            command11.AdminFlags = "CanKill";
            ChatCommand.AddCommand("/kill", command11);
            LoadoutCommand command12 = new LoadoutCommand();

            command12.AdminFlags = "CanLoadout";
            ChatCommand.AddCommand("/loadout", command12);
            ChatCommand.AddCommand("/motd", new MOTDCommand());
            MuteCommand command13 = new MuteCommand();

            command13.AdminFlags = "CanMute";
            ChatCommand.AddCommand("/mute", command13);
            ChatCommand.AddCommand("/location", new LocationCommand());
            ChatCommand.AddCommand("/ping", new PingCommand());
            ChatCommand.AddCommand("/players", new PlayersCommand());
            ChatCommand.AddCommand("/pm", new PrivateMessagesCommand());
            ReloadCommand command14 = new ReloadCommand();

            command14.AdminFlags = "CanReload";
            ChatCommand.AddCommand("/reload", command14);
            RemoveAdminCommand command15 = new RemoveAdminCommand();

            command15.AdminFlags = "CanDeleteAdmin";
            ChatCommand.AddCommand("/unadmin", command15);
            ChatCommand.AddCommand("/r", new ReplyCommand());
            ChatCommand.AddCommand("/rules", new RulesCommand());
            SaveAllCommand command16 = new SaveAllCommand();

            command16.AdminFlags = "CanSaveAll";
            ChatCommand.AddCommand("/saveall", command16);
            MasterAdminCommand command17 = new MasterAdminCommand();

            command17.AdminFlags = "RCON";
            ChatCommand.AddCommand("/setmasteradmin", command17);
            ChatCommand.AddCommand("/share", new ShareCommand());
            ChatCommand.AddCommand("/starter", new StarterCommand());
            TeleportHereCommand command18 = new TeleportHereCommand();

            command18.AdminFlags = "CanTeleport";
            ChatCommand.AddCommand("/tphere", command18);
            TeleportToCommand command19 = new TeleportToCommand();

            command19.AdminFlags = "CanTeleport";
            ChatCommand.AddCommand("/tpto", command19);
            UnbanCommand command20 = new UnbanCommand();

            command20.AdminFlags = "CanUnban";
            ChatCommand.AddCommand("/unban", command20);
            ChatCommand.AddCommand("/unfriend", new UnfriendCommand());
            RemoveFlagsCommand command21 = new RemoveFlagsCommand();

            command21.AdminFlags = "CanUnflag";
            ChatCommand.AddCommand("/unflag", command21);
            UnmuteCommand command22 = new UnmuteCommand();

            command22.AdminFlags = "CanUnmute";
            ChatCommand.AddCommand("/unmute", command22);
            ChatCommand.AddCommand("/unshare", new UnshareCommand());
            WhiteListAddCommand command23 = new WhiteListAddCommand();

            command23.AdminFlags = "CanWhiteList";
            ChatCommand.AddCommand("/addwl", command23);
            ShutDownCommand command24 = new ShutDownCommand();

            command24.AdminFlags = "CanShutdown";
            ChatCommand.AddCommand("/shutdown", command24);
            InstaKOAllCommand command25 = new InstaKOAllCommand();

            command25.AdminFlags = "CanInstaKOAll";
            ChatCommand.AddCommand("/instakoall", command25);
        }
Exemplo n.º 12
0
        protected Task Handle(MuteCommand message)
        {
            var cmd = GetCommand("KEY_MUTE");

            return(MessageBroker.SendToService(cmd));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Handles commands for the Denon published to MQTT.
        /// </summary>
        /// <param name="e">Event args.</param>
        protected override async void Mqtt_MqttMsgPublishReceived(MqttApplicationMessageReceivedEventArgs e)
        {
            var message = e.ApplicationMessage.ConvertPayloadToString();

            _log.LogInformation("MQTT message received for topic " + e.ApplicationMessage.Topic + ": " + message);

            var commandType = e.ApplicationMessage.Topic.Replace(TopicRoot + "/controls/", string.Empty).Replace("/set", string.Empty);

            Command command = null;

            if (commandType == "power")
            {
                command = new PowerCommand {
                    Value = message
                }
            }
            ;

            if (commandType == "volume")
            {
                command = new VolumeCommand {
                    Value = message
                }
            }
            ;

            if (commandType == "mute")
            {
                command = new MuteCommand {
                    Value = message
                }
            }
            ;

            if (commandType == "input")
            {
                command = new InputCommand {
                    Value = message
                }
            }
            ;

            if (commandType == "surroundMode")
            {
                command = new SurroundModeCommand {
                    Value = message
                }
            }
            ;

            if (commandType == "tunerFrequency")
            {
                command = new TunerFrequencyCommand {
                    Value = message
                }
            }
            ;

            if (commandType == "tunerMode")
            {
                command = new TunerModeCommand {
                    Value = message
                }
            }
            ;

            if (commandType.StartsWith("zone"))
            {
                if (int.TryParse(commandType.Substring(4, 1), out int zoneId))
                {
                    if (commandType == $"zone{zoneId}Power")
                    {
                        command = new ZonePowerCommand {
                            Value = message, ZoneId = zoneId
                        }
                    }
                    ;

                    if (commandType == $"zone{zoneId}Volume")
                    {
                        command = new ZoneVolumeCommand {
                            Value = message, ZoneId = zoneId
                        }
                    }
                    ;

                    if (commandType == $"zone{zoneId}Mute")
                    {
                        command = new ZoneMuteCommand {
                            Value = message, ZoneId = zoneId
                        }
                    }
                    ;

                    if (commandType == $"zone{zoneId}Input")
                    {
                        command = new ZoneInputCommand {
                            Value = message, ZoneId = zoneId
                        }
                    }
                    ;
                }
            }

            if (command != null)
            {
                await _client.SendCommandAsync(command)
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 14
0
        public static void InitializeControllersForGameplay(Game1 game, KeyboardController keyboard, GamepadController gamepad)
        {
            keyboard.ClearDictionary();
            gamepad.ClearDictionary();
            //Background sound
            ICommand mutecommand = new MuteCommand(Stage.sound);

            keyboard.Add((int)Keys.M, mutecommand);
            //Add the Reset command to the r
            ICommand resetcommand = new ResetCommand();

            keyboard.Add((int)Keys.R, resetcommand);
            gamepad.Add((int)Buttons.Back, resetcommand);
            //Add the Exit Command to the controllers
            ICommand exitcommand = new ExitCommand(game);

            keyboard.Add((int)Keys.Q, exitcommand);
            gamepad.Add((int)Buttons.Start, exitcommand);
            //add the left command
            ICommand leftcommand = new LeftCommand(Stage.mario);

            keyboard.Add((int)Keys.A, leftcommand);
            keyboard.Add((int)Keys.Left, leftcommand);
            gamepad.Add((int)Buttons.DPadLeft, leftcommand);
            //add the right commmand
            ICommand rightcommand = new RightCommand(Stage.mario);

            keyboard.Add((int)Keys.D, rightcommand);
            keyboard.Add((int)Keys.Right, rightcommand);
            gamepad.Add((int)Buttons.DPadRight, rightcommand);
            //Add the srpint command
            ICommand sprintcommand = new SprintCommand(Stage.mario);

            keyboard.Add((int)Keys.LeftShift, sprintcommand);
            keyboard.Add((int)Keys.RightShift, sprintcommand);
            //add the down command
            ICommand downcommand = new DownCommand(Stage.mario);

            keyboard.Add((int)Keys.S, downcommand);
            keyboard.Add((int)Keys.Down, downcommand);
            gamepad.Add((int)Buttons.DPadDown, downcommand);
            //add the up command
            ICommand upcommand = new UpCommand(Stage.mario);

            keyboard.Add((int)Keys.W, upcommand);
            keyboard.Add((int)Keys.Up, upcommand);
            gamepad.Add((int)Buttons.DPadUp, upcommand);
            //add fireflower command
            ICommand firecommand = new FireMarioCommand(Stage.mario);

            keyboard.Add((int)Keys.I, firecommand);
            //add super command
            ICommand supercommand = new SuperCommand(Stage.mario);

            keyboard.Add((int)Keys.U, supercommand);
            //add normal mario command
            ICommand normalcommand = new NormalCommand(Stage.mario);

            keyboard.Add((int)Keys.Y, normalcommand);
            //add take damage command
            ICommand damagecommand = new DamageCommand(Stage.mario);

            keyboard.Add((int)Keys.O, damagecommand);
            //add star power command
            ICommand starcommand = new StarCommand(Stage.mario);

            keyboard.Add((int)Keys.L, starcommand);
            //add the fireball command with space
            ICommand fireballcommand = new MakeFireBall(Stage.mario);

            keyboard.Add((int)Keys.Space, fireballcommand);
            //add the Pause hud command with N
            ICommand pausehudcommand = new PauseCommand();

            keyboard.Add((int)Keys.P, pausehudcommand);
            ICommand interact = new InteractCommand();

            keyboard.Add((int)Keys.V, interact);
            gamepad.Add((int)Buttons.RightTrigger, interact);
            //add hold command E, no current mapping on gamepad
            ICommand holdcommand = new HoldingCommand(Stage.mario);

            keyboard.Add((int)Keys.E, holdcommand);


            /*
             * Add release commands. These are mainly for mario movement.
             */
            ICommand rightR = new ReleaseRightCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.D, rightR);
            keyboard.AddRelease((int)Keys.Right, rightR);


            ICommand leftR = new ReleaseLeftCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.A, leftR);
            keyboard.AddRelease((int)Keys.Left, leftR);

            ICommand downR = new ReleaseDownCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.S, downR);
            keyboard.AddRelease((int)Keys.Down, downR);


            ICommand upR = new ReleaseUpCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.W, upR);
            keyboard.AddRelease((int)Keys.Up, upR);

            ICommand sprintR = new ReleaseSprintCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.LeftShift, sprintR);
            keyboard.AddRelease((int)Keys.RightShift, sprintR);

            ICommand holdR = new ReleaseHoldingCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.E, holdR);
        }