private bool IsMouseOver(DrawableGameObject Object) { if (this._CursorRectangle.IntersectsWith(Object.Rectangle) == true) { return(true); } return(false); }
public static void DrawGameObject(PaintEventArgs e, DrawableGameObject Object) { if (Object.Texture.IsColorTexture == false) { e.Graphics.DrawImageUnscaled(Object.Texture.Image, Object.Position); } else { e.Graphics.FillRectangle(Object.Texture.Solidbrush, Object.Rectangle); } }
public MouseInputManager() : base() { this._CursorPos = new Point(0, 0); this._CursorSize = new Size(16, 16); this._CursorRectangle = new Rectangle(this._CursorPos, this._CursorSize); this._CurrentCursorType = Cursortypes.NORMAL; this._CursorTypes = new Hashtable(); this._CurrentMouseOverObject = null; this._InteractiveObjects = new List <DrawableGameObject>(); }
public void UpdateCursorPosition(MouseEventArgs e) { if (e.Location != _CursorPos) { base.PushEvent(new EVENT_MOUSE_MOVE(null, EventType.EVENT_MOUSE_MOVE)); this._CursorPos = e.Location; this._CursorRectangle.Location = e.Location; DrawableGameObject MouseOverObject = null; foreach (DrawableGameObject Object in this._InteractiveObjects) { if (IsMouseOver(Object) == true) { MouseOverObject = Object; break; } } if (MouseOverObject != null) { if (this._CurrentMouseOverObject == null) { this._CurrentCursorType = Cursortypes.MOUSEOVER; this._CurrentMouseOverObject = MouseOverObject; base.PushEvent(new EVENT_MOUSE_ENTER(null, EventType.EVENT_MOUSE_ENTER, this._CurrentMouseOverObject)); } else { if (this._CurrentMouseOverObject != MouseOverObject) { this._CurrentCursorType = Cursortypes.NORMAL; base.PushEvent(new EVENT_MOUSE_LEAVE(null, EventType.EVENT_MOUSE_LEAVE, this._CurrentMouseOverObject)); this._CurrentMouseOverObject = null; } } } else { if (this._CurrentMouseOverObject != null) { this._CurrentCursorType = Cursortypes.NORMAL; base.PushEvent(new EVENT_MOUSE_LEAVE(null, EventType.EVENT_MOUSE_LEAVE, this._CurrentMouseOverObject)); this._CurrentMouseOverObject = null; } } } }
public MouseInputManager(string Texture, EventHandler EventHandler) : base(EventHandler) { this._CursorPos = new Point(0, 0); this._CursorSize = new Size(16, 16); this._CursorRectangle = new Rectangle(this._CursorPos, this._CursorSize); this._CurrentCursorType = Cursortypes.NORMAL; this._CursorTypes = new Hashtable(); this._CursorTypes.Add(Cursortypes.NORMAL, new CursorType(Texture)); this._CurrentMouseOverObject = null; this._InteractiveObjects = new List <DrawableGameObject>(); }
public void UnregisterInteractiveObject(DrawableGameObject Object) { this._InteractiveObjects.Remove(Object); }
public void RegisterInteractiveObject(DrawableGameObject Object) { this._InteractiveObjects.Add(Object); }
public static void DrawRectangleOfObject(PaintEventArgs e, DrawableGameObject Object) { e.Graphics.DrawRectangle(Pens.LightGray, Object.Rectangle); }
public EVENT_MOUSE_CLICK(GameObject Sender, string Name, MouseButtons Button, Point ClickPosition, DrawableGameObject ClickedObject) : base(Sender, Name) { this._Button = Button; this._ClickPosition = ClickPosition; this._ClickedObject = ClickedObject; }
public EVENT_MOUSE_CLICK() : base() { this._Button = MouseButtons.None; this._ClickedObject = null; this._ClickPosition = Point.Empty; }
public EVENT_MOUSE_LEAVE(GameObject Sender, string Name, DrawableGameObject LeavedObject) : base(Sender, Name) { this._LeavedObject = LeavedObject; }
public EVENT_MOUSE_LEAVE() : base() { this._LeavedObject = null; }
public EVENT_MOUSE_ENTER(GameObject Sender, string Name, DrawableGameObject EnteredObject) : base(Sender, Name) { this._EnteredObject = EnteredObject; }
public EVENT_MOUSE_ENTER() : base() { _EnteredObject = null; }