示例#1
0
        private void OnOnDoubleClick(int button, int shift, int i, int i1, double mapX, double mapY)
        {
            if (button == 2)
            {
                return;
            }
            if (_polygonFeedback == null)
            {
                return;
            }
            IPoint point = new PointClass();

            point.PutCoords(mapX, mapY);
            _polygonFeedback.AddPoint(point);
            _polygon = _polygonFeedback.Stop();
            IRgbColor rgbColorClass = new RgbColor();

            rgbColorClass.Red   = (0);
            rgbColorClass.Green = (255);
            rgbColorClass.Blue  = (255);
            ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol();

            ((ISymbol)simpleFillSymbolClass).ROP2 = (esriRasterOpCode)(10);
            simpleFillSymbolClass.Color           = (rgbColorClass);
            IElement element = new PolygonElement();

            element.Geometry = _polygon;
            ((IFillShapeElement)element).Symbol = simpleFillSymbolClass;
            _graphicsContainer.DeleteAllElements();
            _graphicsContainer.AddElement(element, 100);
            _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            OnDrawCompleteEvent();
            //_polygon = null;
            _polygonFeedback = null;
        }
示例#2
0
        /// <summary>
        /// 向折线或多边形上添加节点
        /// 在Map的MouseDown事件中调用本方法,将当前光标位置作为节点
        /// 添加到折线或多边形上
        /// </summary>
        /// <param name="point">拐点</param>
        public void AddPoint(IPoint point)
        {
            if (_eMeasureType == EMeasureType.Distance || _eMeasureType == EMeasureType.Angle)
            {
                _newLineFeedback.AddPoint(point);
            }
            else if (_eMeasureType == EMeasureType.Area)
            {
                _newPolygonFeedback.AddPoint(point);
            }

            object ep = System.Reflection.Missing.Value;

            _pointCollection.AddPoint(point, ref ep, ref ep);
        }
示例#3
0
        /// <summary>
        /// 完成新建对象,取得绘制的对象,并添加到图层中
        /// 建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法
        /// </summary>
        public void NewFeatureEnd()
        {
            IGeometry        pGeom = null;
            IPointCollection pPointCollection;

            try
            {
                if (m_pFeedback is INewMultiPointFeedback)
                {
                    INewMultiPointFeedback pMPFeed = (INewMultiPointFeedback)m_pFeedback;
                    pMPFeed.Stop();
                    pGeom = (IGeometry)m_pPointCollection;
                }
                else if (m_pFeedback is INewLineFeedback)
                {
                    INewLineFeedback pLineFeed = (INewLineFeedback)m_pFeedback;

                    pLineFeed.AddPoint(m_pPoint);
                    IPolyline pPolyLine = pLineFeed.Stop();

                    pPointCollection = (IPointCollection)pPolyLine;
                    if (pPointCollection.PointCount < 2)
                    {
                        MessageBox.Show("至少输入两个节点");
                    }
                    else
                    {
                        pGeom = (IGeometry)pPointCollection;
                    }
                }
                else if (m_pFeedback is INewPolygonFeedback)
                {
                    INewPolygonFeedback pPolyFeed = (INewPolygonFeedback)m_pFeedback;
                    pPolyFeed.AddPoint(m_pPoint);

                    IPolygon pPolygon;
                    pPolygon = pPolyFeed.Stop();
                    if (pPolygon != null)
                    {
                        pPointCollection = (IPointCollection)pPolygon;
                        if (pPointCollection.PointCount < 3)
                        {
                            MessageBox.Show("至少输入三个节点");
                        }
                        else
                        {
                            pGeom = (IGeometry)pPointCollection;
                        }
                    }
                }

                CreateFeature(pGeom);
                m_pFeedback = null;
                m_bInUse    = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
示例#4
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add AreaPrintMapClass.OnMouseDown implementation

            if (Button == 1)
            {
                if (m_InUse == true)
                {
                    m_ActiveView    = m_hookHelper.ActiveView;
                    m_ScreenDisplay = m_ActiveView.ScreenDisplay;
                    IMap   pMap = m_ActiveView.FocusMap;
                    IPoint pPoint;
                    pPoint = (IPoint)m_ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    if (m_NewPolygonFeedback == null)
                    {
                        m_NewPolygonFeedback = new NewPolygonFeedbackClass();
                        ISimpleLineSymbol pSlnSym;
                        IRgbColor         pRGB = new RgbColorClass();
                        pSlnSym       = (ISimpleLineSymbol)m_NewPolygonFeedback.Symbol;
                        pRGB.Red      = 225;
                        pRGB.Green    = 0;
                        pRGB.Blue     = 0;
                        pSlnSym.Color = pRGB;
                        pSlnSym.Style = esriSimpleLineStyle.esriSLSSolid;
                        pSlnSym.Width = 2;
                        m_NewPolygonFeedback.Display = m_ScreenDisplay;
                        m_NewPolygonFeedback.Start(pPoint);
                    }
                    else
                    {
                        m_NewPolygonFeedback.AddPoint(pPoint);
                    }
                }
            }
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

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

            if (m_pNewPolygonFeedback == null)  //第一次按下
            {
                IRgbColor         pRGB = new RgbColorClass();
                ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
                pRGB.Red   = 15;
                pRGB.Blue  = 15;
                pRGB.Green = 0;
                pSimpleFillSymbol.Color = pRGB;
                pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;

                m_pNewPolygonFeedback         = new NewPolygonFeedbackClass();
                m_pNewPolygonFeedback.Symbol  = pSimpleFillSymbol as ISymbol;
                m_pNewPolygonFeedback.Display = m_MapControl.ActiveView.ScreenDisplay;

                m_pNewPolygonFeedback.Start(pPoint);
            }
            else                            //将点加入
            {
                m_pNewPolygonFeedback.AddPoint(pPoint);
            }
        }
示例#6
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            //获得鼠标在控件上点击的位置,产生一个点对象
            IPoint pPt = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (pPolygonFeedback == null)
            {
                pPolygonFeedback         = new NewPolygonFeedbackClass();
                pPolygonFeedback.Display = m_ActiveView.ScreenDisplay;
                pPolygonFeedback.Start(pPt);
            }
            else
            {
                pPolygonFeedback.AddPoint(pPt);
            }
        }
示例#7
0
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }
            if (this._context.ActiveView is IPageLayout)
            {
                IPoint location = this._context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                IMap   map      = this._context.ActiveView.HitTestMap(location);
                if (map == null)
                {
                    return;
                }
                if (map != this._context.FocusMap)
                {
                    this._context.ActiveView.FocusMap = map;
                    this._context.ActiveView.Refresh();
                }
            }
            IPoint point = ((IActiveView)this._context.FocusMap).ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            if (inewPolygonFeedback_0 == null)
            {
                inewPolygonFeedback_0         = new NewPolygonFeedback();
                inewPolygonFeedback_0.Display = ((IActiveView)this._context.FocusMap).ScreenDisplay;
                inewPolygonFeedback_0.Start(point);
                return;
            }
            inewPolygonFeedback_0.AddPoint(point);
        }
示例#8
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add CreatShape.OnMouseDown implementation
            if (Button == 1)
            {
                IFeatureLayer m_FeatureLayer = (IFeatureLayer)m_CurrentLayer;
                if (m_FeatureLayer.FeatureClass == null)
                {
                    return;
                }

                IActiveView m_ActiveView     = m_hookHelper.ActiveView;
                IPoint      m_PointMousedown = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_PointStop = m_PointMousedown;
                if (!m_bInUse)
                {
                    switch (m_FeatureLayer.FeatureClass.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:          //点类型
                        CreatFeature(m_PointMousedown);
                        m_hookHelper.ActiveView.Refresh();
                        break;

                    case esriGeometryType.esriGeometryPolyline:        //线类型
                        m_bInUse   = true;
                        m_Feedback = new NewLineFeedback();
                        INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                        m_LineFeed.Start(m_PointMousedown);
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        m_bInUse   = true;
                        m_Feedback = new NewPolygonFeedback();
                        INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback;
                        m_PolyFeed.Start(m_PointMousedown);
                        break;
                    }
                    if (m_Feedback != null)
                    {
                        m_Feedback.Display = m_ActiveView.ScreenDisplay;
                    }
                }
                else
                {
                    if (m_Feedback is INewLineFeedback)
                    {
                        INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                        m_LineFeed.AddPoint(m_PointMousedown);
                    }
                    else if (m_Feedback is INewPolygonFeedback)
                    {
                        INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback;
                        m_PolyFeed.AddPoint(m_PointMousedown);
                    }
                }
            }
        }
