Create new Custom Dialog (1 Viewer)

mrinaljaiswal

New Member
August 6, 2011
2
0
Home Country
India India
Hi,

I want to create a new Dialog in Media Portal,

I tried inheriting an existing dialog class and put my customized code there. But it was not working :( . On Click event the GUIControl was null.

Can anybody suggest how to create our own custom dialog or how to edit any existing dialog to add new features and controls etc.

Thanks in Advance,
Mrinal Jaiswal
 

SilentException

Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    Any custom dialog can be created using template from any dialog in Dialogs project file (other than GUIDialogWindow - that's base). Every dialog inherits from GUIDialogWindow class and overrides some common methods (Init, OnPageLoad, OnPageDestroy, ...), implements it's own GUI controls and possible utility methods. Take GUIDialogNotify for example and modify it to fit your needs.
     

    mrinaljaiswal

    New Member
    August 6, 2011
    2
    0
    Home Country
    India India
    Hi,

    Thanks for reply.

    I did tried that, but what happens is that, it will work properly for first 2 times after that the dialog won't work or after the dialog is shown it will freez the mediaportal all toghter :(.

    Here is the code of my dialog
    ____________________________________________________________________________
    using MediaPortal.Dialogs;
    using MediaPortal.GUI.Library;

    namespace Plugin1
    {
    /// <summary>
    ///
    /// </summary>
    public class MyDlg : GUIDialogWindow
    {
    public enum ResultCode
    {
    Close,
    Next,
    Previous
    } ;

    [SkinControl(2)]
    protected GUILabelControl lblHeading = null;
    [SkinControl(4)]
    protected GUILabelControl lblName = null;
    [SkinControl(10)]
    protected GUIButtonControl btnPlus = null;
    [SkinControl(11)]
    protected GUIButtonControl btnMin = null;
    [SkinControl(12)]
    protected GUIButtonControl btnOk = null;
    [SkinControl(13)]
    protected GUIButtonControl btnNextItem = null;
    [SkinControl(14)]
    protected GUIButtonControl btnPlay = null;
    [SkinControl(15)]
    protected GUIButtonControl btnPreviousItem = null;
    [SkinControl(100)]
    protected GUIImage imgStar1 = null;
    [SkinControl(101)]
    protected GUIImage imgStar2 = null;
    [SkinControl(102)]
    protected GUIImage imgStar3 = null;
    [SkinControl(103)]
    protected GUIImage imgStar4 = null;
    [SkinControl(104)]
    protected GUIImage imgStar5 = null;

    private int rating = 1;
    private string fileName;
    private ResultCode resultCode;

    public MyDlg()
    {
    GetID = 6789;
    }

    public override bool Init()
    {
    return Load(GUIGraphicsContext.Skin + @"\dialogRating.xml");
    }

    protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
    {
    base.OnClicked(controlId, control, actionType);
    if (control == btnOk)
    {
    PageDestroy();
    resultCode = ResultCode.Close;
    return;
    }
    if (control == btnNextItem)
    {
    PageDestroy();
    resultCode = ResultCode.Next;
    return;
    }
    if (control == btnPreviousItem)
    {
    PageDestroy();
    resultCode = ResultCode.Previous;
    return;
    }
    if (control == btnMin)
    {
    if (rating >= 1)
    {
    rating--;
    }
    UpdateRating();
    return;
    }
    if (control == btnPlus)
    {
    if (rating < 5)
    {
    rating++;
    }
    UpdateRating();
    return;
    }
    }

    public override bool OnMessage(GUIMessage message)
    {
    switch (message.Message)
    {
    case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
    {
    resultCode = ResultCode.Close;
    base.OnMessage(message);
    UpdateRating();
    }
    return true;
    }

    return base.OnMessage(message);
    }

    public void SetHeading(string strLine)
    {
    //LoadSkin();
    AllocResources();
    InitControls();

    lblHeading.Label = strLine;
    }

    public void SetHeading(int iString)
    {
    if (iString == 0)
    {
    SetHeading(string.Empty);
    }
    else
    {
    SetHeading(GUILocalizeStrings.Get(iString));
    }
    }

    public void SetTitle(string title)
    {
    //LoadSkin();
    AllocResources();
    InitControls();
    lblName.Label = title;
    }

    }
    }

    Here is the code from where i am calling this dialog
    __________________________________________________________________________

    MyDlg obj = (MyDlg)GUIWindowManager.GetWindow(6789);
    if (obj == null) return;
    obj.Reset();
    obj.SetHeading("Test");
    obj.DoModal(GetID);


    Do you have any sample from where i get some help


    Thanks,
    Mrinal Jaiswal
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    As I said, samples are any current existing dialogs :)

    Code-wise I couldn't spot any issues. Maybe the problem is skin related? Share skin file too, I'll try to test your dialog when I find some time (probably not very soon but in a week or two).
     

    Users who are viewing this thread

    Top Bottom