private void CreateControls() { Texture2D leftTexture = Game.Content.Load <Texture2D>(@"GUI\leftarrowUp"); Texture2D rightTexture = Game.Content.Load <Texture2D>(@"GUI\rightarrowUp"); stopTexture = Game.Content.Load <Texture2D>(@"GUI\StopBar"); backgroundImage = new PictureBox( Game.Content.Load <Texture2D>(@"Backgrounds\titlescreen"), GameRef.ScreenRectangle); ControlManager.Add(backgroundImage); Label label1 = new Label(); label1.Text = "Choose Your Ship"; label1.Size = label1.SpriteFont.MeasureString(label1.Text); label1.Position = new Vector2((GameRef.Window.ClientBounds.Width - label1.Size.X) / 2, 150); ControlManager.Add(label1); /*genderSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture); * genderSelector.SetItems(genderItems, 125); * genderSelector.Position = new Vector2(label1.Position.X, 200); * genderSelector.SelectionChanged += new EventHandler(selectionChanged); * * ControlManager.Add(genderSelector);*/ shipSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture); shipSelector.SetItems(shipItems, 125); shipSelector.Position = new Vector2(label1.Position.X, 250); shipSelector.SelectionChanged += selectionChanged; ControlManager.Add(shipSelector); LinkLabel linkLabel1 = new LinkLabel(); linkLabel1.Text = "Use this Ship."; linkLabel1.Position = new Vector2(label1.Position.X, 300); linkLabel1.Selected += new EventHandler(linkLabel1_Selected); ship = shipSelector.getItem(); //Debug.WriteLine("hgfhfdgdffgs "+ship); ControlManager.Add(linkLabel1); shipImage = new PictureBox( shipImages[0], new Rectangle(600, 200, 96, 96)); ControlManager.Add(shipImage); ControlManager.NextControl(); //Go Back button LinkLabel goBack = new LinkLabel(); goBack.Text = "Go Back"; goBack.Position = new Vector2(label1.Position.X, 450); goBack.Selected += new EventHandler(goBackButton); ControlManager.Add(goBack); }
void selectionChanged(object sender, EventArgs e) { shipImage.Image = shipImages[shipSelector.SelectedIndex]; ship = shipSelector.getItem(); //Debug.WriteLine("hgfhfdgdffgs " + ship); }