예제 #1
0
        private void axPageLayoutControl1_OnDoubleClick(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnDoubleClickEvent e)
        {
            if (e.button == 1)
            {
                //标注的修改
                if (axPageLayoutControl1.CurrentTool == null)
                {
                    return;
                }
                if (((axPageLayoutControl1.CurrentTool) as ICommand).Name == "ControlToolsGraphicElement_SelectTool")
                {
                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(e.pageX, e.pageY);


                    IGraphicsContainer pGraphicsContainer = axPageLayoutControl1.PageLayout as IGraphicsContainer;

                    IEnumElement pEnumElement = pGraphicsContainer.LocateElements(pPoint, 10);
                    if (pEnumElement != null)
                    {
                        IElement pElement = pEnumElement.Next();
                        if (pElement is ITextElement)
                        {
                            ITextElement       ptextElement = pElement as ITextElement;
                            MapPrint.TextSetUp textSetUp    = new MapPrint.TextSetUp();
                            textSetUp.UpdateTextElement(ptextElement);
                            textSetUp.Show();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 查询地图上的标注Element
        /// </summary>
        /// <param name="point">地图上的点</param>
        /// <param name="tolerance">缓冲距离</param>
        /// <returns></returns>
        private IEnumElement queryElementOnMap(IPoint point, double tolerance)
        {
            IGraphicsContainer pGContainer = axMapControl1.Map as IGraphicsContainer;
            IEnumElement       pEunmEle    = pGContainer.LocateElements(point, tolerance);

            return(pEunmEle);
        }
예제 #3
0
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            IMxDocument pmxdoc = ArcMap.Application.Document as IMxDocument;

            IPoint pPoint = pmxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

            IGraphicsContainer pgc       = pmxdoc.ActiveView.GraphicsContainer;
            IEnumElement       eElements = pgc.LocateElements(pPoint, 5);

            if (eElements == null)
            {
                return;
            }

            eElements.Reset();
            IElement pElement = eElements.Next();

            while (pElement != null)
            {
                IElementProperties pElementProps = pElement as IElementProperties;

                MessageBox.Show(pElementProps.Name);

                pElement = eElements.Next();
            }
        }
예제 #4
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView as IGraphicsContainer;
                m_point = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                IEnumElement pEnumElement = pGraphicsContainer.LocateElements(m_point, 1);
                if (pEnumElement == null)
                {
                    return;
                }
                m_element = pEnumElement.Next();

                if (m_element is AnnotationElement)
                {
                    ITextElement pTextElement = new TextElementClass {
                        Text = ((ITextElement)m_element).Text, Symbol = ((ITextElement)m_element).Symbol, ScaleText = true
                    };
                    m_viewElement          = pTextElement as IElement;
                    m_viewElement.Geometry = m_element.Geometry;
                    m_hookHelper.ActiveView.GraphicsContainer.AddElement(m_viewElement, 0);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_viewElement, null);
                }

                // 移动状态信息
                m_moving = true;
            }
        }
예제 #5
0
파일: EditPoint.cs 프로젝트: AnuoF/MapFrame
        // 鼠标按下事件
        private void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button != 1)
            {
                return;
            }

            IPoint point = new PointClass();

            point.PutCoords(e.mapX, e.mapY);
            var elementenum = graphicsContainer.LocateElements(point, 0);

            if (elementenum != null)   // 判断是否点击图元
            {
                isLeftBtnDown           = true;
                mapControl.CurrentTool  = null;
                mapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
            }
        }
예제 #6
0
        public static IElement getElement(AxPageLayoutControl axPageLayoutControl, IPoint pPoint)
        {
            IPageLayout        pageLayout         = axPageLayoutControl.PageLayout;
            IGraphicsContainer pGraphicsContainer = pageLayout as IGraphicsContainer;
            IEnumElement       pEnumElement       = pGraphicsContainer.LocateElements(pPoint, 0);

            pEnumElement.Reset();
            var pElement = pEnumElement.Next();

            while (pElement != null && (pElement is IMapFrame))
            {
                pElement = pEnumElement.Next();
            }
            return(pElement);
        }
