Example #1
0
        /// <summary>
        /// Handles all CiMenu actions from callback
        /// </summary>
        /// <param name="Menu">complete CI menu object</param>
        public void CiMenuCallback(CiMenu Menu)
        {
            ciMenuState = Menu.State;

            switch (ciMenuState)
            {
            // choices available, so show them
            case TvLibrary.Interfaces.CiMenuState.Ready:
                //ciMenuState = CiMenuState.Opened;
                Title.Text      = Menu.Title;
                Subtitle.Text   = Menu.Subtitle;
                BottomText.Text = Menu.BottomText;
                ciMenuChoices   = Menu.NumChoices;

                Choices.Items.Clear();

                // no choices then we are ready yet
                if (ciMenuChoices == 0)
                {
                    ciMenuState = CiMenuState.NoChoices;
                    SetButtonState();
                }
                else
                {
                    foreach (CiMenuEntry entry in Menu.MenuEntries)
                    {
                        Choices.Items.Add(entry);
                    }
                }
                break;

            // errors and menu options with no choices
            case TvLibrary.Interfaces.CiMenuState.Error:
            case TvLibrary.Interfaces.CiMenuState.NoChoices:
                Title.Text      = Menu.Title;
                Subtitle.Text   = Menu.Subtitle;
                BottomText.Text = Menu.BottomText;
                ciMenuChoices   = Menu.NumChoices;
                break;

            // requests require users input so open keyboard
            case TvLibrary.Interfaces.CiMenuState.Request:
                ciMenuState = CiMenuState.Request;
                SetButtonState();
                CiRequest.Text     = String.Format("{0} ({1} Zeichen)", Menu.RequestText, Menu.AnswerLength);
                CiAnswer.MaxLength = (int)Menu.AnswerLength;
                CiAnswer.Text      = "";
                CiAnswer.Focus();
                break;
            }
            SetButtonState();
        }
        /// <summary>
        /// eventhandler to show CI Menu dialog
        /// </summary>
        /// <param name="Menu"></param>
        protected override void CiMenuCallback(CiMenu Menu)
        {
            try
            {
                Log.Debug("Callback from tvserver {0}", Menu.Title);

                // pass menu to calling dialog
                if (refDlg != null)
                {
                    refDlg.CiMenuCallback(Menu);
                }
            }
            catch
            {
                Menu = new CiMenu("Remoting Exception", "Communication with server failed", null,
                                  TvLibrary.Interfaces.CiMenuState.Error);
                // pass menu to calling dialog
                if (refDlg != null)
                {
                    refDlg.CiMenuCallback(Menu);
                }
            }
        }