Help needed: Writing own GUIDialog for Plugin (1 Viewer)


Portal Member
August 14, 2007
Home Country
Germany Germany

I'm playing around with my first window plugin and now I got some problems with the GUIDialogs.
To be more precise, I try to write my own one.

I created a new class and inherited MediaPortal.Dialogs.GUIDialogWindow (the whole class is nearly a copy of GUIDialogYesNo). Then, I created my own skinfile (also, nearly a copy of dialogYesNo.xml).

to load and show the dialog, i tried it with the following code
GUIDialogMyOwnOne dlg = new GUIDialogMyOwnOne();
But it failed (of course :( )
It seems, that I have to use the GUIWindowManager. But I have no idea how to do that.
If I want to load and show one of the existing ones, the GUIWindowManager gives me an Instance of a specified dialog. I just have to pass him some kind of WindowID.
But my own Dialog has no such WindowID.
How could I add my own WindowID to the existing ones?
Is there a simpler way to display a completely customised dialog (I would like to use any control I could use for skins)?

Any ideas?



Portal Pro
August 18, 2008
Home Country
United States of America United States of America
junkixl, I've been down this road before, and had all the same problems you are describing. I was trying to create a dialog with the same functionality as GUIDialogYesNo, only with different button captions (retry/cancel in my case). I was unsucesful in creating my own dialog without requiring a custom skin, etc. What I ended up doing was modifying the GUIDialogYesNo at runtime. I do not know what you are trying to accomplish, but if you just want to change the button captions, you can do what I did:

        /// <summary>
        /// Displays a yes/no dialog with custom labels for the buttons
        /// </summary>
        /// <returns>True if yes was clicked, False if no was clicked</returns>
        private bool ShowCustomYesNo(string heading, string lines, string yesLabel, string noLabel, bool defaultYes) {
            GUIDialogYesNo dialog = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
            try {
                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]);

                foreach (System.Windows.UIElement 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;

                return dialog.IsConfirmed;
            finally {
                // set the standard yes/no dialog back to it's original state (yes/no buttons)
                if (dialog != null)

Hope this helps. If you end up doing something different, please post back here, because I would be interested in seeing it.


Retired Team Member
  • Premium Supporter
  • October 27, 2008
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    you have to make your class GUIMyDialog: GUIDialogWindow, do and override stuff there..

    then calling it like this

    mydlg = (GUIMyDialog)GUIWindowManager.GetWindow(MyDialogID);


    Portal Member
    August 14, 2007
    Home Country
    Germany Germany
    Never try something new with german umlaut in a skin file :oops:
    In the skin file of my own dialog I changed the button caption of the no button to "Löschen". Replacing the ö character and now it runs like SilentExcept said.

    an alternative method to change caption would be to create your own skinfile (copy of dialog skin file you want to change should do) and change caption there. Copy the refering GUIDialogClass and rename it. Now change the IDs in your skin file and in your new GUI Class and call it like SilentExcept said. Do not use strings with special chars in skin files! :rolleyes:

    lets see what happens when I try to customize that dialog...


    Users who are viewing this thread

    Top Bottom