原創(chuàng)|使用教程|編輯:龔雪|2013-11-15 10:01:44.000|閱讀 442 次
概述:在上一文《矢量圖控件VectorDraw使用教程:添加vdFramedControl (Visual C# 2005)》中,我們介紹了如何將VDF vdFramedControl控件添加到VS2005中。接下來(lái),我們將在VS中演示一些更為復(fù)雜的例子。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
在上一文《矢量圖控件VectorDraw使用教程:添加vdFramedControl (Visual C# 2005)》中,我們介紹了如何將VDF vdFramedControl控件添加到VS2005中。接下來(lái),我們將在VS中演示一些更為復(fù)雜的例子。
ActionUtility對(duì)象可用于詢(xún)問(wèn)客戶(hù)是否需要在程序中輸入一個(gè)點(diǎn)、矩形或者距離等數(shù)據(jù)。如何用戶(hù)需要數(shù)據(jù)一個(gè)點(diǎn),你可以調(diào)用下列代碼:
gPoint userpoint; vdFC.BaseControl.ActiveDocument.Prompt("Select a Point:"); //The user can either click a point or type at the command line a point like 5,5,2 StatusCode ret = vdFC.BaseControl.ActiveDocument.ActionUtility.getUserPoint(out userpoint); vdFC.BaseControl.ActiveDocument.Prompt(null); if (ret == StatusCode.Success){ MessageBox.Show("The user selected: x:" + userpoint.x.ToString() + " y:" + userpoint.y.ToString() + " z:" + userpoint.z.ToString() + " In UCS(user coordinate system)"); }
也可以對(duì)上述代碼做一些修改,在輸入一個(gè)點(diǎn),從而創(chuàng)建一個(gè)矩形,代碼如下:
vdFC.BaseControl.ActiveDocument.New(); gPoint userpoint; vdFC.BaseControl.ActiveDocument.Prompt("Select a Point:"); //The user can either click a point or type at the command line a point like 5,5,2 StatusCode ret = vdFC.BaseControl.ActiveDocument.ActionUtility.getUserPoint(out userpoint); vdFC.BaseControl.ActiveDocument.Prompt(null); if (ret == StatusCode.Success){ MessageBox.Show("The user selected: x:" + userpoint.x.ToString() + " y:" + userpoint.y.ToString() + " z:" + userpoint.z.ToString() + " In UCS(user coordinate system)"); } vdFC.BaseControl.ActiveDocument.Prompt("Other corner:"); //The user can either click a point or type at the command line a point like 5,5,2 object ret2 = vdFC.BaseControl.ActiveDocument.ActionUtility.getUserRect(userpoint); vdFC.BaseControl.ActiveDocument.Prompt(null); Vector v = ret2 as Vector; if (v != null) { double angle = v.x; double width = v.y; double height = v.z; //Calculate the point the user clicked. //Use polar command to find the bottom right point moving width distance from the initial point. gPoint userpoint2 = userpoint.Polar(0.0, width); //Use the polar again to go up height distance to find the upper right point. userpoint2 = userpoint2.Polar(VectorDraw.Geometry.Globals.HALF_PI, height); MessageBox.Show("The user selected 2nd point : x:" + userpoint2.x.ToString() + " y:" + userpoint2.y.ToString() + " z:" + userpoint2.z.ToString() + " In UCS(user coordinate system)"); vdFC.BaseControl.ActiveDocument.CommandAction.CmdRect(userpoint, userpoint2); }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)