转自IT-GIS终结者原文ArcEngine创建IElement简单例子

代码下载地址:http://files.cnblogs.com/ogis/MapControlApplication2.rar

以下几个函数功能主要是向地图中添加IElement,一共四个函数:

GetColor,CreateSimpleLineSymbol,CreateSimpleFillSymbol,AddCreateElement

功能函数:AddCreateElement

调用例子:

ISymbol pSymbol = AEUtil.CreateSimpleFillSymbol(Color.Red, 100, esriSimpleFillStyle.esriSFSCross);
AEUtil.AddCreateElement(pFeature.ShapeCopy,   m_MapControl.ActiveView, pSymbol, fucosKey);


通过red green blue 三色创建IRgbColor

public static IRgbColor GetColor(int r, int g, int b)
{
RgbColor color = new RgbColor();
color.Red = r;
color.Green = g;
color.Blue = b;
return color;
}

创建简单线Symbol  

输入参数 color-颜色,width-宽度,style-线型,有七种线型可选

esriSLSSolid  
  esriSLSDash  
  esriSLSDot 
  esriSLSDashDot 
  esriSLSDashDotDot  
  esriSLSNull  
  esriSLSInsideFrame

public static ISymbol CreateSimpleLineSymbol(Color color, int width, esriSimpleLineStyle style)
{
ISimpleLineSymbol pSimpleLineSymbol;
pSimpleLineSymbol = new SimpleLineSymbol();
pSimpleLineSymbol.Width = width;
pSimpleLineSymbol.Color = GetColor(color.R, color.G, color.B);
pSimpleLineSymbol.Style = style;
return (ISymbol)pSimpleLineSymbol; }

创建面填充ISymbol对象.   

fillColor-颜色,oLineWidth-外廓线宽,fillStyle-填充类型,有以下可选

