博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
矢量图控件VectorDraw使用教程:ActionUtility对象
阅读量:2352 次
发布时间:2019-05-10

本文共 2193 字,大约阅读时间需要 7 分钟。

在上一文中,我们介绍了如何将VDF vdFramedControl控件添加到VS2005中。接下来,我们将在VS中演示一些更为复杂的例子。

ActionUtility对象可用于询问客户是否需要在程序中输入一个点、矩形或者距离等数据。如何用户需要数据一个点,你可以调用下列代码:

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.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);
}

转载地址:http://bvqvb.baihongyu.com/

你可能感兴趣的文章
Centos 系统时间与当前时间相差和时区解决办法
查看>>
Linux下如何进行FTP设置
查看>>
linux之LVM操作案例
查看>>
由于CentOS的系统安装了epel-release-latest-7.noarch.rpm 导致在使用yum命令时出现Error: xz compression not available问题。
查看>>
php中抽象类和接口的概念与区别
查看>>
php抽象类和接口
查看>>
如何在linux CentOS 上安装chrome 谷歌浏览器
查看>>
laravel5 怎么实现事务
查看>>
GitLab安装说明
查看>>
Git查看、删除、重命名远程分支和tag
查看>>
PHP类中的抽象类,抽象方法,abstract
查看>>
PHP接口类interface的正确使用方法
查看>>
Sencha Touch之Hello World
查看>>
Tab Layout 之单个Activity实现
查看>>
Tab Layout 之多个Activity实现
查看>>
FrameLayout之我见
查看>>
个人解读Activity之一
查看>>
实现自定义布局的Notification
查看>>
AlarmManager的学习与实现
查看>>
解读Content Provider之一
查看>>