示例#9
0
        private void EndSketch(AxMapControl m_MapControl)                                             //结束一次画图操作
        {
            IGeometry        m_Geometry        = null;
            IPointCollection m_PointCollection = null;

            if (m_pNewLineFeedback != null)                            //线对象有效
            {
                //INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                m_pNewLineFeedback.AddPoint(m_PointStop);
                IPolyline m_PolyLine = m_pNewLineFeedback.Stop();
                m_PointCollection = (IPointCollection)m_PolyLine;
                if (m_PointCollection.PointCount < 2)
                {
                    MessageBoxEx.Show("需要两个点才能生成一条线!", "未能生成线", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }
            else if (m_pPlygonFeadback != null)                    //多边形对象有效
            {
                m_pPlygonFeadback.AddPoint(m_PointStop);
                IPolygon m_Polygon = m_pPlygonFeadback.Stop();
                if (m_Polygon != null)
                {
                    m_PointCollection = (IPointCollection)m_Polygon;
                }
                if (m_PointCollection.PointCount < 3)
                {
                    MessageBoxEx.Show("需要三个点才能生成一个面!", "未能生成面", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }
            CreateFeature(m_Geometry);
            m_pPlygonFeadback  = null;
            m_pNewLineFeedback = null;
            m_bInUse           = false;
        }
示例#10
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add MeasuredisTool.OnMouseDown implementation
            frm = GetFrm();
            frm.Show();
            frm.TopMost = true;


            IPoint      pPnt;
            IMap        pMap     = m_hookHelper.FocusMap;
            IActiveView pActView = m_hookHelper.ActiveView;

            if (Button == 1)
            {
                pPnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                if (frm.CheckedBtn == 1)
                {
                    if (m_FeedbackLine == null)
                    {
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                        m_FeedbackLine         = new NewLineFeedbackClass();
                        m_FeedbackLine.Display = m_hookHelper.ActiveView.ScreenDisplay;
                        m_FeedbackLine.Start(pPnt);
                    }
                    else
                    {
                        m_FeedbackLine.AddPoint(pPnt);
                    }

                    frm.frmLineDown(ref pPnt);
                }

                if (frm.CheckedBtn == 2)
                {
                    if (m_FeedbackPolygon == null)
                    {
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                        m_FeedbackPolygon         = new NewPolygonFeedbackClass();
                        m_FeedbackPolygon.Display = m_hookHelper.ActiveView.ScreenDisplay;
                        m_FeedbackPolygon.Start(pPnt);
                    }
                    else
                    {
                        m_FeedbackPolygon.AddPoint(pPnt);
                    }

                    frm.frmAreaDown(ref pPnt);
                }

                if (frm.CheckedBtn == 3)
                {
                    frm.frmFeatDown(ref pMap, ref pPnt, pActView);
                }
            }
        }
示例#11
0
 /// <summary>
 /// 单机时运行
 /// </summary>
 /// <param name="clickPT">单机的地图点</param>
 public void OnMouseDownRun(IPoint clickPT)
 {
     if (polygonFeedback == null)
     {
         polygonFeedback         = new NewPolygonFeedbackClass();
         polygonFeedback.Display = (mapControl.Map as IActiveView).ScreenDisplay;
         pointCollection.RemovePoints(0, pointCollection.PointCount);
         polygonFeedback.Start(clickPT);
         pointCollection.AddPoint(clickPT, Type.Missing, Type.Missing);
     }
     else
     {
         polygonFeedback.AddPoint(clickPT);
         pointCollection.AddPoint(clickPT, Type.Missing, Type.Missing);
     }
 }
        public void EndSketch()
        {
            IGeometry        resGeometry = null;
            IPointCollection pointColl   = null;

            try
            {
                if ((MyfeedBack as INewMultiPointFeedback) != null)
                {
                    INewMultiPointFeedback multiPointFeedback = MyfeedBack as INewMultiPointFeedback;
                    multiPointFeedback.Stop();
                }
                else if ((MyfeedBack as INewLineFeedback) != null)
                {
                    INewLineFeedback lineFeedback = MyfeedBack as INewLineFeedback;
                    lineFeedback.AddPoint(MycurrentMousePosition);
                    IPolyline polyline = lineFeedback.Stop();
                    pointColl = polyline as IPointCollection;
                    if (pointColl.PointCount > 1)
                    {
                        resGeometry = pointColl as IGeometry;
                    }
                }
                else if ((MyfeedBack as INewPolygonFeedback) != null)
                {
                    INewPolygonFeedback polygonFeedback = MyfeedBack as INewPolygonFeedback;
                    polygonFeedback.AddPoint(MycurrentMousePosition);
                    IPolygon polygon = polygonFeedback.Stop();
                    if (polygon != null)
                    {
                        pointColl = polygon as IPointCollection;
                        if (pointColl.PointCount > 2)
                        {
                            resGeometry = pointColl as IGeometry;
                            ITopologicalOperator pTopo = resGeometry as ITopologicalOperator;
                            if (!pTopo.IsKnownSimple)
                            {
                                pTopo.Simplify();
                            }
                        }
                    }
                }
                MyfeedBack = null;
                If_isInUse = false;
            }
            catch { return; }
        }
示例#13
0
        private void EndSketch()
        {
            IGeometry        m_Geometry        = null;
            IPointCollection m_PointCollection = null;

            if (m_Feedback is INewLineFeedback)
            {
                INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                m_LineFeed.AddPoint(m_PointStop);
                IPolyline m_PolyLine = m_LineFeed.Stop();
                m_PointCollection = (IPointCollection)m_PolyLine;
                if (m_PointCollection.PointCount < 2)
                {
                    MessageBox.Show("需要两个点才能生成一条线!", "未能生成线", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }
            else if (m_Feedback is INewPolygonFeedback)
            {
                INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback;
                m_PolyFeed.AddPoint(m_PointStop);
                IPolygon m_Polygon = m_PolyFeed.Stop();
                if (m_Polygon != null)
                {
                    m_PointCollection = (IPointCollection)m_Polygon;
                }
                if (m_PointCollection.PointCount < 3)
                {
                    MessageBox.Show("需要三个点才能生成一个面!", "未能生成面", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }

            CreatFeature(m_Geometry);
            m_hookHelper.ActiveView.Refresh();
            m_Feedback = null;
            m_bInUse   = false;
        }
示例#14
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     if (Button == 1)
     {
         if (_drawStart && _startPoint == null)
         {
             _startPoint = (myHook.FocusMap as IActiveView).ScreenDisplay.
                           DisplayTransformation.ToMapPoint(X, Y);
             _polyFeedback.Start(_startPoint);
         }
         else if (_drawStart)
         {
             _endPoint = (myHook.FocusMap as IActiveView).ScreenDisplay.
                         DisplayTransformation.ToMapPoint(X, Y);
             _polyFeedback.AddPoint(_endPoint);
         }
     }
 }
示例#15
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolRasterEdit.OnMouseDown implementation
            IMapControl3 pMapCtrl = ClsGlobal.GetMapControl(m_hookHelper);

            if (pMapCtrl == null)
            {
                return;
            }
            IPoint pPoint = pMapCtrl.ToMapPoint(X, Y);

            if (Button == 1)
            {
                if (m_NewPolygonFeedback == null)
                {
                    m_NewPolygonFeedback         = new NewPolygonFeedbackClass();
                    m_NewPolygonFeedback.Display = pMapCtrl.ActiveView.ScreenDisplay;

                    m_NewPolygonFeedback.Start(pPoint);
                }
                else
                {
                    try
                    {
                        object Miss = Type.Missing;
                        m_NewPolygonFeedback.AddPoint(pPoint);
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
            }
            if (Button == 2)
            {
                if (m_NewPolygonFeedback != null)
                {
                    m_NewPolygonFeedback.Stop();
                }

                m_NewPolygonFeedback = null;
            }
        }
示例#16
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolDeleteNodeByArea.OnMouseDown implementation
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            if (pMapCtr != null)
            {
                IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);
                if (mNewPolygonFeedback == null)
                {
                    mNewPolygonFeedback         = new NewPolygonFeedbackClass();
                    mNewPolygonFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
                    mNewPolygonFeedback.Start(mapPoint);
                }
                else
                {
                    mapPoint = pMapCtr.ToMapPoint(X, Y);
                    mNewPolygonFeedback.AddPoint(mapPoint);
                }
            }
        }
        public override void OnKeyUp(int keyCode, int Shift)
        {
            if (Shift != 2 && keyCode != 90)
            {
                return;
            }
            if (m_pNewPolygonFeedback == null)
            {
                return;
            }
            IPolygon pPolygon = m_pNewPolygonFeedback.Stop();

            m_pNewPolygonFeedback = null;
            if (pPolygon == null)
            {
                return;
            }
            IPointCollection pntCol = pPolygon as IPointCollection;

            IRgbColor         pRGB = new RgbColorClass();
            ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();

            pRGB.Red   = 15;
            pRGB.Blue  = 15;
            pRGB.Green = 0;
            pSimpleFillSymbol.Color = pRGB;
            pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;

            m_pNewPolygonFeedback         = new NewPolygonFeedbackClass();
            m_pNewPolygonFeedback.Symbol  = pSimpleFillSymbol as ISymbol;
            m_pNewPolygonFeedback.Display = m_MapControl.ActiveView.ScreenDisplay;

            m_pNewPolygonFeedback.Start(pntCol.get_Point(0));
            for (int i = 1; i < pntCol.PointCount - 2; i++)
            {
                m_pNewPolygonFeedback.AddPoint(pntCol.get_Point(i));
            }

            m_pNewPolygonFeedback.MoveTo(pntCol.get_Point(pntCol.PointCount - 1));
        }
示例#18
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                IPoint cursorPoint = m_screenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                if (m_polygonFeedback == null)
                {
                    m_currentSides            = 0;
                    m_polygonFeedback         = new NewPolygonFeedbackClass();
                    m_polygonFeedback.Display = m_screenDisplay;

                    m_polygonFeedback.Start(cursorPoint);
                }
                else
                {
                    m_polygonFeedback.AddPoint(cursorPoint);
                }

                m_currentSides++;
                if (m_currentSides == m_maxSides) //Finish
                {
                    IPolygon polygon = m_polygonFeedback.Stop();

                    //Report area on status bar
                    IArea feedBackArea = polygon as IArea;
                    m_application.StatusBar.set_Message(0, "Feedback: area = " + Math.Abs(feedBackArea.Area).ToString());

                    m_polygonFeedback = null;
                }
                else
                {
                    //Report vertex remaining
                    m_application.StatusBar.set_Message(0, string.Format("Feedback: {0} point(s) remaining", m_maxSides - m_currentSides));
                }
            }
        }
示例#19
0
文件: mainForm.cs 项目: hehao1999/GIS
        //拉框选择
        private void mainMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (flag == 1)
            {
                baseOrder.box_select(e);
            }
            //屏幕坐标点转化为地图坐标点
            pPointPt = (mainMapControl.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            if (e.button == 1)
            {
                IActiveView pActiveView = mainMapControl.ActiveView;
                IEnvelope   pEnvelope   = new EnvelopeClass();
                if (pMouseOperate == "MeasureLength")
                {
                    //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点
                    if (pNewLineFeedback == null)
                    {
                        //实例化追踪线对象
                        pNewLineFeedback         = new NewLineFeedbackClass();
                        pNewLineFeedback.Display = (mainMapControl.Map as IActiveView).ScreenDisplay;
                        //设置起点,开始动态线绘制
                        pNewLineFeedback.Start(pPointPt);
                        dToltalLength = 0;
                    }
                    else //如果追踪线对象不为空,则添加当前鼠标点
                    {
                        pNewLineFeedback.AddPoint(pPointPt);
                    }
                    //pGeometry = m_PointPt;
                    if (dSegmentLength != 0)
                    {
                        dToltalLength = dToltalLength + dSegmentLength;
                    }
                }
                else if (pMouseOperate == "MeasureArea")
                {
                    if (pNewPolygonFeedback == null)
                    {
                        //实例化追踪面对象
                        pNewPolygonFeedback         = new NewPolygonFeedback();
                        pNewPolygonFeedback.Display = (mainMapControl.Map as IActiveView).ScreenDisplay;
                        ;
                        pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount);
                        //开始绘制多边形
                        pNewPolygonFeedback.Start(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    else
                    {
                        pNewPolygonFeedback.AddPoint(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                }
            }
            else if (e.button == 2)
            {
                pMouseOperate = "";
                mainMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
            }

            if (flag == 0)
            {
                mainMapControl.CurrentTool = null;
                if (e.button != 2)
                {
                    flag = 999;
                    return;
                }
                IPoint point = new PointClass();
                point = mainMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                //设置文本格式
                ITextSymbol textSymbol = new TextSymbolClass();
                StdFont     stdFont    = new stdole.StdFontClass();
                stdFont.Name           = "宋体";
                stdFont.Size           = 24;
                textSymbol.Font        = (IFontDisp)stdFont;
                textSymbol.Angle       = 0;
                textSymbol.RightToLeft = false;
                //垂直方向基线对齐
                textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline;
                //文本两端对齐
                textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;
                textSymbol.Text = C.Text;
                ITextElement textElement = new TextElementClass();
                textElement.Symbol = textSymbol;
                textElement.Text   = textSymbol.Text;
                //获取坐标,添加文本
                IElement element = (IElement)textElement;
                element.Geometry = point;
                mainMapControl.ActiveView.GraphicsContainer.AddElement(element, 0);
                mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element, null);
            }

            if (flag == 66)
            {//画线
                IGeometry pGeom;
                pGeom = (IGeometry)mainMapControl.TrackLine();
                IGraphicsContainer pGraphicsContainer = mainMapControl.Map as IGraphicsContainer;
                baseOrder.AddLineElement(pGeom, pGraphicsContainer);
            }

            if (flag == 77)
            {//闪
                IMap                 pMap        = mainMapControl.Map;
                IActiveView          pActiveView = pMap as IActiveView;
                IPoint               pt          = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                ITopologicalOperator pTopo       = pt as ITopologicalOperator;
                IGeometry            pGeo        = pTopo.Buffer(100);
                IColor               pColor      = new RgbColorClass();
                pColor.RGB = 2556;
                SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color = pColor; ISymbol symbol = simpleFillSymbol as ISymbol;
                pActiveView.ScreenDisplay.SetSymbol(symbol);
                pActiveView.ScreenDisplay.DrawPolygon(pGeo);
                pMap.SelectByShape(pGeo, null, false);
                mainMapControl.FlashShape(pGeo, 25, 200, symbol);
                mainMapControl.ActiveView.Refresh();
            }
        }
示例#20
0
        /// <summary>
        /// 地图中鼠标按下事件监听
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //屏幕坐标点转化为地图坐标点
            pPointPt = (MainMapControl.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            if (e.button == 1)
            {
                IActiveView pActiveView = MainMapControl.ActiveView;
                IEnvelope   pEnvelope   = new EnvelopeClass();

                switch (pMouseOperate)
                {
                case "ZoomIn":
                    pEnvelope = MainMapControl.TrackRectangle();
                    //  如果拉框范围为空则返回
                    if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0)
                    {
                        return;
                    }
                    // 如果拉框有范围,则拉大到拉框范围
                    MainMapControl.ActiveView.Extent = pEnvelope;
                    MainMapControl.ActiveView.Refresh();
                    break;

                case "ZoomOut":
                    pEnvelope = MainMapControl.TrackRectangle();
                    //  如果拉框范围为空则返回
                    if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0)
                    {
                        return;
                    }
                    else
                    {
                        double dWidth  = pActiveView.Extent.Width * pActiveView.Extent.Width / pEnvelope.Width;
                        double dHeight = pActiveView.Extent.Height * pActiveView.Extent.Height / pEnvelope.Height;
                        double dXmin   = pActiveView.Extent.XMin -
                                         ((pEnvelope.XMin - pActiveView.Extent.XMin) * pActiveView.Extent.Width /
                                          pEnvelope.Width);
                        double dYmin = pActiveView.Extent.YMin -
                                       ((pEnvelope.YMin - pActiveView.Extent.YMin) * pActiveView.Extent.Height /
                                        pEnvelope.Height);
                        double dXmax = dXmin + dWidth;
                        double dYmax = dYmin + dHeight;
                        pEnvelope.PutCoords(dXmin, dYmin, dXmax, dYmax);
                    }
                    pActiveView.Extent = pEnvelope;
                    pActiveView.Refresh();
                    break;

                case "Pan":
                    MainMapControl.Pan();
                    break;

                case "MeasureLength":
                    //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点
                    if (pNewLineFeedback == null)
                    {
                        //实例化追踪线对象
                        pNewLineFeedback         = new NewLineFeedbackClass();
                        pNewLineFeedback.Display = (MainMapControl.Map as IActiveView).ScreenDisplay;
                        //设置起点,开始动态线绘制
                        pNewLineFeedback.Start(pPointPt);
                        dToltalLength = 0;
                    }
                    else     //如果追踪线对象不为空,则添加当前鼠标点
                    {
                        pNewLineFeedback.AddPoint(pPointPt);
                    }
                    //pGeometry = m_PointPt;
                    if (dSegmentLength != 0)
                    {
                        dToltalLength = dToltalLength + dSegmentLength;
                    }
                    break;

                case "MeasureArea":
                    if (pNewPolygonFeedback == null)
                    {
                        //实例化追踪面对象
                        pNewPolygonFeedback         = new NewPolygonFeedback();
                        pNewPolygonFeedback.Display = (MainMapControl.Map as IActiveView).ScreenDisplay;
                        ;
                        pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount);
                        //开始绘制多边形
                        pNewPolygonFeedback.Start(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    else
                    {
                        pNewPolygonFeedback.AddPoint(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    break;

                case "SelFeature":
                    IEnvelope pEnv = MainMapControl.TrackRectangle();
                    IGeometry pGeo = pEnv as IGeometry;
                    // 矩形框若为空,即为点选时,对点的范围进行扩展
                    if (pEnv.IsEmpty == true)
                    {
                        tagRECT r;
                        r.left   = e.x - 5;
                        r.top    = e.y - 5;
                        r.right  = e.x + 5;
                        r.bottom = e.y + 5;
                        pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4);
                        pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference;
                    }
                    pGeo = pEnv as IGeometry;
                    MainMapControl.Map.SelectByShape(pGeo, null, false);
                    MainMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                    //IEnvelope pEnv = MainMapControl.TrackRectangle();
                    //IGeometry pGeo = pEnv as IGeometry;
                    ////矩形框若为空,即为点选时,对点范围进行扩展
                    //if (pEnv.IsEmpty == true)
                    //{
                    //    tagRECT r;
                    //    r.left = e.x - 5;
                    //    r.top = e.y - 5;
                    //    r.right = e.x + 5;
                    //    r.bottom = e.y + 5;
                    //    pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4);
                    //    pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference;
                    //}
                    //pGeo = pEnv as IGeometry;
                    //MainMapControl.Map.SelectByShape(pGeo, null, false);
                    //MainMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                    break;

                case "ExportRegion":
                    // 删除视图中的数据
                    MainMapControl.ActiveView.GraphicsContainer.DeleteAllElements();
                    MainMapControl.ActiveView.Refresh();
                    IPolygon polygon = DrawPolygon(MainMapControl);
                    if (polygon == null)
                    {
                        return;
                    }
                    ExportMap.AddElement(polygon, MainMapControl.ActiveView);
                    if (FrmExpMap == null || FrmExpMap.IsDisposed)
                    {
                        FrmExpMap = new FormExportMap(MainMapControl);
                    }
                    FrmExpMap.IsRegion   = true;
                    FrmExpMap.GetGometry = polygon as IGeometry;
                    FrmExpMap.Show();
                    FrmExpMap.Activate();
                    break;

                case "TxtSymbol":
                    TxtSymbol(e);
                    break;

                default:
                    break;
                }
            }
            else if (e.button == 2)
            {
                pMouseOperate = "";
                MainMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
            }
        }
示例#21
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            //增加单击右键结束量测 田晶添加20081028
            if (Button == 2)
            {
                OnDblClick();
                return;
            }

            IActiveView ipAV = this.m_hookHelper.ActiveView;
            ///////////生成新点///////////////
            IPoint ipPt = new PointClass();

            ipPt = ipAV.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            SnapPoint(ipPt);
            ////////////结果窗口///////////////
            //if (this.m_FormDis == null)
            //{
            //    MeasureType type = MeasureType.Area;
            //    this.m_FormDis = new FormDis(type, this);
            //    this.m_FormDis.TopMost = true;
            //    this.m_FormDis.Show();
            //}

            if (this.m_GeoMeasure == null)
            {
                m_pNewPolygonFeed = new NewPolygonFeedbackClass();
                IScreenDisplay pScreen = ipAV.ScreenDisplay;
                m_pNewPolygonFeed.Display = pScreen;
                m_pNewPolygonFeed.Start(ipPt);

                this.m_GeoMeasure = new PolylineClass();
            }
            else
            {
                m_pNewPolygonFeed.AddPoint(ipPt);
            }

            /*
             * /////////生成实体///////////
             * object obj = Type.Missing;
             * if (this.m_GeoMeasure == null)
             * {
             *  this.m_GeoMeasure = new PolygonClass();
             *  IGeometryCollection ipGeoCol = this.m_GeoMeasure as IGeometryCollection;
             *  ISegmentCollection ipSelCol = new RingClass();
             *  ILine ipLine = new LineClass();
             *  ipLine.PutCoords(ipPt, ipPt);
             *  ipSelCol.AddSegment(ipLine as ISegment, ref obj, ref obj);
             *  ipSelCol.AddSegment(ipLine as ISegment, ref obj, ref obj);
             *  ipGeoCol.AddGeometry(ipSelCol as IGeometry, ref obj, ref obj);
             * }
             * else
             * {
             *  IGeometryCollection ipGeoCol = this.m_GeoMeasure as IGeometryCollection;
             *  ISegmentCollection ipSelCol = ipGeoCol.get_Geometry(0) as ISegmentCollection;
             *  ipSelCol.RemoveSegments(ipSelCol.SegmentCount - 1, 1, false);
             *  ILine ipLine = new LineClass();
             *  ipLine.PutCoords(ipSelCol.get_Segment(ipSelCol.SegmentCount - 1).ToPoint, ipPt);
             *  ISegment ipSeg = ipLine as ISegment;
             *  ipSelCol.AddSegment(ipSeg, ref obj, ref obj);
             *  ipLine = new LineClass();
             *  ipLine.PutCoords(ipPt, ipSelCol.get_Segment(0).FromPoint);
             *  ipSeg = ipLine as ISegment;
             *  ipSelCol.AddSegment(ipSeg, ref obj, ref obj);
             * }
             *
             * ////////显示/////////////
             * IClone ipClone = this.m_GeoMeasure as IClone;
             * IGeometry ipGeo = ipClone.Clone() as IGeometry;
             * this.m_Element.Geometry = ipGeo;
             * //局部刷新
             * ipAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, ipGeo, null);
             * //ipAV.Refresh();
             *
             * this.m_FormDis.WriteLabelText(ipGeo);
             *
             * this.m_FormDis.m_timer.Start();
             */
        }
        public void SketchMouseDown(int x, int y)
        {
            if (MyselectedLayer == null)
            {
                return;
            }
            if ((MyselectedLayer as IGeoFeatureLayer) == null)
            {
                return;
            }

            IFeatureLayer featureLayer = MyselectedLayer as IFeatureLayer;
            IFeatureClass featureClass = featureLayer.FeatureClass;

            if (featureClass == null)
            {
                return;
            }

            IPoint              point           = MyMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            INewLineFeedback    lineFeedback    = null;
            INewPolygonFeedback polygonFeedback = null;

            try
            {
                if (!If_isInUse)
                {
                    switch (featureClass.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:
                        break;

                    case esriGeometryType.esriGeometryMultipoint:
                        If_isInUse = true;
                        MyfeedBack = new NewMultiPointFeedbackClass();
                        INewMultiPointFeedback multiPointFeedback = MyfeedBack as INewMultiPointFeedback;
                        MypointCollection = new MultipointClass();
                        multiPointFeedback.Start(MypointCollection, point);
                        break;

                    case esriGeometryType.esriGeometryPolyline:
                        If_isInUse   = true;
                        MyfeedBack   = new NewLineFeedbackClass();
                        lineFeedback = MyfeedBack as INewLineFeedback;
                        lineFeedback.Start(point);
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        If_isInUse      = true;
                        MyfeedBack      = new NewPolygonFeedbackClass();
                        polygonFeedback = MyfeedBack as INewPolygonFeedback;
                        polygonFeedback.Start(point);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    if ((MyfeedBack as INewMultiPointFeedback) != null)
                    {
                        object missing = Type.Missing;
                        MypointCollection.AddPoint(point, ref missing, ref missing);
                    }
                    else if ((MyfeedBack as INewLineFeedback) != null)
                    {
                        lineFeedback = MyfeedBack as INewLineFeedback;
                        lineFeedback.AddPoint(point);
                    }
                    else if ((MyfeedBack as INewPolygonFeedback) != null)
                    {
                        polygonFeedback = MyfeedBack as INewPolygonFeedback;
                        polygonFeedback.AddPoint(point);
                    }
                }
            }
            catch { return; }
        }
示例#23
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            IActiveView pActiveview = axMapControl1.ActiveView;
            IEnvelope   envelope    = new EnvelopeClass();

            pPointPt = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            switch (mousedownname)
            {
            case "":
                break;

            case "zoomin":                                                                               //拉框放大
                envelope = axMapControl1.TrackRectangle();                                               //获取拉框信息
                if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0) //判断是否为空框
                {
                    return;
                }
                pActiveview.Extent = envelope;
                pActiveview.Refresh();
                break;

            case "zoomout":    //拉框缩小
                envelope = axMapControl1.TrackRectangle();
                if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0)
                {
                    return;
                }
                double dwidth  = pActiveview.Extent.Width * pActiveview.Extent.Width / envelope.Width;
                double dheight = pActiveview.Extent.Height * pActiveview.Extent.Height / envelope.Height;
                double dXmin   = pActiveview.Extent.XMin - ((envelope.XMin - pActiveview.Extent.XMin) * pActiveview.Extent.Width / envelope.Width);
                double dYmin   = pActiveview.Extent.YMin - ((envelope.YMin - pActiveview.Extent.YMin) * pActiveview.Extent.Height / envelope.Height);
                double dxMAX   = dXmin + dwidth;
                double dyMAX   = dYmin + dheight;
                envelope.PutCoords(dXmin, dYmin, dxMAX, dyMAX);
                pActiveview.Extent = envelope;
                pActiveview.Refresh();
                break;

            case "manyou":    //漫游
                axMapControl1.Pan();
                break;

            case "MeasureLength":    //长度量测

                if (pNewLineFeedback == null)
                {
                    pNewLineFeedback = new NewLineFeedback {
                        Display = pActiveview.ScreenDisplay
                    };                                   //实例化追踪线对象
                    pNewLineFeedback.Start(pPointPt);    //设置起点,开始动态绘制
                    dToltaLength = 0;
                }
                else    //如果追踪线对象不为空,则添加当前鼠标点
                {
                    pNewLineFeedback.AddPoint(pPointPt);
                }
                if (dSegmentLength != 0)
                {
                    dToltaLength = dToltaLength + dSegmentLength;
                }
                break;

            case "MeasureArea":    //面积量测

                if (pNewPolygonFeedback == null)
                {
                    pNewPolygonFeedback = new NewPolygonFeedback {
                        Display = pActiveview.ScreenDisplay
                    };                                                                     //实例化面对象
                    pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount); //清空点集
                    pNewPolygonFeedback.Start(pPointPt);                                   //开始绘制多边形
                    pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing);
                }
                else
                {
                    pNewPolygonFeedback.AddPoint(pPointPt);
                    pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing);
                }

                break;

            case "selectfeature":    //要素选择
                IEnvelope pEnv = axMapControl1.TrackRectangle();
                IGeometry pGeo = pEnv;
                if (pEnv.IsEmpty)    //若为空则在鼠标当前点进行选择部分区域作为框
                {
                    tagRECT r;
                    r.left   = e.x - 5;
                    r.top    = e.y - 5;
                    r.right  = e.x + 5;
                    r.bottom = e.y + 5;
                    pActiveview.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4);
                    pEnv.SpatialReference = pActiveview.FocusMap.SpatialReference;
                }
                pGeo = pEnv;
                axMapControl1.Map.SelectByShape(pGeo, null, false);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                break;

            case "ExportRegion":
                pActiveview.GraphicsContainer.DeleteAllElements();
                pActiveview.Refresh();
                IPolygon pPolygon = ExportMap.DrawPolygon(axMapControl1);
                if (pPolygon == null)
                {
                    return;
                }
                ExportMap.AddElement(pPolygon, pActiveview);
                if (frmExpMap == null || frmExpMap.IsDisposed)
                {
                    frmExpMap = new mapexport(axMapControl1);
                }
                frmExpMap.isRegion = true;
                frmExpMap.geometry = pPolygon;
                frmExpMap.Show();
                frmExpMap.Activate();
                break;
            }
        }
