翻譯|使用教程|編輯:況魚杰|2019-12-09 09:32:21.873|閱讀 233 次
概述:本系列教程整理了VectorDraw Developer Framework(VDF)最常見問題,教程整理的很齊全,非常適合新手學習。本文將會展示如何在多視圖布局中獲取活動視口的屏幕坐標。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
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:\test\mv.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("\r\n ---- Active Viewport in Screen pixels, ------"); doc.Prompt(null); doc.Prompt("\r\n UpperLeft point: " + onScreen.Location.ToString()); doc.Prompt(null); doc.Prompt("\r\n LowerRight point: X=" + (onScreen.X + onScreen.Width).ToString() + " , Y=" + (onScreen.Y + onScreen.Height).ToString()); doc.Prompt(null); }
請檢查此代碼中的注釋,以了解其計算方式并根據您的需要定制此代碼。還請檢查vdf.chm幫助文件以及這些方法/屬性的主題,以了解其用法。
以上問答,如果您有任何的疑惑都可以在評論區留言,我們會及時回復。此系列的問答教程我們會持續更新,如果您感興趣,可以多多關注本教程。
熱門文章推薦:
如果您對想要購買正版授權VectorDraw Developer Framework(VDF),可以聯系咨詢相關問題。
關注慧聚IT微信公眾號 ???,了解產品的最新動態及最新資訊。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: