public void ActionMenuItemRendersLink()
        {
            MenuItem action = Menu.Action <HomeController>(p => p.Index());

            action.RenderHtml(controllerContext, writer);
            Assert.AreEqual("<li><a href=\"Home/Index/\">Index</a></li>", Out);
        }
        public void ActionMenuItemRendersLinkWithIconAndNoTitle()
        {
            MenuItem action = Menu.Action <HomeController>(p => p.Index(), null, "Icon");

            action.RenderHtml(controllerContext, writer);
            Assert.AreEqual("<li><a href=\"Home/Index/\"><img border=\"0\" src=\"Icon\" /></a></li>", Out);
        }
Beispiel #3
0
    private void WriteMenu(IndentedTextWriter indentWriter, Menu menu, string menuPath, string menuMethodName, int priority)
    {
        if (string.IsNullOrEmpty(menuPath))
        {
            menuPath = menu.Name;
        }
        else
        {
            menuPath = menuPath + "/" + menu.Name;
        }

        menuMethodName += menu.Name;

        if (menu.Action != null)
        {
            indentWriter.WriteLine("[MenuItem(\"{0}\", priority={1})]", menuPath, priority);
            indentWriter.WriteLine("public static void {0}MenuItem() {{", GetCleanUniqueName(menuMethodName));
            indentWriter.Indent++;
            menu.Action(indentWriter);
            indentWriter.Indent--;
            indentWriter.WriteLine("}");
            priority += 1;
        }

        foreach (Menu child in menu.Children)
        {
            WriteMenu(indentWriter, child, menuPath, menuMethodName, priority);
            priority += 1;
        }
    }
Beispiel #4
0
        private void MenuTread()
        {
            Dictionary <string, Action> Actions = new Dictionary <string, Action>
            {
                { phraseProvider.GetPhrase(Phrase.HeaderMain), Plug },

                { phraseProvider.GetPhrase(Phrase.HeaderHistory), ShowHistory },
                { phraseProvider.GetPhrase(Phrase.HeaderTraderList), Plug },
                { phraseProvider.GetPhrase(Phrase.HeaderTraderManaging), Plug },

                { phraseProvider.GetPhrase(Phrase.HeaderAddTrader), AddTrader },
                { phraseProvider.GetPhrase(Phrase.HeaderAddShare), AddShare },
                { phraseProvider.GetPhrase(Phrase.HeaderChandeShare), ChangeShare },

                { phraseProvider.GetPhrase(Phrase.HeaderWhiteList), ShowWightList },
                { phraseProvider.GetPhrase(Phrase.HeaderOrangeList), ShowOrangeList },
                { phraseProvider.GetPhrase(Phrase.HeaderBlackList), ShowBlackList }
            };

            while (true)
            {
                menu.PrintHeader();
                menu.PrintDiscription();
                menu.Action(Actions);
                menu.PrintButtons();
                menu.SwitchPage();
            }
        }