示例#24
0
        /// <summary>
        ///鼠标点击操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapcontrol_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            Dwnpoint = new PointClass();
            Dwnpoint = this.axMapcontrol.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            if (e.button != 1)
            {
                return;
            }
            #region 地图操作
            switch (pMouseOperate)
            {
            case  "区域导出":
                //删除绘制的图片
                this.axMapcontrol.ActiveView.GraphicsContainer.DeleteAllElements();
                this.axMapcontrol.ActiveView.Refresh();
                IPolygon polygon = DrawPolygon(this.axMapcontrol);
                if (polygon == null)
                {
                    return;
                }
                ExportMap.AddElement(polygon, this.axMapcontrol.ActiveView);
                if (polygon == null)
                {
                    return;
                }
                if (exportmapFrm == null || exportmapFrm.IsDisposed)
                {
                    exportmapFrm             = new ExportMapFrm(this.axMapcontrol);
                    exportmapFrm.IsRgion     = true;
                    exportmapFrm.GetGeometry = polygon as IGeometry;
                    exportmapFrm.Show();
                }
                exportmapFrm.GetGeometry = polygon;
                exportmapFrm.IsRgion     = true;
                //获取当前控件焦点
                exportmapFrm.Activate();
                break;

            case "MeasureLength":
                if (m_newline == null)
                {
                    m_newline         = new NewLineFeedbackClass();
                    m_newline.Display = this.axMapcontrol.ActiveView.ScreenDisplay;
                    m_newline.Start(Dwnpoint);
                    TotalLength = 0;
                }
                else
                {
                    TotalLength += SegmentLength;
                    m_newline.AddPoint(Dwnpoint);
                }
                break;

            case "MeasureArea":
                if (m_newpolygon == null || Area_Pocoll == null)
                {
                    m_newpolygon         = new NewPolygonFeedbackClass();
                    Area_Pocoll          = new PolygonClass();
                    m_newpolygon.Display = this.axMapcontrol.ActiveView.ScreenDisplay;
                    m_newpolygon.Start(Dwnpoint);
                    Area_Pocoll.AddPoint(Dwnpoint);
                    TotalLength = 0;
                }
                else
                {
                    m_newpolygon.AddPoint(Dwnpoint);
                    Area_Pocoll.AddPoint(Dwnpoint);
                    TotalLength += SegmentLength;
                }
                break;
            }


            #endregion
        }