예제 #7
0
        /// <summary>
        /// 鼠标点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IGraphicsContainer gc    = layer as IGraphicsContainer;
            IPoint             point = new PointClass();

            point.PutCoords(e.mapX, e.mapY);
            var elementenum = gc.LocateElements(point, 0);

            if (MarkerMouseDownEvent != null && elementenum != null)
            {
                editMarker = elementenum.Next() as EditMarker;
                editMarker.markerSelected = true;
                mapControl.OnMouseMove   += new IMapControlEvents2_Ax_OnMouseMoveEventHandler(mapControl_OnMouseMove);
                mapControl.OnMouseUp     += new IMapControlEvents2_Ax_OnMouseUpEventHandler(mapControl_OnMouseUp);
                MarkerMouseDownEvent(editMarker, e);
            }
        }
예제 #8
0
        /// <summary>
        /// 移动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mapControl_OnMouseMove_Cursor(object sender, IMapControlEvents2_OnMouseMoveEvent e)
        {
            IGraphicsContainer gc    = layer as IGraphicsContainer;
            IPoint             point = new PointClass();

            point.PutCoords(e.mapX, e.mapY);
            var elementenum = gc.LocateElements(point, 0);

            if (elementenum != null)
            {
                mapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
            }
            else
            {
                mapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
            }
        }
예제 #9
0
        /// <summary>
        /// 鼠标弹起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mapControl_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
        {
            IGraphicsContainer gc    = layer as IGraphicsContainer;
            IPoint             point = new PointClass();

            point.PutCoords(e.mapX, e.mapY);
            var elementenum = gc.LocateElements(point, 0);

            if (elementenum != null)
            {
                editMarker = elementenum.Next() as EditMarker;
                editMarker.markerSelected = false;
            }

            if (MarkerMouseUpEvent != null)
            {
                MarkerMouseUpEvent(editMarker, null);
            }
            mapControl.OnMouseUp   -= mapControl_OnMouseUp;
            mapControl.OnMouseMove -= mapControl_OnMouseMove;
        }
예제 #10
0
        private void mainMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 2)
            {
                if (this.mapRightClickPoint == null)
                {
                    this.mapRightClickPoint = new PointClass();
                }
                this.mapRightClickPoint.PutCoords(e.mapX, e.mapY);
                IGraphicsContainer pGraphicContainer = this.mainMapControl.Map as IGraphicsContainer;
                IEnumElement       pEnumElement      = pGraphicContainer.LocateElements(this.mapRightClickPoint, this.mainMapControl.ActiveView.Extent.Width / 500);
                if (pEnumElement != null)
                {
                    return;
                }
                else
                {
                    // this.contextMenuMapNormal.Show(this.mainMapControl as Control, new System.Drawing.Point(e.x, e.y));
                }
            }
            else if (e.button == 1)
            {
                //if (this.btnDrawNewText.Checked == false) return;

                if (this.mapTextPoint == null)
                {
                    this.mapTextPoint = new PointClass();
                }
                this.mapTextPoint.PutCoords(e.mapX, e.mapY);
                //this.txtNewText.Location = new System.Drawing.Point(e.x, e.y);
                //this.txtNewText.Text = "文本";
                //this.txtNewText.Visible = true;
                //this.txtNewText.Focus();
                //this.txtNewText.SelectAll();
                //this.btnDrawNewText.Checked = false;
            }
        }
