Example #1
0
        public void DisplayActionsTest()
        {
            MenuActionManager target = Init();
            var action = new MenuAction(fooHandle, target, target.File, "MenuExit", 1);

            action = new MenuAction(fooHandle, target, target.File, "MenuLogout", 2);
            var actionHC = new MenuAction(target, target.Reports, "", 1);

            actionHC.Caption = "human reports";
            var actionVC = new MenuAction(target, target.Reports, "", 2);

            actionHC.Caption = "vet reports";
            action           = new MenuAction(fooHandle, target, target.Reports, "MenuLogout", 3);
            action           = new MenuAction(fooHandle, target, actionHC, "MenuExit", 1);
            action           = new MenuAction(fooHandle, target, actionVC, "MenuExit", 1);
            target.DisplayActions();

            Assert.AreEqual(2, m_MainForm.BarManager.MainMenu.ItemLinks.Count);
            Assert.AreEqual(2, ((BarSubItem)m_MainForm.BarManager.MainMenu.ItemLinks[0].Item).ItemLinks.Count);
            Assert.AreEqual(3, ((BarSubItem)m_MainForm.BarManager.MainMenu.ItemLinks[1].Item).ItemLinks.Count);
            Assert.AreEqual(1,
                            ((BarSubItem)
                             ((BarSubItem)m_MainForm.BarManager.MainMenu.ItemLinks[1].Item).ItemLinks[0].Item).
                            ItemLinks.Count);
            Assert.AreEqual(1,
                            ((BarSubItem)
                             ((BarSubItem)m_MainForm.BarManager.MainMenu.ItemLinks[1].Item).ItemLinks[1].Item).
                            ItemLinks.Count);
            Assert.AreEqual(EidssMenu.Get("MenuLogout", ""),
                            (((BarSubItem)m_MainForm.BarManager.MainMenu.ItemLinks[1].Item).ItemLinks[2].Item).Caption);
        }
        /// <summary>
        ///  The provider's constructor sets up the MenuAction objects and the MenuGroup which holds them.
        /// </summary>
        public DataGridMenuProvider()
        {
            // Set up the MenuGroup which holds the MenuAction items.
            MenuGroup dataOperationsGroup = new MenuGroup("DataGroup", "DataGrid");

            isDatasourceSetMenuAction = new MenuAction("You need to set ItemsSource to enable some column operations.");

            generateStockColumnsMenuAction = new MenuAction("Generate Columns");
            generateStockColumnsMenuAction.Execute += new EventHandler<MenuActionEventArgs>(GenerateStockColumnsMenuAction_Execute);

            addColumnsMenuAction = new MenuAction("Add/Edit Columns...");
            addColumnsMenuAction.Execute += new EventHandler<MenuActionEventArgs>(AddColumnsMenuAction_Execute);

            removeColumnsMenuAction = new MenuAction("Remove Columns");
            removeColumnsMenuAction.Execute += new EventHandler<MenuActionEventArgs>(RemoveColumnsMenuAction_Execute);

            dataOperationsGroup.HasDropDown = true;
            dataOperationsGroup.Items.Add(isDatasourceSetMenuAction);
            dataOperationsGroup.Items.Add(generateStockColumnsMenuAction);
            dataOperationsGroup.Items.Add(addColumnsMenuAction);
            dataOperationsGroup.Items.Add(removeColumnsMenuAction);

            this.Items.Add(dataOperationsGroup);        // Can have groups - show up as sub menus
            
            // The UpdateItemStatus event is raised immediately before 
            // the menu show, which provides the opportunity to set states.
            UpdateItemStatus += new EventHandler<MenuActionEventArgs>(DataGridMenuProvider_UpdateItemStatus);
        }
Example #3
0
        private void _menuList_SelectionChanged(object sender, MenuAction e)
        {
            switch (e)
            {
            case MenuAction.New:
            case MenuAction.Resume:
                if (e == MenuAction.New)
                {
                    GameManager.Instance.NewGame();
                }

                Application.SwitchTo <GameScreen>();

                break;

            case MenuAction.Save:
                var saves = _saveManager.ListSaves();
                _saveManager.SaveGame(saves.Any() ? saves.Max(s => s.Slot) + 1 : 1);
                Application.SwitchTo <GameScreen>();
                break;

            case MenuAction.Load:
                Application.SwitchTo <LoadForm>();
                break;

            case MenuAction.Exit:
                Application.Quit = true;
                break;
            }

            _menuList.ClearSelection();
        }
Example #4
0
        private IActionSet GetContextMenuActionSet()
        {
            Dictionary <String, List <AimGraphic> > aimUserGraphics = GetAimUserGraphics();
            List <IAction>   actionsList = new List <IAction>();
            String           path        = "imageviewer-contextmenu/Visible AIM Users/";
            ResourceResolver resolver    = new ResourceResolver(GetType(), true);

            foreach (String aimUser in aimUserGraphics.Keys)
            {
                if (aimUserGraphics.Count > 0)
                {
                    string     user   = aimUser;
                    MenuAction action = new MenuAction(aimUser, new ActionPath(path + aimUser, resolver), ClickActionFlags.CheckAction, resolver);
                    action.Checked    = aimUserGraphics[aimUser][0].Visible;
                    action.Enabled    = true;
                    action.Persistent = false;
                    action.Label      = aimUser;
                    actionsList.Add(action);
                    action.SetClickHandler(
                        delegate
                    {
                        bool visible = !action.Checked;
                        _displayMarkupPerUser[user] = visible;
                        action.Checked = visible;
                        this.SelectedPresentationImage.Draw();
                    });
                }
            }
            return(new ActionSet(actionsList));
        }
