private void CheckMouseState(Vector2 formPosition) { MouseState = Mouse.GetState(); mButtonArea.X = (int)PositionOrg.X + (int)formPosition.X; mButtonArea.Y = (int)PositionOrg.Y + (int)formPosition.Y; if (Disabled == false && MathAdd.isInRectangle(new Point(MouseState.X, MouseState.Y), mButtonArea)) { if (BtnState != EBtnState.MouseOver && BtnState != EBtnState.Pressed) { OnMouseOver(this, EventArgs.Empty); } if (MouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { if (BtnState != EBtnState.Pressed) { OnMouseClick(this, EventArgs.Empty); } } else { if (BtnState == EBtnState.Pressed) { OnMouseRelease(this, EventArgs.Empty); } } } else if (Disabled == false && BtnState == EBtnState.MouseOver) { OnMouseOut(this, EventArgs.Empty); } }
private void CheckHorizontalBar() { barArea = new Rectangle((int)Position.X + scrollUp.ControlSize.X, (int)Position.Y, ControlSize.X - (scrollUp.ControlSize.X + scrollDown.ControlSize.X), ControlSize.Y); Point mp = new Point(MouseState.X, MouseState.Y); if (MathAdd.isInRectangle(mp, barArea) && !MathAdd.isInRectangle(mp, scrollerArea)) { if (MouseState.LeftButton == ButtonState.Pressed && !bMouseClicked) { bMouseClicked = true; if (MouseState.X < scrollerPosition.X) { PageUp(); } else { PageDown(); } OnValueChange(this, EventArgs.Empty); } else if (MouseState.LeftButton == ButtonState.Released && bMouseClicked) { bMouseClicked = false; } } else if (MouseState.LeftButton == ButtonState.Released && bMouseClicked) { bMouseClicked = false; } }
private void CheckHorizontalScrolling() { if (MathAdd.isInRectangle(new Point(MouseState.X, MouseState.Y), scrollerArea)) { //FIX ME } }
private void CheckSelection() { MouseState = Mouse.GetState(); if (MouseState.LeftButton == ButtonState.Pressed) { Rectangle listArea; if (Scrollbar == null) { listArea = new Rectangle((int)Position.X, (int)Position.Y, ControlSize.X, ControlSize.Y); } else { listArea = new Rectangle((int)Position.X, (int)Position.Y, ControlSize.X + Scrollbar.ControlSize.X, ControlSize.Y); } if (MathAdd.isInRectangle(new Point(MouseState.X, MouseState.Y), listArea)) { bHasFocus = true; } else if (bHasFocus) { bHasFocus = false; //unselect(); } if (!bItemPressed) { int lastItem = Items.Count; if (lastItem > visibleItems) { lastItem = visibleItems; } for (int i = 0; i < lastItem; i++) { if (bIsOverItem(i)) { selectItem(i + startIndex); bItemPressed = true; } } } } else if (bItemPressed) { bItemPressed = false; } }
private void CheckMouseState() { MouseState = Mouse.GetState(); buttonArea.X = (int)Position.X; buttonArea.Y = (int)Position.Y; if (Disabled == false && MathAdd.isInRectangle(new Point(MouseState.X, MouseState.Y), buttonArea)) { if (BtnState != EBtnState.MouseOver) { Cursor = Cursors.Hand; } else if (BtnState == EBtnState.MouseOver && Cursor != Cursors.Hand) { Cursor = Cursors.Hand; } if (BtnState != EBtnState.MouseOver && BtnState != EBtnState.Pressed) { OnMouseOver(this, EventArgs.Empty); } if (MouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { if (BtnState != EBtnState.Pressed) { OnMouseClick(this, EventArgs.Empty); } } else { if (BtnState == EBtnState.Pressed) { OnMouseRelease(this, EventArgs.Empty); } } } else if (Disabled == false && BtnState == EBtnState.MouseOver) { OnMouseOut(this, EventArgs.Empty); Cursor = Cursors.Default; } }