Esempio n. 1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolCreateParallel.OnMouseDown implementation
            if (Button == 1 && (m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) != null)
            {
                IMap   pMap = m_pMapCtl.Map;
                IPoint po   = m_pMapCtl.ToMapPoint(X, Y);
                ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass();

                IGeometry geometry = new PolygonClass();
                geometry = m_pMapCtl.TrackRectangle();
                pMap.SelectByShape(geometry, pSelectionEnv, true);
                m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                IEnumFeatureSetup pSelectionsetup = pMap.FeatureSelection as IEnumFeatureSetup;
                pSelectionsetup.AllFields = true;//这里是关键
                IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature;
                IFeature     pF = pFeatureCollection.Next();
                if (pF != null && pF.Shape is IPolyline)
                {
                    FrmParallelLineOffset frm = new FrmParallelLineOffset();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        IPolyline pPolyline = ConstructOffset(pF.Shape as IPolyline, frm.offset);
                        IFeature  pFeature  = m_FLayer.FeatureClass.CreateFeature();
                        pFeature.Shape = pPolyline;
                        pFeature.Store();
                        m_pMapCtl.Refresh();
                    }
                }
            }
        }
Esempio n. 2
0
 public override void OnMouseMove(int Button, int Shift, int X, int Y)
 {
     // TODO:  Add ToolCreateCircle.OnMouseMove implementation
     if (m_NewCircleFeedback != null)
     {
         IPoint pPoint;
         pPoint = m_pMapCtl.ToMapPoint(X, Y);
         m_NewCircleFeedback.MoveTo(pPoint);
     }
 }
Esempio n. 3
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolRasterShift.OnMouseDown implementation
            // DownPoint = new PointClass();
            IMapControl3 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl3;

            if (pMapCtr != null)
            {
                IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);

                pMoveEnvelopeFeedback         = new MoveEnvelopeFeedbackClass();
                pMoveEnvelopeFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
                pMoveEnvelopeFeedback.Start(pRasterLayer.VisibleExtent, mapPoint);
                DownPoint = mapPoint;
            }
        }
Esempio n. 4
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolRasterEdit.OnMouseMove implementation
            IMapControl3 pMapCtrl = ClsGlobal.GetMapControl(m_hookHelper);

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

            if (m_NewPolygonFeedback != null)
            {
                m_NewPolygonFeedback.MoveTo(pPoint);
            }
        }
Esempio n. 5
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;
            }
        }
Esempio n. 6
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolCreateCircle.OnMouseDown implementation
            if ((m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) == null)
            {
                return;
            }
            IPoint pPoint = m_pMapCtl.ToMapPoint(X, Y);

            if (Button == 1)
            {
                if (m_NewCircleFeedback == null)
                {
                    m_NewCircleFeedback         = new NewCircleFeedbackClass();
                    m_NewCircleFeedback.Display = m_pMapCtl.ActiveView.ScreenDisplay;

                    m_NewCircleFeedback.Start(pPoint);
                    m_CenterPoint = pPoint;
                }
                else
                {
                    try
                    {
                        object       Miss = Type.Missing;
                        ICircularArc pArc = m_NewCircleFeedback.Stop();
                        //IGeometry geometry = new PolygonClass();
                        //geometry = m_pMapCtl.TrackCircle();
                        IPolygon           pPolygon = new PolygonClass();
                        ISegment           pArcC    = pArc as ISegment;
                        ISegmentCollection pArcP    = pPolygon as ISegmentCollection;
                        pArcP.AddSegment(pArcC, ref Miss, ref Miss);
                        pPolygon.Close();
                        IFeature pFeature = m_FLayer.FeatureClass.CreateFeature();
                        pFeature.Shape = pPolygon;
                        pFeature.Store();
                        m_pMapCtl.Refresh();
                        m_NewCircleFeedback = null;
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
            }
            if (Button == 2)
            {
                double                radius        = Math.Sqrt((pPoint.X - m_CenterPoint.X) * (pPoint.X - m_CenterPoint.X) + (pPoint.Y - m_CenterPoint.Y) * (pPoint.Y - m_CenterPoint.Y));
                FrmDrawCircle         frm           = new FrmDrawCircle(radius);
                IConstructCircularArc pArcConstruct = null;
                if (m_NewCircleFeedback == null)
                {
                    return;
                }

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        pArcConstruct = new CircularArcClass();
                        pArcConstruct.ConstructCircle(m_CenterPoint, frm.m_radius, false);
                        if (pArcConstruct != null)
                        {
                            IPolygon           pPolygon = new PolygonClass();
                            ISegment           pArcC    = pArcConstruct as ISegment;
                            ISegmentCollection pArcP    = pPolygon as ISegmentCollection;
                            pArcP.AddSegment(pArcC);
                            pPolygon.Close();
                            IFeature pFeature = m_FLayer.FeatureClass.CreateFeature();
                            pFeature.Shape = pPolygon;
                            pFeature.Store();
                            m_pMapCtl.Refresh();
                            m_NewCircleFeedback.Stop();
                            m_NewCircleFeedback = null;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        if (m_NewCircleFeedback != null)
                        {
                            m_NewCircleFeedback.Stop();
                        }
                        m_NewCircleFeedback = null;
                    }
                }
            }
        }