Example #1
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)
            {
            }
        }