Exemple #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();
                }
            }
        }
        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();
        }
 public void AddContext <T, TS>(GUIButtonControl button, Func <T, TS, ContextMenuAction> function)
 {
     if (button != null)
     {
         Add(new ContextButtonHandler <T, TS>(button, function));
     }
 }
 public void Add <T, TS>(GUIButtonControl button, Action <T, TS> function)
 {
     if (button != null)
     {
         Add(new VoidButtonHandler <T, TS>(button, function));
     }
 }
 public void Add(GUIButtonControl button, Action function)
 {
     if (button != null)
     {
         Add(new VoidButtonHandler(button, function));
     }
 }
 public void AddFunc <T, TS>(GUIButtonControl button, Func <T, TS, bool> function)
 {
     if (button != null)
     {
         Add(new ButtonHandler <T, TS>(button, function));
     }
 }
 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;
 }
Exemple #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();
                }
            }
        }
Exemple #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();
                }
            }
        }
 public ContextButtonHandler(GUIButtonControl button, Func <ContextMenuAction> function)
 {
     Button   = button;
     Function = function;
 }
 public ButtonHandler(GUIButtonControl button, Func <bool> function)
 {
     Button   = button;
     Function = function;
 }
 public VoidButtonHandler(GUIButtonControl button, Action function)
 {
     Button   = button;
     Function = function;
 }