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)); }
private IGeometry GetUserEnv() { IRubberBand rubberEnv = new RubberEnvelope(); return rubberEnv.TrackNew((_app.Document as IMxDocument).ActiveView.ScreenDisplay, null); }
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(); } }