Example #1
0
 /// <summary>
 /// Returns event position of MouseButtonEvent where it would be if the window wasn't resized
 /// See Terminology above
 /// </summary>
 public MouseButtonEventArgs EventToWindowPos(MouseButtonEventArgs mouseButtonEvent)
 {
     Vector2i windowPos = (Vector2i)_window.MapPixelToCoords(
         new Vector2i((int)mouseButtonEvent.X, (int)mouseButtonEvent.Y), _interfaceView);
     MouseButtonEvent newMouseEvent = new MouseButtonEvent();
     newMouseEvent.X = windowPos.X;
     newMouseEvent.Y = windowPos.Y;
     newMouseEvent.Button = mouseButtonEvent.Button;
     MouseButtonEventArgs eventArgsWindowPos = new MouseButtonEventArgs(newMouseEvent);
     return eventArgsWindowPos;
 }
Example #2
0
 /// <summary>
 /// Constructs the mouse button arguments from a mouse button event.
 /// </summary>
 /// <param name="e">Mouse button event.</param>
 public MouseButtonEventArgs(MouseButtonEvent e)
 {
     Button = e.Button;
     X      = e.X;
     Y      = e.Y;
 }
        public override bool MouseDown(MouseButtonEventArgs e)
        {
            if (disposing || !IsVisible()) return false;

            if (scrollbarH.MouseDown(e))
            {
                SetFocus(scrollbarH);
                return true;
            }
            if (scrollbarV.MouseDown(e))
            {
                SetFocus(scrollbarV);
                return true;
            }

            if (ClientArea.Contains(e.X, e.Y))
            {
                MouseButtonEvent mbe= new MouseButtonEvent();
                mbe.X = e.X-(Position.X + (int) scrollbarH.Value);
                mbe.Y = e.Y-(Position.Y + (int) scrollbarV.Value);
                mbe.Button=e.Button;

                MouseButtonEventArgs modArgs=new MouseButtonEventArgs(mbe);

                foreach (GuiComponent component in components)
                {
                    if (component.MouseDown(modArgs))
                    {
                        SetFocus(component);
                        return true;
                    }
                }
                return true;
            }

            return false;
        }
		public override bool MouseUp(MouseButtonEventArgs e)
        {
            if (disposing || !IsVisible()) return false;
            if (scrollbarH.MouseUp(e)) return true;
            if (scrollbarV.MouseUp(e)) return true;

            if (ClientArea.Contains(new Point((int) e.X, (int) e.Y)))
            {
                MouseButtonEvent mbe= new MouseButtonEvent();
                mbe.X = e.X-(Position.X + (int) scrollbarH.Value);
                mbe.Y = e.Y-(Position.Y + (int) scrollbarV.Value);
                mbe.Button=e.Button;

                MouseButtonEventArgs modArgs=new MouseButtonEventArgs(mbe);

                foreach (GuiComponent component in components)
                {
                    component.MouseUp(modArgs);
                }
            }
            return false;
        }
Example #5
0
 /// <summary>
 /// Construct the mouse button arguments from a mouse button event
 /// </summary>
 /// <param name="e">Mouse button event</param>
 ////////////////////////////////////////////////////////////
 public MouseButtonEventArgs(MouseButtonEvent e)
 {
     Button = e.Button;
     X = e.X;
     Y = e.Y;
 }
        public override void update(GameTime time)
        {
            contentManager.update(time);
            lightLayer.update(contentManager);

            #region DeleteBlocks
            if (Mouse.IsButtonPressed(Mouse.Button.Right))
            {
                Vector2i pos = Game1.getMousePosition();
                MouseButtonEvent e = new MouseButtonEvent();
                e.Button = Mouse.Button.Right;
                e.X = pos.X;
                e.Y = pos.Y;
                this.handleMouseButton(new MouseButtonEventArgs(e));
            }
            #endregion

            this.guide.update(Game1.getMousePosition());
        }
Example #7
0
        public override Boolean OnEvent(BlzEvent evt)
        {
            if (HandlePlayerEvent(evt))
                return true;

            if (evt.IsHandled)
                return base.OnEvent(evt);

            switch (evt.Type)
            {
                case EventType.MouseButtonPressed:

                    if (evt.MouseButton.Button != Mouse.Button.Left)
                        break;

                    if (!MapContainsMouse())
                        break;

                    if (MapClicked == null)
                        break;

                    MouseButtonEvent e = new MouseButtonEvent();
                    Vector2f ePoint = GetMapLocalFromGlobal(new Vector2f(evt.MouseButton.X, evt.MouseButton.Y));
                    e.X = (Int32)ePoint.X;
                    e.Y = (Int32)ePoint.Y;

                    MapClicked(this, new MouseButtonEventArgs(e));

                    return true;
            }

            return base.OnEvent(evt);
        }