public static IEnvelope GetSearchEnvelope(IActiveView pActiveView, IPoint pPoint) { try { double num = 6.0; IEnvelope visibleBounds = null; if (pActiveView != null) { IDisplayTransformation displayTransformation = pActiveView.ScreenDisplay.DisplayTransformation; visibleBounds = displayTransformation.VisibleBounds; tagRECT deviceFrame = displayTransformation.get_DeviceFrame(); double height = 0.0; long num3 = 0L; height = visibleBounds.Height; num3 = deviceFrame.bottom - deviceFrame.top; double num4 = 0.0; num4 = height / ((double)num3); num *= num4; } if (pPoint == null) { return(null); } visibleBounds = pPoint.Envelope; visibleBounds.Width = num; visibleBounds.Height = num; visibleBounds.CenterAt(pPoint); return(visibleBounds); } catch (Exception) { return(null); } }
void ESRI.ArcGIS.Display.IMarkerMask.QueryMarkerMask(int hDC, ITransformation Transform, IGeometry Geometry, IPolygon Boundary) { if (!(Geometry == null | Boundary == null)) { if (Transform is IDisplayTransformation) { if (Geometry is IPoint) { Boundary.SetEmpty(); IPoint geometry = Geometry as IPoint; IDisplayTransformation transform = (IDisplayTransformation)Transform; this.QueryBoundsFromGeom(hDC, ref transform, ref Boundary, ref geometry); ITopologicalOperator boundary = Boundary as ITopologicalOperator; if (!boundary.IsKnownSimple) { if (!boundary.IsSimple) { boundary.Simplify(); } } } } } }
public unsafe ITransformation CreateTransFromDC(int iWidth, int iHeight, long lDpi) { try { if (iWidth == 0) { return(null); } if (iHeight == 0) { return(null); } if (lDpi == 0L) { return(null); } IEnvelope envelope = null; envelope = new EnvelopeClass(); envelope.PutCoords(0.0, 0.0, (double)iWidth, (double)iHeight); tagRECT grect = new tagRECT(); IDisplayTransformation transformation = null; transformation = new DisplayTransformationClass(); IDisplayTransformation transformation2 = transformation; transformation2.VisibleBounds = envelope; transformation2.Bounds = envelope; transformation2.set_DeviceFrame(ref grect); transformation2.Resolution = lDpi; return(transformation); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "CreateTransFromDC", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); return(null); } }
private void InitializeMembers() { this.m_lhDC = 0; this.m_lOldPen = 0; this.m_lPen = 0; this.m_lOldBrush = 0; this.m_lBrushTop = 0; this.m_lBrushLeft = 0; this.m_lBrushRight = 0; this.m_dDeviceRadius = 0; this.m_trans = null; IColor rGBColor = null; rGBColor = Converter.ToRGBColor(System.Drawing.Color.Red); this.m_colorTop = ((IClone)rGBColor).Clone() as IColor; rGBColor = Converter.ToRGBColor(System.Drawing.Color.OrangeRed); this.m_colorLeft = ((IClone)rGBColor).Clone() as IColor; rGBColor = Converter.ToRGBColor(System.Drawing.Color.Pink); this.m_colorRight = ((IClone)rGBColor).Clone() as IColor; rGBColor = Converter.ToRGBColor(System.Drawing.Color.Black); this.m_colorBorder = ((IClone)rGBColor).Clone() as IColor; this.m_lROP2 = esriRasterOpCode.esriROPCopyPen; this.m_dSize = 10; this.m_dAngle = 0; this.m_dXOffset = 0; this.m_dYOffset = 0; this.m_bRotWithTrans = true; }
/// <summary> /// 将像素转换成地图单元 /// </summary> /// <param name="pActiveView">提供各种转换信息</param> /// <param name="pixelUnits">像素单元</param> /// <returns>像素单元大小</returns> public static double ConvertPixelsToMapUnits(IActiveView pActiveView, double pixelUnits) { if (pActiveView == null) { return(-1); } //获取 the ScreenDisplay IScreenDisplay screenDisplay = pActiveView.ScreenDisplay; //获取 DisplayTransformation IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation; //获取一个设备帧并用它来获得x轴方向上的像素数 tagRECT deviceRECT = displayTransformation.get_DeviceFrame(); int pixelExtent = (deviceRECT.right - deviceRECT.left); //获取当前可是区域的地图范围 IEnvelope envelope = displayTransformation.VisibleBounds; double realWorldDisplayExtent = envelope.Width; //计算一个像素大小 if (pixelExtent == 0) { return(-1); } double sizeOfOnePixel = (realWorldDisplayExtent / pixelExtent); //得出像素单元大小 return(pixelUnits * sizeOfOnePixel); }
private IEnvelope Envelope_Search(IActiveView activeView) { IArea Area; IEnvelope pEnvelope; IRubberBand rubberEnv; IGeometry geom; rubberEnv = new RubberEnvelopeClass(); geom = rubberEnv.TrackNew(activeView.ScreenDisplay, null); geom.SpatialReference = Map.SpatialReference; pEnvelope = geom.Envelope; Area = (IArea)pEnvelope; if (pEnvelope.IsEmpty || Area.Area == 0) { pEnvelope = new EnvelopeClass(); //////////////////////////////////////////////////////////////////////////////////////// ESRI.ArcGIS.esriSystem.tagRECT RECT = new tagRECT(); RECT.bottom = 0; RECT.left = 0; RECT.right = 5; RECT.top = 5; IDisplayTransformation dispTrans = activeView.ScreenDisplay.DisplayTransformation; dispTrans.TransformRect(pEnvelope, RECT, 4); pEnvelope.CenterAt(clickedPoint); } return(pEnvelope); }
/// <summary> /// Initializes the specified data table. /// </summary> /// <param name="dataTable">The data table.</param> /// <param name="map">The map.</param> public void Initialize(DataTable dataTable, IMap map) { this._dt = dataTable; this._map = map; this._displayTrans = (this._map as IActiveView).ScreenDisplay.DisplayTransformation; this._PageRow = this._dt.Rows.Count; if (this._PageRow % this._Pagesize > 0) { this._PageCount = this._PageRow / this._Pagesize + 1; } else { this._PageCount = this._PageRow / this._Pagesize; } this.dataNavigator.TextStringFormat = string.Format("第 {0} 页,共 {1} 页", _PageIndex, _PageCount); DataTable dataSource = this._dt.AsEnumerable().Take(this._Pagesize).CopyToDataTable <DataRow>(); this.gridView.Columns.Clear(); this.gridControl.DataSource = dataSource; this.dataNavigator.Buttons.CustomButtons[0].Enabled = false; this.dataNavigator.Buttons.CustomButtons[1].Enabled = false; if (this._PageCount > 1) { this.dataNavigator.Buttons.CustomButtons[2].Enabled = true; this.dataNavigator.Buttons.CustomButtons[3].Enabled = true; } else { this.dataNavigator.Buttons.CustomButtons[2].Enabled = false; this.dataNavigator.Buttons.CustomButtons[3].Enabled = false; } }
static void SelectFeaturesScreenPoint(IMap pMap, int x, int y, int pixelTol) { tagRECT r; //Construct a small rectangle out of the x,y coordinates' pixel tolerance. r.left = x - pixelTol; //Upper left x, top left is 0,0. r.top = y - pixelTol; //Upper left y, top left is 0,0. r.right = x + pixelTol; //Lower right x, top left is 0,0. r.bottom = y + pixelTol; //Lower right y, top left is 0,0. //Transform the device rectangle into a geographic rectangle via the display transformation. IEnvelope pEnvelope = new EnvelopeClass(); IActiveView pActiveView = pMap as IActiveView; IDisplayTransformation pDisplayTrans = pActiveView.ScreenDisplay.DisplayTransformation; pDisplayTrans.TransformRect(pEnvelope, ref r, 5); //5 = esriTransformPosition + esriTransformToMap. pEnvelope.SpatialReference = pMap.SpatialReference; //ISelectionEnvironment pSelectionEnvironment = new SelectionEnvironmentClass(); //pSelectionEnvironment.CombinationMethod = // esriSelectionResultEnum.esriSelectionResultNew; //pMap.SelectByShape(pEnvelope, pSelectionEnvironment, false); }
public override void Execute() { if (!(this.Hook is IDFApplication)) { return; } else { m_App = (IDFApplication)this.Hook; } try { m_MapControl = m_App.CurrentMapControl; m_ActiveView = m_App.CurrentMapControl.ActiveView; m_FocusMap = m_ActiveView.FocusMap; UltraToolbarsManager tbManager; tbManager = m_App.Workbench.CommandBarManager; ComboBoxTool tbUltraCombo; tbUltraCombo = (ComboBoxTool)tbManager.Tools["2dmap.Scale"]; IDisplayTransformation pDisplayTransform = m_App.CurrentMapControl.ActiveView.ScreenDisplay.DisplayTransformation; pDisplayTransform.ScaleRatio = tbUltraCombo.Value == null?1000:double.Parse(tbUltraCombo.Value.ToString()); m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_MapControl.Extent); } catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); } }
void m_TransformEvents_VisibleBoundsUpdated(IDisplayTransformation sender, bool sizeChanged) { Url = ""; // MessageBox.Show(Url); GoogleMap(); double Ax = 0; double Ay = 0; double Az = 0; double Bx = 0; double By = 0; double Bz = 0; Ax = Math.Truncate(pCenterPt.X); double Temp = pCenterPt.X - Ax; Temp = Temp * 60; Ay = Math.Truncate(Temp); Az = Temp - Ay; Bx = Math.Truncate(pCenterPt.Y); Temp = pCenterPt.Y - Bx; Temp = Temp * 60; By = Math.Truncate(Temp); Bz = (Temp - By); Ay += Az; By += Bz; Url = "http://maps.google.com/maps?q=" + Bx + "+" + By + "'+N,+" + Ax + "+" + Ay + "'+E&hl=en&geocode=+&t=h&z=12"; WebBrowser_Map.Navigate(Url); return; E: return; }
private void axMapControl1_OnAfterScreenDraw(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnAfterScreenDrawEvent e) { IActiveView pAcv = axPageLayoutControl1.ActiveView.FocusMap as IActiveView; IDisplayTransformation displayTransformation = pAcv.ScreenDisplay.DisplayTransformation; displayTransformation.VisibleBounds = axMapControl1.Extent;//设置焦点地图的可视范围 GeomapLoad.CopyAndOverwriteMap(axMapControl1, axPageLayoutControl1); }
private void Terminate() { this.m_trans = null; this.m_colorTop = null; this.m_colorLeft = null; this.m_colorRight = null; this.m_colorBorder = null; }
private void axMapControl1_OnAfterScreenDraw(object sender, IMapControlEvents2_OnAfterScreenDrawEvent e) { IActiveView pActiveView = axPageLayoutControl1.ActiveView.FocusMap as IActiveView; IDisplayTransformation displayTransformation = pActiveView.ScreenDisplay.DisplayTransformation; displayTransformation.VisibleBounds = axMapControl1.Extent; axPageLayoutControl1.ActiveView.Refresh(); BasicMethod.CopyAndOverwriteMap(axMapControl1, axPageLayoutControl1); }
public void repGeoMap() { IActiveView pActiveView = axPageLayoutControl1.ActiveView.FocusMap as IActiveView; IDisplayTransformation displayTransformation = pActiveView.ScreenDisplay.DisplayTransformation; displayTransformation.VisibleBounds = axMapControl1.Extent; axPageLayoutControl1.ActiveView.Refresh(); CopyAndWriteMap(); }
private void mapControl_OnAfterScreenDraw(object sender, IMapControlEvents2_OnAfterScreenDrawEvent e) { IActiveView activeView = (IActiveView)pagelayoutcontrol.ActiveView.FocusMap; //axPageLayoutControl1的活动视图的地图 IDisplayTransformation displayTransformation = activeView.ScreenDisplay.DisplayTransformation; //活动视图的屏幕显示的显示信息 displayTransformation.VisibleBounds = mapControl.Extent; //将axMapControl1的范围赋值给axPageLayoutControl1的范围 pagelayoutcontrol.ActiveView.Refresh(); //刷新axPageLayoutControl1的活动视图 copyToPageLayout(); //将axMapControl1的地图拷贝到axPageLayoutControl1中 }
/// <summary> /// nDeviceFrameUpdated event handler /// </summary> /// <param name="sender"></param> /// <param name="sizeChanged"></param> private void OnDeviceFrameUpdated(IDisplayTransformation sender, bool sizeChanged) { //update the device frame rectangle m_deviceFrame = sender.get_DeviceFrame(); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { //make sure to switch into dynamic mode m_dynamicMap = (IDynamicMap)m_hookHelper.FocusMap; if (!m_dynamicMap.DynamicMapEnabled) m_dynamicMap.DynamicMapEnabled = true; //do initializations if (m_bOnce) { //generate the navigation data GenerateNavigationData(); m_displayTransformation = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation; m_bOnce = false; } //hook the dynamic display events if (!m_bIsRunning) { ((IDynamicMapEvents_Event)m_dynamicMap).DynamicMapFinished += new IDynamicMapEvents_DynamicMapFinishedEventHandler(OnTimerElapsed); ((IDynamicMapEvents_Event)m_dynamicMap).AfterDynamicDraw += new IDynamicMapEvents_AfterDynamicDrawEventHandler(OnAfterDynamicDraw); } else { ((IDynamicMapEvents_Event)m_dynamicMap).DynamicMapFinished -= new IDynamicMapEvents_DynamicMapFinishedEventHandler(OnTimerElapsed); ((IDynamicMapEvents_Event)m_dynamicMap).AfterDynamicDraw -= new IDynamicMapEvents_AfterDynamicDrawEventHandler(OnAfterDynamicDraw); } //set the running flag m_bIsRunning = !m_bIsRunning; }
private void OnVisibleBoundsUpdated(IDisplayTransformation sender, bool sizeChanged) { //Set the extent to the new visible extent m_Envelope = sender.VisibleBounds; //Refresh the MapControl's foreground phase axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); }
/// <summary> /// Initialize the synthetic data of the layer /// </summary> private void IntializeLayerData (IDisplayTransformation displayTransformation) { try { //get the map's fitted bounds IEnvelope extent = displayTransformation.FittedBounds; //calculate the step for which will be used to increment the items double XStep = extent.Width / 5000.0; double YStep = extent.Height / 5000.0; Random rnd = new Random (); double stepX, stepY; //generate the items for (int i = 0; i < m_nNumOfItems; i++) { //calculate the step for each item stepX = XStep * rnd.NextDouble (); stepY = YStep * rnd.NextDouble (); //create new record DataRow r = NewItem (); //set the item's coordinate r[1] = extent.XMin + rnd.NextDouble () * (extent.XMax - extent.XMin); r[2] = extent.YMin + rnd.NextDouble () * (extent.YMax - extent.YMin); //set the item's steps r[3] = stepX; r[4] = stepY; //calculate the heading r[5] = (360.0 + 90.0 - Math.Atan2 (stepY, stepX) * 180 / Math.PI) % 360.0; //add a type ID in order to define the symbol for the item switch (i % 3) { case 0: r[6] = 0; break; case 1: r[6] = 1; break; case 2: r[6] = 2; break; } //add the new item record to the table AddItem (r); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine (ex.Message); } }
private double PointsToMap(IDisplayTransformation displayTransform, double dPointSize) { double tempPointsToMap = 0; if (displayTransform == null) tempPointsToMap = dPointSize * m_dDeviceRatio; else { tempPointsToMap = displayTransform.FromPoints(dPointSize); } return tempPointsToMap; }