第二章 使用ArcGIS Engine控件编程
来源:互联网 发布:java动态注入方法 编辑:程序博客网 时间:2024/06/05 08:49
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Display;namespace EngineWindowsApplication2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } int flag = 0; private void Form1_Load(object sender, EventArgs e) { IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory(); IWorkspace pWorkSpace = pWorkspaceFactory.OpenFromFile(Application.StartupPath+"\\实验一数据",0); IFeatureWorkspace pFeatureWorkspace= pWorkSpace as IFeatureWorkspace; IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass("塔林林场"); IFeatureLayer pFeatureLayer=new FeatureLayerClass(); pFeatureLayer.FeatureClass = pFeatureClass; axMapControl1.AddLayer(pFeatureLayer as ILayer); axMapControl2.AddLayer(pFeatureLayer as ILayer); } private void extendToolStripMenuItem_Click(object sender, EventArgs e)//fangda { flag = 1; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerZoomIn; } private void 缩小ToolStripMenuItem_Click(object sender, EventArgs e) { flag = 2; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerZoomOut; } private void 移动ToolStripMenuItem_Click(object sender, EventArgs e) { flag = 3; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPan; } private void 全图ToolStripMenuItem_Click(object sender, EventArgs e) { axMapControl1.Extent = axMapControl1.FullExtent; } private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (flag == 1) axMapControl1.Extent = axMapControl1.TrackRectangle(); else if(flag==3) axMapControl1.Pan(); else if (flag == 2) { IEnvelope pEnvelope = axMapControl1.Extent; pEnvelope.Expand(2, 2, true); axMapControl1.Extent = pEnvelope; } } private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) { IEnvelope envelope = (IEnvelope)e.newEnvelope; IGraphicsContainer graphicsContainer = axMapControl2.Map as IGraphicsContainer; IActiveView activeView = graphicsContainer as IActiveView; //在绘图前,清除axMapControl2中的任何图形元素 graphicsContainer.DeleteAllElements(); IElement element = new RectangleElementClass(); element.Geometry = envelope; //设置鹰眼图中的红线 //产生一个线符号对象 ILineSymbol outLineSymbol = new SimpleLineSymbolClass(); outLineSymbol.Width = 2; outLineSymbol.Color = GetColor(255, 0, 0, 255); //设置颜色属性 //设置填充符号的属性 IFillSymbol fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = GetColor(9, 0, 0, 0); fillSymbol.Outline = outLineSymbol; IFillShapeElement fillShapeElement = element as IFillShapeElement; fillShapeElement.Symbol = fillSymbol; graphicsContainer.AddElement((IElement)fillShapeElement, 0); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } private IRgbColor GetColor(int r, int g, int b, int t) { IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = r; rgbColor.Green = g; rgbColor.Blue = b; rgbColor.Transparency = (byte)t; return rgbColor; } private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { IPoint point = new PointClass(); point.PutCoords(e.mapX, e.mapY); axMapControl1.CenterAt(point); } }}
0 0
- 第二章 使用ArcGIS Engine控件编程
- arcGIS Engine控件介绍
- ArcGIS Engine控件运行许可
- ArcGIS Engine控件运行许可
- Arcgis Engine主要控件介绍
- ArcGIS Engine 中的多线程使用
- ArcGIS Engine 中的多线程使用
- ArcGIS Engine控件运行许可学习总结
- 使用XAML在WPF项目中承载ArcGIS Engine地图控件开发
- 关于在WPF应用程序中使用ArcGIS Engine控件的局限性
- 使用XAML在WPF项目中承载ArcGIS Engine地图控件开发
- Arcgis engine编程报错查询
- 使用 ArcGIS Engine Runtime 制作安装包
- ArcGIS Engine栅格数据使用总结
- ArcGIS Engine 中多线程的使用
- ArcGIS Engine栅格数据使用总结
- ArcGIS Engine栅格数据使用总结
- 在WPF中使用ArcGIS Engine
- Maven设置项目java默认编译版本
- HADOOP大数据离线分析+实时分析框架;Hadoop+Flume+Kafka+Storm+Hive+Sqoop+mysql/oracle
- Majority Element
- ntsysv命令
- 解决Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null···
- 第二章 使用ArcGIS Engine控件编程
- php 页面静态化
- android简单服务Service
- How Many Maos Does the Guanxi Worth
- 深度分析如何在Hadoop中控制Map的数量
- JAVA多线程面试50题 -- 内容由浅及深
- 1.定义原型对象
- 数据库使用NULL对于效率有什么影响
- JAVA Web.xml 加载顺序