示例#1
0
        protected override void OnShowContextMenu()
        {
            GUIListItem item      = lstDetails.SelectedListItem;
            BaseScore   itemScore = item.TVTag as BaseScore;

            int menuIndice = 1;

            #region Create Menu
            GUIDialogMenu menu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            menu.Reset();
            menu.SetHeading(m_center.Setup.Name);

            // configure
            menu.Add(LocalizationManager.GetString(Labels.Configuration));
            int menuConfigure = menuIndice++;

            // enable/disable live
            if (m_liveEnabled)
            {
                menu.Add(LocalizationManager.GetString(Labels.StopLive));
            }
            else
            {
                menu.Add(LocalizationManager.GetString(Labels.StartLive));
            }
            int menuLive = menuIndice++;

            // clear all live
            int menuClearLive = 0;
            if (!m_liveEnabled)
            {
                menu.Add(LocalizationManager.GetString(Labels.ClearLive));
                menuClearLive = menuIndice++;
            }

            int menuDelete  = 0;
            int menuSetHome = 0;
            int menuSetLive = 0;
            if (item.Label != "..")
            {
                // disable
                menu.Add(LocalizationManager.GetString(Labels.DisableItem, item.Label));
                menuDelete = menuIndice++;

                // set home
                if (!itemScore.IsContainer())
                {
                    menu.Add(LocalizationManager.GetString(Labels.SetAsHome));
                    menuSetHome = menuIndice++;
                }

                if (!m_liveEnabled && itemScore.CanLive())
                {
                    // set live
                    menu.Add(LocalizationManager.GetString(item.PinImage == m_livePinImage ? Labels.DisableLive : Labels.ActivateLive, item.Label));
                    menuSetLive = menuIndice++;
                }
            }

            #endregion

            // show the menu
            menu.DoModal(GetID);

            #region process user action
            if (menu.SelectedId == menuLive)
            {
                SetLiveSettings();
            }
            else if (menu.SelectedId == menuClearLive)
            {
                ClearLiveSettings();
            }
            else if (menu.SelectedId == menuConfigure)
            {
                ShowConfigurationMenu();
            }
            else if (menu.SelectedId == menuDelete)
            {
                GUIDialogYesNo dlg     = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                string         disable = LocalizationManager.GetString(Labels.DisableItem, item.Label);
                dlg.SetHeading(m_center.Setup.Name);
                dlg.SetLine(1, LocalizationManager.GetString(Labels.DisableItem, item.Label) + " ?");
                dlg.DoModal(GetID);

                if (dlg.IsConfirmed)
                {
                    m_center.DisableScore(itemScore);
                    SaveSettings();
                }
            }
            else if (menu.SelectedId == menuSetHome)
            {
                m_center.SetHomeScore(itemScore);
                SaveSettings();
            }
            else if (menu.SelectedId == menuSetLive)
            {
                bool on = item.PinImage == m_livePinImage;
                m_center.SetLiveScore(itemScore, !on);
                string pin = "";
                if (!on)
                {
                    pin = m_livePinImage;
                }
                else if (itemScore.CanLive())
                {
                    pin = m_livePinImageDisabled;
                }

                item.PinImage = pin;
                SaveSettings();
                SetLiveStatus();
            }
            #endregion

            base.OnShowContextMenu();
        }