Beispiel #1
0
 private void Device_MouseInput(object sender, MouseInputEventArgs e) {
     switch (e.ButtonFlags) {
         case MouseButtonFlags.Button1Down:
             mouseStateDict[MouseButtons.Button1] = true;
             break;
         case MouseButtonFlags.Button1Up:
             mouseStateDict[MouseButtons.Button1] = false;
             break;
         case MouseButtonFlags.Button2Down:
             mouseStateDict[MouseButtons.Button2] = true;
             break;
         case MouseButtonFlags.Button2Up:
             mouseStateDict[MouseButtons.Button2] = false;
             break;
         case MouseButtonFlags.Button3Down:
             mouseStateDict[MouseButtons.Button3] = true;
             break;
         case MouseButtonFlags.Button3Up:
             mouseStateDict[MouseButtons.Button3] = false;
             break;
         case MouseButtonFlags.MouseWheel:
             //处理滚轮
             break;
         default:
             break;
     }
     PrintMouseDict();
 }
Beispiel #2
0
		/// <summary>
		///	Mouse handler
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		void MouseHandler ( object sender, MouseInputEventArgs e )
		{
			if (Game.GraphicsDevice.Display.Window != null && !Game.GraphicsDevice.Display.Window.IsDisposed) {

				var p				= Game.GraphicsDevice.Display.Window.PointToClient(Forms.Cursor.Position);
			
				GlobalMouseOffset	= new Vector2(p.X, p.Y);
				
				if (MouseMove!=null) {
					MouseMove(this, new MouseMoveEventArgs(){ Position = GlobalMouseOffset });
				}
			}


			//Console.WriteLine( "{0} {1} {2}", e.X, e.Y, e.ButtonFlags.ToString() );

			RelativeMouseOffset += new Vector2( e.X, e.Y );

			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.LeftButtonDown		) ) AddPressedKey( Keys.LeftButton );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.RightButtonDown	) )	AddPressedKey( Keys.RightButton );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.MiddleButtonDown	) )	AddPressedKey( Keys.MiddleButton );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.Button4Down		) )	AddPressedKey( Keys.MouseButtonX1 );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.Button5Down		) )	AddPressedKey( Keys.MouseButtonX2 );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.LeftButtonUp		) ) RemovePressedKey( Keys.LeftButton );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.RightButtonUp		) )	RemovePressedKey( Keys.RightButton );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.MiddleButtonUp		) )	RemovePressedKey( Keys.MiddleButton );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.Button4Up			) )	RemovePressedKey( Keys.MouseButtonX1 );
			if ( e.ButtonFlags.HasFlag( MouseButtonFlags.Button5Up			) )	RemovePressedKey( Keys.MouseButtonX2 );

			if ( Game.IsActive ) {
				if ( MouseScroll!=null && e.WheelDelta!=0 ) {
					MouseScroll( this, new MouseScrollEventArgs(){ WheelDelta = e.WheelDelta } );
				}
				TotalMouseScroll	+=	e.WheelDelta;
			}
		}
        private static void Device_MouseInput(object sender, MouseInputEventArgs e)
        {
            int s = (int)e.ButtonFlags;

            if ((s & (int)MouseButtonFlags.LeftButtonDown) > 0) LB = true;
            else if ((s & (int)MouseButtonFlags.LeftButtonUp) > 0) LB = false;

            if ((s & (int)MouseButtonFlags.RightButtonDown) > 0) RB = true;
            else if (((int)s & (int)MouseButtonFlags.RightButtonUp) > 0) RB = false;

            if ((s & (int)MouseButtonFlags.MiddleButtonDown) > 0) MB = true;
            else if ((s & (int)MouseButtonFlags.MiddleButtonUp) > 0) MB = false;

            if ((s & (int)MouseButtonFlags.MouseWheel) > 0) WD += e.WheelDelta;
        }
 public void mouseEvent(MouseInputEventArgs args)
 {
 }
 private void OnMouseInput(object sender, MouseInputEventArgs args)
 {
     PostMouseEvent(new MouseEvent(null, args.X, args.Y, 0, 0));
 }