示例#25
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            #region 处理各种交互情况
            switch (m_sketchshape)
            {
            case "polygon":
            {
                IScreenDisplay iSDisplay = m_MapCtrls.ActiveView.ScreenDisplay;

                IPoint newPoint = new PointClass();
                newPoint = iSDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

                if (e.button == 1)
                {
                    //左单击画多边形添加点:
                    if (m_NewPolygonFeedback == null)
                    {
                        m_NewPolygonFeedback = new NewPolygonFeedbackClass();

                        m_NewPolygonFeedback.Display = iSDisplay;
                        m_NewPolygonFeedback.Start(newPoint);
                    }
                    else
                    {
                        m_NewPolygonFeedback.AddPoint(newPoint);
                    }
                }
                if (e.button == 2)
                {
                    if (m_NewPolygonFeedback == null)
                    {
                        return;
                    }
                    //右键结束绘制:
                    m_NewPolygonFeedback.AddPoint(newPoint);
                    m_NewPolygon = m_NewPolygonFeedback.Stop();

                    //若是逆时针创建,反转一下,变为顺时针:
                    IArea feedBackArea = m_NewPolygon as IArea;
                    if (feedBackArea.Area < 0)
                    {
                        m_NewPolygon.ReverseOrientation();
                    }

                    IGeometry         newGeometry       = m_NewPolygon as IGeometry;
                    IFeatureWorkspace checkWorkspace    = m_GlobalWorkspace as IFeatureWorkspace;
                    IFeatureClass     checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea");


                    if (!(m_EditWorkspace.IsBeingEdited()))
                    {
                        m_EditWorkspace.StartEditing(false);
                    }

                    m_EditWorkspace.StartEditOperation();
                    int OID = CheckFeatueEditor.InsertNewFeature(newGeometry, checkFeatureClass, AppManager.GetInstance().TaskName);
                    m_EditWorkspace.StopEditOperation();
                    //ISelectionEnvironment selectionEnv = new SelectionEnvironmentClass();
                    //selectionEnv.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelOverlaps;
                    //selectionEnv.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
                    //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, null, true);
                    //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, selectionEnv, true);
                    //m_MapCtrls.Map.SelectByShape(m_NewPolygon, null, true);
                    ILayer   iLayer   = m_MapCtrls.Layer[0];
                    IFeature iFeature = checkFeatureClass.GetFeature(OID);

                    clearFeatureSelection();

                    m_MapCtrls.Map.SelectFeature(iLayer, iFeature);
                    m_NewPolygonFeedback = null;
                    m_MapCtrls.ActiveView.Refresh();
                }
                break;
            }

            case "rectangle":
            {
                IScreenDisplay iSDisplay = m_MapCtrls.ActiveView.ScreenDisplay;

                IPoint newPoint = new PointClass();
                newPoint = iSDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                if (e.button == 1)
                {
                    if (m_RecFeedback == null)
                    {
                        m_RecFeedback         = new NewRectangleFeedbackClass();
                        m_RecFeedback.Display = iSDisplay;
                        m_RecFeedback.Angle   = 90;
                        m_RecFeedback.Start(newPoint);

                        newPoint.Y = newPoint.Y + 20;

                        m_RecFeedback.SetPoint(newPoint);
                    }
                    else
                    {
                        m_RecFeedback.SetPoint(newPoint);
                    }
                }
                if (e.button == 2)
                {
                    if (m_RecFeedback != null)
                    {
                        m_NewPolygon = m_RecFeedback.Stop(newPoint) as IPolygon;

                        //若是逆时针创建,反转一下,变为顺时针:
                        IArea feedBackArea = m_NewPolygon as IArea;
                        if (feedBackArea.Area < 0)
                        {
                            m_NewPolygon.ReverseOrientation();
                        }

                        IGeometry         newGeometry       = m_NewPolygon as IGeometry;
                        IFeatureWorkspace checkWorkspace    = m_GlobalWorkspace as IFeatureWorkspace;
                        IFeatureClass     checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea");


                        if (!(m_EditWorkspace.IsBeingEdited()))
                        {
                            m_EditWorkspace.StartEditing(false);
                        }

                        m_EditWorkspace.StartEditOperation();
                        int OID = CheckFeatueEditor.InsertNewFeature(newGeometry, checkFeatureClass, AppManager.GetInstance().TaskName);
                        m_EditWorkspace.StopEditOperation();

                        ILayer   iLayer   = m_MapCtrls.Layer[0];
                        IFeature iFeature = checkFeatureClass.GetFeature(OID);

                        clearFeatureSelection();

                        m_MapCtrls.Map.SelectFeature(iLayer, iFeature);
                        m_MapCtrls.ActiveView.Refresh();
                        m_RecFeedback = null;
                    }
                }

                break;
            }
            }
            #endregion
        }
