VectorDraw Developer Framework试用版下载
问:
如何获取vdLayoutSplit的活动视口左下角和右上角的显示坐标(像素)。我想在文档的鼠标按下事件下检查鼠标位置是否在活动视口内。
答:
使用包含四个视口的LayoutSplit的图形(mv.vdcl)尝试以下代码:
private void button1_Click(object sender, EventArgs e){ vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument; doc.New(); doc.Open(@"c:testmv.vdcl");// load a drawing that contains multiviews doc.ActiveLayOut = doc.LayOuts.FindName("Four_Left"); // set the active layout doc.Redraw(true); doc.ActiveLayOut.ActiveViewPort = doc.ActiveLayOut.Entities[1] as vdViewport; //set the activeViewport vdViewport vLeft = doc.ActiveLayOut.ActiveViewPort; // for this viewport we will get its coordinates in screen pixels Box bbox = vLeft.BoundingBox; // in World Coordinate System gPoint LR = bbox.LowerRight; // in World CS gPoint UL = bbox.UpperLeft;// in World CS Matrix matView2Pixel = doc.ActiveLayOut.Pixel2ViewMatrix.GetInvertion(); Matrix matWorld2View=doc.ActiveLayOut.World2ViewMatrix; UL = matWorld2View.Transform(UL); // from World CS to View CS UL = matView2Pixel.Transform(UL); // From View CS to Pixels LR = matWorld2View.Transform(LR); // from World CS to View CS LR = matView2Pixel.Transform(LR); // From View CS to Pixels Rectangle rc = new Rectangle(new Point((int)UL.x,(int)UL.y),new Size((int)(LR.x-UL.x),(int)(LR.y-UL.y)));// this is the viewport rectangle Rectangle onScreen = vdFramedControl1.BaseControl.RectangleToScreen(rc); // from VDF control's pixels to screen pixels // here you get the Upper/left point in screen pixels (onScreen.Location) // and the lower-right point like OnScreen.X+OnScreen.Width , OnScreen.Y+onScreen.Height // Display the results: doc.Prompt("rn ---- Active Viewport in Screen pixels, ------"); doc.Prompt(null); doc.Prompt("rn UpperLeft point: " + onScreen.Location.ToString()); doc.Prompt(null); doc.Prompt("rn LowerRight point: X=" + (onScreen.X + onScreen.Width).ToString() + " , Y=" + (onScreen.Y + onScreen.Height).ToString()); doc.Prompt(null);}
请检查此代码中的注释,以了解其计算方式并根据您的需要定制此代码。还请检查vdf.chm帮助文件以及这些方法/属性的主题,以了解其用法。
以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
-
如何排除GroundSurface对象的三角形区域/strong>
-
复杂自定义对象的入门指南
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!