Example #5
0
        public override void ExecuteThis()
        {
            base.BeSilent = true;
            base.ExecuteThis();
            base.BeSilent = false;

            WindowInfo winfo = ListedWindows[0];
            IntPtr     hMenu = MenuAction.GetMenuHandle(winfo.Hwnd);

            WriteLine("Window:" + winfo);
            if (MenuAction.IsMenu(hMenu))
            {
                int    x = MenuAction.MenuItemLocationFromPoint(winfo.Hwnd, hMenu, new System.Drawing.Point(xyParam.X, xyParam.Y));
                object o = MenuAction.GetMenuItemText(hMenu, (uint)x, true);

                WriteLine("Menu, hMenu : " + hMenu.ToInt64() + ", " + hMenu.ToString("X") + ", Text : " + o);

                System.Drawing.Rectangle rect = MenuAction.GetMenuItemRect(winfo.Hwnd, hMenu, (uint)x);
                Highlighter h = new Highlighter();
                h.Flash(rect);
            }
            else
            {
                WriteLine("Not a Menu");
            }
        }
Example #6
0
        private void writeGameMenu()
        {
            string path = modPath + "\\resource\\gamemenu.res";

            SourceSDK.KeyValue gameMenu = new SourceSDK.KeyValue("gamemenu");

            for (int i = 0; i < actions.Count; i++)
            {
                MenuAction         action   = actions[i];
                SourceSDK.KeyValue actionKV = new SourceSDK.KeyValue(i.ToString());
                actionKV.addChild(new SourceSDK.KeyValue("label", action.label));
                actionKV.addChild(new SourceSDK.KeyValue("command", action.command));
                actionKV.addChild(new SourceSDK.KeyValue("ingameorder", i.ToString()));
                if (action.inGame)
                {
                    actionKV.addChild(new SourceSDK.KeyValue("onlyingame", "1"));
                }
                if (action.onlySingle)
                {
                    actionKV.addChild(new SourceSDK.KeyValue("nomulti", "1"));
                }
                if (action.onlyMulti)
                {
                    actionKV.addChild(new SourceSDK.KeyValue("nosingle", "1"));
                }

                gameMenu.addChild(actionKV);
            }

            SourceSDK.KeyValue.writeChunkFile(path, gameMenu, true, new UTF8Encoding(false));
        }
Example #7
0
    void Action(MenuAction a)
    {
        if (a == MenuAction.wait)
        {
            Network.InitializeServer(2, 5300, !Network.HavePublicAddress());
            _Loader.WriteDebug("Waiting For Players");
            _MenuGui.enabled = false;
        }
        if (a == MenuAction.join)
        {
            _Loader.WriteDebug("Connecting");
            var ips = new List <string>();

            for (int i = 0; i < 255; i++)
            {
                ips.Add("192.168.30." + i);
            }
            Network.Connect(ips.ToArray(), 5300);
        }
        if (a == MenuAction.single)
        {
            singlePlayer = true;
            Network.InitializeServer(1, 5300, true);
        }
    }
Example #8
0
        public TagWriterContextMenuProvider()
        {
            var lastFill = new MenuAction("Writer Editor");

            lastFill.Checkable = true;
            lastFill.Execute  += (s, e) =>
            {
                ModelItem      item      = e.Selection.PrimarySelection;
                var            tagWriter = item.GetCurrentValue() as ITagWriter;
                TagWriteEditor frm       = new TagWriteEditor(tagWriter);
                frm.ShowDialog();
                if (frm.IsSaved)
                {
                    string txt = frm.TagText;
                    if (string.IsNullOrEmpty(txt) == false)
                    {
                        item.Properties["TagWriteText"].SetValue(txt);
                    }
                    else if (txt == string.Empty)
                    {
                        item.Properties["TagWriteText"].ClearValue();
                    }
                    if (frm.IsPulse)
                    {
                        item.Properties["IsPulse"].SetValue(true);
                    }
                    else
                    {
                        item.Properties["IsPulse"].ClearValue();
                    }
                }
            };
            Items.Add(lastFill);
        }
Example #9
0
        private void readGameMenu()
        {
            string path = modPath + "\\resource\\gamemenu.res";

            Directory.CreateDirectory(Path.GetDirectoryName(path));

            if (!File.Exists(path))
            {
                MessageBox.Show("File does not exist. Creating new one");
                createGameMenu();
            }

            SourceSDK.KeyValue gameMenu = SourceSDK.KeyValue.readChunkfile(path);
            actions.Clear();
            foreach (SourceSDK.KeyValue actionKv in gameMenu.getChildren())
            {
                string label      = actionKv.getValue("label");
                string command    = actionKv.getValue("command");
                bool   inGame     = (actionKv.getValue("onlyingame") == "1");
                bool   onlySingle = (actionKv.getValue("nomulti") == "1");
                bool   onlyMulti  = (actionKv.getValue("nosingle") == "1");

                MenuAction action = new MenuAction(label, command)
                {
                    inGame = inGame, onlySingle = onlySingle, onlyMulti = onlyMulti
                };
                actions.Add(action);
            }
        }
Example #10
0
 private void AddSubMenuItem(MenuItem parent, string name, bool isChecked, MenuAction action)
 {
     MenuItem item = new MenuItem(name);
     item.Checked = isChecked;
     item.Click += new EventHandler(action);
     parent.MenuItems.Add(item);
 }
Example #11
0
        public void ConnectChild(object userData)
        {
            MenuAction menuAction = userData as MenuAction;

            connectOrigin = menuAction.nodeIDs[0];
            view.StartConnectChild();
        }
