示例#1
0
        public ChatBox(int width, int height, int numberOfrows = 5, SpriteFont font = null)
        {
            Initialize();

            Font = font;

            // Initialize child control TextBox
            var textBoxInfo = new TextBoxInfo
            {
                MaxLength = 50,
                SpriteFont = font
            };
            textBox = new TextBox("", textBoxInfo);
            textBox.EnterKeyDown += textBox_EnterKeyDown;

            // Initialize child controls textBlocks
            numberOfLines = numberOfrows;
            textBlocks = new TextBlock[numberOfLines];
            for (int i = 0; i < numberOfLines; i++)
            {
                textBlocks[i] = new TextBlock("", font);
            }

            Height = height;
            Width = width;
        }
示例#2
0
        public void InitializeGui(GuiManager gui)
        {
            this.gui = gui;

            panel = new Panel();
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment = VerticalAlignment.Top;
            panel.Width = Context.View.Area.Width;
            panel.Height = Context.View.Area.Height;
            gui.Elements.Add(panel);

            menuOptions = new StackPanel();
            menuOptions.HorizontalAlignment = HorizontalAlignment.Left;
            menuOptions.VerticalAlignment = VerticalAlignment.Center;
            menuOptions.Margin = new Thickness(100, 40, 0, 0);
            menuOptions.Width = 176;
            menuOptions.Height = 400;
            menuOptions.Spacing.Bottom = 32;
            panel.Children.Add(menuOptions);

            // Add the address textbox to the stackpanel
            var textBoxInfo = new TextBoxInfo()
            {
                MaxLength = 100,
                SpriteFont = Context.Resources.Fonts["Global.Normal"],
                Background = Context.Resources.Textures["MainMenu.TextBox"]
            };
            textBoxIp = new TextBox("", textBoxInfo);
            textBoxIp.HorizontalAlignment = HorizontalAlignment.Left;
            textBoxIp.VerticalAlignment = VerticalAlignment.Top;
            textBoxIp.Width = 220;
            textBoxIp.Text = "";
            textBoxIp.EnterKeyDown += textBoxIp_EnterKeyDown;
            menuOptions.Children.Add(textBoxIp);

            for (int i = 0; i < 2; i++)
            {
                menuOptions.Children.Add(GetMenuOption(i));
            }

            gui.UpdateLayout();
        }