示例#1
0
        /// <summary>
        /// Displays a yes/no dialog with custom labels for the buttons.
        /// This method may become obsolete in the future if media portal adds more dialogs.
        /// </summary>
        /// <returns>True if yes was clicked, False if no was clicked</returns>
        public static bool ShowCustomYesNoDialog(string heading, string lines, string yesLabel, string noLabel, bool defaultYes)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                ShowCustomYesNoDialogDelegate d = ShowCustomYesNoDialog;
                return((bool)GUIGraphicsContext.form.Invoke(d, heading, lines, yesLabel, noLabel, defaultYes));
            }

            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            try
            {
                dlgYesNo.Reset();
                dlgYesNo.SetHeading(heading);
                string[] linesArray = lines.Split(new string[] { "\\n", "\n" }, StringSplitOptions.None);
                if (linesArray.Length > 0)
                {
                    dlgYesNo.SetLine(1, linesArray[0]);
                }
                if (linesArray.Length > 1)
                {
                    dlgYesNo.SetLine(2, linesArray[1]);
                }
                if (linesArray.Length > 2)
                {
                    dlgYesNo.SetLine(3, linesArray[2]);
                }
                if (linesArray.Length > 3)
                {
                    dlgYesNo.SetLine(4, linesArray[3]);
                }
                dlgYesNo.SetDefaultToYes(defaultYes);

                foreach (GUIControl item in dlgYesNo.Children)
                {
                    if (item is GUIButtonControl)
                    {
                        GUIButtonControl btn = (GUIButtonControl)item;
                        if (btn.GetID == 11 && !string.IsNullOrEmpty(yesLabel)) // Yes button
                        {
                            btn.Label = yesLabel;
                        }
                        else if (btn.GetID == 10 && !string.IsNullOrEmpty(noLabel)) // No button
                        {
                            btn.Label = noLabel;
                        }
                    }
                }
                dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                return(dlgYesNo.IsConfirmed);
            }
            finally
            {
                // set the standard yes/no dialog back to it's original state (yes/no buttons)
                if (dlgYesNo != null)
                {
                    dlgYesNo.ClearAll();
                }
            }
        }
示例#2
0
        public void Load(GUIFacadeControl facade, ImageSwapper backdrop, DBItem startupItem, bool launch, GUILabelControl showVideoPreviewControl, GUIListControl goodmergeList, GUIButtonControl detailsPlayButton)
        {
            this.facade                  = facade;
            this.goodmergeList           = goodmergeList;
            this.backdrop                = backdrop;
            this.showVideoPreviewControl = showVideoPreviewControl;
            this.detailsPlayButton       = detailsPlayButton;

            clearGUIProperties();
            currentLayout = -1;

            int prevWindow = GUIWindowManager.GetPreviousActiveWindow();

            if (GUIWindowManager.ActiveWindow == prevWindow || prevWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO)
            {
                launchStartupItem = false;
                Refresh(true); //Catch when MP is refreshing plugin after resizing/restoring and maintain current view
            }
            else
            {
                resetStartupItem(startupItem);
                this.launchStartupItem = launch;
                SortProperty           = ListItemProperty.DEFAULT; //set skin property
                GUIPropertyManager.SetProperty("#Emulators2.sortenabled", "no");
                currentView = ViewState.Items;
                setFacadeVisibility(true);
                loadStartupItems(0);
            }
            //resume import if previously paused
            resumeImporter();
        }
示例#3
0
 public void AddContext <T, TS>(GUIButtonControl button, Func <T, TS, ContextMenuAction> function)
 {
     if (button != null)
     {
         Add(new ContextButtonHandler <T, TS>(button, function));
     }
 }
示例#4
0
 public void Add <T, TS>(GUIButtonControl button, Action <T, TS> function)
 {
     if (button != null)
     {
         Add(new VoidButtonHandler <T, TS>(button, function));
     }
 }
示例#5
0
 public void Add(GUIButtonControl button, Action function)
 {
     if (button != null)
     {
         Add(new VoidButtonHandler(button, function));
     }
 }
示例#6
0
 public void AddFunc <T, TS>(GUIButtonControl button, Func <T, TS, bool> function)
 {
     if (button != null)
     {
         Add(new ButtonHandler <T, TS>(button, function));
     }
 }