Example #12
0
        private static IAction CreateAction(
            string actionID,
            string path,
            WebBrowserComponent webBrowser)
        {
            string url      = ExtractUrlFromFavourite(path);
            string menuPath = CreateMenuPath(path);

            // Create the menu action
            ActionPath actionPath = new ActionPath(menuPath, null);
            MenuAction action     = new MenuAction(actionID, actionPath, ClickActionFlags.None, null);

            action.Label = actionPath.LastSegment.LocalizedText;

            // Set what we're supposed to do when the menu item is clicked
            action.SetClickHandler(
                delegate
            {
                // Navigate to the URL
                webBrowser.Url = url;
                webBrowser.Go();
            });

            return(action);
        }
        public LevelElement(string text, Texture2D texture, Vector2 pos, bool selectable, Menu m, MenuAction a, string levelname)
            : base(text, texture, pos, selectable,m, a)
        {
            if (levelname == "alley")
            { unlocked = true; }
            topLeft = pos;
            bottomRight = new Vector2(pos.X + smallWidth, pos.Y + smallHeight);

            topLeftDest = topLeft;
            bottomRightDest = bottomRight;

            world = new World();
            world.Init(levelname);

            vp = new Viewport();
            this.levelname = levelname;
            smallfont = new GFont(TextureManager.smallFont, 5, 10);

            levelThatUnlocks.Add("airport", "alley");
            levelThatUnlocks.Add("jungle", "airport");
            levelThatUnlocks.Add("city", "jungle");
            levelThatUnlocks.Add("powerplant", "city");

            if (levelThatUnlocks.ContainsKey(levelname))
            {
                if (Config.highScore[levelThatUnlocks[levelname]] >= neededScore)
                {
                    unlocked = true;
                }
            }
        }
        /// <summary>
        ///  The provider's constructor sets up the MenuAction objects and the MenuGroup which holds them.
        /// </summary>
        public DataGridMenuProvider()
        {
            // Set up the MenuGroup which holds the MenuAction items.
            MenuGroup dataOperationsGroup = new MenuGroup("DataGroup", "DataGrid");
            dataOperationsGroup.HasDropDown = true;

            editPropertyBoundColumnsMenuAction = new MenuAction(Properties.Resources.Edit_Property_Bound_Columns);
            editPropertyBoundColumnsMenuAction.Execute += new EventHandler<MenuActionEventArgs>(EditPropertyBoundColumnsMenuAction_Execute);
            dataOperationsGroup.Items.Add(editPropertyBoundColumnsMenuAction);

// These methods are not used, but they are very useful when developing the Design experience
#if Development

            generateStockColumnsMenuAction = new MenuAction(Properties.Resources.Generate_Columns);
            generateStockColumnsMenuAction.Execute += new EventHandler<MenuActionEventArgs>(GenerateStockColumnsMenuAction_Execute);

            removeColumnsMenuAction = new MenuAction(Properties.Resources.Remove_Columns);
            removeColumnsMenuAction.Execute += new EventHandler<MenuActionEventArgs>(RemoveColumnsMenuAction_Execute);

            dataOperationsGroup.Items.Add(generateStockColumnsMenuAction);
            dataOperationsGroup.Items.Add(removeColumnsMenuAction);
#endif

            this.Items.Add(dataOperationsGroup);        // Can have groups - show up as sub menus

            // The UpdateItemStatus event is raised immediately before 
            // the menu show, which provides the opportunity to set states.
            UpdateItemStatus += new EventHandler<MenuActionEventArgs>(DataGridMenuProvider_UpdateItemStatus);
        }
 void ActionPerformed(MenuAction newActionPerformed)
 {
     if (ToolManager.IsActiveTool(m_Tool) && newActionPerformed.GetType() != this.GetType())
     {
         LeaveTool();
     }
 }
Example #16
0
        private void DoEquipmentStuff(MenuItem selectedItem, MenuAction selectedAction)
        {
            if (selectedItem.Text == "Cancel")
            {
                CloseActivity();
                return;
            }

            var item = _systemContainer.EntityEngine.Get((uint)selectedItem.Value);

            switch (selectedAction)
            {
            case MenuAction.Unequip:
                var done = _systemContainer.EquipmentSystem.Unequip(_systemContainer.PlayerSystem.Player, item);

                if (done)
                {
                    SpendATurn();
                    CloseActivity();
                    _systemContainer.MessageSystem.Write($"You unequip the {item.DescriptionName}.");
                }

                break;

            case MenuAction.Examine:
                var actionData = new ActionEventData {
                    Action = ActionType.Examine, Parameters = item.EntityId.ToString()
                };
                _systemContainer.EventSystem.Try(EventType.Action, _systemContainer.PlayerSystem.Player, actionData);
                break;

            default:
                throw new ApplicationException($"Unknown MenuAction in {nameof(EquipmentMenu)}");
            }
        }
Example #17
0
    private void Update()
    {
        if (_menuInput.DownButtonPressed && _actionIndex < _actions.Count - 1)
        {
            AudioManager.Instance.PlayOneShot("UI Menu Toggle");
            _actionIndex++;
            _selectedAction = _actions[_actionIndex];
        }

        if (_menuInput.UpButtonPressed && _actionIndex > 0)
        {
            AudioManager.Instance.PlayOneShot("UI Menu Toggle");
            _actionIndex--;
            _selectedAction = _actions[_actionIndex];
        }

        if (_menuInput.ExecuteButtonPressed)
        {
            AudioManager.Instance.PlayOneShot("UI Menu Confirm");
            _selectedAction.action.Invoke();
        }

        _actions.ForEach(a =>
        {
            a.button.GetComponent <Image>().color = _staticColor;
            a.button.transform.localScale         = _startingScale;
        });
        _selectedAction.button.GetComponent <Image>().color = _hoverColor;
        _selectedAction.button.transform.localScale        *= 1.08f;
    }
