原創(chuàng)|使用教程|編輯:龔雪|2013-11-15 10:01:44.000|閱讀 442 次
概述:在上一文《矢量圖控件VectorDraw使用教程:添加vdFramedControl (Visual C# 2005)》中,我們介紹了如何將VDF vdFramedControl控件添加到VS2005中。接下來,我們將在VS中演示一些更為復雜的例子。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在上一文《矢量圖控件VectorDraw使用教程:添加vdFramedControl (Visual C# 2005)》中,我們介紹了如何將VDF vdFramedControl控件添加到VS2005中。接下來,我們將在VS中演示一些更為復雜的例子。
ActionUtility對象可用于詢問客戶是否需要在程序中輸入一個點、矩形或者距離等數(shù)據(jù)。如何用戶需要數(shù)據(jù)一個點,你可以調用下列代碼:
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)"); }
也可以對上述代碼做一些修改,在輸入一個點,從而創(chuàng)建一個矩形,代碼如下:
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); }
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網(wǎng)