示例#1
0
        private void CreateButtonsPrivate(ButtonData returnButton, ButtonData cancelButton)
        {
            int maxButtonsPerPage = rowCount * columnCount;

            if (!(returnButton is null))
            {
                maxButtonsPerPage--;
            }
            if (!(cancelButton is null))
            {
                maxButtonsPerPage--;
            }

            if (numberOfButtons > maxButtonsPerPage)
            {
                ButtonData[][] buttonGroups = new ButtonData[(int)Math.Ceiling(numberOfButtons * 1.0 / maxButtonsPerPage)][];

                int remainingButtons = numberOfButtons;
                for (int x = 0; x < buttonGroups.Length; x++)
                {
                    var iter = numberOfButtons - remainingButtons;
                    if (remainingButtons >= maxButtonsPerPage)
                    {
                        buttonGroups[x]   = new ButtonData[rowCount * columnCount];
                        remainingButtons -= maxButtonsPerPage;
                    }
                    else
                    {
                        buttonGroups[x] = new ButtonData[remainingButtons];
                    }

                    for (int y = 0; y < buttonGroups[x].Length; y++)
                    {
                        buttonGroups[x][y] = buttons[iter];
                        iter++;
                    }
                }

                generatePageCallback = new Action[buttonGroups.Length];

                for (int x = 0; x < generatePageCallback.Length; x++)
                {
                    int q = x;
                    generatePageCallback[q] = () =>
                    {
                        GenerateButtons(buttonGroups[q], returnButton, cancelButton);
                        if (x > 0)
                        {
                            display.AddButton((byte)((rowCount - 1) * columnCount), new ButtonData(GlobalStrings.PREVIOUS_PAGE(), true,
                                                                                                   () => GenerateButtons(buttonGroups[q - 1], returnButton, cancelButton)), true);
                        }
                        if (x < generatePageCallback.Length - 1)
                        {
                            display.AddButton((byte)((rowCount - 1) * columnCount + 1), new ButtonData(GlobalStrings.NEXT_PAGE(), true,
                                                                                                       () => GenerateButtons(buttonGroups[q + 1], returnButton, cancelButton)), true);
                        }
                    };
                }
            }
            else
            {
                GenerateButtons(buttons, returnButton, cancelButton);
            }
        }
示例#2
0
 public static ButtonData PrevButtonBecauseWereAssholes(Action callback)
 {
     return(new ButtonData(GlobalStrings.PREVIOUS_PAGE(), true, callback));
 }