码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGIS Engine 开发(二)线、圆、矩形、面、文本编辑功能

时间:2015-04-03 09:26:00      阅读:403      评论:0      收藏:0      [点我收藏+]

标签:源代码   arcgis   arcgisengine   webgis   线圆矩形面文本编辑功能   

ArcGIS Engine 开发(二)线、圆、矩形、面、文本编辑功能,这些都是实现课上的源代码,自己调试好了,直接可以放到vs2010下跑,希望能对大家有所帮助

好了,先来看效果

技术分享

二.下面是调试好的代码

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.esriSystem;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Carto;

namespace lesson5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
        int flag = 0;
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            axMapControl1.MousePointer =esriControlsMousePointer.esriPointerCrosshair;
            
            IGeometry geometry =null  ;
            //
            if (flag ==1)
            {
                geometry =axMapControl1.TrackLine() ;
            }
            else if (flag==2)
            {
                geometry =axMapControl1.TrackCircle ();
            }
            else if (flag==3)
            {
                geometry=axMapControl1.TrackRectangle ();
            }
            else if (flag==4)
            {
                geometry=axMapControl1.TrackPolygon ();
            }
            else if (flag==5)
            {
                IPoint point =new PointClass  ();
                point.X =e.x ;
                point.Y =e.y ;
                geometry =point as IGeometry ; 
            }
            if (flag >= 1 && flag <= 4)
            {
                drawMapShape(geometry);
            }
            else if (flag == 5)
            {
                drawMapText(geometry);
            }           
            //axMapControl1.Refresh (esriViewDrawPhase.esriViewGeography, null, null);
        }
        //画线对象
        private void button1_Click(object sender, EventArgs e)
        {
            flag = 1;
        }
        //画圆对象
        private void button2_Click(object sender, EventArgs e)
        {
            flag = 2;
        }
        //画矩形对象
        private void button3_Click(object sender, EventArgs e)
        {
            flag = 3;
        }
        //画面对象
        private void button4_Click(object sender, EventArgs e)
        {
            flag = 4;
        }
        //画文本对象
        private void button5_Click(object sender, EventArgs e)
        {
            flag = 5;
        }
        private void drawMapText(IGeometry geometry)
        {
            IRgbColor color = new RgbColorClass();
            color.Red = 255;
            color.Blue = 0;
            color.Green = 0;
            ITextSymbol txtSystem = new TextSymbolClass();
            txtSystem.Color = color;
            //txtSystem.Text = "测试DrawText";
            object symbol = txtSystem;
            axMapControl1.DrawText(geometry, "测试DrawText", ref  symbol);
        }
        private void drawMapShape(IGeometry pGeom)
        {
            IRgbColor pColor;
            pColor = new RgbColorClass();
            pColor.Red = 255;
            pColor.Green =255;
            pColor.Blue =0;  
            object symbol=null;
            if (pGeom.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ISimpleLineSymbol simpleLineSymbol;
                simpleLineSymbol = new SimpleLineSymbolClass();
                simpleLineSymbol.Color = pColor;
                simpleLineSymbol.Width = 5;
                symbol = simpleLineSymbol;
            }
            else
            {
                ISimpleFillSymbol simpleFillSymbol;
                simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color = pColor;
                symbol = simpleFillSymbol;
            }
           
            axMapControl1.DrawShape(pGeom, ref symbol);
        }
       

       
    }
}


ArcGIS Engine 开发(二)线、圆、矩形、面、文本编辑功能

标签:源代码   arcgis   arcgisengine   webgis   线圆矩形面文本编辑功能   

原文地址:http://blog.csdn.net/vector5210/article/details/44839105

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!