通过在新建的窗体中的RadioButton来实现在MapControl上画出矢量图形,用到接口有ICommand,ITool。
用到的方法有TrackPolyLine(),TrackPolygon(),MapToPoint(),三个方法建立矢量要素,通过IElement接口创建的对象的Geometry属性接收IGeometry接口定义的,通过IElement接口的element类型对象,AddElement方法添加到MapControl的属性GraphicsContainer中并且通过axMapControl对象刷新MapControl窗口。
最后通过ISimpleMarkerSymbol接口设置对象的RGB值,将该对象给予IElement对象,实现矢量要素的symbol更改。

建立步骤及代码如下


1、新建createfeature类
添加引用

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.ADF;

定义全局变量

IMapControlDefault mapp;

实例窗体

createfeatureform fr = new createfeatureform();

实现ICommand接口,ITool接口,在如下位置添加对应代码

public void OnClick(){fr.Show();}public void OnCreate(object Hook){mapp = Hook as IMapControlDefault;}public void OnMouseDown(int button, int shift, int x, int y){//GraphicsContainer添加数据须添加IElement类型的Objectif(fr.radioButton1.Checked){IGeometry point = mapp.ToMapPoint(x, y);IElement pelement = new MarkerElementClass();pelement.Geometry = point;ISimpleMarkerSymbol psims = new SimpleMarkerSymbolClass();psims.Style = esriSimpleMarkerStyle.esriSMSCircle;psims.Size = 5;IRgbColor prgb = new RgbColorClass();prgb.Blue = 255;prgb.Red = 0;prgb.Green = 0;psims.Color = prgb;(pelement as IMarkerElement).Symbol = psims;mapp.ActiveView.GraphicsContainer.AddElement(pelement,0);}if (fr.radioButton2.Checked){IGeometry line = mapp.TrackLine();IElement pelement = new LineElementClass();pelement.Geometry = line;mapp.ActiveView.GraphicsContainer.AddElement(pelement, 0);}if (fr.radioButton3.Checked){IGeometry polygon = mapp.TrackPolygon();IElement pelement = new PolygonElementClass();pelement.Geometry = polygon;mapp.ActiveView.GraphicsContainer.AddElement(pelement, 0);}if (fr.radioButton4.Checked){IGeometry ptext = mapp.ToMapPoint(x, y);IElement pelement = new TextElementClass();(pelement as ITextElement).Text = fr.textBox1.Text;pelement.Geometry = ptext;mapp.ActiveView.GraphicsContainer.AddElement(pelement, 0);}mapp.ActiveView.Refresh();}

2、新建窗体,布局如图所示:


3、主窗口TooltripButton事件代码如下

 private void toolStripButton1_Click(object sender, EventArgs e){ICommand createfeature = new createfeature();createfeature.OnCreate(axMapControl1.Object);createfeature.OnClick();ITool ptool = createfeature as ITool;axMapControl1.CurrentTool = ptool;}

ArcGISEngine二次开发(5):添加矢量要素相关推荐

  1. 基于ZFAKA二次开发,添加PayJS支付渠道

    基于ZFAKA二次开发,添加PayJS支付渠道 项目地址:https://github.com/hiyouli/payjs-for-zfaka 关于ZFAKA,请移步:ZFAKA 免费.安全.稳定.高 ...

  2. QGIS二次开发地图添加标记添加注记Svg小图标SvgItem

    QGIS二次开发地图添加标记添加注记Svg小图标 即QgsAnnotationLayer.QgsMarkerSymbol和QgsAnnotationMarkerItem的用法,我把QGIS3.20软件 ...

  3. UG二次开发GRIP添加属性

    组件 或 零件 添加属性 entity/COMP,ent string/std(2,132),str(4,132),mold(132) string/add(2,132) entity/obj STR ...

  4. 【CAD二次开发】添加cad支持文件夹

    我们有时候自己的模板需要用到指定的字体,我们可以把字体放到插件的安装目录里,通过添加支持路径的方式来实现添加CAD字体. //添加自定义字体搜索目录string filePath = Assembly ...

  5. ArcGISEngine二次开发(4):属性查询(2)

    属性查询(2) 使用IGeometry接口TrackPolygon方法建立对象实现属性查询 使用ISpatialFilter接口SpatialRel属性定义Intersects取交集为查询对象 之后将 ...

  6. Mission Planner 二次开发之添加海康威视摄像机

    需求 需要在无人艇上添加海康威视的实时摄像头. 本地IP192.168.0.100 摄像头IP 192.168.0.64 用户名admin 密码nanfoon51077533 端口8000 海康配置可 ...

  7. 【Revit二次开发】添加菜单和按钮

    添加菜单和按钮 Ribbon菜单 Ribbon菜单的创建以及各种不同的button Ribbon菜单 这个类是PushButton和PulldownButton的基类. 按钮放在panel内,pane ...

  8. UG二次开发GRIP添加加工工序

    注 我不是原创,转载的 ENTITY/OBJ(25),SURF1(5000),cbnd(90),BEID ENTITY/surf2(5000)NUMBER/NUM L00: PARAM/'请您输入料厚 ...

  9. UG/NX10二次开发学习视频目录整理(NXOPEN基础篇)

    为了方便搜索需要的视频资料,整理了唐康林老师发布在B站的视频目录,支持全局目录搜索,点击直达视频. NX10二次开发(NXOPEN基础篇) P1第07章-01-NX10二次开发之与用户界面的结合运用[ ...

  10. CAD二次开发-MFC对话框domal显示错误

    问题:CAD二次开发时添加MFC对话框后显示错误,显示为多重引线样式管理器. 解决:在对话框之前需要使用AfxGetResourceHandle和AfxSetResourceHandle进行模块资源切 ...

最新文章

  1. 几个重要的RedHat Linux内核文件介绍 (1)
  2. 开源大数据:Apache Pulsar
  3. 如何使柱状图左右展示_关于微生物门类堆叠柱状图,你知道的并不够
  4. 不要相信程序员在加班时间写的代码
  5. Shell 脚本 ssh免密码 登录 远程服务器 sshpass用法示例
  6. Linux下的基本操作
  7. 外贸软件常见图片类问题丨汇信
  8. 贵州省相关GIS公司或单位
  9. 如何管理一盘散沙的团队?
  10. 浅谈云原生的“前世今生”
  11. 随机梯度下降(SGD)
  12. .net世界 最好的东西!! 你拥有几个 ——转贴
  13. planetb word中格式调整
  14. 微信公众号代运营公司哪家好?
  15. oracle.简单查询、排序、限定查询、单行函数
  16. python文本编辑器下载_python文本编辑器下载-TextPad下载v 8.2.0最新免费版-西西软件下载...
  17. nrf51822资料
  18. The Innovation | 粪菌移植治疗肥胖,如何突破瓶颈?
  19. 白月黑羽教程小收获记录-python基础
  20. jdbc之操作BLOB类型字段

热门文章

  1. (day 12 - 双指针)剑指 Offer 22. 链表中倒数第k个节点
  2. vue中的组件 (全局注册和本地注册组件)
  3. linux根目录9个g,linux根目录下5个主要的目录,及目录的功能
  4. django 轮播图上传_拼多多规则更新:关于【商品轮播图】你所不知道的秘密!...
  5. java ajax分页_使用Jquery+Ajax+Json如何实现分页显示附JAVA+JQuery实现异步分页
  6. cpu与简单模型机设计实验_180套经典夹具设计方案(附详解+模型),原来夹具设计这么简单!...
  7. python同时执行多个py文件_【经验分享】如何同时运行多个python脚本
  8. 13. Django基础:admin后台管理
  9. LIO-SAM探秘之文章索引
  10. Network in Network 算法解析