void socket_GeneralCommand(object sender, GeneralCommandEventArgs e)
 {
     if (e.KnownCommandType.HasValue)
     {
         switch (e.KnownCommandType.Value)
         {
             case GeneralCommandType.GoHome:
                 _nav.NavigateToHomePage();
                 break;
             case GeneralCommandType.GoToSettings:
                 _nav.NavigateToSettingsPage();
                 break;
             case GeneralCommandType.Mute:
                 _playbackManager.Mute();
                 break;
             case GeneralCommandType.Unmute:
                 _playbackManager.UnMute();
                 break;
             case GeneralCommandType.ToggleMute:
                 if (_playbackManager.IsMuted)
                 {
                     _playbackManager.UnMute();
                 }
                 else
                 {
                     _playbackManager.Mute();
                 }
                 break;
             case GeneralCommandType.VolumeDown:
                 _playbackManager.VolumeStepDown();
                 break;
             case GeneralCommandType.VolumeUp:
                 _playbackManager.VolumeStepUp();
                 break;
             default:
                 _logger.Warn("Unrecognized command: " + e.KnownCommandType.Value);
                 break;
         }
     }
 }
Пример #2
0
        void socket_GeneralCommand(object sender, GeneralCommandEventArgs e)
        {
            _logger.Debug("socket_GeneralCommand {0} {1}", e.KnownCommandType, e.Command.Arguments);

            if (e.KnownCommandType.HasValue)
            {
                switch (e.KnownCommandType.Value)
                {
                    case GeneralCommandType.MoveUp:
                        _userInputManager.SendKeyDownEventToFocusedElement(Key.Up);
                        break;

                    case GeneralCommandType.MoveDown:
                        _userInputManager.SendKeyDownEventToFocusedElement(Key.Down);
                        break;

                    case GeneralCommandType.MoveLeft:
                        _userInputManager.SendKeyDownEventToFocusedElement(Key.Left);
                        break;

                    case GeneralCommandType.MoveRight:
                        _userInputManager.SendKeyDownEventToFocusedElement(Key.Right);
                        break;

                    case GeneralCommandType.PageUp:
                        _userInputManager.SendKeyDownEventToFocusedElement(Key.PageUp);
                        break;

                    case GeneralCommandType.PreviousLetter:
                        _commandManager.ExecuteCommand(Command.Null, null); //todo
                        break;

                    case GeneralCommandType.NextLetter:
                        _commandManager.ExecuteCommand(Command.Null, null); //todo
                        break;

                    case GeneralCommandType.ToggleOsd:
                        _commandManager.ExecuteCommand(Command.ToggleOsd, null);
                        break;

                    case GeneralCommandType.ToggleContextMenu:
                        _commandManager.ExecuteCommand(Command.ToggleInfoPanel, null);        // todo generalise - make work not just for meida playing
                        break;

                    case GeneralCommandType.Select:
                        _userInputManager.SendKeyDownEventToFocusedElement(Key.Enter);
                        _userInputManager.SendKeyUpEventToFocusedElement(Key.Enter);
                        break;

                    case GeneralCommandType.Back:
                        _navigationService.NavigateBack();
                        break;

                    case GeneralCommandType.TakeScreenshot:
                        _commandManager.ExecuteCommand(Command.ScreenDump, null);
                        break;

                    case GeneralCommandType.SendKey:
                        ExecuteSendSendKeyCommand(sender, e);
                        break;

                    case GeneralCommandType.GoHome:
                        _commandManager.ExecuteCommand(Command.GotoHome, null);
                        break;

                    case GeneralCommandType.GoToSettings:
                        _commandManager.ExecuteCommand(Command.GotoSettings, null);
                        break;

                    case GeneralCommandType.VolumeDown:
                        _commandManager.ExecuteCommand(Command.VolumeDown, null);
                        break;

                    case GeneralCommandType.VolumeUp:
                        _commandManager.ExecuteCommand(Command.VolumeUp, null);
                        break;

                    case GeneralCommandType.Mute:
                        _commandManager.ExecuteCommand(Command.Mute, null);
                        break;

                    case GeneralCommandType.Unmute:
                        _commandManager.ExecuteCommand(Command.UnMute, null);
                        break;

                    case GeneralCommandType.ToggleMute:
                        _commandManager.ExecuteCommand(Command.ToggleMute, null);
                        break;

                    case GeneralCommandType.ToggleFullscreen:
                        _commandManager.ExecuteCommand(Command.ToggleFullScreen, null);
                        break;

                    case GeneralCommandType.DisplayContent:
                        ExecuteDisplayContent(e.Command.Arguments);
                        break;
                    default:
                        _logger.Warn("Unrecognized command: " + e.KnownCommandType.Value);
                        break;
                }
            }
        }
        private void GeneralCommand(object sender, GeneralCommandEventArgs args)
        {
            switch (args.Command.Name)
            {
                case "DisplayContent":
                    var newArgs = new BrowseRequestEventArgs {Request = new BrowseRequest {ItemType = args.Command.Arguments["ItemType"], ItemId = args.Command.Arguments["ItemId"], ItemName = args.Command.Arguments["ItemName"]}};
                    BrowseRequest(this, newArgs);
                    break;

                case "Back":
                    Back();
                    break;

                case "GoHome":
                    BackToRoot();
                    break;

                case "GoToSettings":
                    OpenConfiguration(true);
                    break;

                case "Mute":
                    WMCMute = true;
                    break;

                case "Unmute":
                    WMCMute = false;
                    break;

                case "ToggleMute":
                    WMCMute = !WMCMute;
                    break;

            }
        }
