ArcEngine创建IElement简单例子
转自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简单例子的更多相关文章
- ASP.NET 创建WebService——简单例子
Web service是一个基于可编程的web的应用程序,用于开发分布式的互操作的应用程序,也是一种web服务 WebService的特性有以下几点: 1.使用XML(标准通用标记语言)来作为数据交互 ...
- asp.net mvc项目创建WebApi简单例子
1.创建默认路由的映射. namespace RedisDemo.App_Start { public class WebApiConfig { public static void Register ...
- Hibernate4.2.4入门(一)——环境搭建和简单例子
一.前言 发下牢骚,这段时间要做项目,又要学框架,搞得都没时间写笔记,但是觉得这知识学过还是要记录下.进入主题了 1.1.Hibernate简介 什么是Hibernate?Hibernate有什么用? ...
- 如何创建一个简单的Visual Studio Code扩展
注:本文提到的代码示例下载地址>How to create a simple extension for VS Code VS Code 是微软推出的一款轻量级的代码编辑器,免费,开源,支持多种 ...
- AgileEAS.NET SOA 中间件平台.Net Socket通信框架-简单例子-实现简单的服务端客户端消息应答
一.AgileEAS.NET SOA中间件Socket/Tcp框架介绍 在文章AgileEAS.NET SOA 中间件平台Socket/Tcp通信框架介绍一文之中我们对AgileEAS.NET SOA ...
- 如何创建一个简单的C++同步锁框架(译)
翻译自codeproject上面的一篇文章,题目是:如何创建一个简单的c++同步锁框架 目录 介绍 背景 临界区 & 互斥 & 信号 临界区 互斥 信号 更多信息 建立锁框架的目的 B ...
- mysql定时任务简单例子
mysql定时任务简单例子 ? 1 2 3 4 5 6 7 8 9 如果要每30秒执行以下语句: [sql] update userinfo set endtime = now() WHE ...
- 最简单例子图解JVM内存分配和回收
一.简介 JVM采用分代垃圾回收.在JVM的内存空间中把堆空间分为年老代和年轻代.将大量(据说是90%以上)创建了没多久就会消亡的对象存储在年轻代,而年老代中存放生命周期长久的实例对象.年轻代中又被分 ...
- CANoe 入门 Step by step系列(三)简单例子的剖析【转】
最好的学习方式是什么?模仿.有人会问,那不是山寨么?但是我认为,那是模仿的初级阶段,当把别人最好的设计已经融化到自己的血液里,变成自己的东西,而灵活运用的时候,才是真正高级阶段.正所谓画虎画皮难画骨. ...
随机推荐
- golang 逐行读取文件
package main import ( "bufio" "fmt" "io" "os" ) func main() ...
- CF1009F Dominant Indices(树上DSU/长链剖分)
题目大意: 就是给你一棵以1为根的树,询问每一个节点的子树内节点数最多的深度(相对于这个子树根而言)若有多解,输出最小的. 解题思路: 这道题用树链剖分,两种思路: 1.树上DSU 首先想一下最暴力的 ...
- 巧用数据流让 Word 文档在线阅读
常常写博客或空间日记的朋友,对网络编辑器(如图1,是CSDN的博客编辑器)并不陌生.也比較easy做出非常绚烂的排版.但这次在做一个BS的项目,客户一直在用Office的软件中的Wor ...
- 第6章4节《MonkeyRunner源代码剖析》Monkey原理分析-事件源-事件源概览-翻译命令字串
在第2节中我们看到了MonkeySourceNetwork是怎样从Socket中获取MonkeyRunner发送过来的命令字串的,可是最后怎样将它翻译成事件的代码我们还没有进行分析,由于在那之前我们还 ...
- A glance on VDBI
Just like other thing in data transfter, a resource should have themselves description. And the reso ...
- WINWORD.EXE-损坏的图像
问题详情: 系统键 + R键,运行 再输入regedit HKEY_CLASSES_ROOT\.docx HKEY_CLASSES_ROOT\Word.Document.12 HKEY_CURREN ...
- JQuery滑动到指定位置
$('html, body').animate({ scrollTop: next_tip.offset().top + "px"},500);
- vue 自定义分页组件
vue2.5自定义分页组件,可设置每页显示条数,带跳转框直接跳转到相应页面 Pagination.vue 效果如下图: all: small(只显示数字和上一页和下一页): html <temp ...
- 【hihocoder 1564】同步H公司的终端
[链接]http://hihocoder.com/problemset/problem/1564 [题意] 在这里写题意 [题解] 如下图 (上图中节点旁边的红色数字为它的权值) 从叶子节点开始考虑. ...
- js进阶 14-1 jquery的ajax系列中的load方法的作用是什么
js进阶 14-1 jquery的ajax系列中的load方法的作用是什么 一.总结 一句话总结:jQuery load()方法作用是从服务器加载数据,是一个简单但强大的AJAX方法. 1.load函 ...