示例#26
0
文件: Form1.cs 项目: Flame-c/CYHGIS
        private void AxMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //屏幕坐标点转化为地图坐标点
            pPointPt = (axMapControl1.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            if (e.button == 1)
            {
                IActiveView pActiveView = axMapControl1.ActiveView;
                IEnvelope   pEnvelope   = new EnvelopeClass();

                switch (pMouseOperate)
                {
                    #region 拉框放大

                case "ZoomIn":
                    pEnvelope = axMapControl1.TrackRectangle();
                    //如果拉框范围为空则返回
                    if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0)
                    {
                        return;
                    }
                    //如果有拉框范围,则放大到拉框范围
                    pActiveView.Extent = pEnvelope;
                    pActiveView.Refresh();
                    break;

                    #endregion

                    #region 拉框缩小

                case "ZoomOut":
                    pEnvelope = axMapControl1.TrackRectangle();

                    //如果拉框范围为空则退出
                    if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0)
                    {
                        return;
                    }
                    //如果有拉框范围,则以拉框范围为中心,缩小倍数为:当前视图范围/拉框范围
                    else
                    {
                        double dWidth  = pActiveView.Extent.Width * pActiveView.Extent.Width / pEnvelope.Width;
                        double dHeight = pActiveView.Extent.Height * pActiveView.Extent.Height / pEnvelope.Height;
                        double dXmin   = pActiveView.Extent.XMin -
                                         ((pEnvelope.XMin - pActiveView.Extent.XMin) * pActiveView.Extent.Width /
                                          pEnvelope.Width);
                        double dYmin = pActiveView.Extent.YMin -
                                       ((pEnvelope.YMin - pActiveView.Extent.YMin) * pActiveView.Extent.Height /
                                        pEnvelope.Height);
                        double dXmax = dXmin + dWidth;
                        double dYmax = dYmin + dHeight;
                        pEnvelope.PutCoords(dXmin, dYmin, dXmax, dYmax);
                    }
                    pActiveView.Extent = pEnvelope;
                    pActiveView.Refresh();
                    break;

                    #endregion

                    #region 漫游

                case "Pan":
                    axMapControl1.Pan();
                    break;

                    #endregion

                    #region  择要素

                case "SelFeature":
                    IEnvelope pEnv = axMapControl1.TrackRectangle();
                    IGeometry pGeo = pEnv as IGeometry;
                    //矩形框若为空,即为点选时,对点范围进行扩展
                    if (pEnv.IsEmpty == true)
                    {
                        tagRECT r;
                        r.left   = e.x - 5;
                        r.top    = e.y - 5;
                        r.right  = e.x + 5;
                        r.bottom = e.y + 5;
                        pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4);
                        pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference;
                    }
                    pGeo = pEnv as IGeometry;
                    axMapControl1.Map.SelectByShape(pGeo, null, false);
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    break;

                    #endregion

                    #region 要素选择
                case "SelectFeature":
                    IPoint    point     = new PointClass();
                    IGeometry pGeometry = point as IGeometry;
                    axMapControl1.Map.SelectByShape(pGeometry, null, false);
                    axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    break;
                    #endregion

                    #region 距离量算
                case "MeasureLength":
                    //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点
                    if (pNewLineFeedback == null)
                    {
                        //实例化追踪线对象
                        pNewLineFeedback         = new NewLineFeedbackClass();
                        pNewLineFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay;
                        //设置起点,开始动态线绘制
                        pNewLineFeedback.Start(pPointPt);
                        dToltalLength = 0;
                    }
                    else     //如果追踪线对象不为空,则添加当前鼠标点
                    {
                        pNewLineFeedback.AddPoint(pPointPt);
                    }
                    //pGeometry = m_PointPt;
                    if (dSegmentLength != 0)
                    {
                        dToltalLength = dToltalLength + dSegmentLength;
                    }
                    break;
                    #endregion

                    #region 面积量算
                case "MeasureArea":
                    if (pNewPolygonFeedback == null)
                    {
                        //实例化追踪面对象
                        pNewPolygonFeedback         = new NewPolygonFeedback();
                        pNewPolygonFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay;
                        ;
                        pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount);
                        //开始绘制多边形
                        pNewPolygonFeedback.Start(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    else
                    {
                        pNewPolygonFeedback.AddPoint(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    break;
                    #endregion

                    #region 添加文字
                case "AddCharacters":
                {
                    //本例的实现类似于前面测量工具的实现
                    //在工具条添加自定义的工具之后,在其Click事件中用m_flag变量记录操作
                    //然后在MapControl的OnMouseDown事件的适当位置添加如下代码:
                    IFontDisp font = new StdFontClass() as IFontDisp; font.Bold = true;
                    font.Name = "Arial"; font.Size = 20;
                    IColor pColor = new RgbColorClass();
                    pColor.RGB        = 0; ITextSymbol pTextSymbol = new TextSymbolClass();
                    pTextSymbol.Size  = 200;
                    pTextSymbol.Font  = font;
                    pTextSymbol.Color = pColor;
                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(e.mapX, e.mapY);
                    ITextElement pTextElement = new TextElementClass();
                    pTextElement.Symbol = pTextSymbol;
                    pTextElement.Text   = toolStripTextBox1.Text;
                    IElement pElement = pTextElement as IElement;
                    pElement.Geometry = pPoint as IGeometry;
                    axMapControl1.ActiveView.GraphicsContainer.AddElement(pElement, 3);
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                }
                break;
                    #endregion

                    #region 添加线型元素
                case "AddLine":
                    IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer;
                    IActiveView        pAv  = pGra as IActiveView;
                    IGeometry          pgeo = axMapControl1.TrackLine();
                    AddLineElement(pgeo, pGra);
                    break;
                    #endregion

                    #region 缓冲区闪烁
                case "Buffer":
                    //IMap pMap = axMapControl1.Map;
                    IPoint pt = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                    ITopologicalOperator pTopo = pt as ITopologicalOperator;
                    IGeometry            pGeo1 = pTopo.Buffer(50);
                    IColor pColor1             = new RgbColorClass();
                    pColor1.RGB = 2556;
                    SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                    simpleFillSymbol.Color = pColor1;
                    ISymbol symbol = simpleFillSymbol as ISymbol;
                    pActiveView.ScreenDisplay.SetSymbol(symbol);
                    pActiveView.ScreenDisplay.DrawPolygon(pGeo1);
                    //pMap.SelectByShape(pGeo1, null, false);
                    //闪动
                    axMapControl1.FlashShape(pGeo1, 26, 200, symbol);
                    //ThreadInfo threadInfo = new ThreadInfo();
                    //threadInfo.pActiveView = pActiveView;                                     //GPU并行
                    //threadInfo.e = e;
                    //ThreadPool.QueueUserWorkItem(new WaitCallback(processfile), threadInfo);
                    axMapControl1.ActiveView.Refresh();
                    break;

                    #endregion
                default:
                    break;
                }
            }
        }