Пример #4
0
        void ExecuteSendSendKeyCommand(object sender, GeneralCommandEventArgs e)
        {
            _logger.Debug("ExecuteSendStringCommand {0}", e.Command.Arguments != null && e.Command.Arguments.Count > 0 ? e.Command.Arguments.First().Value : null);
            if (e.Command.Arguments == null || e.Command.Arguments.Count() != 1)
                throw new ArgumentException("ExecuteSendStringCommand: expecting a single string argurment for send Key");

            var input = e.Command.Arguments.First().Value;

            // now the key can be
            // 1. An integer value of the  System.Windows.Input.Key enum, 0 to 172
            // 2. The text representation of System.Windows.Input.Key ie. Key.None..Key.DeadCharProcessed
            // 3. A single Char value

            // try int first
            int intVal;
            if (int.TryParse(input, out intVal))
            {
                System.Windows.Input.Key key;

                if (!IsWindowsKeyEnum(intVal, out key))
                    throw new ArgumentException(String.Format("ExecuteSendStringCommand: integer argument {0} does not map to  System.Windows.Input.Key", intVal));

                _userInputManager.SendKeyDownEventToFocusedElement(key);
            }
            else if (input.StartsWith("Key."))  // check if the string maps to a enum element name i.e Key.A
            {
                System.Windows.Input.Key key;
                try
                {
                    key = (System.Windows.Input.Key)System.Enum.Parse(typeof(System.Windows.Input.Key), input);
                }
                catch (Exception)
                {
                    throw new ArgumentException(String.Format("ExecuteSendStringCommand: Argument '{0}' must be a Single Char or a Windows Key literial (i.e Key.A)  or the Integer value for Key literial", input));
                }

                _userInputManager.SendKeyDownEventToFocusedElement(key);
            }
            else if (input.Length == 1)
            {
                _userInputManager.SendTextInputToFocusedElement(input);
            }
            else
            {
                throw new ArgumentException(String.Format("ExecuteSendStringCommand: Argument '{0}' must be a Single Char or a Windows Key literial (i.e Key.A)  or the Integer value for Key literial", input));
            }
        }
 void _serverEvents_GeneralCommand(object sender, GeneralCommandEventArgs e)
 {
     _presentationManager.Window.Dispatcher.InvokeAsync(OnRemoteControlCommand, DispatcherPriority.Background);
 }