/// 响应鼠标按下事件 public void OnMouseDown(XMouseEventArgs args) { XMouseHandler <XMouseEventArgs> temp = m_mouseDown; if (temp != null) { temp.Invoke(args); } }
protected override void GameMouseDown(XMouseEventArgs args) { if (args.GetKey() == XMouseButtons.Left) { Console.SetCursorPosition(15, 2); Console.WriteLine("鼠标工作区坐标:" + args.ToString() + " " + args.GetKey().ToString()); } else if (args.GetKey() == XMouseButtons.Right) { Console.SetCursorPosition(15, 3); Console.WriteLine("鼠标工作区坐标:" + args.ToString() + " " + args.GetKey().ToString()); } if (args.GetKey() == XMouseButtons.Middle) { Console.SetCursorPosition(15, 4); Console.WriteLine("鼠标工作区坐标:" + args.ToString() + " " + args.GetKey().ToString()); } }
/// 鼠标事件的处理 public void MouseEventsHandler() { XMouseEventArgs args; XPoint point = GetMousePoint(); XMouseButtons vKey = GetCurDownMouse(); if (!isLeave()) { if (vKey != XMouseButtons.None) { args = new XMouseEventArgs(point.X, point.Y, vKey); this.OnMouseDown(args); } args = new XMouseEventArgs(point.X, point.Y, vKey); this.OnMouseMove(args); } else { args = new XMouseEventArgs(-1, -1, true); this.OnMouseAway(args); } }
protected override void GameMouseMove(XMouseEventArgs args) { SetTitle("鼠标回到了工作区!"); }
protected override void GameMouseAway(XMouseEventArgs args) { SetTitle("鼠标离开了工作区!"); }
/// 鼠标按下虚拟函数 protected virtual void GameMouseDown(XMouseEventArgs e) { // 此处处理鼠标按下事件 }
/// 鼠标离开虚拟函数 protected virtual void GameMouseAway(XMouseEventArgs e) { // 此处处理鼠标离开事件 }
/// 鼠标移动虚拟函数 protected virtual void GameMouseMove(XMouseEventArgs e) { // 此处处理鼠标移动事件 }