背景:

 private System.Windows.Controls.Border _borderTouch;
private bool _mouseDown = false;

   private System.Windows.Point _currentPoint = new System.Windows.Point(0, 0);
    private System.Windows.Point _lastPoint = new System.Windows.Point(0, 0);

一个wpf Border控件,然后注册鼠标事件

 touch.MouseLeftButtonDown += new MouseButtonEventHandler(touch_MouseLeftButtonDown);
touch.MouseLeftButtonUp += new MouseButtonEventHandler(touch_MouseLeftButtonUp);
touch.MouseLeave += new MouseEventHandler(touch_MouseLeave);
touch.MouseMove += new MouseEventHandler(touch_MouseMove);
    private void touch_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//if (this._mouseDown)
//{
this._mouseDown = false;
//}
}
private void touch_MouseLeave(object sender, MouseEventArgs e)
{
//if (this._mouseDown)
//{
this._mouseDown = false;
//}
}
private void touch_MouseMove(object sender, MouseEventArgs e)
{
if (this._mouseDown)
{
_currentPoint = e.GetPosition(this._borderTouch);
//if (_currentPoint == _lastPoint) return;
//_lastPoint = _currentPoint;
}
}
private void touch_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (!this._mouseDown)
{
this._mouseDown = true;
_currentPoint = e.GetPosition(this._borderTouch);
//_lastPoint = _currentPoint;
}
}

操作过程:

1. 点鼠标左键触发touch_MouseLeftButtonDown一次,

2. 然后移动鼠标触发touch_MouseMove(注明:如果鼠标在某点不动,相同坐标只触发一次,然后事件不再触发,如果再移动接触发),

3. 鼠标离开(或者左键松开)触发touch_MouseLeave(touch_MouseLeftButtonUp)一次。

问题:

1. 在我的电脑上对应以上操作过程包括触发事件的次数。

我的电脑配置:

2. 但是在第二个电脑上就不一样,

第2个过程鼠标不动的时候会触发10多次然后就不触发啦(也就是说相同的坐标会触发10多次touch_MouseMove然后不再触发)

第3个过程也是触发10多次,然后停止触发。

第二个电脑配置:

解决:

我想要的当然是我电脑上的正常操作过程,为同步另一台电脑。

我改啦下代码,但是我不知道为什么会有这样的差异。

1. touch_MouseMove   添加判断上一次的坐标和现在的坐标是否相同,如果相同就return
     if (_currentPoint == _lastPoint) return;
_lastPoint = _currentPoint;
2. touch_MouseLeftButtonUp/touch_MouseLeave 添加判断
 if (this._mouseDown)
{
this._mouseDown = false;
}

最新文章

  1. JavaScript(二) DOM
  2. 跨平台的加密算法XXTEA 的封装
  3. jeecms附件标签用法
  4. SQL Server 在线进程分析处理
  5. Android仿微信SlideView聊天列表滑动删除效果
  6. iOS越狱开发手记 - iOS9.3 dyld_decache不能提取arm64的dyld的解决方法
  7. 维护Study
  8. webpack打包编译时,不识别src目录以外的js或css
  9. Exceptionless 本地部署踩坑记录
  10. RGBA 和 opacity的区别
  11. 接口和抽象类的区别(JDK1.8)
  12. ORALCE删除临时表空间的方法---解决ORA01033: oralce initialization or shutdown in progress方案
  13. ORA-12541:TNS:无监听程序
  14. 利用Kettle 从Excel中抽取数据写入SQLite
  15. 开源播放器 ijkplayer (一) :使用Ijkplayer播放直播视频
  16. HTTP接口-跨域-callback
  17. 应对新型“蠕虫”式比特币勒索软件“wannacry”的紧急措施
  18. ie10以上媒体查询 css
  19. 连接数据库-stone
  20. Java机器学习框架deeplearing4j入门教程

热门文章

  1. SQLServer(MSSQL)、MySQL、SQLite、Access相互迁移转换工具 DB2DB v1.3
  2. MVC+EF 理解和实现仓储模式和工作单元模式
  3. 东大OJ-1391-Big big Power
  4. Spring学习进阶(四) Spring JDBC
  5. Yii2 使用小部件 Breadcrumbs
  6. morris的用法
  7. 'hibernate.dialect' must be set when no Connection avalable’
  8. Elasticsearch: Indexing SQL databases. The easy way
  9. react.js 之 批量添加与删除功能
  10. jquery-焦点定位追加内容