Example #1
0
 /// <summary>
 /// 绘制矩形
 /// </summary>
 /// <params name="pLayer"></params>
 /// <params name="pScreenDisplay"></params>
 private void DrawRectangular(ILayer pLayer, IGeometry pGeo)
 {
     if (pLayer != null)
     {
         ISegmentCollection pSegmentCollection = null;
         if (pLayer is IFeatureLayer)
         {
             IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
             IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
             if (pFeatureClass != null)
             {
                 if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                 {
                     pSegmentCollection = new PolylineClass();
                 }
                 else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                 {
                     pSegmentCollection = new PolygonClass();
                 }
                 pSegmentCollection.SetRectangle(pGeo.Envelope);
                 IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, (IGeometry)pSegmentCollection);
                 m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                 m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
             }
         }
     }
 }
Example #2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            IPoint pMovePt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            pMovePt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pMovePt);
            IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(m_featureLayer, pMovePt);

            m_hookHelper.FocusMap.SelectFeature(m_featureLayer, pFeature);
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Example #3
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            if (m_lMouseDownCount > 2)
            {
                m_lMouseDownCount = 0;
                ISegmentCollection pSegColl     = null;
                IFeatureLayer      featureLayer = m_pCurrentLayer as IFeatureLayer;

                if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)   //创建线要素
                {
                    IPolyline pPolyline;
                    pSegColl = new PolylineClass();
                    pSegColl.AddSegment(m_pCircleArc as ISegment);
                    pPolyline = pSegColl as IPolyline;
                    if (pPolyline.Length < 0.001)
                    {
                        return;
                    }
                    IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolyline);
                    m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
                }
                else   //创建面要素
                {
                    IPolygon pPolygon;
                    pSegColl = new PolygonClass();
                    pSegColl.AddSegment(m_pCircleArc as ISegment);
                    pPolygon = pSegColl as IPolygon;
                    pPolygon.Close();
                    if (pPolygon.Length < 0.001)
                    {
                        return;
                    }
                    IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolygon);
                    m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
                }

                //局部刷新
                //IInvalidArea pInvalidArea = new InvalidAreaClass();
                //pInvalidArea.Add(pSegColl);
                //pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
                //pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);

                m_bCreated = true;
            }
        }
Example #4
0
        /// <summary>
        /// 根据绘制的圆形创建要素
        /// </summary>
        /// <params name="pLayer"></params>
        /// <params name="pCircuArc"></params>
        /// <params name="pScreenDisplay"></params>
        private void DrawCircleFeature(ILayer pLayer, ICircularArc pCircuArc, IScreenDisplay pScreenDisplay)
        {
            if (pLayer == null)
            {
                return;
            }
            ISegmentCollection pSegmentCollection = null;

            if (pLayer is IFeatureLayer)
            {
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                if (pFeatureClass != null)
                {
                    IPolyline pPolyline = null;
                    IPolygon  pPolygon  = null;

                    if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        pSegmentCollection = new PolylineClass();
                        pSegmentCollection.AddSegment(pCircuArc as ISegment);
                        pPolyline = pSegmentCollection as IPolyline;
                    }
                    else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        pSegmentCollection = new PolygonClass();
                        pSegmentCollection.AddSegment(pCircuArc as ISegment);
                        pPolygon = pSegmentCollection as IPolygon;
                    }
                    else
                    {
                        return;
                    }
                    IFeature pFeature = null;
                    if (pPolyline != null)
                    {
                        pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolyline);
                    }
                    else if (pPolygon != null)
                    {
                        pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolygon);
                    }
                    else
                    {
                        return;
                    }
                    m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
                }
            }
        }
Example #5
0
        private void OnMouseUp()
        {
            if (m_lMouseDownCount != 2)
            {
                return;
            }
            if (m_pEllipticArc == null)
            {
                return;
            }

            m_lMouseDownCount = 0;
            ISegmentCollection pSegColl = null;

            if (m_pEllipticArc.Envelope.Width > 0.001 && m_pEllipticArc.Envelope.Height > 0.001)
            {
                m_pCurrentLayer = DataEditCommon.g_pLayer;
                IFeatureLayer featureLayer = m_pCurrentLayer as IFeatureLayer;

                if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)   //创建线要素
                {
                    IPolyline pPolyline;
                    pSegColl = new PolylineClass();
                    pSegColl.AddSegment(m_pEllipticArc as ISegment);
                    pPolyline = pSegColl as IPolyline;
                    IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolyline);
                    m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
                }
                if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)   //创建面要素
                {
                    IPolygon pPolygon;
                    pSegColl = new PolygonClass();
                    pSegColl.AddSegment(m_pEllipticArc as ISegment);
                    pPolygon = pSegColl as IPolygon;
                    IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(featureLayer, pPolygon);
                    m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
                }

                //局部刷新
                IInvalidArea pInvalidArea = new InvalidAreaClass();
                pInvalidArea.Add(pSegColl);
                pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
                pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);

                m_bCreated = true;
            }
        }
Example #6
0
        public override void OnDblClick()
        {
            IGeometry pGeometry;

            pGeometry = m_newBezierCurveFeedback.Stop();
            IActiveView pActiveView = m_hookHelper.ActiveView;

            m_newBezierCurveFeedback = null;
            IFeatureLayer pFeatureLayer = m_pCurrentLayer as IFeatureLayer;
            IPolyline     polyline      = new PolylineClass();

            polyline = (IPolyline)pGeometry;
            IFeature pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, polyline);

            m_hookHelper.FocusMap.SelectFeature(pFeatureLayer, pFeature);
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
        }