Check for dialog window (1 Viewer)

horned_reaper

Test Group
  • Team MediaPortal
  • January 7, 2011
    1,233
    461
    Munich
    Home Country
    Germany Germany
    Hello all,

    does someone know how to find out if a dialog window is currently opened in MediaPortal e. g. the MovingPictures dialog asking if the movie shall be resumed on the last stopped position?

    Thank you for your help in advance!


    Best regards
    Horned_Reaper
     

    horned_reaper

    Test Group
  • Team MediaPortal
  • January 7, 2011
    1,233
    461
    Munich
    Home Country
    Germany Germany
    AW: Re: Check for dialog window

    GUIWindowManager.IsRouted

    Thank you for your reply.
    Just tried it with the following code:
    Code:
            private static void closeRoutedWindow()
            {
                if (GUIWindowManager.IsRouted)
                {
                    GUIWindow win = GUIWindowManager.GetWindow(GUIWindowManager.RoutedWindow);
                    
                    if (win != null)
                    {
                        if (win is GUIDialogFile) ((GUIDialogFile)win).Close();
                        else if (win is VirtualKeyboard) ((VirtualKeyboard)win).PageDestroy();
                        else ((GUIDialogWindow)win).PageDestroy();
                    }
                }
            }

    It seems working fine.
    My problem is that the dialog windows of MP-TV Series and Moving Pictures (see attached screenshot) click the default button on closing. The same is on pressing the ESC or Back keys.
    Is it possible to just destroy the dialog window without clicking the default button?
     

    Attachments

    • 09-02-08.png
      09-02-08.png
      713 KB

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    Well, the inner-workings depend on dialog. Yes/no dialog does not have "cancelled" status and because of this, yes/no always has to be returned.

    Also, GUIDialogWindow.cs has the similar code to yours and does this automatically. You don't have to do such things in your own code.
     

    horned_reaper

    Test Group
  • Team MediaPortal
  • January 7, 2011
    1,233
    461
    Munich
    Home Country
    Germany Germany
    AW: Re: Check for dialog window

    Well, the inner-workings depend on dialog. Yes/no dialog does not have "cancelled" status and because of this, yes/no always has to be returned.

    Also, GUIDialogWindow.cs has the similar code to yours and does this automatically. You don't have to do such things in your own code.

    Thanks for your quick reply!

    The following code line sounds like it does a window destroy:
    Code:
    ((GUIDialogWindow)win).PageDestroy();

    Does it return yes/no nevertheless?
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    In reality it doesn't return anything but it has internal boolean variable set to true (yes) or false (no). DoModal call effectively "blocks" the calling thread (in your case Moving Pictures) until dialog is destroyed (user clicks yes/no or in your case you destroy it). After destruction Moving Pictures continues with checking of dialog status. Dialog IsConfirmed property returns the bool status. There is no cancelled status and it just uses what it's currently there.
     

    horned_reaper

    Test Group
  • Team MediaPortal
  • January 7, 2011
    1,233
    461
    Munich
    Home Country
    Germany Germany
    AW: Re: Check for dialog window

    In reality it doesn't return anything but it has internal boolean variable set to true (yes) or false (no). DoModal call effectively "blocks" the calling thread (in your case Moving Pictures) until dialog is destroyed (user clicks yes/no or in your case you destroy it). After destruction Moving Pictures continues with checking of dialog status. Dialog IsConfirmed property returns the bool status. There is no cancelled status and it just uses what it's currently there.

    I see. Thank you for your good explaination!

    I think in this case I only can do a workaround and add queries if there currently is a dialog window of MP-TV Series or Moving Pictures opened and don't show the notify of my plugin in this case. Not a perfect solution but better than a movie is played accidentally.

    The following code would return the name of the plugin showing the dialog window (e. g. MP-TV Series or Moving Pictures), right?
    Code:
    string moduleName = ((GUIDialogFile)win).GetModuleName();

    Do you know more methods to savely detect a specific dialog type? Querying the window text is not save because of internationalization.
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    There is:

    GUIWindowManager.ActiveWindow - which would return window ID of current window (in your case MovingPictures = 96742)
    GUIWindowManager.ActiveWindowEx - which would return window ID of routed window as well (in your case dialog yes/no = 100), if there is no dialog open it would return normal window ID, 96742)

    You should always use IDs to distinguish different windows.
     

    horned_reaper

    Test Group
  • Team MediaPortal
  • January 7, 2011
    1,233
    461
    Munich
    Home Country
    Germany Germany
    AW: Re: Check for dialog window

    There is:

    GUIWindowManager.ActiveWindow - which would return window ID of current window (in your case MovingPictures = 96742)
    GUIWindowManager.ActiveWindowEx - which would return window ID of routed window as well (in your case dialog yes/no = 100), if there is no dialog open it would return normal window ID, 96742)

    You should always use IDs to distinguish different windows.

    Ah, OK. Does every plugin have a fixed unique ID? Who takes care about ID assignment?
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    Noone takes care about ID assignment. IDs up to 1000 are reserved for MediaPortal internal stuff. Plugin authors just choose random ID larger than that. But you cannot have two plugins using same window ID. So far, there have been not many conflicts (I know of two).
     

    Users who are viewing this thread

    Top Bottom