Beispiel #5
0
        /// <summary>
        /// Navigiert durchs Menu.
        /// </summary>
        private void MenuNavigation()
        {
            Menu menu = (Menu)Controllee;

            // Hoch wurde gedrückt
            if (KeyPressed(KBconfig.Up) || KeyPressed(Keys.Up)) //geändert zu Settingsdatei -CK
            {
                menu.Up();
            }

            // Runter wurde gedrückt
            if (KeyPressed(KBconfig.Down) || KeyPressed(Keys.Down)) //geändert zu Settingsdatei -CK
            {
                menu.Down();
            }

            // Links wurde gedrückt
            if (KeyPressed(KBconfig.Left) || KeyPressed(Keys.Left)) //geändert zu Settingsdatei -CK
            {
                menu.Left();
            }

            // Rechts wurde gedrückt
            if (KeyPressed(KBconfig.Right) || KeyPressed(Keys.Right)) //geändert zu Settingsdatei -CK
            {
                menu.Right();
            }

            // Bestätigen wurde gedrückt
            if (KeyPressed(KBconfig.Fire) || KeyPressed(Keys.Enter)) //geändert zu Settingsdatei -CK
            {
                menu.Action();
            }
        }
        public void SelectedItemsShouldRenderAsSuch()
        {
            MenuItem link = Menu.Action <HomeController>(p => p.Index());

            link.SetSelectedClass("selected");
            link.RenderHtml(controllerContext, writer);
            Assert.AreEqual("<li><a class=\"selected\" href=\"Home/Index/\">Index</a></li>", Out);
        }
        public void CanAssignTitleViaFluentMenu()
        {
            var item       = Menu.Action <HomeController>(p => p.Index(), "A Title");
            var secureItem = Menu.Secure <HomeController>(p => p.Index2(), "A Different Title");

            Assert.AreEqual("A Title", item.Title);
            Assert.AreEqual("A Different Title", secureItem.Title);
        }
        public void MenuTitleAndMenuHelpAttributesSetValues()
        {
            MenuItem action = Menu.Action <HomeController>(p => p.Index2());

            action.Prepare(controllerContext);
            Assert.AreEqual("Title", action.Title);
            Assert.AreEqual("Help Text", action.HelpText);
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Menu menu = new Menu();

            bool showMenu = true;

            while (showMenu)
            {
                Console.Clear();
                menu.ShowMenu();
                showMenu = menu.Action();
            }
        }
        public static MenuItem MainMenu(UrlHelper url)
        {
            Menu.DefaultIconDirectory = url.Content("~/Content/");
            Menu.DefaultDisabledClass = "disabled";
            Menu.DefaultSelectedClass = "selected";
            return(Menu.Begin(
                       Menu.Items("Grid Samples",
                                  Menu.Action <GridController>(c => c.Index(), "Simple Grid"),
                                  Menu.Action <GridController>(c => c.Paged(null), "Paged Grid"),
                                  Menu.Action <GridController>(c => c.UsingGridModel(), "Using a GridModel"),
                                  Menu.Action <GridController>(c => c.WithSections(), "Using Grid Sections"),
                                  Menu.Action <GridController>(c => c.AutoColumns(), "Auto-Generated Columns"),
                                  Menu.Action <GridController>(c => c.Sorting(null), "Sorting"),
                                  Menu.Action <GridController>(c => c.SortingAndPaging(null, null), "Sorting and Paging")
                                  ),

                       Menu.Items("FluentHtml Samples",
                                  Menu.Action <FluentHtmlController>(c => c.Index(), "FluentHtml Samples")
                                  ),

                       Menu.Items("DerivedTypeModelBinder Samples",
                                  Menu.Action <DerivedTypeModelBinderController>(c => c.Index(), "DerivedTypeModelBinder Samples")
                                  ),

                       Menu.Items("Secure",
                                  Menu.Secure <HomeController>(p => p.Index()),
                                  Menu.Secure <HomeController>(p => p.About()),
                                  Menu.Secure <HomeController>(p => p.SecurePage1()),
                                  Menu.Secure <HomeController>(p => p.SecurePage2())
                                  ),
                       Menu.Items("Insecure",
                                  Menu.Action <HomeController>(p => p.Index()),
                                  Menu.Action <HomeController>(p => p.About(), "About", "blarg.gif"),
                                  Menu.Action <HomeController>(p => p.SecurePage1()),
                                  Menu.Action <HomeController>(p => p.SecurePage2())
                                  ),
                       Menu.Items("Disabled",
                                  Menu.Action <HomeController>(p => p.Index(), "Disabled Index").SetDisabled(true).SetShowWhenDisabled(true),
                                  Menu.Action <HomeController>(p => p.About(), "Disabled About").SetDisabled(true).SetShowWhenDisabled(true)
                                  ),
                       Menu.Items("Direct",
                                  Menu.Link("http://microsoft.com", "Big Blue"),
                                  Menu.Link("http://google.com", "Google")
                                  ),
                       Menu.Items("Administrivia",
                                  Menu.Secure <AccountController>(p => p.LogOff()),
                                  Menu.Action <AccountController>(p => p.MagicLogOn()))
                       ).SetListClass("jd_menu"));
        }
Beispiel #11
0
    // Buttons
    public override void Action()
    {
        if (blockInput)
        {
            return;
        }

        try {
            Menu menu = mm.GetCurrentMenu();
            if (menu != null && menu.isActive)
            {
                menu.Action(this);
            }
        } catch (InvalidOperationException) {       // No menu is open, stack is empty
            /* Debug */
            mm.DebugMenu();
        }
    }
