翻譯|使用教程|編輯:況魚杰|2019-10-09 11:47:44.050|閱讀 268 次
概述:本文章將會介紹在使用VectorDraw Developer Framework過程中遇到的小問題。例如由于缺少SHX字體,文件打開緩慢;如何獲取要復制或移動的對象等問題的解決辦法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
在使用任何軟件過程中都不可避免的會遇到一些問題,VectorDraw Developer Framework(VDF)也是同樣的,本篇文章就將會解決幾個我們使用過程的小問題。
怎么解決缺少SHX字體,文件打開緩慢的問題?
問:
我在使用過程中,由于缺少SHX字體,文件打開緩慢,這種情況怎么解決?
答:
繪圖使用一些.SHX字體文件作為默認VDF搜索路徑中不存在的vdTextStyles,如果缺少,這會導致這種現象。因為在這些文本樣式中,默認情況下,這些字體文件將替換為Arial TrueType字體,因為Arial的字符過多且Arial的復雜性,這些字符要花費更多的時間來計算其圖形表示形式。
為了加快此速度,繪圖所使用的shx字體文件必須存在于VDF搜索路徑中(例如,在繪圖文件夾中-or-在vdDocument.SupportPath中定義的文件夾中-或- 應用程序的路徑)。
如果沒有這些SHX字體文件,則還可以覆蓋應用程序中的OnNoFileFind事件,以便用始終存在于應用程序路徑中的SHX文件替換未引用的SHX字體文件,如下所示:
//In this example we substitute all unreferenced shx files with txt.shx which must exist in the drawing folder or in the application path. .... doc.OnNoFileFind += new vdDocument.NoFileFindEventHandler(ActiveDocument_OnNoFileFind); // add the event handler bool fontSubstitute = false; // a “public” variable to avoid recursion of event .... void ActiveDocument_OnNoFileFind(object sender, ref string fileName, ref bool success) { //Substitute shx font files with existing txt.shx font file. if (!fontSubstitute && fileName.EndsWith(".shx")) { fontSubstitute = true;//set it to true in order not to have recursion success = doc.FindFile("txt.shx", out fileName); fontSubstitute = false; if (success) return; } doc.Prompt("\r\n Can not find file: " + fileName); doc.Prompt(null); }
如何清除已刪除的布局或塊項目?
問:
如何清除已刪除的布局或塊項目?
答:
在下面,我們創建了兩個不同的示例,說明如何從布局或塊中清除已擦除的項目。
示例1:清除已刪除的活動布局項目。
var tempCol = []; var activelayout = vdcanvas.GetActiveLayout(); for (var k = 0; k < activelayout.Entities.Items.length; k++) { var fig = vdcanvas.GetEntityItem(activelayout.Entities.Items[k]); if (!fig.Deleted) tempCol.push(activelayout.Entities.Items[k]);//If not an item is Deleted we push it in our tempCol } activelayout.Entities.Items = tempCol;//update the active layout entities with the tempCol
示例2:清除塊中已擦除的項目
var tempCol = []; var blk = vdcanvas.AddBlock("myblock");//let's say that the block we want to update is the 'blk' for (var k = 0; k < blk.Entities.Items.length; k++) { var fig = vdcanvas.GetEntityItem(blk.Entities.Items[k]); if (!fig.Deleted) tempCol.push(blk.Entities.Items[k]);//If not an item is Deleted we push it in our tempCol } blk.Entities.Items = tempCol;//update the block entities with the tempCol
如何獲取要復制或移動的對象?
問:
我想在復制/移動動作結束之前獲取要復制或移動的對象的新位置,以便在新位置有效的情況下進行一些計算。如何執行此操作?
答:
當動作為ActionGetTranfromSelection時,可以使用OnActionDraw事件,并使用動作的GetMatrix并檢查諸如以下的對象:
void doc_OnActionDraw(object sender, object action, bool isHideMode, ref bool cancel) { if (action != null && action is VectorDraw.Professional.CommandActions.ActionGetTranfromSelection) { VectorDraw.Professional.CommandActions.ActionGetTranfromSelection trans = action as VectorDraw.Professional.CommandActions.ActionGetTranfromSelection; vdSelection sel = trans.Layout.Document.Selections.FindName("VDRAW_PREVIOUS_SELSET");// sel contains the object that are moved/copied/rotated etc. if (sel == null || sel.Count == 0) return; // this.Text = sel.Count.ToString(); /// for debugging Matrix mat = trans.GetMatrix(); // this is the matrix that is applied to the source object by the action foreach (vdFigure item in sel) { vdFigure tempfig = item.Clone(item.Document) as vdFigure; // get a coly of this object being transformed (copied/moved etc) tempfig.Transformby(mat); // transform this with the action’s GetMatrix // this tempfig is the temporary figure rendered by action copy/move etc // using this tempfig object you can do your calid position check, using bounding box etc } } }
活動激活時如何使用鼠標中鍵進行平移
問:
活動激活時如何使用鼠標中鍵進行平移?
答:
您可以通過使用vdmoudown和vdmouseup事件來執行此操作,因為要這樣做,您必須在要平移時暫停活動操作,然后將其恢復到當前命令。一旦使用鼠標中鍵進行平移,而不是使用左鍵完成命令,就可能發生這種情況。
在下面,您可以看到一個示例:
var vdcanvas = vdmanager.AttachCanvas('canvas'); vdcanvas.vdmousedown = _vdmousedown; //set to the initialize page load vdcanvas.vdmouseup = _vdmouseup; vdcanvas.ActiveAction().PanMouseButton = vdConst.MouseMiddleButton; // set the middle mouse button for panning procedure function _vdmousedown(e) { var code = e.mousebutton; //get the mouse button code if (code === 2)vdcanvas.ActiveAction().Pause(); // middle mouse code is 2 } function _vdmouseup(e) { //resume the action when finishing the panning var code = e.mousebutton; if (code === 2)vdcanvas.ActiveAction().Resume(); }
對于以上問答,如果您有任何的疑惑都可以在評論區留言,我們會及時回復。此系列的問答教程我們會持續更新,如果您感興趣,可以多多關注本教程。
熱門文章推薦:
點擊此處還有VectorDraw Developer Framework的demo示例等著你來體驗哦!
如果您對想要購買正版授權VectorDraw Developer Framework(VDF),可以聯系咨詢相關問題。
關注慧聚IT微信公眾號 ???,了解產品的最新動態及最新資訊。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: