Exemplo n.º 1
0
        /// <summary>
        /// 绘制椭圆
        /// </summary>
        /// <params name="pEnvelope"></params>
        public void DrawEllipse(IEnvelope pEnvelope)
        {
            IFeatureLayer         pFeatureLayer        = m_pCurrentLayer as IFeatureLayer;
            IFeatureClass         pFeatureClass        = pFeatureLayer.FeatureClass;
            IConstructEllipticArc constructEllipticArc = new EllipticArcClass();

            constructEllipticArc.ConstructEnvelope(pEnvelope);
            IEllipticArc ellipse = constructEllipticArc as IEllipticArc;

            ISegment           segment   = ellipse as ISegment;
            ISegmentCollection pPolyline = new Polyline() as ISegmentCollection;
            object             Missing   = Type.Missing;

            pPolyline.AddSegment(segment, ref Missing, ref Missing);
            IGeometry poly           = pPolyline as IGeometry;
            IFeature  pCircleFeature = pFeatureClass.CreateFeature();

            pCircleFeature.Shape = poly as PolylineClass;
            pCircleFeature.Store();

            //局部刷新
            IInvalidArea pInvalidArea = new InvalidAreaClass();

            pInvalidArea.Add(poly);

            pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
            pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);
        }
Exemplo n.º 2
0
 public override void OnKeyDown(int keyCode, int Shift)
 {
     if (keyCode == (int)Keys.Escape)
     {
         m_pFeedback       = null;
         m_pEllipticArc    = null;
         m_pEnvFeedback    = null;
         m_lMouseDownCount = 0;
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
     }
 }
Exemplo n.º 3
0
 private IGeometry EllipticArcTransPolygon(IEllipticArc pEll)
 {
     try
     {
         object             missing      = Type.Missing;
         ISegmentCollection pSegmentColl = new RingClass();
         pSegmentColl.AddSegment((ISegment)pEll, ref missing, ref missing);
         IRing pRing = (IRing)pSegmentColl;
         pRing.Close();                                                    //得到闭合的环
         IGeometryCollection pGeometryCollection = new PolygonClass();
         pGeometryCollection.AddGeometry(pRing, ref missing, ref missing); //环转面
         IPolygon pPolygon = (IPolygon)pGeometryCollection;
         return(pPolygon);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            m_pMovePoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            m_pMovePoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pMovePoint);

            if (m_lMouseDownCount == 1)
            {
                m_bCreated = false;

                IEnvelope pEnv = new EnvelopeClass();
                pEnv.UpperLeft  = m_pFirstPoint;
                pEnv.LowerRight = m_pMovePoint;

                IConstructEllipticArc pEllipArc = new EllipticArcClass();
                pEllipArc.ConstructEnvelope(pEnv);
                m_pEllipticArc = pEllipArc as IEllipticArc;
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            }
            DataEditCommon.g_pAxMapControl.Focus();
        }
Exemplo n.º 5
0
        private void DrawArc(IEllipticArc pEllipArc)
        {
            if (pEllipArc == null)
            {
                return;
            }

            try
            {
                ISegmentCollection pSegColl;
                IPolyline          pPolyline;
                pSegColl = new PolylineClass();
                pSegColl.AddSegment(pEllipArc as ISegment);
                pPolyline = pSegColl as IPolyline;

                IRgbColor pColor = new RgbColor();
                pColor.Red   = 0;
                pColor.Green = 0;
                pColor.Blue  = 0;

                m_LineSym       = new SimpleLineSymbol();
                m_LineSym.Color = pColor;
                m_LineSym.Width = 1;
                m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;

                ISymbol pSym = m_LineSym as ISymbol;
                pSym.ROP2             = esriRasterOpCode.esriROPNotXOrPen;
                m_pEnvFeedback.Symbol = pSym;

                m_hookHelper.ActiveView.ScreenDisplay.StartDrawing(m_hookHelper.ActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
                m_hookHelper.ActiveView.ScreenDisplay.SetSymbol(pSym);
                m_hookHelper.ActiveView.ScreenDisplay.DrawPolyline(pPolyline);
                m_hookHelper.ActiveView.ScreenDisplay.FinishDrawing();
            }
            catch (Exception)
            {
                return;
            }
        }
Exemplo n.º 6
0
        private void AddEllipseElement()
        {
            IEnvelope pEnvelope = axMapControl1.TrackRectangle();

            if (pEnvelope == null)
            {
                return;
            }

            IConstructEllipticArc pConstructEllipticArc = new  EllipticArcClass();    //建立橢圓的Geometry

            pConstructEllipticArc.ConstructEnvelope(pEnvelope);
            IEllipticArc       pEllipticArc       = (IEllipticArc)pConstructEllipticArc;
            ISegmentCollection pSegmentCollection = new PolygonClass();
            object             Missing            = Type.Missing;

            pSegmentCollection.AddSegment((ISegment)pEllipticArc, ref Missing, ref Missing);
            IGeometry       pGeometry       = pSegmentCollection as IGeometry;
            IEllipseElement pEllipseElement = new EllipseElementClass();
            IElement        pElement        = pEllipseElement as IElement;

            pElement.Geometry = pGeometry;
            AddElement(pElement);
        }
Exemplo n.º 7
0
        private void DrawArc(IEllipticArc pEllipArc)
        {
            if (pEllipArc == null) return;

            try
            {
                ISegmentCollection pSegColl;
                IPolyline pPolyline;
                pSegColl = new PolylineClass();
                pSegColl.AddSegment(pEllipArc as ISegment);
                pPolyline = pSegColl as IPolyline;

                IRgbColor pColor = new RgbColor();
                pColor.Red = 0;
                pColor.Green = 0;
                pColor.Blue = 0;

                m_LineSym = new SimpleLineSymbol();
                m_LineSym.Color = pColor;
                m_LineSym.Width = 1;
                m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;

                ISymbol pSym = m_LineSym as ISymbol;
                pSym.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
                m_pEnvFeedback.Symbol = pSym;

                m_hookHelper.ActiveView.ScreenDisplay.StartDrawing(m_hookHelper.ActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
                m_hookHelper.ActiveView.ScreenDisplay.SetSymbol(pSym);
                m_hookHelper.ActiveView.ScreenDisplay.DrawPolyline(pPolyline);
                m_hookHelper.ActiveView.ScreenDisplay.FinishDrawing();
            }
            catch (Exception)
            {
                return;
            }
        }
Exemplo n.º 8
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            m_pMovePoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            m_pMovePoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pMovePoint);

            if (m_lMouseDownCount == 1)
            {
                m_bCreated = false;

                IEnvelope pEnv = new EnvelopeClass();
                pEnv.UpperLeft = m_pFirstPoint;
                pEnv.LowerRight = m_pMovePoint;

                IConstructEllipticArc pEllipArc = new EllipticArcClass();
                pEllipArc.ConstructEnvelope(pEnv);
                m_pEllipticArc = pEllipArc as IEllipticArc;
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            }
            DataEditCommon.g_pAxMapControl.Focus();
        }
Exemplo n.º 9
0
 public override void OnKeyDown(int keyCode, int Shift)
 {
     if (keyCode == (int)Keys.Escape)
     {
         m_pFeedback = null;
         m_pEllipticArc = null;
         m_pEnvFeedback = null;
         m_lMouseDownCount = 0;
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
     }
 }