Dialogs: action when choosing option (1 Viewer)

Dragy

Portal Pro
April 27, 2009
778
333
31
Home Country
Netherlands Netherlands
I have 2 Dialogs:
Code:
       private void OnDeviceClick()
        {
            GUIDialogSelect2 DeviceMenu = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_SELECT2);

            DeviceMenu.SetHeading(GuiDeviceList.SelectedListItem.Label);
            DeviceMenu.Add("on");
            DeviceMenu.Add("off");
            DeviceMenu.Add("dim 50%");
            
            DeviceMenu.DoModal(GUIWindowManager.ActiveWindow);
        }

        private void OnMacroClick()
        {
            GUIDialogYesNo MacroMenu = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            MacroMenu.SetHeading(GuiDeviceList.SelectedListItem.Label);
            MacroMenu.SetLine(1, "Weet u zeker dat u de macro met de naam");
            MacroMenu.SetLine(2, "\""+GuiDeviceList.SelectedListItem.Label+"\"");
            MacroMenu.SetLine(3, "wilt uitvoeren?");
            MacroMenu.SetDefaultToYes(true);

            MacroMenu.DoModal(GUIWindowManager.ActiveWindow);
            //ExecuteAction(GuiDeviceList.SelectedListItem.ItemId)
        }

I have no clue about how to assign an function to the one of the options of the GUIDialogSelect2 menu and the same for the GUIDialogYesNo when pressing yes.

My first plugin is almost working, I only need to assign some functions to the dialogs' options. How to do that?
What does "DoModal" do?

I'm am a noob at c# programming, but I learn fast. :)
 

SilentException

Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    DoModal shows the dialog on screen and blocks execution until user closes dialog. After a call to DoModal you can see if user pressed Yes or No in YesNo dialog by examining MacroMenu.Confirmed property. I'm quite sure there is a similar property or function for GUIDialogSelect2.
     

    Dragy

    Portal Pro
    April 27, 2009
    778
    333
    31
    Home Country
    Netherlands Netherlands
    Thanks! Now I understand :)

    btw, its not dlg.Confirmed, but dlg.IsConfirmed
     

    Users who are viewing this thread

    Top Bottom