示例#27
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 2)
            {
                return;
            }
            IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt);
            IGraphicsContainer graphicContainer = m_hookHelper.ActiveView.GraphicsContainer;
            IEnvelope          pEnvBounds       = null;

            //获取上一次轨迹线的范围,以便确定刷新范围
            try
            {
                if (m_TracePolygon != null)
                {
                    m_TracePolygon.QueryEnvelope(pEnvBounds);
                    pEnvBounds.Expand(4, 4, true); //矩形框向四周扩大4倍(大于2倍就行),目的是为了保证有充足的刷新区域
                }
                else
                {
                    pEnvBounds = m_hookHelper.ActiveView.Extent;
                }
            }
            catch
            {
                pEnvBounds = m_hookHelper.ActiveView.Extent;
            }

            #region 启动画面
            if (m_NewPolygonFeedback == null)
            {
                //移除element
                RemoveElements();
                //刷新
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                Application.DoEvents();

                m_NewPolygonFeedback = new NewPolygonFeedbackClass();

                //必须先得到symbol,后设置symbol
                ISimpleLineSymbol simpleLineSymbol = m_NewPolygonFeedback.Symbol as ISimpleLineSymbol;
                simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 2;
                simpleLineSymbol.Color = TransColorToAEColor(Color.Blue);

                m_simpleFillSymbol.Outline = simpleLineSymbol;

                m_NewPolygonFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
                m_NewPolygonFeedback.Start(pt);
            }
            else
            {
                m_NewPolygonFeedback.AddPoint(pt);
            }


            if (m_ptCollection == null)
            {
                m_ptCollection = new PolylineClass();
            }
            //记录节点
            object obj = Type.Missing;
            m_ptCollection.AddPoint(pt, ref obj, ref obj);

            #endregion

            #region 绘制结点

            try
            {
                IElement vertexElement = createElement_x(pt);
                //
                graphicContainer = m_hookHelper.ActiveView as IGraphicsContainer;

                //g.AddElement(vertexElement, 0);
                //g.MoveElementToGroup(vertexElement, m_VertexElement);

                m_VertexElement.AddElement(vertexElement);
                //刷新
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, vertexElement, pEnvBounds);
            }
            catch
            { }
            #endregion

            try
            {
                if (m_ptCollection.PointCount >= 2)
                {
                    IPoint fromPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 2); //倒数第二个点
                    IPoint toPt   = m_ptCollection.get_Point(m_ptCollection.PointCount - 1); //最后第一个点
                    ILine  line   = new LineClass();
                    line.PutCoords(fromPt, toPt);

                    #region 绘制轨迹线

                    try
                    {
                        object             missing = Type.Missing;
                        ISegmentCollection segColl = new PolylineClass();
                        segColl.AddSegment(line as ISegment, ref missing, ref missing);

                        IPolyline polyline = new PolylineClass();
                        polyline = segColl as IPolyline;
                        IElement traceElement = createElement_x(polyline);

                        //graphicContainer = m_hookHelper.ActiveView as IGraphicsContainer;
                        m_TraceElement.AddElement(traceElement);

                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, traceElement, pEnvBounds);
                    }
                    catch
                    { }
                    #endregion

                    #region 计算单线的长度,并将结果显示在单线中点偏上上面
                    //try
                    //{
                    //    double angle = line.Angle;
                    //    if ((angle > (Math.PI / 2) && angle < (Math.PI)) || (angle > -Math.PI && angle < -(Math.PI / 2))) // 大于90度小于等于180
                    //        angle += Math.PI;

                    //    //标注点Y值偏移量
                    //    double d_OffsetY = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.FromPoints(9);

                    //    //标注点
                    //    double d_CenterX = (fromPt.X + toPt.X) / 2;
                    //    double d_CenterY = (fromPt.Y + toPt.Y) / 2 + d_OffsetY; //向上偏移

                    //    IPoint labelPt = new PointClass();
                    //    labelPt.PutCoords(d_CenterX, d_CenterY);

                    //    ITextElement txtElement = CreateTextElement(line.Length.ToString("0.00"));

                    //    IElement labelelement = txtElement as IElement;
                    //    labelelement.Geometry = labelPt;
                    //    object oElement = (object)labelelement;

                    //    //根据角度旋转
                    //    TransformByRotate(ref oElement, labelPt, angle);

                    //    ////添加到GraphicsContainer
                    //    //g.AddElement(labelelement, 0);

                    //    ////移到m_LabelElement组中
                    //    //g.MoveElementToGroup(labelelement, m_LabelElement);

                    //    //添加到组
                    //    m_LabelElement.AddElement(labelelement);

                    //    //刷新
                    //    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, labelelement, pEnvBounds);
                    //}
                    //catch
                    //{ }
                    #endregion
                }
            }
            catch
            { }

            m_frmMeasureResult.PolygonResultChange();
        }
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            try
            {
                IPoint pPt = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                if (m_EngineEditor == null)
                {
                    return;
                }
                if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing)
                {
                    return;
                }
                if (m_EngineEditLayers == null)
                {
                    return;
                }
                IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;
                if (pFeatLyr == null)
                {
                    return;
                }
                IFeatureClass pFeatCls = pFeatLyr.FeatureClass;
                if (pFeatCls == null)
                {
                    return;
                }

                //解决编辑要素的Z值问题
                IZAware pZAware = pPt as IZAware;
                pZAware.ZAware = true;
                pPt.Z          = 0;

                object missing = Type.Missing;

                m_Map.ClearSelection();

                switch (pFeatCls.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    //当为点层时,直接创建要素
                    CreateFeature(pPt as IGeometry);
                    break;

                case esriGeometryType.esriGeometryMultipoint:
                    //点集的处理方式
                    if (m_pointCollection == null)
                    {
                        m_pointCollection = new MultipointClass();
                    }
                    else
                    {
                        m_pointCollection.AddPoint(pPt, ref missing, ref missing);
                    }
                    if (m_newMultPtFeedBack == null)
                    {
                        m_newMultPtFeedBack         = new NewMultiPointFeedbackClass();
                        m_newMultPtFeedBack.Display = m_activeView.ScreenDisplay;
                        m_newMultPtFeedBack.Start(m_pointCollection, pPt);
                    }
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    //多义线处理方式
                    if (m_newLineFeedBack == null)
                    {
                        m_newLineFeedBack         = new NewLineFeedbackClass();
                        m_newLineFeedBack.Display = m_activeView.ScreenDisplay;
                        m_newLineFeedBack.Start(pPt);
                    }
                    else
                    {
                        m_newLineFeedBack.AddPoint(pPt);
                    }
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    //多边形处理方式
                    if (m_newPolyFeedBack == null)
                    {
                        m_newPolyFeedBack         = new NewPolygonFeedbackClass();
                        m_newPolyFeedBack.Display = m_activeView.ScreenDisplay;
                        m_newPolyFeedBack.Start(pPt);
                    }
                    else
                    {
                        m_newPolyFeedBack.AddPoint(pPt);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                //SysLogHelper.WriteOperationLog("要素创建错误", ex.Source, "数据编辑");
            }
        }