esriSFSSolid
esriSFSNull
esriSFSHollow
esriSFSHorizontal
esriSFSVertical
esriSFSForwardDiagonal
esriSFSBackwardDiagonal
esriSFSCross
esriSFSDiagonalCross public static ISymbol CreateSimpleFillSymbol(Color fillColor, int oLineWidth, esriSimpleFillStyle fillStyle)
{
ISimpleFillSymbol pSimpleFillSymbol;
pSimpleFillSymbol = new SimpleFillSymbol();
pSimpleFillSymbol.Style = fillStyle;
pSimpleFillSymbol.Color = GetColor(fillColor.R, fillColor.G, fillColor.B);
pSimpleFillSymbol.Outline = (ILineSymbol)CreateSimpleLineSymbol(fillColor, , esriSimpleLineStyle.esriSLSDash);
return (ISymbol)pSimpleFillSymbol; } // 函数实现向地图中添加元素,pGeometry-元素形状,pActiveView-地图视图,pSymbol-符号,key-元素属性 public static IElement AddCreateElement(IGeometry pGeometry, IActiveView pActiveView, ISymbol pSymbol, string key)
{
try
{
IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;
IElement pElement = null;
ILineElement pLineElement = null;
IFillShapeElement pFillShapeElement = null;
IMarkerElement pMarkerElement = null;
ICircleElement pCircleElement = null;
IElementProperties pElmentProperties = null;
switch (pGeometry.GeometryType)
{ case esriGeometryType.esriGeometryEnvelope:
{
pElement = new RectangleElement();
pElement.Geometry = pGeometry;
pFillShapeElement = (IFillShapeElement)pElement;
pFillShapeElement.Symbol = (IFillSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryPolyline:
{
pElement = new LineElement();
pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement;
pLineElement.Symbol = (ILineSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryLine:
{
pElement = new LineElement();
pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement;
pLineElement.Symbol = (ILineSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryPolygon:
{
pElement = new PolygonElement();
pElement.Geometry = pGeometry;
pFillShapeElement = (IFillShapeElement)pElement; pFillShapeElement.Symbol = (IFillSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryMultipoint:
case esriGeometryType.esriGeometryPoint:
{
pElement = new MarkerElement();
pElement.Geometry = pGeometry; pMarkerElement = (IMarkerElement)pElement; pMarkerElement.Symbol = (IMarkerSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryCircularArc:
{
pElement = new CircleElementClass();
pElement.Geometry = pGeometry; pCircleElement = (ICircleElement)pElement;
break;
}
default:
pElement = null;
break;
} if (pElement != null)
{
pElmentProperties = pElement as IElementProperties;
pElmentProperties.Name = key; pGraphicsContainer.AddElement(pElement, );
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, pGeometry.Envelope);
return pElement;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}

esriSFSSolid

esriSFSNull

esriSFSHollow

esriSFSHorizontal

esriSFSVertical

esriSFSForwardDiagonal

esriSFSBackwardDiagonal

esriSFSCross

esriSFSDiagonalCross

public static ISymbol CreateSimpleFillSymbol(Color fillColor, int oLineWidth, esriSimpleFillStyle fillStyle)

{

ISimpleFillSymbol pSimpleFillSymbol;

pSimpleFillSymbol = new SimpleFillSymbol();

pSimpleFillSymbol.Style = fillStyle;

pSimpleFillSymbol.Color = GetColor(fillColor.R, fillColor.G, fillColor.B);

pSimpleFillSymbol.Outline = (ILineSymbol)CreateSimpleLineSymbol(fillColor, 1, esriSimpleLineStyle.esriSLSDash);

return (ISymbol)pSimpleFillSymbol;

}

函数实现向地图中添加元素,pGeometry-元素形状,pActiveView-地图视图,pSymbol-符号,key-元素属性

public static IRgbColor GetColor(int r, int g, int b)
{
RgbColor color = new RgbColor();
color.Red = r;
color.Green = g;
color.Blue = b;
return color;
} public static IElement AddCreateElement(IGeometry pGeometry, IActiveView pActiveView, ISymbol pSymbol, string key)
{
try
{
IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;
IElement pElement = null;
ILineElement pLineElement = null;
IFillShapeElement pFillShapeElement = null;
IMarkerElement pMarkerElement = null;
ICircleElement pCircleElement = null;
IElementProperties pElmentProperties = null;
switch (pGeometry.GeometryType)
{ case esriGeometryType.esriGeometryEnvelope:
{
pElement = new RectangleElement();
pElement.Geometry = pGeometry;
pFillShapeElement = (IFillShapeElement)pElement;
pFillShapeElement.Symbol = (IFillSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryPolyline:
{
pElement = new LineElement();
pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement;
pLineElement.Symbol = (ILineSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryLine:
{
pElement = new LineElement();
pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement;
pLineElement.Symbol = (ILineSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryPolygon:
{
pElement = new PolygonElement();
pElement.Geometry = pGeometry;
pFillShapeElement = (IFillShapeElement)pElement; pFillShapeElement.Symbol = (IFillSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryMultipoint:
case esriGeometryType.esriGeometryPoint:
{
pElement = new MarkerElement();
pElement.Geometry = pGeometry; pMarkerElement = (IMarkerElement)pElement; pMarkerElement.Symbol = (IMarkerSymbol)pSymbol;
break;
}
case esriGeometryType.esriGeometryCircularArc:
{
pElement = new CircleElementClass();
pElement.Geometry = pGeometry; pCircleElement = (ICircleElement)pElement;
break;
}
default:
pElement = null;
break;
} if (pElement != null)
{
pElmentProperties = pElement as IElementProperties;
pElmentProperties.Name = key; pGraphicsContainer.AddElement(pElement, );
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, pGeometry.Envelope);
return pElement;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}

Normal
0

7.8 磅
0
2

false
false
false

EN-US
ZH-CN
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-font-kerning:1.0pt;}

ArcEngine创建IElement简单例子的更多相关文章

  1. ASP.NET 创建WebService——简单例子

    Web service是一个基于可编程的web的应用程序,用于开发分布式的互操作的应用程序,也是一种web服务 WebService的特性有以下几点: 1.使用XML(标准通用标记语言)来作为数据交互 ...

  2. asp.net mvc项目创建WebApi简单例子

    1.创建默认路由的映射. namespace RedisDemo.App_Start { public class WebApiConfig { public static void Register ...

  3. Hibernate4.2.4入门(一)——环境搭建和简单例子

    一.前言 发下牢骚,这段时间要做项目,又要学框架,搞得都没时间写笔记,但是觉得这知识学过还是要记录下.进入主题了 1.1.Hibernate简介 什么是Hibernate?Hibernate有什么用? ...

  4. 如何创建一个简单的Visual Studio Code扩展

    注:本文提到的代码示例下载地址>How to create a simple extension for VS Code VS Code 是微软推出的一款轻量级的代码编辑器,免费,开源,支持多种 ...

  5. AgileEAS.NET SOA 中间件平台.Net Socket通信框架-简单例子-实现简单的服务端客户端消息应答

    一.AgileEAS.NET SOA中间件Socket/Tcp框架介绍 在文章AgileEAS.NET SOA 中间件平台Socket/Tcp通信框架介绍一文之中我们对AgileEAS.NET SOA ...

  6. 如何创建一个简单的C++同步锁框架(译)

    翻译自codeproject上面的一篇文章,题目是:如何创建一个简单的c++同步锁框架 目录 介绍 背景 临界区 & 互斥 & 信号 临界区 互斥 信号 更多信息 建立锁框架的目的 B ...

  7. mysql定时任务简单例子

    mysql定时任务简单例子 ? 1 2 3 4 5 6 7 8 9     如果要每30秒执行以下语句:   [sql] update userinfo set endtime = now() WHE ...

  8. 最简单例子图解JVM内存分配和回收

    一.简介 JVM采用分代垃圾回收.在JVM的内存空间中把堆空间分为年老代和年轻代.将大量(据说是90%以上)创建了没多久就会消亡的对象存储在年轻代,而年老代中存放生命周期长久的实例对象.年轻代中又被分 ...

  9. CANoe 入门 Step by step系列(三)简单例子的剖析【转】

    最好的学习方式是什么?模仿.有人会问,那不是山寨么?但是我认为,那是模仿的初级阶段,当把别人最好的设计已经融化到自己的血液里,变成自己的东西,而灵活运用的时候,才是真正高级阶段.正所谓画虎画皮难画骨. ...

随机推荐

  1. SpringCloud核心教程 | 第一篇: 使用Intellij中的Spring Initializr来快速构建Spring Cloud工程

    spring cloud简介 spring cloud 为开发人员提供了快速构建分布式系统的一些工具,包括配置管理.服务发现.断路器.路由.微代理.事件总线.全局锁.决策竞选.分布式会话等等.它运行环 ...

  2. 关于MyBatis sqlSession的一点整理

    工作中,需要学习一下MyBatis sqlSession的产生过程,翻看了mybatis-spring的源码,阅读了一些mybatis的相关doc,对mybatis sqlSession有了一些认知和 ...

  3. Elasticsearch入门系列~通过Java一系列操作Elasticsearch

    Elasticsearch索引的创建.数据的增删该查操作 上一章节已经在Linux系统上安装Elasticsearch并且可以外网访问,这节主要通过Java代码操作Elasticsearch 1.创建 ...

  4. 洛谷 P1893 山峰暸望

    P1893 山峰暸望 题目描述 一天,Bessie在眺望美丽的威斯康星的群山的时候,她突然产生了疑问:那座山是最宽的? 她决定在地平线上,利用她的新式大量程山峰高度测量仪依次做N (1 <= N ...

  5. 看好腾讯,鄙视百度(腾讯的核心竞争力,不是超过10亿的QQ的注册用户,也不是某一项产品、技术方面优势,而是“耐心”:懂得在合适的时间推出合适的产品。”)

    百度,自始至终只是一个低劣的模仿者,且一切向前看,完全违背了一个搜索引擎所应该遵循的基本原则.谁给的钱多就能搜着谁,这跟贩毒有什么区别? 腾讯也在模仿别人,但是,它是模仿然后超越.在中国互联网发展历史 ...

  6. v-for一定要与v-bind:key="id"连用

    1. v-for: <div v-for="(item,index) in todolist" v-bind:key="item.id"> < ...

  7. python3 分解质因数

    python3 分解质因数 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wan num = int(input(&quo ...

  8. postman--基本使用1

    本文转自:http://blog.csdn.net/five3/article/details/53021084 HTTP的接口测试工具有很多,可以进行http请求的方式也有很多,但是可以直接拿来就用 ...

  9. .NetCore微服务Surging新手傻瓜式 入门教程 学习日志---结构简介(二)

    原文:.NetCore微服务Surging新手傻瓜式 入门教程 学习日志---结构简介(二) 先上项目解决方案图: 以上可以看出项目结构可以划分为4大块,1是surging的核心底层,2,3,4都可以 ...

  10. 翻翻git之---闪烁动画的TextView RevealTextView

    转载请注明出处:王亟亟的大牛之路 今天没有P1啦!. 对换工作有想法的.能够找昨天的P1.哈哈 地址:http://blog.csdn.net/ddwhan0123/article/details/5 ...