Example #18
0
        /**
         * Updates the visible and enabled state of actions in the menu without rebuilding
         * the menu entirely.
         */

        public void UpdateMenuActions(IActionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            bool visibleChanged             = false;
            ActionPresentation presentation = new ActionPresentation();

            foreach (DictionaryEntry de in _itemToActionMap)
            {
                presentation.Reset();
                MenuItem   item       = (MenuItem)de.Key;
                MenuAction menuAction = (MenuAction)de.Value;
                UpdateAction(menuAction, context, ref presentation);

                bool wasVisible = item.Visible;
                SetActionFlags(item, ref presentation);
                if (wasVisible != item.Visible)
                {
                    visibleChanged = true;
                }
            }

            if (visibleChanged)
            {
                UpdateSeparatorVisibility(_menuItems);
            }
        }
Example #19
0
    public override void SpawMenu(KeyCode menuKeyCode)
    {
        var weapons = _inventory.GetWeapons();

        if (_inventory == null || weapons == null)
        {
            return;
        }

        MenuAction[] buttons = new MenuAction[weapons.Length];

        for (var i = 0; i < weapons.Length; i++)
        {
            var weapon       = weapons[i];
            var weaponSetter = weapon.GetComponent <WeaponSetter>();

            if (weapon != null)
            {
                buttons[i] = new MenuAction
                {
                    ButtonAction = () => _weaponHolster.Equip(weapon),
                    Title        = weaponSetter.Weapon.name,
                    Sprite       = weaponSetter.Weapon.Avatar,
                    Color        = Color.white
                };
            }
        }

        var menu = Instantiate(MenuPrefab) as Menu;

        menu.Initialize(menuKeyCode, transform, buttons);
    }
Example #20
0
 private void UpdateAction(MenuAction menuAction, IActionContext context, ref ActionPresentation presentation)
 {
     presentation.Text = menuAction.Name;
     try
     {
         if (menuAction.Filters != null)
         {
             foreach (IActionStateFilter filter in menuAction.Filters)
             {
                 filter.Update(context, ref presentation);
                 if (!presentation.Visible)
                 {
                     break;
                 }
             }
         }
         if (presentation.Visible)
         {
             menuAction.Action.Update(context, ref presentation);
         }
     }
     catch (Exception ex)
     {
         ICore.Instance.ReportException(ex, false);
         presentation.Visible = false;
     }
 }
Example #21
0
 void Selected(object sender, RoutedEventArgs e)
 {
     if (e.Source is MenuItem menuItem)
     {
         MenuAction?.Invoke((string)menuItem.Header);
     }
 }
Example #22
0
 private void CreateDeleteActions()
 {
     _deleteAllMenuAction   = CreateMenuAction("deleteAll", String.Format("{0}/MenuDeleteAllClipboardItems", _menuSite), SR.TooltipDeleteAllClipboardItems, CreateDeleteAllIconSet(), DeleteAll);
     _deleteMenuAction      = CreateMenuAction("delete", String.Format("{0}/MenuDeleteClipboardItem", _menuSite), SR.TooltipDeleteClipboardItem, CreateDeleteIconSet(), DeleteSelected);
     _deleteAllButtonAction = CreateToolbarAction("deleteAll", String.Format("{0}/ToolbarDeleteAllClipboardItems", _toolbarSite), SR.TooltipDeleteAllClipboardItems, CreateDeleteAllIconSet(), DeleteAll);
     _deleteButtonAction    = CreateToolbarAction("delete", String.Format("{0}/ToolbarDeleteClipboardItem", _toolbarSite), SR.TooltipDeleteClipboardItem, CreateDeleteIconSet(), DeleteSelected);
 }
Example #23
0
        public static Task ShowMenuCommandWatcher(
            AutoResetEvent autoResetEvent,
            DialogProvider dialogProvider,
            Menu <MenuAction> menu,
            PaintBrush brush)
        {
            return(Task.Run(() =>
            {
                do
                {
                    if (!Console.KeyAvailable)
                    {
                        Thread.Sleep(100);
                        continue;
                    }

                    var key = Console.ReadKey(false).Key;

                    switch ((int)key)
                    {
                    case (int)MenuAction.ServiceStart:
                        Action = MenuAction.ServiceStart;
                        break;

                    case (int)MenuAction.ServiceStop:
                        Action = MenuAction.ServiceStop;
                        break;

                    case (int)MenuAction.ServicePause:
                        Action = MenuAction.ServicePause;
                        break;

                    case (int)MenuAction.ServiceContinue:
                        Action = MenuAction.ServiceContinue;
                        break;

                    case (int)MenuAction.ServiceShutdown:
                        Action = MenuAction.ServiceShutdown;
                        break;

                    case (int)MenuAction.Exit:
                        Action = MenuAction.Exit;
                        break;

                    case (int)ConsoleKey.F1:
                        lock (ConsoleGuardian)
                        {
                            Console.WriteLine("\n" + menu);
                        }

                        continue;

                    default:
                        continue;
                    }

                    autoResetEvent.Set();
                } while (Action != MenuAction.Exit);
            }));
        }
        private IActionSet CreateActions()
        {
            var toolType = typeof(CustomizeViewerActionModelTool);
            var resolver = new ActionResourceResolver(toolType);

            var idPrefix       = toolType.FullName + ":";
            var mainMenuAction = new MenuAction(idPrefix + _mainMenuCustomizeId,
                                                new ActionPath("global-menus/MenuTools/MenuCustomizeActionModels", resolver),
                                                ClickActionFlags.None, resolver)
            {
                GroupHint  = new GroupHint(_groupHint),
                Label      = SR.MenuCustomizeActionModels,
                Persistent = true
            };

            mainMenuAction.SetClickHandler(Customize);

            var contextMenuAction = new ContextMenuAction(idPrefix + _contextMenuCustomizeId,
                                                          new ActionPath(ImageViewerComponent.ContextMenuSite + "/MenuCustomizeActionModels", resolver),
                                                          ClickActionFlags.None, resolver)
            {
                GroupHint  = new GroupHint(_groupHint),
                Label      = SR.MenuCustomizeActionModels,
                Persistent = true
            };

            contextMenuAction.SetClickHandler(Customize);
            contextMenuAction.Initialize(mainMenuAction);

            return(new ActionSet(new[] { mainMenuAction, contextMenuAction }));
        }
        /// <summary>
        ///  The provider's constructor sets up the MenuAction objects and the MenuGroup which holds them.
        /// </summary>
        public DataGridMenuProvider()
        {
            // Set up the MenuGroup which holds the MenuAction items.
            MenuGroup dataOperationsGroup = new MenuGroup("DataGroup", "DataGrid");

            isDatasourceSetMenuAction = new MenuAction("You need to set ItemsSource to enable some column operations.");

            generateStockColumnsMenuAction          = new MenuAction("Generate Columns");
            generateStockColumnsMenuAction.Execute += new EventHandler <MenuActionEventArgs>(GenerateStockColumnsMenuAction_Execute);

            addColumnsMenuAction          = new MenuAction("Add/Edit Columns...");
            addColumnsMenuAction.Execute += new EventHandler <MenuActionEventArgs>(AddColumnsMenuAction_Execute);

            removeColumnsMenuAction          = new MenuAction("Remove Columns");
            removeColumnsMenuAction.Execute += new EventHandler <MenuActionEventArgs>(RemoveColumnsMenuAction_Execute);

            dataOperationsGroup.HasDropDown = true;
            dataOperationsGroup.Items.Add(isDatasourceSetMenuAction);
            dataOperationsGroup.Items.Add(generateStockColumnsMenuAction);
            dataOperationsGroup.Items.Add(addColumnsMenuAction);
            dataOperationsGroup.Items.Add(removeColumnsMenuAction);

            this.Items.Add(dataOperationsGroup);        // Can have groups - show up as sub menus

            // The UpdateItemStatus event is raised immediately before
            // the menu show, which provides the opportunity to set states.
            UpdateItemStatus += new EventHandler <MenuActionEventArgs>(DataGridMenuProvider_UpdateItemStatus);
        }