示例#29
0
        public static void EndSketch(bool bool_0, IActiveView iactiveView_0, IFeatureLayer ifeatureLayer_0)
        {
            INewLineFeedback    feedback;
            IPointCollection    pointCollection;
            IGeometryCollection mLastPartGeometry;

            try
            {
                if (SketchToolAssist.m_pPointColn != null)
                {
                    SketchToolAssist.m_pPointColn.RemovePoints(0, SketchToolAssist.m_pPointColn.PointCount);
                }
                IPoint mPAnchorPoint = null;
                if (SketchToolAssist.Feedback != null)
                {
                    if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Line)
                    {
                        feedback      = (INewLineFeedback)SketchToolAssist.Feedback;
                        mPAnchorPoint = SketchShareEx.m_pAnchorPoint;
                        if (bool_0)
                        {
                            feedback.AddPoint(mPAnchorPoint);
                        }
                        SketchToolAssist.TempLine = feedback.Stop();
                        SketchShareEx.m_bInUse    = false;
                        if (SketchToolAssist.CurrentTask != null)
                        {
                            SketchToolAssist.CurrentTask.Excute();
                        }
                        SketchToolAssist.Feedback = null;
                        return;
                    }
                    else if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Fill)
                    {
                        INewPolygonFeedbackEx newPolygonFeedbackEx = (INewPolygonFeedbackEx)SketchToolAssist.Feedback;
                        mPAnchorPoint = SketchShareEx.m_pAnchorPoint;
                        if (bool_0)
                        {
                            newPolygonFeedbackEx.AddPoint(mPAnchorPoint);
                        }
                        SketchToolAssist.TempLine = newPolygonFeedbackEx.Stop();
                        SketchShareEx.m_bInUse    = false;
                        if (SketchToolAssist.CurrentTask != null)
                        {
                            SketchToolAssist.CurrentTask.Excute();
                        }
                        SketchToolAssist.Feedback = null;
                        return;
                    }
                    else if (SketchToolAssist.IsDrawTempLine != DrawTempGeometry.Point)
                    {
                        mPAnchorPoint = SketchShareEx.m_pAnchorPoint;
                        IGeometry mPPointCollection = null;
                        if (SketchToolAssist.Feedback is INewMultiPointFeedback)
                        {
                            ((INewMultiPointFeedback)SketchToolAssist.Feedback).Stop();
                            mPPointCollection = (IGeometry)SketchShareEx.m_pPointCollection;
                        }
                        else if (SketchToolAssist.Feedback is INewLineFeedback)
                        {
                            feedback = (INewLineFeedback)SketchToolAssist.Feedback;
                            if (bool_0)
                            {
                                feedback.AddPoint(mPAnchorPoint);
                            }
                            IPolyline polyline = feedback.Stop();
                            if (polyline != null)
                            {
                                pointCollection = (IPointCollection)polyline;
                                if (pointCollection.PointCount >= 2)
                                {
                                    mPPointCollection = (IGeometry)pointCollection;
                                    if (SketchShareEx.m_LastPartGeometry != null &&
                                        SketchShareEx.m_LastPartGeometry is IPolyline)
                                    {
                                        mLastPartGeometry = SketchShareEx.m_LastPartGeometry as IGeometryCollection;
                                        mLastPartGeometry.AddGeometryCollection(polyline as IGeometryCollection);
                                        mPPointCollection = mLastPartGeometry as IGeometry;
                                        SketchShareEx.m_LastPartGeometry = null;
                                    }
                                }
                                SketchShareEx.m_pLastPoint1 = null;
                                SketchShareEx.m_pEndPoint1  = null;
                                SketchShareEx.m_totalLength = 0;
                                if ((mPPointCollection == null ? false : SketchShareEx.IsCreateParrel))
                                {
                                    object          value           = Missing.Value;
                                    object          constructOffset = SketchShareEx.ConstructOffset;
                                    IConstructCurve polylineClass   = new Polyline() as IConstructCurve;
                                    polylineClass.ConstructOffset(mPPointCollection as IPolycurve,
                                                                  SketchShareEx.m_offset, ref constructOffset, ref value);
                                    IGeometryCollection geometryCollection = new Polyline() as IGeometryCollection;
                                    geometryCollection.AddGeometryCollection(polylineClass as IGeometryCollection);
                                    polylineClass = new Polyline() as IConstructCurve;
                                    polylineClass.ConstructOffset(mPPointCollection as IPolycurve,
                                                                  -SketchShareEx.m_offset, ref constructOffset, ref value);
                                    geometryCollection.AddGeometryCollection(polylineClass as IGeometryCollection);
                                    mPPointCollection = geometryCollection as IGeometry;
                                }
                            }
                        }
                        else if (SketchToolAssist.Feedback is INewPolygonFeedback)
                        {
                            INewPolygonFeedback newPolygonFeedback = (INewPolygonFeedback)SketchToolAssist.Feedback;
                            if (bool_0)
                            {
                                newPolygonFeedback.AddPoint(mPAnchorPoint);
                            }
                            IPolygon polygon = newPolygonFeedback.Stop();
                            if (polygon != null)
                            {
                                pointCollection = (IPointCollection)polygon;
                                if (pointCollection.PointCount >= 3)
                                {
                                    mPPointCollection = (IGeometry)pointCollection;
                                    if (!(mPPointCollection as ITopologicalOperator).IsSimple)
                                    {
                                        (mPPointCollection as ITopologicalOperator).Simplify();
                                    }
                                    if (SketchShareEx.m_LastPartGeometry != null &&
                                        SketchShareEx.m_LastPartGeometry is IPolygon)
                                    {
                                        mLastPartGeometry = SketchShareEx.m_LastPartGeometry as IGeometryCollection;
                                        mLastPartGeometry.AddGeometryCollection(polygon as IGeometryCollection);
                                        mPPointCollection = mLastPartGeometry as IGeometry;
                                        SketchShareEx.m_LastPartGeometry = null;
                                    }
                                }
                                SketchToolAssist.m_pPointColn = null;
                            }
                        }
                        CreateFeatureTool.CreateFeature(mPPointCollection, iactiveView_0, ifeatureLayer_0);
                    }
                    else
                    {
                        SketchToolAssist.TempLine = SketchShareEx.m_pAnchorPoint;
                        SketchShareEx.m_bInUse    = false;
                        if (SketchToolAssist.CurrentTask != null)
                        {
                            SketchToolAssist.CurrentTask.Excute();
                        }
                        SketchToolAssist.Feedback = null;
                        return;
                    }
                }
            }
            catch (COMException cOMException1)
            {
                COMException cOMException = cOMException1;
                if (cOMException.ErrorCode != -2147220936)
                {
                    Logger.Current.Error("", cOMException, "");
                }
                else
                {
                    MessageBox.Show("坐标值或量测值超出范围!", "创建要素", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGeography, ifeatureLayer_0, null);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGeography, ifeatureLayer_0, null);
                Logger.Current.Error("", exception, "");
            }
            SketchShareEx.m_bInUse          = false;
            SketchShareEx.LastPoint         = null;
            SketchToolAssist.Feedback       = null;
            SketchShareEx.PointCount        = 0;
            SketchShareEx.m_bSnapSuccessful = false;
            SketchToolAssist.m_pAP          = null;
        }
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)      //地图单击
        {
            //屏幕坐标点转化为地图坐标点
            pPointPt = (axMapControl1.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            if (e.button == 1)   //左键
            {
                IActiveView pActiveView = axMapControl1.ActiveView;
                IEnvelope   pEnvelope   = new EnvelopeClass();
                switch (pMouseOperate)
                {
                    #region 距离量算
                case "MeasureLength":
                    //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点
                    if (pNewLineFeedback == null)
                    {
                        //实例化追踪线对象
                        pNewLineFeedback         = new NewLineFeedbackClass();
                        pNewLineFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay;
                        //设置起点,开始动态线绘制
                        pNewLineFeedback.Start(pPointPt);
                        dToltalLength = 0;
                    }
                    else     //如果追踪线对象不为空,则添加当前鼠标点
                    {
                        pNewLineFeedback.AddPoint(pPointPt);
                    }
                    if (dSegmentLength != 0)
                    {
                        dToltalLength = dToltalLength + dSegmentLength;
                    }
                    break;

                    #endregion
                    #region 面积量算
                case "MeasureArea":
                    if (pNewPolygonFeedback == null)
                    {
                        //实例化追踪面对象
                        pNewPolygonFeedback         = new NewPolygonFeedback();
                        pNewPolygonFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay;
                        pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount);
                        //开始绘制多边形
                        pNewPolygonFeedback.Start(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    else
                    {
                        pNewPolygonFeedback.AddPoint(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    break;

                    #endregion
                    #region 其他
                case "SelFeature":
                    //////////
                    #endregion
                default:
                    break;
                }
            }
            else if (e.button == 2) //右键
            {
            }
        }