Exemplo n.º 1
0
 private static IEnvelope GetExtents()
 {
     IScreenDisplay screenDisplay = ((IActiveView)ArcMap.Document.ActiveView.FocusMap).ScreenDisplay;
     IRubberBand rubberEnv = new RubberEnvelope();
     var envelope = rubberEnv.TrackNew(screenDisplay, null) as IEnvelope;
     return envelope;
     //if (envelope.IsEmpty)
     //    return;
 }
        private IGeometry GetUserEnv()
        {
            IRubberBand rubberEnv = new RubberEnvelope();

            return rubberEnv.TrackNew((_app.Document as IMxDocument).ActiveView.ScreenDisplay, null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 屏幕上绘画几何形状
        /// </summary>
        /// <param name="screenDisplay">ESRI屏幕显示接口</param>
        /// <param name="geomType">几何形状类型的枚举类</param>
        /// <returns>ESRI几何形状接口</returns>
        public static IGeometry ScreenTrackGeometry(IScreenDisplay screenDisplay, DsGeometryType geomType)
        {
            IGeometry trackGeom = null;

            if (screenDisplay != null)
            {
                IRubberBand rubberBand = null;
                switch (geomType)
                {
                case DsGeometryType.dsGTPoint:
                    rubberBand = new RubberPoint();
                    break;

                case DsGeometryType.dsGTLine:
                    rubberBand = new RubberLine();
                    break;

                case DsGeometryType.dsGTPolyline:
                    rubberBand = new RubberLine();
                    break;

                case DsGeometryType.dsGTRectangle:
                    rubberBand = new RubberEnvelope();
                    break;

                case DsGeometryType.dsGTCircle:
                    rubberBand = new RubberCircle();
                    break;

                case DsGeometryType.dsGTEllipse:
                    rubberBand = new RubberEnvelope();
                    break;

                case DsGeometryType.dsGTPolygon:
                    rubberBand = new RubberPolygon();
                    break;

                case DsGeometryType.dsGTRectangularPolygon:
                    rubberBand = new RubberRectangularPolygon();
                    break;

                default:
                    break;
                }
                if (rubberBand != null)
                {
                    trackGeom = rubberBand.TrackNew(screenDisplay, null);
                }
                if (geomType == DsGeometryType.dsGTEllipse)
                {
                    trackGeom = ConvertEnvelopeToEllipticArc(trackGeom);
                }
                else if ((geomType == DsGeometryType.dsGTLine) ||
                         (geomType == DsGeometryType.dsGTPolyline) ||
                         (geomType == DsGeometryType.dsGTPolygon))
                {
                    if (trackGeom is ITopologicalOperator)
                    {
                        (trackGeom as ITopologicalOperator).Simplify();
                    }
                }
            }
            return(trackGeom);
        }
Exemplo n.º 4
0
        private IGeometry GetUserEnv()
        {
            IRubberBand rubberEnv = new RubberEnvelope();

            return(rubberEnv.TrackNew((_app.Document as IMxDocument).ActiveView.ScreenDisplay, null));
        }
Exemplo n.º 5
0
        private void MapIndex_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            IEnvelope   pEnv;
            IActiveView pActView;
            IRubberBand pRubberBand;
            double      dWidth;
            double      dHeight;
            double      dXmin;
            double      dYmin;
            double      dXmax;
            double      dYmax;

            if (m_strCommand == "Fence")
            {
                pRubberBand = new RubberEnvelope();
                IActiveView pActiveViewFrmMain;
                pActiveViewFrmMain = m_FrmActive.mapMain.ActiveView;
                pActView           = MapIndex.ActiveView;

                pEnv = MapIndex.TrackRectangle();
                if (pEnv.IsEmpty)
                {
                    IPoint pPt;
                    pPt  = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                    pEnv = pActiveViewFrmMain.Extent;
                    pEnv.CenterAt(pPt);
                }
                pActiveViewFrmMain.Extent = pEnv;
                pActiveViewFrmMain.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, pActiveViewFrmMain.Extent);
                pActView.Refresh();
            }
            else if (m_strCommand == "ZoomToEnvlope")
            {
                IPoint PtDown;
                PtDown  = new ESRI.ArcGIS.Geometry.Point();
                PtDown  = MapIndex.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                PtStart = PtDown;

                EyeMove = new EnvelopeClass();
                EyeMove.PutCoords(EyeRect.XMin, EyeRect.YMin, EyeRect.XMax, EyeRect.YMax);
            }
            else if (m_strCommand == "ZoomIn")
            {
                MapIndex.Extent = MapIndex.TrackRectangle();
            }
            else if (m_strCommand == "ZoomOut")
            {
                pRubberBand = new RubberEnvelope();
                pActView    = MapIndex.ActiveView;                                         //pActView为当前窗口
                pEnv        = pRubberBand.TrackNew(pActView.ScreenDisplay, null).Envelope; //pEnv为拉框范围
                if (pEnv.IsEmpty)
                {
                    return;
                }
                if (pEnv.Width == 0 || pEnv.Height == 0)
                {
                    return;
                }

                dWidth  = pActView.Extent.Width * (pActView.Extent.Width / pEnv.Width);
                dHeight = pActView.Extent.Height * (pActView.Extent.Height / pEnv.Height);

                dXmin = pActView.Extent.XMin - ((pEnv.XMin - pActView.Extent.XMin) * (pActView.Extent.Width / pEnv.Width));
                dYmin = pActView.Extent.YMin - ((pEnv.YMin - pActView.Extent.YMin) * (pActView.Extent.Height / pEnv.Height));
                dXmax = (pActView.Extent.XMin - ((pEnv.XMin - pActView.Extent.XMin) * (pActView.Extent.Width / pEnv.Width))) + dWidth;
                dYmax = (pActView.Extent.YMin - ((pEnv.YMin - pActView.Extent.YMin) * (pActView.Extent.Height / pEnv.Height))) + dHeight;

                pEnv.PutCoords(dXmin, dYmin, dXmax, dYmax);
                pActView.Extent = pEnv;
                pActView.Refresh();
            }
            else if (m_strCommand == "Pan")
            {
                this.MapIndex.Pan();
            }
        }