Example #26
0
        public void FindActionTest1()
        {
            MenuActionManager target      = Init();
            string            resourceKey = "MenuEdit";
            IMenuAction       expected    = target.Edit;
            IMenuAction       actual;

            actual = target.FindAction(resourceKey);
            Assert.AreEqual(expected, actual);
            actual = target.FindAction("AbsentMenu");
            Assert.AreEqual(null, actual);
            var actionHC = new MenuAction(target, target.Reports, "", 1);

            actionHC.Caption = "human reports";
            var actionVC = new MenuAction(target, target.Reports, "", 2);

            actionHC.Caption = "vet reports";
            var action = new MenuAction(target, target.Reports, "MenuLogout", 3);

            action = new MenuAction(target, actionHC, "MenuExit", 1);
            actual = target.FindAction("MenuExit");
            Assert.AreEqual(action, actual);
            actual = target.FindAction(actionHC.Caption);
            Assert.AreEqual(actionHC, actual);
            actual = target.FindAction("AbsentMenu");
            Assert.AreEqual(null, actual);
        }
Example #27
0
        private void createAction(IAction i_Action, string i_Title, MainMenu i_ParentMenu)
        {
            MenuAction action = new MenuAction(i_Action, i_Title);

            i_ParentMenu.AddMenuItem(action);
            action.AttachReporter(this as IActionReporter);
        }
        private MenuGroup InitNavigationMenuGroup()
        {
            firstPageMenuAction          = new MenuAction(Resources.FirstPageText);
            firstPageMenuAction.Execute += OnGoToFirstPage;
            firstPageMenuAction.ImageUri = ResourceHelper.GetImageUri("GoToFirstPage.png");

            previousPageMenuAction          = new MenuAction(Resources.PreviousPageText);
            previousPageMenuAction.Execute += OnGoToPreviousPage;
            previousPageMenuAction.ImageUri = ResourceHelper.GetImageUri("GoToPreviousPage.png");

            nextPageMenuAction          = new MenuAction(Resources.NextPageText);
            nextPageMenuAction.Execute += OnGoToNextPage;
            nextPageMenuAction.ImageUri = ResourceHelper.GetImageUri("GoToNextPage.png");

            lastPageMenuAction          = new MenuAction(Resources.LastPageText);
            lastPageMenuAction.Execute += OnGoToLastPage;
            lastPageMenuAction.ImageUri = ResourceHelper.GetImageUri("GoToLastPage.png");

            MenuGroup navigationGroup = new MenuGroup("WizardPagesNavigationGroup");

            navigationGroup.Items.Add(firstPageMenuAction);
            navigationGroup.Items.Add(previousPageMenuAction);
            navigationGroup.Items.Add(nextPageMenuAction);
            navigationGroup.Items.Add(lastPageMenuAction);
            return(navigationGroup);
        }
Example #29
0
 public ActionMenu(byte value, string name, MenuAction action, ActionMenu defaults)
 {
     Default    = defaults;
     MenuAction = ActionMenuEntry.AllActionMenuEntries[(byte)action];
     Name       = name;
     Value      = value;
 }
    public void ButtonPress(MenuAction action)
    {
        switch (action)
        {
        case MenuAction.LoadFightScene:
            LoadScene(fightSceneName);
            ButtonWasPressed();
            break;

        case MenuAction.LoadInstructionsScene:
            LoadScene(instructionsSceneName);
            ButtonWasPressed();
            break;

        case MenuAction.LoadCreditsScene:
            LoadScene(creditsSceneName);
            ButtonWasPressed();
            break;

        case MenuAction.ExitGame:
            Invoke("Exit", actionDelay);
            ButtonWasPressed();
            break;
        }
    }
