/// <summary> /// Displays a menu dialog from list of items /// </summary> /// <returns>Selected item index, -1 if exited</returns> public static int ShowMenuDialog(string heading, List <GUIListItem> items, int selectedItemIndex) { if (GUIGraphicsContext.form.InvokeRequired) { ShowMenuDialogDelegate d = ShowMenuDialog; return((int)GUIGraphicsContext.form.Invoke(d, heading, items)); } GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_MENU); dlgMenu.Reset(); dlgMenu.SetHeading(heading); foreach (GUIListItem item in items) { dlgMenu.Add(item); } if (selectedItemIndex >= 0) { dlgMenu.SelectedLabel = selectedItemIndex; } dlgMenu.DoModal(GUIWindowManager.ActiveWindow); if (dlgMenu.SelectedLabel < 0) { return(-1); } return(dlgMenu.SelectedLabel); }
/// <summary> /// Displays a menu dialog from list of items /// </summary> /// <returns>Selected item index, -1 if exited</returns> public static int ShowMenuDialog(string heading, List <GUIListItem> items, int selectedItemIndex) { if (GUIGraphicsContext.form.InvokeRequired) { ShowMenuDialogDelegate d = ShowMenuDialog; return((int)GUIGraphicsContext.form.Invoke(d, heading, items)); } //GUIDialogSelect2 dlgSelect = // (GUIDialogSelect2)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_SELECT2); GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_MENU); //if (dlgMenu == null) return -1; dlgMenu.Reset(); dlgMenu.SetHeading(heading); //dlgSelect.EnableButton(true); //dlgSelect.SetButtonLabel(2087); // backwards foreach (GUIListItem item in items) { dlgMenu.Add(item); } if (selectedItemIndex >= 0) { dlgMenu.SelectedLabel = selectedItemIndex; } dlgMenu.DoModal(GUIWindowManager.ActiveWindow); if (dlgMenu.SelectedLabel < 0) { return(-1); } return(dlgMenu.SelectedLabel); }