private void HandleMenuInput(GameTime gameTime) { if (TouchPanel.IsGestureAvailable) { while (TouchPanel.IsGestureAvailable) { var gesture = TouchPanel.ReadGesture(); switch (gesture.GestureType) { case GestureType.Tap: Rectangle touchPoint = new Rectangle((int)gesture.Position.X, (int)gesture.Position.Y, 1, 1); cButton selected = null; if (btnMenu.isPressed(touchPoint)) { CurrentAppState = AppState.DESIGN; } else if (btnDesign.isPressed(touchPoint)) { selected = btnDesign; } else if (btnSave.isPressed(touchPoint)) { watch.Xml(); selected = btnSave; } else if (btnLoad.isPressed(touchPoint)) { selected = btnLoad; } else if (btnCart.isPressed(touchPoint)) { selected = btnCart; } else if (btnSetting.isPressed(touchPoint)) { selected = btnSetting; } else { CurrentAppState = AppState.DESIGN; } foreach (cButton button in buttons) { button.TurnOff(); } if (selected != null) { selected.TurnOn(); } break; } } } }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. // dials = new SpriteBatch(graphics.GraphicsDevice); // spriteFont = Content.Load<SpriteFont> ("Courier New"); texture = Content.Load <Texture2D> ("face"); effect.Texture = texture; // button init btnMenu = new cButton(graphics.GraphicsDevice, spriteBatch, Content.Load <Texture2D>("icon_menu"), rectangle_menu); btnTitle = new cButton(graphics.GraphicsDevice, spriteBatch, Content.Load <Texture2D> ("menu_title"), rectangle_title); btnDesign = new cButton(graphics.GraphicsDevice, spriteBatch, Content.Load <Texture2D> ("menu_design"), rectangle_design); btnSave = new cButton(graphics.GraphicsDevice, spriteBatch, Content.Load <Texture2D>("menu_save"), rectangle_save); btnLoad = new cButton(graphics.GraphicsDevice, spriteBatch, Content.Load <Texture2D>("menu_load"), rectangle_load); btnCart = new cButton(graphics.GraphicsDevice, spriteBatch, Content.Load <Texture2D>("menu_cart"), rectangle_cart); btnSetting = new cButton(graphics.GraphicsDevice, spriteBatch, Content.Load <Texture2D>("menu_settings"), rectangle_setting); buttons.Add(btnDesign); buttons.Add(btnSave); buttons.Add(btnLoad); buttons.Add(btnCart); buttons.Add(btnSetting); }