示例#1
0
 /*! \brief Raising an event invokes the event handler through a delegate.
  *
  * The \b OnMenuSelection method also allows derived classes to handle the
  * event without attaching a delegate. This is the preferred technique for
  * handling the event in a derived class.
  * \note  When overriding \b OnMenuSelection in a derived class, be sure to
  * call the base class's \b OnMenuSelection method so that registered delegates
  * receive the event.  */
 protected virtual void OnMenuSelection(Wimp.MenuSelectionEventArgs e)
 {
     if (MenuSelection != null)
     {
         MenuSelection(this, e);
     }
 }
示例#2
0
    // Because we're a derived object, override the method in the WimpTask base class
    // rather than subscribe to the events.
    protected override void OnMenuSelection(Wimp.MenuSelectionEventArgs e)
    {
        if (Wimp.Menu.IsCurrent(main_menu))
        {
            int[] selection = e.MenuSelectionWimpBlock.Selection;

            /* Each element of the array gives the index of the selected item of the menu at
             * that level. So selection[0] gives the item selected in the first/root menu.
             * The last selection is terminated by -1.  */
            switch (selection[(int)MainMenu.Root])
            {
            case (int)MainMenuItem.FileSubMenu:
                if (selection[1] == (int)FileMenuItem.Save)
                {
                    Reporter.WriteLine("Save menu item selected");
                }
                break;

            case (int)MainMenuItem.EditSubMenu:
                if (selection[1] == (int)EditMenuItem.RenameSubMenu &&
                    selection[2] == (int)RenameMenuItem.Rename)
                {
                    Reporter.WriteLine("Rename menu item selected - new text is {0}",
                                       rename_menuitem.GetText());
                }
                break;

            case (int)MainMenuItem.Quit:
                Reporter.WriteLine("Quit menu item selected");
                Quit = true;
                break;
            }
        }
    }