Example #31
0
 void Menu(MenuAction action)
 {
     if (action == MenuAction.open && !isMenuOpen)
     {
         isMenuOpen = true;
         if (isGameOver)
         {
             menuPanelText.text = "game over";
         }
         else
         {
             menuPanelText.text = "paused";
         }
         menuPanel.SetActive(true);
         Cursor.visible   = true;
         Cursor.lockState = CursorLockMode.None;
         Time.timeScale   = 0f;
         ReadMenuOptions(); // Read values from SO
         SaveStatistics();
         ShowStatistics();
     }
     if (action == MenuAction.close)                                // If menu opened, closes it (upd: 1st check changes + confirm dialog)
     {
         if (hasOptionsChanged && !confirmDialog.isConfirmDialogOn) // Ask for save changes before exit
         {
             if (!confirmDialog.isYesSelected && !confirmDialog.isNoSelected)
             {
                 confirmDialog.ConfirmationDialog("save Khanges?");
             }
         }
         else
         {
             if (!isGameOver)
             {
                 isMenuOpen = false;
                 menuPanel.SetActive(false);
                 Cursor.visible   = false;
                 Cursor.lockState = CursorLockMode.Locked;
                 Time.timeScale   = 1f;
             }
         }
     }
     if (action == MenuAction.wait)
     {
         if (confirmDialog.isYesSelected || confirmDialog.isNoSelected)
         {
             if (confirmDialog.isYesSelected)
             {
                 SaveMenuOptions();                               // If confirms, save and apply changes globally
             }
             if (confirmDialog.isNoSelected)
             {
                 ReadMenuOptions();                               // If cancel changes, read again from SO
             }
             // isDialogOpen = false;
             confirmDialog.Close();
             Menu(MenuAction.close);
         }
     }
 }
Example #32
0
 public void Disable()
 {
     UITooltip.CanActivate  = true;
     _canvas.alpha          = 0;
     _canvas.interactable   = false;
     _canvas.blocksRaycasts = false;
     if (OnMenuDisabled != null)
     {
         OnMenuDisabled();
     }
     if (_menuActions != null)
     {
         for (int i = 0; i < _menuActions.Count; i++)
         {
             MenuAction.Store(_menuActions[i]);
         }
     }
     if (_items != null)
     {
         for (int i = 0; i < _items.Length; i++)
         {
             ItemPool.Despawn(_items[i].gameObject);
         }
     }
     _items       = null;
     _menuActions = null;
 }
Example #33
0
        public Menu Add(string menuPath, MenuAction action, bool collapsable = false)
        {
            Menu childMenu = null;

            string[] bits = menuPath.Split(new[] { '/' }, 2);
            if (bits.Length > 0)
            {
                string childMenuName = bits[0];

                if (!m_Children.TryGetValue(childMenuName, out childMenu))
                {
                    childMenu = new Menu(childMenuName, m_Children.Comparer, collapsable);
                    m_Children.Add(childMenuName, childMenu);
                }
                if (bits.Length > 1)
                {
                    childMenu = childMenu.Add(bits[1], action, collapsable);
                }
                else
                {
                    childMenu.m_Action = action;
                }
            }
            return(childMenu);
        }
Example #34
0
    public void SpawnButton(MenuAction a)
    {
        GameObject button = Instantiate(menuButtonPrefab, new Vector3(0, 0, 0), Quaternion.identity);

        button.transform.SetParent(transform);
        button.GetComponent <MenuActionButton>().MenuAction = a;
    }
Example #35
0
 void displayMenuButton(MenuAction button, Texture texon, Texture texoff, Rect rect)
 {
     if (GUI.Button (rect, _menuAction == button ? texon : texoff, GUIStyle.none))
     if (_menuAction == button)
         _menuAction = MenuAction.None;
     else
         _menuAction = button;
 }
Example #36
0
 public MenuBouton(string Text, MenuPosition Position, MenuAction Action, int screenWidth, int screenHeight)
 {
     _screenWidth = screenWidth;
     _screenHeight = screenHeight;
     _Text = Text;
     _MenuPosition = Position;
     _MenuAction = Action;
 }
Example #37
0
 /// <summary>
 /// Add a new MenuItem to the current menu
 /// </summary>
 /// <param name="text">What does the menu item say?</param>
 /// <param name="pos">Where is it (NOTE, not px value, its a ratio / 20)</param>
 /// <param name="index">Specifiy the horizontal menu</param>
 /// <param name="action">The function it runs</param>
 public void AddMenuItem(string text, Vector2 pos, int index, MenuAction action)
 {
     while (menuItems.Count - 1 < index)
     {
         menuItems.Add(new List<MenuItem>());
     }
     menuItems[index].Add(new MenuItem(text, pos, action));
 }
Example #38
0
 public MenuItem(string text, Vector2 pos, MenuAction action)
 {
     this.text = text;
     this.pos = pos;
     this.action = action;
     texture = null;
     Init();
 }
        public MonthViewDesignMenuProvider()
        {
            var grp = new MenuGroup("FarsiLibrary", "Farsi Library");
            aboutMenuAction = new MenuAction("About...");
            aboutMenuAction.Execute += OnAboutActionExecuted;

            grp.Items.Add(aboutMenuAction);
            Items.Add(grp);
        }
Example #40
0
 public void Action(MenuAction a)
 {
     Debug.Log("Action:" + a);
     if (a == MenuAction.StartServer)
     {
         _Popup.ShowPopup("Loading Map");
         HostGame();
     }
 }
Example #41
0
    // Use this for initialization
    void Start()
    {
        sprite = this.GetComponent<SpriteRenderer>();

        if ( OnClick == null )
        {
            this.OnClick = GetComponent<MenuAction>();
        }
    }
Example #42
0
 public MenuItem(Game game, string text, Vector2 position, Color color, MenuAction action)
     : base(game)
 {
     this.Font = game.Content.Load<SpriteFont>("Fonts/MenuFont");
     this.Text = text;
     this.Position = position;
     this.Color = color;
     this._action = action;
 }
