📄 cmouse.cs
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
class CMouse
{
private Microsoft.DirectX.Direct3D.Device mouse = null;
public System.Threading.AutoResetEvent MouseUpdated;
private float x, y, z = 0.0f;
public float Z
{
get { return z; }
set { z = value; }
}
public float Y
{
get { return y; }
set { y = value; }
}
public float X
{
get { return x; }
set { x = value; }
}
private byte[] buttons;
public CMouse(System.Windows.Forms.Control control)
{
mouse = new Microsoft.DirectX.Direct3D.Device(SystemGuid.Mouse);
mouse.setSetCooperativeLevel(control, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
mouse.Properties.AxisModeAbsolute = false;
MouseUpdated = new System.Threading.AutoResetEvent(false);
mouse.SetEventNotification(MouseUpdated);
mouse.Acquire();
Update();
}
public void Update()
{
MouseState state = mouse.CurrentMouseState;
x = state.X;
y = state.Y;
z = state.Z;
buttons = state.GetMouseButtons();
}
public bool LeftButtonDown
{
get
{
bool a;
return a = (buttons[0] != 0);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -