Пример #1
0
        private int x = 2; // отместването от началото

        /// <summary>
        /// Добавя нов бутон
        /// </summary>
        /// <param name="text">Текста на бутона</param>
        /// <param name="handler">Функцията, която се извиква при натискане</param>
        public override UiButton AddItem(string text, ComponentClickedHandler handler)
        {
            UiButton newButton = new UiButton(text, 20);
            newButton.X = x;
            newButton.Y = 2;

            shouldAdd = true;
            AddChild(newButton);
            newButton.ComponentClicked += handler;
            x += newButton.Width + 2;
            return newButton;
        }
Пример #2
0
        /// <summary>
        /// Добавя бутон в долната част на менюто
        /// </summary>
        /// <param name="text">Текста на бутона</param>
        /// <param name="handler">Функцията, която се извиква при натискане</param>
        public virtual UiButton AddItem(String text, ComponentClickedHandler handler)
        {
            UiButton newButton = new UiButton(text, 20);
            newButton.X = 3;
            newButton.Y = 5 + 25 * children.Count;
            if (Width < (newButton.Width + 6))
            {
                Width = newButton.Width + 6;
                UpdateButtons();
            }
            else newButton.UpdateWidth(Width - 6);

            shouldAdd = true;
            AddChild(newButton);
            newButton.ComponentClicked += handler;
            Height = 5 + 25 * children.Count;
            return newButton;
        }