Example #43
0
 public Menu(Menu parent, string name, MenuAction action, object context = null)
 {
     MenuOptions = new List<Menu>();
     Name = name;
     Action = action;
     Context = context;
     SelectedIndex = 0;
     Parent = parent;
 }
Example #44
0
    //ENT_GameManager game;

    void Awake() {
        if (instance == null) {
            instance = this;
        }
        manager = MenuManager.Instance;

        //		menu = GameObject.Find ("Menu2").GetComponent<Menu> ();
        //Debug.Log (this.GetComponent<PieMenu> ().commands.Count);
    }
Example #45
0
 public MenuItem(Texture2D texture, Vector2 pos, int w, int h, MenuAction action)
 {
     this.text = "";
     this.pos = pos;
     this.action = action;
     this.texture = texture;
     this.w = w;
     this.h = h;
     Init();
 }
 public MenuElement(string text, Texture2D texture, Vector2 pos, bool selectable, Menu m, MenuAction a)
 {
     this.text = text;
     this.texture = texture;
     this.pos = pos;
     destination = pos;
     font = new GFont(TextureManager.font, 4, 10);
     this.m = m;
     action = a;
 }
Example #47
0
        public void AddItem(string text, Texture2D texture, Vector2 pos, Color c, MenuAction a, bool half = false)
        {
            int w = this.w - 6;
            if (half)
            {
                w = MenuItem.defaultHeight;
            }

            items.Add(new MenuItem(text, texture, new Vector2(pos.X + 3, pos.Y + 2),
                w, MenuItem.defaultHeight, true, c, this, a));
        }
        public UIObjectSelectable(String name, String assetName, Vector3 position, String selectedTextureName, MenuAction action) : base(name, assetName, position)
        {
            // Set selected texture name
            m_SelectedTextureName = selectedTextureName;

            // Set action and set default key press
            m_Action = action;

            if (m_Action != null)
                m_Action.SetKeyPress("select");
        }
Example #49
0
 public MenuItem(string text, Texture2D texture, Vector2 pos, int w, int h, bool selectable, Color c, Menu m, MenuAction a)
 {
     this.text = text;
     this.texture = texture;
     this.pos = pos;
     destination = pos;
     font = TextureManager.FontMap["menuFont"];
     this.m = m;
     action = a;
     this.width = w;
     this.height = h;
     this.c = c;
 }
Example #50
0
    void Awake()
    {
        escIsEnabled = true;
        menuAction = null;
        levelNameDic=new Hashtable();

        startMenuMusic ();

        mainMenu = getMainMenu ();
        creditsMenu = getCreditsMenu ();
        startGameMenu = getStartGameMenu ();

        activeMenu = mainMenu;
    }
        /// <summary>
        /// Add a "Add Tab" context menu item.
        /// </summary>
        public TabControlContextMenuProvider()
        {
            this.UpdateItemStatus += new EventHandler<MenuActionEventArgs>(TabControlContextMenuProvider_UpdateItemStatus);

            _addTabMenuAction = new MenuAction(Properties.Resources.TabControl_AddTabMenuItem);
            _addTabMenuAction.ImageUri = new Uri(
                String.Format(
                    CultureInfo.InvariantCulture,
                    "pack://application:,,,/{0};component/Images/AddTab.bmp", 
                    this.GetType().Assembly.GetName().Name),
                UriKind.Absolute);

            _addTabMenuAction.Execute += new EventHandler<MenuActionEventArgs>(AddTabMenuAction_Execute);
            this.Items.Add(_addTabMenuAction);
        }
Example #52
0
 public void Action(MenuAction a)
 {
     Debug.Log("Action:" + a);
     if (a == MenuAction.StartServer)
     {
         HostGame();
     }
     if (a == MenuAction.JoinGame)
     {
         //SetTimeOut();
         joingame = true;
         MasterServer.RequestHostList("Ropector");
         _Popup.ShowPopup("Searching for games");
         _Popup.enabled = true;            
         LocalConnect();            
     }
 }
Example #53
0
 public MenuItem(GameMenu gm, MenuItemSpec spec)
     : base(gm)
 {
     this.gm = gm;
     this.fm = gm.FacetManager;
     text = spec.text;
     command = spec.command;
     textcolor = spec.normalcolor;
     hovercolor = spec.hovercolor;
     scale = 1.0f;
     location = Rectangle.Empty;
     selSprite = Menu.Game.Content.LoadImage("mnu/TitleButtonSelected");
     deselSprite = Menu.Game.Content.LoadImage("mnu/TitleButtonDeselected");
     location.Width = selSprite.Width;
     location.Height = selSprite.Height;
     Enabled = true;
 }
        public void Init(GraphicsDevice g, Entity e, MenuAction c)
        {
            entity = e;
            graphics = g;
            callback = c;

            if (File.Exists("blueprints\\anim\\" + e.Name + ".json"))
            {
                StreamReader sr = new StreamReader("blueprints\\anim\\" + e.Name + ".json");
                string json = sr.ReadToEnd();
                sr.Close();
                LoadAnim(json);
            }
            foreach (Animation a in anims)
            {
                listBox1.Items.Add(a.name);
            }
        }
Example #55
0
    void Action(MenuAction a)
    {
        if (a == MenuAction.wait)
        {
            Network.InitializeServer(2, 5300, !Network.HavePublicAddress());
            _Loader.WriteDebug("Waiting For Players");
            _MenuGui.enabled = false;
        }
        if (a == MenuAction.join)
        {
            _Loader.WriteDebug("Connecting");
            var ips = new List<string>();

            for (int i = 0; i < 255; i++)
                ips.Add("192.168.30." + i);
            Network.Connect(ips.ToArray(), 5300);
        }
        if (a == MenuAction.single)
        {
            singlePlayer = true;
            Network.InitializeServer(1, 5300, true);
        }
    }
