VDF常见问题整理(四十九):VDF的鼠标滚轮控制

本系列教程整理了VectorDraw Developer Framework(VDF)最常见问题,教程整理的很齐全,非常适合新手学习。本文将会展示如何实现禁用鼠标平移以及鼠标滚轮缩放。

VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。该库还支持许多矢量和栅格输入和输出格式,包括本地PDF和SVG导出。

点击立即下载VectorDraw Developer Framework


问:

请问是否可以实现禁用鼠标平移以及鼠标滚轮缩放。在禁用滚轮同时,还想要控制图形的水平和垂直滚动。怎样才能做到这一点/span>

答:

禁用鼠标中键平移和鼠标滚轮放大/缩小:

对于包装器,我们必须获取如下的vdDocument对象。

VectorDraw.Professional.vdObjects.vdDocument doc = vd.ActiveDocument.WrapperObject as VectorDraw.Professional.vdObjects.vdDocument;doc.MouseWheelZoomScale = 1.0; 

1.0表示禁用了鼠标滚轮。 0.8(小于1.0)或1.2(大于1.0)值可以反转鼠标滚轮功能。
为了禁用平移,您必须使用JobStart事件,如下所示。

vd.JobStart += new AxVDrawLib5._DVdrawEvents_JobStartEventHandler(vd_JobStart);void vd_JobStart(object sender, AxVDrawLib5._DVdrawEvents_JobStartEvent e){if (e.jobName == "BaseAction_ActionPan") e.cancel = 1;}

要滚动视图,请使用如下代码

  ... // these events must be used            doc.MouseWheelZoomScale = 1.0d; // disable mouse wheel zoom                doc.ActionStart += new vdDocument.ActionStartEventHandler(doc_ActionStart);            vdFramedControl1.BaseControl.MouseWheel += new MouseEventHandler(BaseControl_MouseWheel);        ...        void BaseControl_MouseWheel(object sender, MouseEventArgs e)        {            if ((e != null) && (e.Delta != 0))            {                vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument;                double height = doc.ActiveRender.Height * doc.ActiveRender.PixelSize;                double width = doc.ActiveRender.Width * doc.ActiveRender.PixelSize;                double stepY = height * (e.Delta / Math.Abs(e.Delta)) / 10.0d;                double stepX = width * (-1.0d * e.Delta / Math.Abs(e.Delta)) / 10.0d;                if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)                { // if Shift key is pressed scroll horizontally                    doc.ScrollActiveActionRenderView(stepX, 0.0d, true); // scroll only in dX                }                else //else scroll vertically                {                    doc.ScrollActiveActionRenderView(0.0d, stepY, true); // scroll only in dY                }            }        }        void doc_ActionStart(object sender, string actionName, ref bool cancel)        {            if (actionName == "BaseAction_ActionPan") cancel = true; // cancel middle mouse button pan        }        

以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。

热门文章推荐:

  • 如何排除GroundSurface对象的三角形区域/strong>

  • 复杂自定义对象的入门指南

=======================================================

如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。

关注慧聚IT微信公众号 了解产品的最新动态及最新资讯。

标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年1月1日
下一篇 2020年1月1日

相关推荐

发表回复

登录后才能评论