예제 #11
0
        //鼠标双击被选中的元素时将出现属性对话框更改属性
        private void m_pageLayoutControl_OnDoubleClick(object sender, IPageLayoutControlEvents_OnDoubleClickEvent e)
        {
            IGraphicsContainer pSelected = m_pageLayoutControl.ActiveView as IGraphicsContainer;
            IPoint             pt        = new PointClass();

            pt.X = e.pageX; pt.Y = e.pageY;
            IEnumElement pEnumElement = pSelected.LocateElements(pt, 0);
            IElement     pEle         = pEnumElement.Next();

            if (pEle is IMapSurroundFrame)
            {
                IMapSurroundFrame pSurround = pEle as IMapSurroundFrame;
                if (pSurround.MapSurround is ILegend)
                {
                    LegendPropertyForm legendForm = new LegendPropertyForm(GetCompleteLegend(), pEle);
                    legendForm.ShowDialog();
                }
                if (pSurround.MapSurround is INorthArrow)
                {
                    NorthArrowPropertyFr nap = new NorthArrowPropertyFr(pEle);
                    nap.ShowDialog();
                }
                if (pSurround.MapSurround is IScaleBar)
                {
                    ScalePropertyFr scaleForm = new ScalePropertyFr(pEle);
                    scaleForm.ShowDialog();
                }
            }
            if (pEle is ITextElement)
            {
                TitlePropertyFr titleForm = new TitlePropertyFr(pEle as ITextElement, pt);
                titleForm.Text = "文本属性";
                titleForm.ShowDialog();
                m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
        }
예제 #12
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1)
            {
                //给m_graphicsContainer赋值
                m_graphicsContainer = axMapControl1.Map as IGraphicsContainer;
                //在添加polygon被选中时
                if (miAddPolygon.Checked)
                {
                    //在鼠标点击的位置生成一个点
                    IPoint p_Point = new PointClass();
                    p_Point.PutCoords(e.mapX, e.mapY);
                    IActiveView    p_activeview    = axMapControl1.Map as IActiveView;
                    IScreenDisplay p_ScreenDisplay = p_activeview.ScreenDisplay;
                    //标记符等于0时
                    if (m_marker == 0)
                    {
                        //对m_DisplayFeedback重新初始化
                        m_DisplayFeedback = new NewPolygonFeedbackClass();
                        //设置m_DisplayFeedback的display
                        m_DisplayFeedback.Display = p_ScreenDisplay;
                        //开始绘制polygon的第一个点
                        ((INewPolygonFeedback)m_DisplayFeedback).Start(p_Point);
                        //将m_polyline转为pointcollection
                        IPointCollection p_PointCollection = m_polyline as IPointCollection;
                        //将第一个点加入pointcollection中
                        p_PointCollection.AddPoint(p_Point);
                        //将第一个点记录到m_point中
                        m_point = p_Point;
                        //对m_polyline重新赋值
                        m_polyline = p_PointCollection as IPolyline;
                        if (m_marker == 0)
                        {
                            m_marker = 1;
                        }
                        //刷新
                        axMapControl1.ActiveView.Refresh();
                    }
                    //如果不是第一次点击,就添加节点
                    else
                    {
                        //初始化红线和蓝线
                        if (m_element_red != null)
                        {
                            m_graphicsContainer.DeleteElement(m_element_red);
                        }
                        if (m_element_green != null)
                        {
                            m_graphicsContainer.DeleteElement(m_element_green);
                        }
                        //向m_DisplayFeedback中添加顶点
                        ((INewPolygonFeedback)m_DisplayFeedback).AddPoint(p_Point);
                        IPointCollection p_PointCollection = m_polyline as IPointCollection;
                        p_PointCollection.AddPoint(p_Point);
                        //生成红线
                        m_polyline = p_PointCollection as IPolyline;
                        ILineElement p_LineElement_red = new LineElementClass();
                        m_element_red          = p_LineElement_red as IElement;
                        m_element_red.Geometry = m_polyline;
                        ISimpleLineSymbol p_SimpleLineSymbol = new SimpleLineSymbolClass();
                        IRgbColor         p_rgbcolor         = new RgbColorClass();
                        p_rgbcolor.Red           = 255;
                        p_rgbcolor.Green         = 0;
                        p_rgbcolor.Blue          = 0;
                        p_SimpleLineSymbol.Color = p_rgbcolor as IColor;
                        p_LineElement_red.Symbol = p_SimpleLineSymbol as ILineSymbol;
                        //设置蓝线symbol
                        ISimpleLineSymbol p_SimpleLine_green = new SimpleLineSymbolClass();
                        IRgbColor         p_rgbcolor_green   = new RgbColorClass();
                        p_rgbcolor_green.Red     = 0;
                        p_rgbcolor_green.Green   = 255;
                        p_rgbcolor_green.Blue    = 255;
                        p_SimpleLine_green.Color = p_rgbcolor_green as IColor;
                        //生成蓝线
                        IPolyline        p_polyline        = new PolylineClass();
                        IPointCollection p_pointColl_green = p_polyline as IPointCollection;
                        //向蓝线中添加两个顶点
                        p_pointColl_green.AddPoint(m_point);
                        p_pointColl_green.AddPoint(p_Point);
                        p_polyline = p_pointColl_green as IPolyline;
                        ILineElement p_LineElement_green = new LineElementClass();
                        m_element_green            = p_LineElement_green as IElement;
                        p_LineElement_green.Symbol = p_SimpleLine_green as ILineSymbol;
                        m_element_green.Geometry   = p_polyline;
                        //将红线和蓝线加入containner显示
                        m_graphicsContainer.AddElement(m_element_red, 0);
                        m_graphicsContainer.AddElement(m_element_green, 0);
                        //更新视图
                        axMapControl1.ActiveView.Refresh();
                    }
                }
                //当选择polygon被选中时
                if (miSelectPolygon.Checked)
                {
                    //如果m_list不为空,则从容器中把其所对应element删除并将m_list清空
                    if (m_list.Count != 0)
                    {
                        for (int i = 0; i < m_list.Count; i++)
                        {
                            m_graphicsContainer.DeleteElement(m_list[i]);
                        }
                        m_list.Clear();
                    }
                    //刷新
                    axMapControl1.ActiveView.Refresh();
                    IPoint p_point = new PointClass();
                    //记录点下的点
                    p_point.PutCoords(e.mapX, e.mapY);
                    //得到选中的element集合
                    IEnumElement p_EnumElement = m_graphicsContainer.LocateElements(p_point, 5);
                    IGeometry    p_geometry;
                    //选中的element集合不为空时
                    if (p_EnumElement != null)
                    {
                        m_hitElement = p_EnumElement.Next();
                        p_geometry   = m_hitElement.Geometry;
                        //循环找到类型为polygon的element
                        while (p_geometry.GeometryType != esriGeometryType.esriGeometryPolygon && m_hitElement != null)
                        {
                            m_hitElement = p_EnumElement.Next();
                            if (m_hitElement != null)
                            {
                                p_geometry = m_hitElement.Geometry;
                            }
                        }
                        if (p_geometry.GeometryType == esriGeometryType.esriGeometryPolygon)
                        {
                            m_polygon   = (IPolygon)p_geometry;
                            m_PointColl = m_polygon as IPointCollection;
                            //循环将选中的polygon的每个点以element加入容器中
                            for (int k = 1; k < m_PointColl.PointCount; k++)
                            {
                                IMarkerElement      p_MarkerElement = new MarkerElementClass();
                                ISimpleMarkerSymbol p_simpleMarker  = new SimpleMarkerSymbolClass();
                                p_simpleMarker.Size = 5;

                                IElement p_element = (IElement)p_MarkerElement;
                                p_MarkerElement.Symbol = p_simpleMarker as IMarkerSymbol;

                                if (!(p_element == null))
                                {
                                    p_element.Geometry = m_PointColl.get_Point(k);

                                    m_graphicsContainer.AddElement(p_element, 0);
                                }
                                m_list.Add(p_element);
                            }
                            axMapControl1.ActiveView.Refresh();
                        }
                    }
                }
                //当编辑polygon被选中时
                if (miEditPolygon.Checked)
                {
                    if (m_polygon != null)
                    {
                        //在鼠标点击的位置生成一个点
                        IPoint p_Point = new PointClass();
                        p_Point.PutCoords(e.mapX, e.mapY);
                        IActiveView    p_ActiveView    = axMapControl1.Map as IActiveView;
                        IScreenDisplay p_ScreenDisplay = p_ActiveView.ScreenDisplay;
                        //建立新的hittest,设置相关变量,获取点击处polygon的顶点
                        IHitTest p_HitTest         = m_polygon as IHitTest;
                        IPoint   p_hitPoint        = new PointClass();
                        double   p_distance        = 0;
                        bool     p_isOnRightSide   = true;
                        int      p_hitPartIndex    = 0;
                        int      p_hitSegmentIndex = 0;
                        bool     p_isHit           = p_HitTest.HitTest(p_Point, this.axMapControl1.ActiveView.Extent.Width / 100, esriGeometryHitPartType.esriGeometryPartVertex, p_hitPoint, ref p_distance, ref p_hitPartIndex, ref p_hitSegmentIndex, ref p_isOnRightSide);
                        //如果有点被选中,开始拖动该点
                        if (p_isHit)
                        {
                            m_DisplayFeedback         = new PolygonMovePointFeedbackClass();
                            m_marker                  = 2;
                            m_DisplayFeedback.Display = p_ScreenDisplay;
                            ((IPolygonMovePointFeedback)m_DisplayFeedback).Start(m_polygon, p_hitSegmentIndex, p_Point);
                        }
                    }
                }
            }
        }
