Esempio n. 1
0
        private bool IsMouseOver(DrawableGameObject Object)
        {
            if (this._CursorRectangle.IntersectsWith(Object.Rectangle) == true)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
        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>();
        }
Esempio n. 4
0
        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;
                    }
                }
            }
        }
Esempio n. 5
0
        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>();
        }
Esempio n. 6
0
 public void UnregisterInteractiveObject(DrawableGameObject Object)
 {
     this._InteractiveObjects.Remove(Object);
 }
Esempio n. 7
0
 public void RegisterInteractiveObject(DrawableGameObject Object)
 {
     this._InteractiveObjects.Add(Object);
 }
Esempio n. 8
0
 public static void DrawRectangleOfObject(PaintEventArgs e, DrawableGameObject Object)
 {
     e.Graphics.DrawRectangle(Pens.LightGray, Object.Rectangle);
 }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 public EVENT_MOUSE_CLICK() : base()
 {
     this._Button        = MouseButtons.None;
     this._ClickedObject = null;
     this._ClickPosition = Point.Empty;
 }
Esempio n. 11
0
 public EVENT_MOUSE_LEAVE(GameObject Sender, string Name, DrawableGameObject LeavedObject) : base(Sender, Name)
 {
     this._LeavedObject = LeavedObject;
 }
Esempio n. 12
0
 public EVENT_MOUSE_LEAVE() : base()
 {
     this._LeavedObject = null;
 }
Esempio n. 13
0
 public EVENT_MOUSE_ENTER(GameObject Sender, string Name, DrawableGameObject EnteredObject) : base(Sender, Name)
 {
     this._EnteredObject = EnteredObject;
 }
Esempio n. 14
0
 public EVENT_MOUSE_ENTER() : base()
 {
     _EnteredObject = null;
 }