Example #56
0
    public MenuAction draw()
    {
        MenuAction menuAction = null;
        Rect rect = new Rect (0, 0, Screen.width, Screen.height);
        GUI.DrawTexture (rect, mainBackground, ScaleMode.ScaleAndCrop, false, 0);

        GUILayout.BeginArea (new Rect (Screen.width / 12, Screen.height / 12, Screen.width * 10 / 12, Screen.height * 10 / 12));
        GUILayout.BeginVertical ();
        GUILayout.Label ("Sandbox", titleStyle);

        drawIntegerSlider ("Width", ref blobData.size.width, 1, 100);
        drawIntegerSlider ("Height", ref blobData.size.height, 1, 100);
        drawIntegerSlider ("Depth", ref blobData.size.depth, 1, 100);
        drawFloatSlider ("Speed", ref blobData.speed, 0.5f, 20f);
        drawIntegerSlider ("xOffset", ref blobData.offset.x, -200, 200);
        drawIntegerSlider ("yOffset", ref blobData.offset.y, -200, 200);

        drawBoolCheckbox ("Guarentee Hit", ref blobData.offset.guarenteeHit);
        drawFloatSlider ("Viroid Ratio", ref blobData.viroid.exposure, 0f, 1f);
        drawFloatSlider ("Viroid Height Pref", ref blobData.viroid.heightPreference, 0f, 1f);
        drawHashtableSlider ("Move Direction", ref moveDirection, directions);
        drawHashtableSlider ("Generator Type", ref generatorType, generatorTypes);

        GUILayout.BeginHorizontal ();
        GUILayout.Space (Screen.width / 3);
        if (GUILayout.Button (menuCommand))
            menuAction = new MenuAction (menuName, menuCommand);
        GUILayout.Space (Screen.width / 3);
        GUILayout.EndHorizontal ();

        GUILayout.EndVertical ();

        GUILayout.EndArea ();

        return menuAction;
    }
Example #57
0
    public MenuAction draw()
    {
        MenuAction menuAction = null;
        Rect rect = new Rect (0, 0, Screen.width, Screen.height);
        GUI.DrawTexture (rect, mainBackground, ScaleMode.ScaleAndCrop, false, 0);

        GUILayout.BeginArea (new Rect (0, 0, Screen.width * 5 / 6, Screen.height * 19 / 20));
        GUILayout.BeginVertical ();

        GUILayout.FlexibleSpace ();

        foreach (MenuItemTemplate item in itemTemplates) {
            if (item.itemType == "button") {
                if (GUILayout.Button (item.text, item.style))
                    menuAction = new MenuAction (menuName, item.text);
            }
            if (item.itemType == "text")
                GUILayout.Label (item.text, item.style);

        }

        GUILayout.EndVertical ();
        GUILayout.EndArea ();

        return menuAction;
    }
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                RequestWindowFeature(WindowFeatures.NoTitle);

                base.OnCreate(bundle);
                LoggerMobile.Instance.logMessage("Opening LeaguesActibity", LoggerEnum.message);
                SetContentView(Resource.Layout.PublicLeagues);
                LegacyBar = FindViewById<LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);
                LegacyBar.SetHomeLogo(Resource.Drawable.icon);
                LegacyBar.SeparatorColor = Color.Purple;

                LegacyBarAction azAction = new MenuAction(this, null, Resource.Drawable.a_z);
                LegacyBar.AddAction(azAction);

                LegacyBar = FindViewById<LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);
                AddHomeAction(typeof(Main), Resource.Drawable.icon);
                // Get our button from the layout resource,
                // and attach an event to it

                Action<LeaguesJson> leagues = new Action<LeaguesJson>(UpdateAdapter);
                LegacyBar.ProgressBarVisibility = ViewStates.Visible;
                League.PullLeagues(lastPagePulled, PAGE_COUNT, "", (Context)this, leagues);


                skaterList = FindViewById<ListView>(Resource.Id.leagueList);
                initialArray = new LeaguesJson();
                Action pullMore= new Action(PullMore);
                ListAdapter = new LeagueAdapter(this, initialArray.Leagues, pullMore);
                skaterList.Adapter = ListAdapter;
                skaterList.FastScrollEnabled = true;


                skaterList.ItemClick += skaterList_ItemClick;
                var myString = new SpannableStringBuilder("lol");
                Selection.SelectAll(myString); // needs selection or Index Out of bounds
                _dialog = new MyCharacterPickerDialog(this, new View(this), myString, options, false);
                _dialog.Clicked += (sender, args) =>
                {
                    lastPagePulled = 0;
                    lastLetterPulled = args.Text;
                    LegacyBar.ProgressBarVisibility = ViewStates.Visible;
                    League.PullLeagues(0, PAGE_COUNT, lastLetterPulled, (Context)this, leagues);
                    initialArray.Leagues.Clear();
                };
                search_leagues = FindViewById<EditText>(Resource.Id.search_leagues);
                search_leagues.TextChanged += search_skaters_TextChanged;
                var searchMenuItemAction = new SearchAction(this, null, Resource.Drawable.ic_action_search, search_leagues);
                LegacyBar.AddAction(searchMenuItemAction);

                LegacyBarAction infoAction = new DefaultLegacyBarAction(this, CreateInfoIntent(), Resource.Drawable.action_about);
                LegacyBar.AddAction(infoAction);

                m_AdView = FindViewById(Resource.Id.adView);
                if (SettingsMobile.Instance.User != null && SettingsMobile.Instance.User.IsValidSub)
                {
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.Android, (Context)this);
            }
        }
Example #59
0
        internal virtual void Invoke(MenuAction action)
        {
            if (action != null)
            {
                action();

                Reset();
            }
        }
Example #60
0
 /// <summary>
 /// Activates the MenuAction if it is not null
 /// </summary>
 public static void StaticInvoke(MenuAction action)
 {
     if (action != null)
         action();
 }