public HostNetworkGameScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D background) : base(game, spriteBatch) { this.background = background; formBackground = game.Content.Load<Texture2D>("alienmetal"); buttonTexture = game.Content.Load<Texture2D>("buttonTexture"); textboxTexture = game.Content.Load<Texture2D>("textboxTexture"); //center the form ont he screen Rectangle center = this.CenterGUIForm(242, 224); hostGameForm = new Form("Host", "Host a Game", new Rectangle(center.X, center.Y, center.Width, center.Height), formBackground, spriteFont, Color.White); //figure out the width and heigh of the text on the buttons Vector2 startButtonSize, backButtonSize; startButtonSize = spriteFont.MeasureString("Start Game"); backButtonSize = spriteFont.MeasureString("Back"); startButton = new Button("Start", "Start Game", new Rectangle(6, 186, (int)startButtonSize.X + 10, (int)startButtonSize.Y + 10), buttonTexture, spriteFont, Color.White); backButton = new Button("BackButton", @"Back", new Rectangle(132, 186, (int)startButtonSize.X + 10, (int)startButtonSize.Y + 10), buttonTexture, spriteFont, Color.White); textBoxMaxConnections = new TextBox("MaxConnections", "10", 100, new Rectangle(11, 42, 60, 20), textboxTexture, spriteFont, Color.Black); maxConnectionsLabel = new Label("maxConnectionsLabel", @"Max Connections", new Vector2(8, 26), spriteFont, Color.White, 0, 0); textBoxPort = new TextBox("Port", "14242", 8, new Rectangle(11, 116, 60, 20), textboxTexture, spriteFont, Color.Black); portLabel = new Label("portLabel", @"Port", new Vector2(8, 91), spriteFont, Color.White, 0, 0); hostGameForm.AddControl(startButton); hostGameForm.AddControl(backButton); hostGameForm.AddControl(textBoxMaxConnections); hostGameForm.AddControl(maxConnectionsLabel); hostGameForm.AddControl(textBoxPort); hostGameForm.AddControl(portLabel); startButton.onClick += new EHandler(ButtonClick); backButton.onClick += new EHandler(ButtonClick); imageRectangle = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height); }
public void AddLabel(String labelName, String labelText, Vector2 position, String PanelName) { Label myLabel = new Label(labelName, labelName, new Vector2(position.X, position.Y), Font, Color.Black, 15, 2); Lables.Add(myLabel); if (PanelName == "MainPanel") Frm.AddControl(myLabel); else { Form myFrm = null; Panels.TryGetValue(PanelName, out myFrm); if (myFrm != null) { myFrm.AddControl(myLabel); } } }
public void AddLabel(String labelName = "lb", String labelText = "Label", String PanelName = "MainPanel") { if (PanelName == "MainPanel") { Label myLabel = new Label(labelName, labelText, new Vector2(_LabelPosition.X, _LabelPosition.Y), Font, Color.Black, 15, 2); Lables.Add(myLabel); Frm.AddControl(myLabel); } else { AddLabel(labelName, labelText, _LabelPosition, PanelName); } _LabelPosition.Y += 25; }
public void AddLabel(String labelName, String labelText, Point position, String PanelName) { Label myLabel = new Label(labelName, labelName, new Vector2(position.X, position.Y), Font, Color.Black, 15, 2); Lables.Add(myLabel); //Frm.AddControl(Lables.Last<Label>()); Form myFrm = null; Panels.TryGetValue(PanelName, out myFrm); if (myFrm != null) { myFrm.AddControl(myLabel); } }