Ejemplo n.º 1
0
 // Our Keyboard Handler. Ensure that the key that was pressed is something that we can handle.
 public bool ProcessSessionEvents(object sender, KeyCommandEventArgs args)
 {
     if (null != args)
     {
         // ensure that there are no control keys with the keystroke and we only process up,down, left, right keys
         if ((args.InputModifiers == Microsoft.MediaCenter.TVVM.InputModifiers.None) &&
             (args.State == Microsoft.MediaCenter.TVVM.KeyCommandState.Down) &&  // CHECK IF WE NEED THIS
             ((args.Key == Microsoft.MediaCenter.TVVM.KeyHandlerKey.Up) ||
              (args.Key == Microsoft.MediaCenter.TVVM.KeyHandlerKey.Down) ||
              (args.Key == Microsoft.MediaCenter.TVVM.KeyHandlerKey.Left) ||
              (args.Key == Microsoft.MediaCenter.TVVM.KeyHandlerKey.Right) ||
              (args.Key == Microsoft.MediaCenter.TVVM.KeyHandlerKey.Return)))
         {
             _userInterface.ProcessKeyboardEvent(args);
             // we know that these keys are handled, so return true
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        // Moving to a different cell results only in the audio stream switch.  Pressing Enter/Ok causes the tune to happen.
        public void ProcessKeyboardEvent(KeyCommandEventArgs args)
        {
            try
            {
                switch (args.Key)
                {
                // Move Left
                case Microsoft.MediaCenter.TVVM.KeyHandlerKey.Left:
                    if (_selectionX > 0)
                    {
                        _selectionX--;
                    }
                    break;

                // Move Right
                case Microsoft.MediaCenter.TVVM.KeyHandlerKey.Right:
                    if (_selectionX < (_description.Columns - 1))
                    {
                        _selectionX++;
                    }
                    break;

                // Move Up
                case Microsoft.MediaCenter.TVVM.KeyHandlerKey.Up:
                    if (_selectionY > 0)
                    {
                        _selectionY--;
                    }
                    break;

                // Move Down
                case Microsoft.MediaCenter.TVVM.KeyHandlerKey.Down:
                    if (_selectionY < (_description.Rows - 1))
                    {
                        _selectionY++;
                    }
                    break;

                // User hit OK/Enter. Tune to the channel and exit the Addin.
                case Microsoft.MediaCenter.TVVM.KeyHandlerKey.Return:
                    // get the channel box
                    ChannelBox channelBox = _description.Lookup(_selectionX, _selectionY);

                    if (null != channelBox)
                    {
                        // check if this has a valid tune string
                        if (channelBox.TuneString != string.Empty)
                        {
                            // Start tuning request
                            _tuning.Tune(channelBox.TuneString, true);
                            // Call exit.
                            _addin.Exit();
                            return;
                        }
                    }
                    break;
                }
                UpdateDisplayAndAudio();
            }
            catch (Exception)
            {
            }
        }