ArcEngine开发鹰眼浏览

ArcEngine开发鹰眼浏览
用c#做ARCengine鹰眼开发时代码没有提示错误,但是运行之后没有效果,这是咋回事呢?问下大神
代码和结果如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;

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

    private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
    {

    }

    private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
    {
       
    }
    private void axMapContral1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
    {
    //得到新范围
        IEnvelope pEnvelope = (IEnvelope)e.newEnvelope;
        IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
        IActiveView pActiveView = pGraphicsContainer as IActiveView;
        //在绘制前清除axMapContral2中的任何图形元素
        pGraphicsContainer.DeleteAllElements();
        IRectangleElement pRectangleEle = new RectangleElementClass();
        IElement pElement = pRectangleEle as IElement;
        pElement.Geometry = pEnvelope;
        //设置鹰眼图中的红线框
        IRgbColor pColor = new RgbColorClass();
        pColor.Red = 255;
        pColor.Green = 0;
        pColor.Blue = 0;
        pColor.Transparency = 0;
        //产生一个线符号对象
        ILineSymbol pOutline = new SimpleLineSymbolClass();
        pOutline.Width = 3;
        pOutline.Color = pColor;
        //设置颜色属性
        pColor = new RgbColorClass();
        pColor.Red = 255;
        pColor.Green = 0;
        pColor.Blue = 0;
        pColor.Transparency = 0;
        //设置填充符号属性
        IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
        pFillSymbol.Color = pColor;
        pFillSymbol.Outline = pOutline;
        IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;
        pFillShapeEle.Symbol = pFillSymbol;
        pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
        pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
    }
    private void axMapContral1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)
    {
        if (axMapControl1.LayerCount > 0)
        {
            axMapControl2.Map = new MapClass();
            for (int i = 0; i <= axMapControl1.Map.LayerCount - 1; i++)
            {
                axMapControl2.AddLayer(axMapControl1.get_Layer(i));
            }
            axMapControl2.Extent = axMapControl1.Extent;
            axMapControl2.Refresh();
        }
    }
    private void axMapControl2_OnMouseMove(object sender,IMapControlEvents2_OnMouseMoveEvent e)
    {
        if (e.button == 1)
        {
            IPoint pPoint = new PointClass();
            pPoint.PutCoords(e.mapX,e.mapY);
            axMapControl1.CenterAt(pPoint);
            axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);

        }
    }
    private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
    {
        if (axMapControl2.Map.LayerCount > 0)
        {
            if (e.button == 1)
            {
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(e.mapX,e.mapY);
                axMapControl1.CenterAt(pPoint);
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
            else if (e.button == 2)
            {
                IEnvelope pEnv = axMapControl2.TrackRectangle();
                axMapControl1.Extent = pEnv;
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);
            }
        }
    }
}

}
在这里插入图片描述在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值