예제 #13
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            switch (toolAction)
            {
            case "Drag Zoom In":                                      //判定当前的操作是否为拉框放大

                IEnvelope pEnvelope = axMapControl1.TrackRectangle(); // 调用axMapControl1的矩形框跟踪功能进行拉框操作,
                //将拉框完成后的范围赋值给一个Envelope对象
                //此处,你可以尝试axMapControl1.TrackPolygon(),axMapControl1.TrackCircle(),axMapControl1.TrackLine()等方法的调用,看有什么效果
                if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0) //判定所获取的拉框范围是否无效
                {
                    return;                                                                                  // 拉框范围无效,就直接返回
                }
                axMapControl1.Extent = pEnvelope;                                                            // 给地图窗口的空间范围赋值为刚才拉框的范围
                axMapControl1.ActiveView.Refresh();                                                          //地图刷新
                return;

            case "Drag Zoom Out":                                      //判定当前的操作是否为拉框缩小
                IEnvelope pEnvelope1 = axMapControl1.TrackRectangle(); // 调用axMapControl1的矩形框跟踪功能进行拉框操作,
                //将拉框完成后的范围赋值给一个Envelope对象
                //此处,你可以尝试axMapControl1.TrackPolygon(),axMapControl1.TrackCircle(),axMapControl1.TrackLine()等方法的调用,看有什么效果
                if (pEnvelope1 == null || pEnvelope1.IsEmpty || pEnvelope1.Height == 0 || pEnvelope1.Width == 0)                                                 ////判定所获取的拉框范围是否无效
                {
                    return;                                                                                                                                      //// 拉框范围无效,就直接返回
                }
                IActiveView pActiveView = axMapControl1.ActiveView;                                                                                              // 获取地图视窗对象
                double      mHeight     = pActiveView.Extent.Height * pActiveView.Extent.Height / pEnvelope1.Height;                                             // 根据倍数计算新空间范围高度
                double      mWidth      = pActiveView.Extent.Width * pActiveView.Extent.Width / pEnvelope1.Width;                                                // 根据倍数计算新空间范围宽度
                double      mMinX       = pActiveView.Extent.XMin - (pEnvelope1.XMin - pActiveView.Extent.XMin) * pActiveView.Extent.Width / pEnvelope1.Width;   //计算新空间范围的x的最小值
                double      mMinY       = pActiveView.Extent.YMin - (pEnvelope1.YMin - pActiveView.Extent.YMin) * pActiveView.Extent.Height / pEnvelope1.Height; //计算新空间范围的y的最小值
                double      mMaxX       = mMinX + mWidth;                                                                                                        //计算新空间范围的x的最大值
                double      mMaxY       = mMinY + mHeight;                                                                                                       // 计算新空间范围的y的最大值
                pEnvelope1.PutCoords(mMinX, mMinY, mMaxX, mMaxY);                                                                                                // 给Envelope对象赋值新的空间范围

                //(pActiveView.Extent.XMax-pActiveView.Extent.XMin)*
                axMapControl1.Extent = pEnvelope1;      // 给地图范围赋值为新的空间范围
                axMapControl1.ActiveView.Refresh();     //地图刷新
                return;

            case "Pan":              // 判定是否进行地图平移操作
                axMapControl1.Pan(); //可执行地图平移
                return;

            case "Select Feature Using Point":                                                              //点选要素

                axMapControl1.ActiveView.FocusMap.ClearSelection();                                         // 清空当前地图的选择集;
                axMapControl1.ActiveView.Refresh();
                tagRECT r;                                                                                  //   定义一个tagRECT结构变量,用于存放以当前鼠标为中心的长宽各为10个像素的小矩形
                r.left   = e.x - 5;                                                                         //
                r.right  = e.x + 5;                                                                         //
                r.bottom = e.y - 5;                                                                         //
                r.top    = e.y + 5;                                                                         //
                IEnvelope pEnv = new Envelope() as IEnvelope;                                               // 创建一个Envelope对象,用于接受刚才创建的小矩形范围由屏幕坐标转换为地图坐标的值
                axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4); //把r的屏幕坐标转换为地图坐标,存入Envelope对象中
                pEnv.SpatialReference = axMapControl1.ActiveView.FocusMap.SpatialReference;                 //设定Envelope对象的空间坐标参考与当前地图窗口的坐标一致
                IGeometry pGeo = pEnv as IGeometry;                                                         //接口访问到IGeometry接口
                axMapControl1.Map.SelectByShape(pGeo, null, false);                                         //调用地图控件中map对象的SelectByShape方法,在地图中选择与pGeo相交或包含在其中的地图要素
                //int selCount = axMapControl1.Map.SelectionCount;
                //IEnumFeature pEnumFeature = axMapControl1.Map.FeatureSelection as IEnumFeature;
                //IFeature pFeature = pEnumFeature.Next();
                //while (pFeature != null)
                //{
                //    int index = pFeature.Fields.FindField("GB");
                //    str1 = Convert.ToString(pFeature.get_Value(index));
                //    MessageBox.Show(str1);
                //    //string str2 = pFeature.get_Value(2).ToString();
                //    pFeature = pEnumFeature.Next();
                //}



                ISelection        selection         = axMapControl1.Map.FeatureSelection;
                IEnumFeatureSetup iEnumFeatureSetup = (IEnumFeatureSetup)selection;
                iEnumFeatureSetup.AllFields = true;
                IEnumFeature pEnumFeature = (IEnumFeature)iEnumFeatureSetup;
                pEnumFeature.Reset();
                IFeature pFeature = pEnumFeature.Next();
                if (pFeature != null)
                {
                    int index = pFeature.Fields.FindField("RNAME");
                    //string str1 = pFeature.OID.ToString();
                    if (index != -1)
                    {
                        str1 = pFeature.get_Value(index).ToString();
                    }
                    //MessageBox.Show(str1);
                    //pFeature = pEnumFeature.Next();
                }
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);        //

                toolAction = "";
                return;

            case "Select Feature Using Rectangle":                    //矩形选择要素
                IEnvelope pEnvlope2 = axMapControl1.TrackRectangle(); //  进行矩形框的绘制追踪,
                if (pEnvlope2.IsEmpty == true)                        // 若矩形框为空
                {
                    tagRECT r1;
                    r1.left   = e.x - 5;
                    r1.right  = e.x + 5;
                    r1.bottom = e.y - 5;
                    r1.top    = e.y + 5;
                    axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnvlope2, ref r1, 4);
                    pEnvlope2.SpatialReference = axMapControl1.ActiveView.FocusMap.SpatialReference;
                }
                IGeometry pGeo1 = pEnvlope2 as IGeometry;
                axMapControl1.Map.SelectByShape(pGeo1, null, false);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);


                toolAction = "";
                return;


            case "Select Feature Using Circle":                 // 圆形选择要素
                IGeometry pCircl = axMapControl1.TrackCircle(); //圆形绘制
                if (pCircl.IsEmpty == true)
                {
                    return;
                }
                // IGeometry pGeo1 = pEnvlope2 as IGeometry;
                axMapControl1.Map.SelectByShape(pCircl, null, false);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                toolAction = "";
                return;

            case "Select Feature Using Polygon":                   //多边形选择要素

                IGeometry pPolygon = axMapControl1.TrackPolygon(); // 绘制多边形
                if (pPolygon.IsEmpty == true)
                {
                    return;
                }
                // IGeometry pGeo1 = pEnvlope2 as IGeometry;
                axMapControl1.Map.SelectByShape(pPolygon, null, false);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                toolAction = "";
                return;

            case "Select Feature Using Polyline":            // 线性选择要素

                IGeometry pLine = axMapControl1.TrackLine(); //绘制线
                if (pLine.IsEmpty == true)
                {
                    return;
                }
                // IGeometry pGeo1 = pEnvlope2 as IGeometry;
                axMapControl1.Map.SelectByShape(pLine, null, false);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                toolAction = "";
                return;

            case "Draw Polygon":
                IGeometry pPolygon1 = axMapControl1.TrackPolygon();       // 绘制多边形
                if (pPolygon1 == null)
                {
                    return;
                }
                IElement pElement = new PolygonElement();
                pElement.Geometry = pPolygon1;
                IFillShapeElement pPolygonEle = pElement as IFillShapeElement;
                if (pSelectedFillSymbol != null)
                {
                    pPolygonEle.Symbol = pSelectedFillSymbol;
                }

                IGraphicsContainer pGc = axMapControl1.ActiveView.GraphicsContainer;
                pGc.AddElement(pElement, 0);
                IGraphicsContainerSelect pGSelection = pGc as IGraphicsContainerSelect;
                pGSelection.UnselectAllElements();
                pGSelection.SelectElement(pElement);

                toolAction = "";
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                return;

            case "Draw Point":
                IPoint pPointMark = new ESRI.ArcGIS.Geometry.Point(); // 创建一个点

                pPointMark.PutCoords(e.mapX, e.mapY);                 //给点赋值为当前鼠标所在位置的地图坐标
                IGeometry pPointGeo = pPointMark as IGeometry;
                IElement  pMElement = new MarkerElement();
                pMElement.Geometry = pPointGeo;
                IMarkerElement pMarkElement = pMElement as IMarkerElement;
                if (pSelectedMarkSymbol != null)
                {
                    pMarkElement.Symbol = pSelectedMarkSymbol;
                }

                IGraphicsContainer pGraphiscont = axMapControl1.ActiveView.GraphicsContainer;
                pGraphiscont.AddElement(pMElement, 0);
                IGraphicsContainerSelect pGS = pGraphiscont as IGraphicsContainerSelect;
                pGS.UnselectAllElements();
                pGS.SelectElement(pMElement);

                toolAction = "";
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                return;

            case "Draw Line":
                IGeometry pLineGeo = axMapControl1.TrackLine();       // 绘制Line
                if (pLineGeo == null)
                {
                    return;
                }
                IElement     pElement4 = new LineElement();
                ILineElement pLineEle  = pElement4 as ILineElement;
                if (pSelectedLineSymbol != null)
                {
                    pLineEle.Symbol = pSelectedLineSymbol;
                }

                pElement4.Geometry = pLineGeo;
                IGraphicsContainer pGc4 = axMapControl1.ActiveView.GraphicsContainer;
                pGc4.AddElement(pElement4, 0);
                IGraphicsContainerSelect pGSelection4 = pGc4 as IGraphicsContainerSelect;
                pGSelection4.UnselectAllElements();
                pGSelection4.SelectElement(pElement4);

                toolAction = "";
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                return;

            case "Draw Text":
                IRgbColor pColor = new RgbColor();
                pColor.Red   = 150;
                pColor.Green = 150;
                pColor.Blue  = 0;

                ITextSymbol    pTextSymbol = new TextSymbol();
                stdole.StdFont font        = new stdole.StdFont();
                font.Name         = "宋体";
                font.Size         = 20;
                pTextSymbol.Font  = font as stdole.IFontDisp;
                pTextSymbol.Color = pColor;
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                pTextSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVABaseline;
                pTextSymbol.Text = "This is my First Text";


                IPoint pTextPoint = new ESRI.ArcGIS.Geometry.Point(); // 创建一个点

                pTextPoint.PutCoords(e.mapX, e.mapY);                 //给点赋值为当前鼠标所在位置的地图坐标
                IGeometry pTextGeo = pTextPoint as IGeometry;

                IElement pTElement = new TextElement();
                pTElement.Geometry = pTextGeo;
                ITextElement pTextEle = pTElement as ITextElement;
                pTextEle.Symbol = pTextSymbol;
                pTextEle.Text   = pTextSymbol.Text;

                IGraphicsContainer pGraphisCon = axMapControl1.ActiveView.GraphicsContainer;
                pGraphisCon.AddElement(pTElement, 0);

                IGraphicsContainerSelect pGrhSelection = pGraphisCon as IGraphicsContainerSelect;
                pGrhSelection.UnselectAllElements();
                pGrhSelection.SelectElement(pTElement);

                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                toolAction = "";
                break;


            case "Select Graphics by using Point":                                                       //通过点击获得GraphicsContainor中的element

                IPoint pPoint = new ESRI.ArcGIS.Geometry.Point();                                        // 创建一个点
                pPoint.PutCoords(e.mapX, e.mapY);                                                        //给点赋值为当前鼠标所在位置的地图坐标
                double                   dist         = axMapControl1.ActiveView.Extent.Width / 15;      //设置以点为圆心的查询的半径
                IGraphicsContainer       pGc1         = axMapControl1.ActiveView.GraphicsContainer;      //获得地图的GraphicsContainor容器
                IEnumElement             pEnumElement = pGc1.LocateElements(pPoint, dist);               //以点为中心点,按照指定半径选择element
                IGraphicsContainerSelect pGSelection1 = pGc1 as IGraphicsContainerSelect;                //获得地图的容器中的图形要素选择集
                if (pEnumElement != null)                                                                //
                {
                    pEnumElement.Reset();                                                                //回到-1位置
                    pGSelection1.UnselectAllElements();                                                  //清空原来选择到的图形要素
                    pGSelection1.SelectElements(pEnumElement);                                           //将新查询到的图形要素添加到GraphicsContainor容器中的图形要素选择集中
                }
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //图形要素刷新

                return;
            }
            if (e.button == 2)                                   //若单击鼠标右键
            {
                contextMenuStrip2.Show(axMapControl1, e.x, e.y); //在TOC控件的当前鼠标位置弹出右键菜单
            }
        }