笔记:C# Halcon之HSmartWindowControl:鼠标定点缩放、Region操作、比例显示

开始

以前用的是HWindowControl控件,显示的平移缩放都是自己处理。听说过HSmartWindowControl控件,有空看了一下,觉得比HWindowControl简单,而且AttachDrawingObjectToWindow功能不错,halcon自己维护了HDrawingObject对象,可以用鼠标移动和调整不需要写代码重绘,省心。

一,鼠标定点缩放

1,在Form上加入HSmartWindowControl控件

2,手动加上Form的滚轮处理

public Form1()
{
	...
   	MouseWheel += Form1_MouseWheel;
  	 ...
}
//
public void Form1_MouseWheel(object sender, MouseEventArgs e)
{
	//HSmartWindowControl控件的区域
    Rectangle rect = hSmartWindowControl1.RectangleToScreen(hSmartWindowControl1.ClientRectangle);
    //滚动时,鼠标悬停在在HSmartWindowControl控件上
    if (rect.Contains(Cursor.Position))
    {
    	//缩放
        hSmartWindowControl1.HSmartWindowControl_MouseWheel(sender, e);
    }
}
//显示原图
private void buttonRefresh_Click(object sender, EventArgs {
    if (image != null)
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值