c#添加事件,以xtraTabPage控件添加MouseWheel事件为例,实现图像的放大缩小
来源:互联网 发布:数据库系统概念第六版 编辑:程序博客网 时间:2024/05/24 05:03
参考文章:http://blog.csdn.net/dszgf5717/article/details/12997163#
要在控件xtraTabPage上实现用鼠标滚轮控制图像大小的功能,则需要添加MouseWheel事件,而xtraTabPage控件中没有自带这个事件,所以需要手动添加这个实现来实现功能,两步完成。
1、在xxx.Designer.cs文件中的InitializeComponent()函数里添加添加事件代码。
this.xtraTabPage3.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.xtraTabPage3_MouseWheel);
2、在xxx.cs文件中添加事件实现函数。
private void xtraTabPage3_MouseWheel(object sender, MouseEventArgs e) { base.OnMouseWheel(e); Matrix4D oldTo2DTransform = CalculateTo2DTransform1(); int compare = Math.Sign(e.Delta); // wheel movement is forward if (compare > 0) { scaleFactor *= 1.1d; } // wheel movement is backward else if (compare < 0) { scaleFactor /= 1.1d; } // --- Begin of correction on the translation to zoom into mouse position. // Comment out this section to zoom into center of model. Point3D currentScreenPoint = new Point3D(e.X, e.Y, 0d); Point3D modelPoint = oldTo2DTransform.GetInverse().Transform(currentScreenPoint); Matrix4D intermediateTo2DTransform = CalculateTo2DTransform1(); Point3D screenPoint = intermediateTo2DTransform.Transform(modelPoint); translation += (currentScreenPoint - screenPoint); // --- End of translation correction. CalculateTo2DTransform1(); this.xtraTabPage3.Invalidate(); }
0 0
- c#添加事件,以xtraTabPage控件添加MouseWheel事件为例,实现图像的放大缩小
- 为控件添加事件
- 为C#自定义控件添加自定义事件
- 为C#自定义控件添加自定义事件
- c# web 为自定义控件添加事件
- 为C#自定义控件添加自定义事件
- c#为chart控件添加MouseMove事件
- C# 中手动添加Mousewheel鼠标滚轮事件
- C#为控件动态添加事件绑定的时机
- 为控件动态添加事件
- c# 用户控件添加事件
- C#为控件添加拖拽文件事件
- 为printPreviewControl添加mousewheel的处理
- C# 中panel的mousewheel事件触发
- C# panel的mousewheel事件触发
- C#之WinForm基础 在哪里为控件添加新的触发事件
- MKMapView放大缩小事件
- 浏览器放大缩小事件
- 在MAC平台下使用Eclipse出现了中文乱码
- 微信小程序-scroll-view滚动到指定位置(一)
- 3DGIS第二章 大数据量场景加速绘制基本原理与方法
- Mac Command line
- HDU 1847 Good Luck in CET-4 Everybody!(博弈sg函数)
- c#添加事件,以xtraTabPage控件添加MouseWheel事件为例,实现图像的放大缩小
- OpenCart 常见错误解决
- 3DGIS第三章 约束条件下二次误差度量简化方法
- ip地址的几种处理方式
- Camera Calibration and 3D Reconstruction(opencv 2.4)
- LintCode(M)带min函数的栈
- 跨域CORS原理及调用具体示例
- 百度API接口开发,创建标注和Label标签。
- iOS -- 网络请求到的数据,中文出现乱码!!!