Exemple #1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 2)
            {
                return;
            }
            INewLineFeedback pLineFeed;

            if (m_PT1 == null)
            {
                m_PT1       = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_PT1       = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_PT1);
                m_pFeedback = new NewLineFeedbackClass();
                pLineFeed   = (INewLineFeedback)m_pFeedback;
                pLineFeed.Start(m_PT1);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
                }
            }
            else if (m_PT2 == null)
            {
                m_PT2     = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_PT2     = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_PT2);
                pLineFeed = (INewLineFeedback)m_pFeedback;
                pLineFeed.AddPoint(m_PT2);
            }
            else if (m_PT3 == null)
            {
                m_PT3     = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_PT3     = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_PT3);
                pLineFeed = (INewLineFeedback)m_pFeedback;
                pLineFeed.AddPoint(m_PT3);
            }
            else if (m_PT4 == null)
            {
                m_PT4     = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_PT4     = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_PT4);
                pLineFeed = (INewLineFeedback)m_pFeedback;
                pLineFeed.AddPoint(m_PT4);

                pLineFeed.Stop();
                IBezierCurveGEN bezier = CreateBazerCurve();
                DrawCircleByCenterAndRadius(m_pCurrentLayer, bezier, m_hookHelper.ActiveView.ScreenDisplay);

                m_PT1       = null;
                m_PT2       = null;
                m_PT3       = null;
                m_PT4       = null;
                m_pFeedback = null;
            }
        }
Exemple #2
0
        private void DrawCircleByCenterAndRadius(ILayer pLayer, IBezierCurveGEN pCircularArc, IScreenDisplay pScreenDisplay)
        {
            object o = Type.Missing;

            if (pLayer != null)
            {
                ISegmentCollection pSegmentCollection = null;
                pSegmentCollection = new PathClass();
                if (pLayer is IFeatureLayer)
                {
                    IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                    IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                    if (pFeatureClass != null)
                    {
                        ISegment pSegment = pCircularArc as ISegment;
                        pSegmentCollection.AddSegment(pSegment, ref o, ref o);
                        IGeometryCollection pPolyline = new PolylineClass();
                        //通过IGeometryCollection为Polyline对象添加Path对象
                        pPolyline.AddGeometry(pSegmentCollection as IGeometry, ref o, ref o);

                        m_pMap.ClearSelection();

                        IFeature pCircleFeature = pFeatureClass.CreateFeature();
                        pCircleFeature.Shape = pPolyline as PolylineClass;
                        pCircleFeature.Store();

                        m_pMap.SelectFeature(m_pCurrentLayer, pCircleFeature);

                        IActiveView pActiveView = (IActiveView)m_pMap;
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
                        //局部刷新
                        IInvalidArea pInvalidArea = new InvalidAreaClass();
                        pInvalidArea.Add(pPolyline);

                        pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
                        pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);
                    }
                }
            }
        }
        private void DrawCircleByCenterAndRadius(ILayer pLayer, IBezierCurveGEN pCircularArc, IScreenDisplay pScreenDisplay)
        {
            object o = Type.Missing;
            if (pLayer != null)
            {
                ISegmentCollection pSegmentCollection = null;
                pSegmentCollection = new PathClass();
                if (pLayer is IFeatureLayer)
                {
                    IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                    IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                    if (pFeatureClass != null)
                    {

                        ISegment pSegment = pCircularArc as ISegment;
                        pSegmentCollection.AddSegment(pSegment, ref o, ref o);
                        IGeometryCollection pPolyline = new PolylineClass();
                        //ͨ��IGeometryCollectionΪPolyline�������Path����
                        pPolyline.AddGeometry(pSegmentCollection as IGeometry, ref o, ref o);

                        m_pMap.ClearSelection();

                        IFeature pCircleFeature = pFeatureClass.CreateFeature();
                        pCircleFeature.Shape = pPolyline as PolylineClass;
                        pCircleFeature.Store();

                        m_pMap.SelectFeature(m_pCurrentLayer, pCircleFeature);

                        IActiveView pActiveView = (IActiveView)m_pMap;
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
                        //�ֲ�ˢ��
                        IInvalidArea pInvalidArea = new InvalidAreaClass();
                        pInvalidArea.Add(pPolyline);

                        pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
                        pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);
                    }
                }
            }
        }