Beispiel #12
0
    public void Run()
    {
        Func <Menu, bool> RunMenu = (Menu menu) =>
        {
            ConsoleKey inputKey = ConsoleKey.NumPad0;
            while (inputKey != ConsoleKey.Q && inputKey != ConsoleKey.Escape)
            {
                System.Console.WriteLine(today.ToString());
                System.Console.WriteLine(user.ToString());
                System.Console.Write(menu.ToString());
                System.Console.Write(">");
                inputKey = System.Console.ReadKey(true).Key;
                menu.Action(inputKey);
            }// while
            return(true);
        };// RunMenu
        Menu topMenu = new Menu();

        topMenu[ConsoleKey.P] = new MenuItem("Add or Remove Portfolios", () =>
        {
            Menu portMenu    = new Menu();
            MenuItem addPort = new MenuItem("Add Portfolio",
                                            () =>
            {
                System.Console.Write("\nEnter Portfolio Name: ");
                string newPort = System.Console.ReadLine();
                user.AddPortfolio(newPort);
                if (user.numPorts >= 3)
                {
                    portMenu.Remove(ConsoleKey.A);
                }
                return(true);
            });
            if (user.numPorts < 3)
            {
                portMenu[ConsoleKey.A] = addPort;
            }
            portMenu[ConsoleKey.D] = new MenuItem("Delete Portfolio", () =>
            {
                try
                {
                    System.Console.Write("\nWhich one? ");
                    string delPort = System.Console.ReadLine();
                    user.DeletePortfolio(delPort);
                    if (user.numPorts < 3)
                    {
                        portMenu[ConsoleKey.A] = addPort;
                    }
                    return(true);
                }// try
                catch (KeyNotFoundException)
                {
                    System.Console.WriteLine("Invalid Portfolio name\n>");
                    return(false);
                }
            });
            System.Console.WriteLine("(D) Delete Portfolio");
            portMenu[ConsoleKey.Q] = new MenuItem("Quit Menu", () => { return(true); });
            RunMenu(portMenu);
            return(true);
        });
        topMenu[ConsoleKey.X] = new MenuItem("Deposit, Withdraw, or Transfer", () =>
        {
            Menu moneyMenu          = new Menu();
            moneyMenu[ConsoleKey.D] = new MenuItem("Deposit Funds", () => {
                try
                {
                    System.Console.Write("\nTo which Portfolio? (blank for account) ");
                    string port = System.Console.ReadLine();
                    System.Console.Write("\nHow much? ");
                    double amount = Int32.Parse(System.Console.ReadLine());
                    if (port == "")
                    {
                        user.AddFunds(amount);
                    }
                    else
                    {
                        user.AddFunds(amount, port);
                    }
                    return(true);
                }// try
                catch (Exception)
                {
                    System.Console.WriteLine("Invalid Input\n>");
                    return(false);
                }
            });
            moneyMenu[ConsoleKey.W] = new MenuItem("Withdraw Funds", () => {
                try
                {
                    System.Console.Write("\nFrom which Portfolio? (blank for account) ");
                    string port = System.Console.ReadLine();
                    System.Console.Write("\nHow much? ");
                    double amount = Int32.Parse(System.Console.ReadLine());
                    if (port == "")
                    {
                        user.WithdrawFunds(amount);
                    }
                    else
                    {
                        user.WithdrawFunds(amount, port);
                    }
                    return(true);
                }// try
                catch (Exception)
                {
                    System.Console.WriteLine("Invalid Input\n>");
                    return(false);
                }
            });
            moneyMenu[ConsoleKey.X] = new MenuItem("Transfer Funds", () => {
                try
                {
                    System.Console.Write("\nTo which Portfolio? (blank for account) ");
                    string port2 = System.Console.ReadLine();
                    System.Console.Write("\nFrom which Portfolio? (blank for account) ");
                    string port = System.Console.ReadLine();
                    System.Console.Write("\nHow much? ");
                    double amount = Int32.Parse(System.Console.ReadLine());
                    if (port == "")
                    {
                        user.WithdrawFunds(amount + user.transferFee);
                    }
                    else
                    {
                        user.WithdrawFunds(amount + user.transferFee, port);
                    }
                    if (port2 == "")
                    {
                        user.AddFunds(amount + user.transferFee);
                    }
                    else
                    {
                        user.AddFunds(amount + user.transferFee, port2);
                    }
                    return(true);
                }// try
                catch (Exception)
                {
                    System.Console.WriteLine("Invalid Input\n>");
                    return(false);
                }
            });
            moneyMenu[ConsoleKey.Q] = new MenuItem("Quit Menu", () => { return(true); });
            RunMenu(moneyMenu);
            return(true);
        });
        topMenu[ConsoleKey.G] = new MenuItem("View Gains/Losses", () =>
        {
            try
            {
                System.Console.Write("\nEnter Portfolio Name: ");
                string port = System.Console.ReadLine();
                System.Console.Write("\nEnter Start Date Year: ");
                int sYear = Int32.Parse(System.Console.ReadLine());
                System.Console.Write("\nEnter Start Date Month: ");
                int sMonth = Int32.Parse(System.Console.ReadLine());
                System.Console.Write("\nEnter Start Date Day: ");
                int sDay = Int32.Parse(System.Console.ReadLine());
                System.Console.Write("\nEnter End Date Year: ");
                int eYear = Int32.Parse(System.Console.ReadLine());
                System.Console.Write("\nEnter End Date Month: ");
                int eMonth = Int32.Parse(System.Console.ReadLine());
                System.Console.Write("\nEnter End Date Day: ");
                int eDay = Int32.Parse(System.Console.ReadLine());
                System.Console.Write("Net Difference of $" +
                                     user.GainLossReport(port, new DateTime(sYear, sMonth, sDay),
                                                         new DateTime(eYear, eMonth, eDay)));
            }// try
            catch (Exception)
            {
                System.Console.WriteLine("Invalid Input\n>");
            }
            return(true);
        });
        topMenu[ConsoleKey.S] = new MenuItem("Stock Prices", () =>
        {
            System.Console.WriteLine();
            foreach (string symbol in this.stocks.Keys)
            {
                System.Console.WriteLine(symbol + " $" + this.stocks[symbol].price
                                         + "  " + this.stocks[symbol].name);
            }
            return(true);
        });
        topMenu[ConsoleKey.T] = new MenuItem("Trade", () =>
        {
            Menu posMenu = new Menu();
            System.Console.WriteLine("(N) Purchase Number of Stock");
            System.Console.WriteLine("(P) Purchase Dollar Amount");
            System.Console.WriteLine("(S) Sell");
            System.Console.WriteLine("(B) Back");
            posMenu[ConsoleKey.N] = new MenuItem("Purchase Number of Stocks",
                                                 () =>
            {
                try
                {
                    System.Console.Write("\nEnter Portfolio Name: ");
                    string port = System.Console.ReadLine();
                    System.Console.Write("\nEnter Stock Symbol: ");
                    string symbol = System.Console.ReadLine().ToUpper();
                    System.Console.Write("\nEnter Number of Stocks: ");
                    int amount = Int32.Parse(System.Console.ReadLine());
                    user.Purchase(port, symbol, amount, stocks[symbol].price, today);
                    return(true);
                }    // try
                catch (Exception)
                {
                    System.Console.WriteLine("Invalid Input\n>");
                    return(false);
                }
            });
            posMenu[ConsoleKey.P] = new MenuItem("Purchase Dollar Amount",
                                                 () =>
            {
                try
                {
                    System.Console.Write("\nEnter Portfolio Name: ");
                    string port = System.Console.ReadLine();
                    System.Console.Write("\nEnter Stock Symbol: ");
                    string symbol = System.Console.ReadLine().ToUpper();
                    System.Console.Write("\nEnter Amount to Spend: ");
                    int amount = Int32.Parse(System.Console.ReadLine());
                    user.Purchase(port, symbol, amount / (int)stocks[symbol].price,
                                  stocks[symbol].price, today);
                    return(true);
                }    // try
                catch (Exception)
                {
                    System.Console.WriteLine("Invalid Input\n>");
                    return(false);
                }
            });
            posMenu[ConsoleKey.S] = new MenuItem("Sell Stocks",
                                                 () =>
            {
                try
                {
                    System.Console.Write("\nEnter Portfolio Name: ");
                    string port = System.Console.ReadLine();
                    System.Console.Write("\nEnter Stock Symbol: ");
                    string symbol = System.Console.ReadLine().ToUpper();
                    System.Console.Write("\nEnter Number of Sell: ");
                    int amount = Int32.Parse(System.Console.ReadLine());
                    user.Sell(port, symbol, amount, stocks[symbol].price, today);
                    return(true);
                }    // try
                catch (Exception)
                {
                    System.Console.WriteLine("Invalid Input\n>");
                    return(false);
                }
            });
            posMenu[ConsoleKey.Q] = new MenuItem("Quit Menu", () =>
            {
                return(true);
            });
            RunMenu(posMenu);
            return(true);
        });
        topMenu[ConsoleKey.Spacebar] = new MenuItem("Advance Day", () =>
        {
            Menu dayMenu          = new Menu();
            dayMenu[ConsoleKey.H] = new MenuItem("3%-15%", () =>
            {
                vol = 3;
                return(true);
            });
            dayMenu[ConsoleKey.M] = new MenuItem("2%-8%", () =>
            {
                vol = 2;
                return(true);
            });
            dayMenu[ConsoleKey.L] = new MenuItem("1%-4%", () =>
            {
                vol = 1;
                return(true);
            });
            System.Console.WriteLine("Select Market Volatility:");
            System.Console.WriteLine(dayMenu.ToString());
            LoadStocks();
            today = today.AddDays(1);
            ConsoleKey inputKey = ConsoleKey.NumPad0;
            while (inputKey != ConsoleKey.Q && inputKey != ConsoleKey.Escape)
            {
                System.Console.WriteLine(today.ToString());
                System.Console.WriteLine(user.ToString());
                System.Console.Write(dayMenu.ToString());
                if (inputKey != ConsoleKey.NumPad0)
                {
                    System.Console.WriteLine("Day advanced! Advance another day, or hit Q to go back.");
                }
                System.Console.Write(">");
                inputKey = System.Console.ReadKey(true).Key;
                dayMenu.Action(inputKey);
            }// while
            return(true);
        });
        topMenu[ConsoleKey.Q] = new MenuItem("Quit", () =>
        {
            return(true);
        });
        user.AddPortfolio("Guile");
        user.AddFunds(10000, "Guile");
        user.Purchase("Guile", "MMMM", 40, 33.3, today);
        RunMenu(topMenu);
    }// Run
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            if (index < totalLines - 1)
            {
                index++;
                Vector3 position = guiArrowLink.transform.localPosition;
                position.y -= yOffset;
                guiArrowLink.transform.localPosition = position;
            }
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            if (index > 0)
            {
                index--;
                Vector3 position = guiArrowLink.transform.localPosition;
                position.y += yOffset;
                guiArrowLink.transform.localPosition = position;
            }
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            totalLines = menu.Action(index, menu, guiTextLink);
            guiArrowLink.transform.localPosition = arrStartPos;
            index = 0;
            guiScrollLink.value = 1f;
        }

        if (Input.GetKeyDown(KeyCode.Backspace) || Input.GetKeyDown(KeyCode.Delete))
        {
            if (menu.stateId == 2)
            {
                totalLines = 3;
                menu.SetState(new MainMenu(), 1);
                menu.Display(new List <string>(), guiTextLink, 0);
            }
            if (menu.stateId == 3)
            {
                menu.SetState(new PickCard(), 2);
                List <string> list = new List <string>();
                for (int i = 1; i <= Session.totalCardAmount; i++)
                {
                    list.Add("Card №" + i + "\n\n");
                }
                totalLines = Session.totalCardAmount;
                menu.Display(list, guiTextLink, Session.totalCardAmount);
            }
            if (menu.stateId == 4)
            {
                menu.SetState(new PickQuestion(), 3);
                int           i    = Session.card.questions.Count;
                List <string> list = new List <string>();
                for (int j = 1; j <= i; j++)
                {
                    string s;
                    if (Session.card.questions[j - 1].text.Length > 40)
                    {
                        s = Session.card.questions[j - 1].text.Substring(0, 40) + "...\n\n";
                    }
                    else
                    {
                        s = Session.card.questions[j - 1].text + "\n\n";
                    }
                    if (Session.card.questions[j - 1].isAnswered)
                    {
                        list.Add("✓ " + s);
                    }
                    else
                    {
                        list.Add(s);
                    }
                }
                GameObject go = GameObject.FindGameObjectWithTag("help");
                go.GetComponent <Text>().text = "";

                Session.focusedQuestion = -1;
                totalLines = i + 1;
                menu.Display(list, guiTextLink, i);
            }
            guiArrowLink.transform.localPosition = arrStartPos;
            index = 0;
            guiScrollLink.value = 1f;
        }
    }