翻譯|使用教程|編輯:況魚杰|2019-11-06 10:34:57.647|閱讀 260 次
概述:本系列教程整理了VectorDraw Developer Framework(VDF)最常見問題,教程整理的很齊全,非常適合新手學習。本文將會介紹如何選定實體的用戶操作。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
問:
如何選定實體的用戶操作?
答:
為了選擇許多圖形并對其進行處理,請參見以下代碼:
//Set the section window colors.It is not important but help the user for selecting.
vdcanvas.SetActionFillColor(new Array(0, 0, 255, 100));// fill color for simple window select, from left to right
// ( select only entities completely inside rectangle).
vdcanvas.SetActionCrossFillColor(new Array(0, 255, 0, 100));//fill color for crossing window select ,from right to left
// (select entities that are inside or intersect rectangle).
//begin a selection action
//If a user pick to a point with no entity a new window select will open
//continue add entities until command cancel by right click
// -or-
// a vdcanvas.ActiveAction.cancel(); method is called by your application
//Selected entities are drawn with Red color
//cmdselectCallback a callback function that is fire when the selection is successfully finished.
vdcanvas.CmdSelect(_cmdselectCallback);
//Is fired when selection successfully finished
function _cmdselectCallback(action) {
//enum all selected entities
if (!action.customData || action.customData.length == 0) return;
for (var k = 0; k < action.customData.length; k++) {
var fig = action.customData[k];//get the selected figure
//do something with figure like hightlight it
fig.HighLight = true;
}
action.vdrawOwner().redraw();
}
In order select a single figure see following code:
vdcanvas.PickSize = 8;// 8 pixel wide
vdcanvas.GetUserPoint(_onActionPointIdStateChanged); // prompts the user to pick a point on the control and fire the
// _onActionPointIdStateChanged when the action finsh or cancel
function _onActionPointIdStateChanged(action, status) {
var vdcanvas = action.vdrawOwner();
if (status == 'start') {
vdcanvas.Prompt('pick a point');
} else if (status == 'end') {
if (!action.IsCanceled()) {
//vdcanvas.Prompt('X= ' + action.ResValue[X].toString() + ' Y= ' + action.ResValue[Y].toString());
var p1 = vdcanvas.WorldToPixel(action.ResValue); //transorm the passed action point from world to pixel
var fig = vdcanvas.GetEntityFromPoint(p1[X], p1[Y]); //get the last drawn entity passing throw a pick box
//with center the p1 and size define by vdcanvas.PickSize
if (fig) {
//do somthing with selected figure
//for example mark as highlight and re-draw it
fig.HighLight = true;
//redraw a single entity procedure
vdcanvas.UpdateFig(fig);
vdcanvas.DrawEntity(fig);
vdcanvas.Refresh();
vdcanvas.Prompt(String(fig.HandleId) + " selected");//display the selected figure handle
}
} else {
vdcanvas.Prompt('');
}
}
} 對于以上問答,如果您有任何的疑惑都可以在評論區留言,我們會及時回復。此系列的問答教程我們會持續更新,如果您感興趣,可以多多關注本教程。
熱門文章推薦:
如果您對想要購買正版授權VectorDraw Developer Framework(VDF),可以聯系咨詢相關問題。
關注慧聚IT微信公眾號 ???,了解產品的最新動態及最新資訊。

本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自: