public override void Draw(SpriteBatch batch) { game.Window.Title = string.Format("{0} - Sh.Framework", ScreenManager.Instance.currentscreen); batch.Draw(pixel, new Rectangle(0, 0, 160, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height), Color.DarkGray); int i = 0; newState = Mouse.GetState(); foreach (testcase t in testcases) { Vector2 position = new Vector2(4, 55 * i + 45 + scrollmanager.offset.Y); buttonsize = new Rectangle((int)position.X, (int)position.Y, 150, 50); batch.Draw(pixel, buttonsize, Color.DarkSlateGray); batch.DrawString(font, t.testcasename ?? "<not specified>", new Vector2(buttonsize.X, buttonsize.Y), Color.White); if (MouseTouching.RectWithIn(buttonsize) && MouseStroke.LeftButtonDown(oldState, newState)) { ScreenManager.Instance.currentscreen = t; ScreenManager.Instance.reloadscreen(); } i++; } oldState = newState; scrollmanager.Update(); base.Draw(batch); }
public override void Draw(SpriteBatch batch) { Base.Draw(batch); playrandom.Draw(batch); repeat.Draw(batch); stop.Draw(batch); pause.Draw(batch); play.Draw(batch); string np = string.Format("Now playing: {0}", NowPlaying ?? "nothing"); nowPlaying.text = np; nowPlaying.position = new Vector2(1366 - (nowPlaying.useFont.MeasureString(np).X + 15), 768 - 50); nowPlaying.Draw(batch); if (MediaPlayer.State != MediaState.Stopped) { download.np = NowPlaying; download.music = music; download.rect = new Rectangle(1366 - ((int)nowPlaying.useFont.MeasureString(np).X + 30 + 180), 768 - 65, 180, 50); download.Draw(batch); if (MouseTouching.RectWithIn(download.rect)) { message.Draw(batch); } } base.Draw(batch); }
public override void Draw(SpriteBatch spritebatch) { spritebatch.Draw(pixel, new Rectangle((int)Sh.Framework.Graphics.ShWindow.getWidth() - 1000, 0, 1000, (int)Sh.Framework.Graphics.ShWindow.getHeight()), Color.Black * 0.75f); if (MouseTouching.RectWithIn(new Rectangle((int)Sh.Framework.Graphics.ShWindow.getWidth() - 1000, 0, 1000, (int)Sh.Framework.Graphics.ShWindow.getHeight()))) { tt.Draw(spritebatch); } base.Draw(spritebatch); }
public void Update() { if (MouseTouching.RectWithIn(container)) { mouse = Mouse.GetState(); offset.Y = mouse.ScrollWheelValue - mouseOffset; //I'm very good at writing code if (offset.Y > 0) { offset.Y = 0; mouseOffset = mouse.ScrollWheelValue; } } else { mouseOffset = mouse.ScrollWheelValue; } }
public override void Update() { newstate = Mouse.GetState(); if (MouseTouching.Rect(newstate, rect)) { if (newstate.LeftButton == ButtonState.Pressed && oldstate.LeftButton != ButtonState.Pressed) { OnClick(); } hovering = true; } else { hovering = false; } oldstate = newstate; base.Update(); }
public override void Update() { mouse = Mouse.GetState(); if (focused) { if (MouseTouching.RectWithIn(rect)) { buttonColor = buttonColorHover; } else { buttonColor = buttonColorDefault; } } else { buttonColor = buttonColorPressed; } base.Update(); }
public override void Update() { MouseState mouse = Mouse.GetState(); if (MouseTouching.Rect(mouse, rect)) { hovering = true; if (mouse.LeftButton == ButtonState.Pressed) { switch (lockOn) { case AxisLockOn.X: position.X = mouse.Position.X - texture.Width / 2; break; case AxisLockOn.Y: position.Y = mouse.Position.Y - texture.Height / 2; break; case AxisLockOn.none: position.X = mouse.Position.X - texture.Width / 2; position.Y = mouse.Position.Y - texture.Height / 2; break; default: position.X = mouse.Position.X; position.Y = mouse.Position.Y; break; //nice codebase ;) } dragging = true; } } else { hovering = false; dragging = false; } }
public override void Update() { mouse = Mouse.GetState(); if (focused) { if (MouseTouching.Rect(mouse, rect)) { boxColor = hoverColor; } else { boxColor = defaultColor; } } else { boxColor = disableColor; } base.Update(); }
public override void Draw(SpriteBatch batch) { pane.color = useColor; pane.Draw(batch); m_newState = Mouse.GetState(); if (MouseTouching.RectWithIn(pane.rect)) //if touching { MouseState mouse = Mouse.GetState(); useColor = focusColour; if (m_newState.LeftButton == ButtonState.Pressed && m_oldState.LeftButton == ButtonState.Released) { focus = true; } isTouching = true; } else //if not touching { useColor = fillColour; if (m_newState.LeftButton == ButtonState.Pressed && m_oldState.LeftButton == ButtonState.Released) { submit(); } isTouching = false; } //managing dummyText if (currentText == "") { batch.DrawString(font, dummyText, new Vector2(pane.rect.X + paddingX, (pane.rect.Y + pane.rect.Height) - (pane.rect.Height / 2) - (font.MeasureString(dummyText).Y / 2)), dummyTextColour); } else { batch.DrawString(font, currentText, new Vector2(pane.rect.X + paddingX, (pane.rect.Y + pane.rect.Height) - (pane.rect.Height / 2) - (font.MeasureString(currentText).Y / 2)), TextColour); } //blinker if (focus) { Color blinkColour; if (allowBlink) { if (blinkTimer > blinkRate) { if (a) { a = false; } else { a = true; } blinkTimer = 0; } else { blinkTimer++; } } else { a = true; } if (a) { blinkColour = BlinkColor; } else { blinkColour = BlinkColor * 0; } float blinkerPadding = pane.rect.Height / 4; batch.Draw(pixel, new Rectangle((int)(pane.rect.X + paddingX + font.MeasureString(currentText).X), pane.rect.Y + (int)blinkerPadding, 1, pane.rect.Height - (int)blinkerPadding * 2), blinkColour); } m_oldState = m_newState; base.Draw(batch); }