示例#7
0
 public MainPresenter(GUIFacadeControl facade, GUIImage[] stars, GUIImage bg_description, GUITextScrollUpControl text_description, GUIButtonControl button_view, GUILabelControl gamelabel_year, GUILabelControl gamelabel_genre, GUILabelControl gamelabel_company, GUILabelControl gamelabel_latestplay, GUILabelControl gamelabel_playcount)
 {
     this.facade               = facade;
     this.stars                = stars;
     this.bg_description       = bg_description;
     this.text_description     = text_description;
     this.button_view          = button_view;
     this.gamelabel_year       = gamelabel_year;
     this.gamelabel_genre      = gamelabel_genre;
     this.gamelabel_company    = gamelabel_company;
     this.gamelabel_latestplay = gamelabel_latestplay;
     this.gamelabel_playcount  = gamelabel_playcount;
 }
示例#8
0
        /// <summary>
        /// Displays a yes/no dialog with custom labels for the buttons
        /// This method may become obsolete in the future if media portal adds more dialogs
        /// </summary>
        /// <returns>True if yes was clicked, False if no was clicked</returns>
        /// This has been taken (stolen really) from the wonderful MovingPictures Plugin -Anthrax.
        public bool ShowCustomYesNo(int parentWindowID, string heading, string lines, string yesLabel, string noLabel, bool defaultYes)
        {
            GUIDialogYesNo dialog = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            try {
                dialog.Reset();
                dialog.SetHeading(heading);
                string[] linesArray = lines.Split(new string[] { "\\n" }, StringSplitOptions.None);
                if (linesArray.Length > 0)
                {
                    dialog.SetLine(1, linesArray[0]);
                }
                if (linesArray.Length > 1)
                {
                    dialog.SetLine(2, linesArray[1]);
                }
                if (linesArray.Length > 2)
                {
                    dialog.SetLine(3, linesArray[2]);
                }
                if (linesArray.Length > 3)
                {
                    dialog.SetLine(4, linesArray[3]);
                }
                dialog.SetDefaultToYes(defaultYes);

                foreach (var item in dialog.Children)
                {
                    if (item is GUIButtonControl)
                    {
                        GUIButtonControl btn = (GUIButtonControl)item;
                        if (btn.GetID == 11 && !String.IsNullOrEmpty(yesLabel)) // Yes button
                        {
                            btn.Label = yesLabel;
                        }
                        else if (btn.GetID == 10 && !String.IsNullOrEmpty(noLabel)) // No button
                        {
                            btn.Label = noLabel;
                        }
                    }
                }
                dialog.DoModal(parentWindowID);
                return(dialog.IsConfirmed);
            } finally {
                // set the standard yes/no dialog back to it's original state (yes/no buttons)
                if (dialog != null)
                {
                    dialog.ClearAll();
                }
            }
        }
示例#9
0
        /// <summary>
        /// Displays a notification dialog.
        /// </summary>
        public static void ShowNotifyDialog(string heading, string text, string image, string buttonText, int timeout)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                ShowNotifyDialogDelegate d = ShowNotifyDialog;
                GUIGraphicsContext.form.Invoke(d, heading, text, image, buttonText, timeout);
                return;
            }

            GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);

            if (pDlgNotify == null)
            {
                return;
            }

            try
            {
                pDlgNotify.Reset();
                pDlgNotify.SetHeading(heading);
                pDlgNotify.SetImage(image);
                pDlgNotify.SetText(text);
                if (timeout >= 0)
                {
                    pDlgNotify.TimeOut = timeout;
                }

                foreach (GUIControl item in pDlgNotify.Children)
                {
                    if (item is GUIButtonControl)
                    {
                        GUIButtonControl btn = (GUIButtonControl)item;
                        if (btn.GetID == 4 && !string.IsNullOrEmpty(buttonText) && !string.IsNullOrEmpty(btn.Label))
                        {
                            // Only if ID is 4 and we have our custom text and if button already has label (in case the skin "hides" the button by emptying the label)
                            btn.Label = buttonText;
                        }
                    }
                }

                pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
            }
            finally
            {
                if (pDlgNotify != null)
                {
                    pDlgNotify.ClearAll();
                }
            }
        }
示例#10
0
 public ContextButtonHandler(GUIButtonControl button, Func <ContextMenuAction> function)
 {
     Button   = button;
     Function = function;
 }
示例#11
0
 public ButtonHandler(GUIButtonControl button, Func <bool> function)
 {
     Button   = button;
     Function = function;
 }
示例#12
0
 public VoidButtonHandler(GUIButtonControl button, Action function)
 {
     Button   = button;
     Function = function;
 }