public override void OnCreate(HookHelper hook) { Name = "绘制多边形"; mMapCtrl = hook.MapControl as RgMapControl; mScreenDisplay = mMapCtrl.ScreenDisplay; mScreenDisplayDraw = mScreenDisplay as IScreenDisplayDraw; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { m_ActiveView = m_hookHelper.ActiveView; m_Map = m_hookHelper.FocusMap; IScreenDisplay pScreenDisplay = m_ActiveView.ScreenDisplay; IRubberBand pRubberCircle = new RubberCircleClass(); ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = getRGB(255, 255, 0); IGeometry pCircle = pRubberCircle.TrackNew(pScreenDisplay, (ISymbol)pFillSymbol) as IGeometry; IConstructCircularArc pConstructArc = pCircle as IConstructCircularArc; IPolygon pPolygon = new PolygonClass(); ISegmentCollection pSegmentCollection = pPolygon as ISegmentCollection; ISegment pSegment = pConstructArc as ISegment; object missing = Type.Missing; pSegmentCollection.AddSegment(pSegment, ref missing, ref missing); pFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross; pFillSymbol.Color = getRGB(255, 0, 0); IFillShapeElement pPolygonEle = new PolygonElementClass(); pPolygonEle.Symbol = pFillSymbol; IElement pEle = pPolygonEle as IElement; pEle.Geometry = pPolygon; IGraphicsContainer pGraphicsContainer = m_Map as IGraphicsContainer; pGraphicsContainer.AddElement(pEle, 0); m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
/// <summary> /// 高亮显示多边形 /// </summary> /// <param name="pDisplay">用于操作的显示屏幕</param> /// <param name="pGeometry">欲高亮显示的几何图形</param> private void FlashPolygon(IScreenDisplay pDisplay, IGeometry pGeometry) { if (pGeometry == null) { return; } //设置显示格式 ISimpleFillSymbol pFillSymbol = null; pFillSymbol = new SimpleFillSymbol(); pFillSymbol.Outline = null; pFillSymbol.Color = GetRGBColor(255, 150, 150); ISymbol pSymbol = default(ISymbol); pSymbol = pFillSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; //用所设置的格式绘制几何图形 pDisplay.SetSymbol((ISymbol)pFillSymbol); pDisplay.DrawPolygon(pGeometry); Thread.Sleep(100); pDisplay.DrawPolygon(pGeometry); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button == 1) { //产生一个当前的点击的点对象 IPoint pPoint; pPoint = new PointClass(); pPoint.SpatialReference = pmap.SpatialReference; pPoint = pactiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); //判断是否为第一个点 if (pPointStd == null) { pPointStd = pPoint; //在屏幕上绘制 IScreenDisplay screenDisplay = pactiveView.ScreenDisplay; screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); screenDisplay.SetSymbol(new SimpleMarkerSymbolClass()); screenDisplay.DrawPoint(pPointStd); screenDisplay.FinishDrawing(); } else { IProximityOperator pProximity; pProximity = pPointStd as IProximityOperator; double pDistance; pDistance = pProximity.ReturnDistance(pPoint); //标签对象上出现两点间的距离 MessageBox.Show(pDistance.ToString()); } } }
/// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (hook == null) { return; } if (m_hookHelper == null) { m_hookHelper = new HookHelperClass(); } m_pAppForm = hook as Plugin.Application.IAppFormRef; Plugin.Application.IAppGisUpdateRef appHK = hook as Plugin.Application.IAppGisUpdateRef; m_hookHelper.Hook = appHK.MapControl.Object; m_pActiveView = m_hookHelper.FocusMap as IActiveView; m_pActiveViewEvents = m_pActiveView as IActiveViewEvents_Event; m_pScreenDisplay = m_pActiveView.ScreenDisplay; try { m_pActiveViewEvents.AfterDraw += new IActiveViewEvents_AfterDrawEventHandler(m_pActiveViewEvents_AfterDraw); } catch { } // TODO: Add other initialization code }
public void SelectByLine(int IndexOfLayer, RubberLineClass Line) { int ConstantNum = 255; IActiveView CurrentView = axMapControl1.ActiveView; IScreenDisplay CurScreenDisplay = CurrentView.ScreenDisplay; CurScreenDisplay.StartDrawing(CurScreenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache); IRgbColor RGBCOLORS = new ESRI.ArcGIS.Display.RgbColorClass(); RGBCOLORS.Red = ConstantNum; IColor MyColor = RGBCOLORS; ISimpleFillSymbol MySimpleFillSymbol = new SimpleFillSymbolClass(); MySimpleFillSymbol.Color = MyColor; ISymbol MySymbol = MySimpleFillSymbol as ISymbol; IRubberBand MyIRubberBand = Line; IGeometry MyGeometry = MyIRubberBand.TrackNew(CurScreenDisplay, MySymbol); CurScreenDisplay.SetSymbol(MySymbol); CurScreenDisplay.DrawPolygon(MyGeometry); CurScreenDisplay.FinishDrawing(); ISpatialFilter MySpatialFilter = new SpatialFilterClass(); MySpatialFilter.Geometry = MyGeometry; MySpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureLayer SelectedLayer = axMapControl1.ActiveView.FocusMap.get_Layer(IndexOfLayer) as IFeatureLayer; IFeatureSelection SelectedFeatures = SelectedLayer as IFeatureSelection; SelectedFeatures.SelectFeatures(MySpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false); ISelectionSet FinalSelection = SelectedFeatures.SelectionSet; axMapControl1.ActiveView.Refresh(); }
public void SelectByPolygon(int IndexOfLayer, RubberPolygonClass Polygon) { int ConstantNum = 255; IActiveView CurrentView = axMapControl1.ActiveView; IScreenDisplay MyScreenDispaly = CurrentView.ScreenDisplay; MyScreenDispaly.StartDrawing(MyScreenDispaly.hDC, (System.Int16)esriScreenCache.esriNoScreenCache); IRgbColor MYRGBCOLOR = new RgbColorClass(); MYRGBCOLOR.Red = ConstantNum; IColor MyColor = MYRGBCOLOR; ISimpleFillSymbol MySimpleFillPolygon = new SimpleFillSymbolClass(); MySimpleFillPolygon.Color = MyColor; ISymbol MySymbol = MySimpleFillPolygon as ISymbol; IRubberBand MyIRubberBand = Polygon; IGeometry MyGeometry = MyIRubberBand.TrackNew(MyScreenDispaly, MySymbol); MyScreenDispaly.SetSymbol(MySymbol); MyScreenDispaly.DrawPolygon(MyGeometry); MyScreenDispaly.FinishDrawing(); ISpatialFilter MyISpatialFilter = new SpatialFilterClass(); MyISpatialFilter.Geometry = MyGeometry; MyISpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureLayer SelectedLayer = axMapControl1.ActiveView.FocusMap.get_Layer(IndexOfLayer) as IFeatureLayer; IFeatureSelection SelectedFeature = SelectedLayer as IFeatureSelection; SelectedFeature.SelectFeatures(MyISpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false); ISelectionSet MyISelectionSet = SelectedFeature.SelectionSet; axMapControl1.ActiveView.Refresh(); }
private void FlashGeometry(IGeometry geometry, int flashCount, int interval) { IScreenDisplay display = m_activeView.ScreenDisplay; ISymbol symbol = CreateSimpleSymbol(geometry.GeometryType); display.StartDrawing(0, (short)esriScreenCache.esriNoScreenCache); display.SetSymbol(symbol); for (int i = 0; i < flashCount; i++) { switch (geometry.GeometryType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: display.DrawPoint(geometry); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint: display.DrawMultipoint(geometry); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: display.DrawPolyline(geometry); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: display.DrawPolygon(geometry); break; default: break; } System.Threading.Thread.Sleep(interval); } display.FinishDrawing(); }
public void Draw(IScreenDisplay iscreenDisplay_0) { iscreenDisplay_0.StartDrawing(0, -1); switch ((this.itopologyErrorFeature_0 as IFeature).Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: { this.method_0(iscreenDisplay_0, (this.itopologyErrorFeature_0 as IFeature).Shape); break; } case esriGeometryType.esriGeometryMultipoint: { this.method_1(iscreenDisplay_0, (this.itopologyErrorFeature_0 as IFeature).Shape); break; } case esriGeometryType.esriGeometryPolyline: { this.method_2(iscreenDisplay_0, (this.itopologyErrorFeature_0 as IFeature).Shape); break; } case esriGeometryType.esriGeometryPolygon: { this.method_3(iscreenDisplay_0, (this.itopologyErrorFeature_0 as IFeature).Shape); break; } } iscreenDisplay_0.FinishDrawing(); }
public static void FlashPoint(IScreenDisplay pDisplay, IGeometry pGeometry) { try { ISimpleMarkerSymbol pMarkerSymbol; ISymbol pSymbol; IRgbColor pRGBColor; pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 150; pRGBColor.Blue = 150; pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Color = pRGBColor; pSymbol = (ISymbol)pMarkerSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPoint(pGeometry); System.Threading.Thread.Sleep(300); pDisplay.DrawPoint(pGeometry); } catch (Exception) { throw; } }
/// <summary> /// 点击事件 /// </summary> public override void OnClick() { DataEditCommon.InitEditEnvironment(); DataEditCommon.CheckEditState(); m_pCurrentLayer = DataEditCommon.g_pLayer; IFeatureLayer featureLayer = m_pCurrentLayer as IFeatureLayer; if (featureLayer == null) { MessageBox.Show(@"请选择绘制图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DataEditCommon.g_pMyMapCtrl.CurrentTool = null; return; } else { if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline && featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon || featureLayer.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) { MessageBox.Show(@"请选择线状图层或面状图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DataEditCommon.g_pMyMapCtrl.CurrentTool = null; return; } } m_pMap = m_hookHelper.FocusMap; m_pScrD = m_hookHelper.ActiveView.ScreenDisplay; m_pNewCircleFeedback = null; }
public void OnMouseDown(int button, int shift, int x, int y) { if (button != 1) { return; } IActiveView activeView = m_pHookHelper.ActiveView; IPoint point; //If in PageLayout view, find the closest map if (!(activeView is IMap)) { point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IMap hitMap = activeView.HitTestMap(point); //Exit if no map found if (hitMap == null) { return; } if (activeView != m_pHookHelper.FocusMap) { activeView.FocusMap = hitMap; } } //Start the pan operation m_focusScreenDisplay = getFocusDisplay(); point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); m_focusScreenDisplay.PanStart(point); m_PanOperation = true; }
private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { switch (m_sketchshape) { case "polygon": { if (m_NewPolygonFeedback != null) { IPoint iPoint = new PointClass(); iPoint = m_MapCtrls.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); m_NewPolygonFeedback.MoveTo(iPoint); } } break; case "rectangle": { IScreenDisplay iSDisplay = m_MapCtrls.ActiveView.ScreenDisplay; IPoint newPoint = new PointClass(); newPoint = iSDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (m_RecFeedback != null) { m_RecFeedback.MoveTo(newPoint); } } break; } }
public override void Run(object sender, System.EventArgs e) { Map2DCommandManager.Push(this); IMap2DView mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView; if (mapView == null) { return; } bool bBind = mapView.Bind(this); if (!bBind) { return; } m_App = DF2DApplication.Application; if (m_App == null || m_App.Current2DMapControl == null) { return; } m_MapControl = m_App.Current2DMapControl; this.m_ActiveView = m_MapControl.ActiveView; this.m_Display = m_ActiveView.ScreenDisplay; this.m_pCurEditLayer = Class.Common.CurEditLayer as IFeatureLayer; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add AreaPrintMapClass.OnMouseDown implementation if (Button == 1) { if (m_InUse == true) { m_ActiveView = m_hookHelper.ActiveView; m_ScreenDisplay = m_ActiveView.ScreenDisplay; IMap pMap = m_ActiveView.FocusMap; IPoint pPoint; pPoint = (IPoint)m_ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_NewPolygonFeedback == null) { m_NewPolygonFeedback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSlnSym; IRgbColor pRGB = new RgbColorClass(); pSlnSym = (ISimpleLineSymbol)m_NewPolygonFeedback.Symbol; pRGB.Red = 225; pRGB.Green = 0; pRGB.Blue = 0; pSlnSym.Color = pRGB; pSlnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSlnSym.Width = 2; m_NewPolygonFeedback.Display = m_ScreenDisplay; m_NewPolygonFeedback.Start(pPoint); } else { m_NewPolygonFeedback.AddPoint(pPoint); } } } }
/// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (hook == null) { return; } if (m_hookHelper == null) { m_hookHelper = new HookHelperClass(); } m_hookHelper.Hook = hook; IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2; pMapCtl.CurrentTool = null; m_pActiveView = m_hookHelper.FocusMap as IActiveView; m_pActiveViewEvents = m_pActiveView as IActiveViewEvents_Event; m_pScreenDisplay = m_pActiveView.ScreenDisplay; try { m_pActiveViewEvents.AfterDraw += new IActiveViewEvents_AfterDrawEventHandler(m_pActiveViewEvents_AfterDraw); } catch { } // TODO: Add other initialization code }
/// <summary> /// /// </summary> /// <param name="pDisplay">用于操作的显示屏幕</param> /// <param name="pGeometry">欲高亮显示的几何图形</param> private void FlashPoint(IScreenDisplay pDisplay, IGeometry pGeometry) { if (pGeometry == null) { return; } //设置显示格式 ISimpleMarkerSymbol pMarkerSymbol = null; pMarkerSymbol = new SimpleMarkerSymbol(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Color = GetRGBColor(255, 150, 150); ISymbol pSymbol = null; pSymbol = pMarkerSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; //用所设置的格式绘制几何图形 pDisplay.SetSymbol((ISymbol)pMarkerSymbol); pDisplay.DrawPoint(pGeometry); Thread.Sleep(100); pDisplay.DrawPoint(pGeometry); }
private static double GetLengthInMapUnits(IActiveView activeView, double mm) { if (activeView == null) { return(-1); } IScreenDisplay screenDisplay = activeView.ScreenDisplay; IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation; var dpi = displayTransformation.Resolution; var inches = mm / 25.4; tagRECT deviceRect = displayTransformation.get_DeviceFrame(); int pixelExtent = (deviceRect.right - deviceRect.left); var pixels = dpi * inches; IDistanceConverter distanceConverter = new DistanceConverter(); IEnvelope envelope = displayTransformation.VisibleBounds; double realWorldDisplayExtent = envelope.Width; if (pixelExtent == 0) { return(-1); } var sizeOfOnePixel = (realWorldDisplayExtent / pixelExtent); return(pixels * sizeOfOnePixel); }
/// <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); }
/// <summary> /// 高亮显示线 /// </summary> /// <param name="pDisplay">用于操作的显示屏幕</param> /// <param name="pGeometry">欲高亮显示的几何图形</param> private void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry) { if (pGeometry == null) { return; } //设置显示格式 ISimpleLineSymbol pLineSymbol = null; pLineSymbol = new SimpleLineSymbol(); pLineSymbol.Width = 4; pLineSymbol.Color = GetRGBColor(255, 150, 150); ISymbol pSymbol = null; pSymbol = pLineSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; //用所设置的格式绘制几何图形 pDisplay.SetSymbol((ISymbol)pLineSymbol); pDisplay.DrawPolyline(pGeometry); Thread.Sleep(100); pDisplay.DrawPolyline(pGeometry); }
/// <summary> /// 使用线要素刷新(已解决重叠问题)(推荐使用) /// 使用IScreenDisplay的DrawPolyline方法,在鹰眼视图画出红线框 /// </summary> /// <param name="activeView">鹰眼视图的活动窗体</param> /// <param name="geometry">制框范围</param> private void DrawPolyline(IActiveView activeView, IGeometry geometry) { if (activeView == null) { return; //如果活动窗体为空, 则返回 } //强行刷新鹰眼视图, 目的: 清除前一次的绘图框, 避免重复绘图框 axMapControl2.ActiveView.ScreenDisplay.UpdateWindow(); //解决重复绘图框的关键代码 IScreenDisplay screenDisplay = activeView.ScreenDisplay; //Screen的绘图状态处于准备状态 //参数: (指定设备(Dc=Device), 缓冲区(-1=NoScreenCache,-2=AllScreenCache, -3=ScreenRecoding)) //解析: 设备(Device)参数指图形的绘制区域 //缓冲区(Cache)参数指图形是否经由缓存后再绘制在屏幕(Window/Screen)上。 //一般默认为NoScreenCache, 即不经过缓存直接绘制 screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache); //实例化颜色对象 IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; IColor color = rgbColor; //实例化符号(Symbol)对象 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = color; simpleLineSymbol.Width = 2; ISymbol symbol = (ISymbol)simpleLineSymbol; screenDisplay.SetSymbol(symbol); screenDisplay.DrawPolyline(geometry); screenDisplay.FinishDrawing(); }
public override void Run(object sender, EventArgs e) { Map2DCommandManager.Push(this); IMap2DView mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView; if (mapView == null) { return; } bool bBind = mapView.Bind(this); if (!bBind) { return; } app = DF2DApplication.Application; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } //app.Workbench.SetMenuEnable(false); m_ActiveView = app.Current2DMapControl.ActiveView; m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; pGraphicsContainer = app.Current2DMapControl.ActiveView.GraphicsContainer; app.Current2DMapControl.MousePointer = esriControlsMousePointer.esriPointerArrow; }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; bool ready = true; if (app == null || app.Current2DMapControl == null) { return; } m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; ISimpleFillSymbol pFillSym = new SimpleFillSymbol(); pFillSym.Color = pColor; pFillSym.Style = esriSimpleFillStyle.esriSFSDiagonalCross; pFillSym.Outline = pLineSym; object symbol = pFillSym as object; IRubberBand band = new RubberPolygonClass(); IGeometry pGeo = band.TrackNew(m_Display, null); app.Current2DMapControl.DrawShape(pGeo, ref symbol); WaitForm.Start("正在查询...", "请稍后"); if (pGeo.IsEmpty) { IPoint searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); //m_ActiveView.FocusMap.SelectByShape(geo, s, false); } if (ready) { IMap pMap = app.Current2DMapControl.Map; ISelectionEnvironment selEnv = new SelectionEnvironmentClass(); pMap.SelectByShape(pGeo, selEnv, false); ISelection pSelection = pMap.FeatureSelection; FrmDxfExport dialog = new FrmDxfExport(pSelection, pMap); WaitForm.Stop(); dialog.ShowDialog(); } } } catch (System.Exception ex) { WaitForm.Stop(); } }
private void DrawSymbol(ISymbol symbol, IGeometry geometry) { IScreenDisplay pDisplay = m_activeView.ScreenDisplay; pDisplay.StartDrawing(0, (short)esriScreenCache.esriNoScreenCache); pDisplay.SetSymbol(symbol); for (int i = 0; i < 10; i++) { switch (geometry.GeometryType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: pDisplay.DrawPoint(geometry); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint: pDisplay.DrawMultipoint(geometry); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: pDisplay.DrawPolyline(geometry); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: pDisplay.DrawPolygon(geometry); break; default: break; } System.Threading.Thread.Sleep(100); } //m_mapControl.FlashShape(geometry, 5, 300, symbol); pDisplay.FinishDrawing(); }
public void FlashGeometry(IMap pMap, IGeometry pGeometry, long lFlashRate, bool bDoubleFlag) { try { if ((pMap != null) && (pGeometry != null)) { if (lFlashRate <= 0L) { lFlashRate = 200L; } IActiveView view = pMap as IActiveView; IScreenDisplay screenDisplay = view.ScreenDisplay; screenDisplay.StartDrawing(screenDisplay.hDC, Convert.ToInt16(esriScreenCache.esriNoScreenCache)); switch (pGeometry.GeometryType) { case esriGeometryType.esriGeometryPoint: this.FlashPoint(screenDisplay, pGeometry, true, lFlashRate, bDoubleFlag); break; case esriGeometryType.esriGeometryPolyline: this.FlashLine(screenDisplay, pGeometry, true, lFlashRate, bDoubleFlag); break; case esriGeometryType.esriGeometryPolygon: this.FlashPolygon(screenDisplay, pGeometry, true, lFlashRate, bDoubleFlag); break; } screenDisplay.FinishDrawing(); } } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.FlashFun", "FlashGeometry", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } }
public void UpdateCurrentTime(double progress) { if (progress <= 0) { progress = 0.05; } else if (progress >= 100) { progress = 0.95; } //Calculate how far into the layer to jump ITimeDuration offsetToNewCurrentTime = m_myLayerTimeExtent.QueryTimeDuration(); offsetToNewCurrentTime.Scale(progress); IMxDocument pMxDoc = ArcMap.Document; IMap pMap = pMxDoc.FocusMap; IActiveView pActiveView = pMap as IActiveView; IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay; ITimeDisplay pTimeDisplay = pScreenDisplay as ITimeDisplay; ITime startTime = m_myLayerTimeExtent.StartTime; ITime endTime = (ITime)((IClone)startTime).Clone(); ((ITimeOffsetOperator)endTime).AddDuration(m_layerInterval); ITimeExtent pTimeExt = new TimeExtentClass(); pTimeExt.SetExtent(startTime, endTime); pTimeExt.Empty = false; ((ITimeOffsetOperator)pTimeExt).AddDuration(offsetToNewCurrentTime); pTimeDisplay.TimeValue = pTimeExt as ITimeValue; pActiveView.Refresh(); }
public void ShowFlow(IActiveView ipAV) { if (this.m_pPointcol != null) { double num = 4.0 * Math.Atan(1.0); IScreenDisplay screenDisplay = ipAV.ScreenDisplay; screenDisplay.StartDrawing(0, 0); IMarkerSymbol determinateFolwArrow = NetworkAnalyst.m_pFlowSymbol.DeterminateFolwArrow as IMarkerSymbol; for (int i = 0; i < this.m_pPointcol.PointCount; i++) { esriFlowDirection direction = (esriFlowDirection)this.m_eFlowDirection[i]; if (direction == esriFlowDirection.esriFDWithFlow) { determinateFolwArrow.Angle = (180.0 * ((double)this.m_angle[i])) / num; screenDisplay.SetSymbol(determinateFolwArrow as ISymbol); } else if (direction == esriFlowDirection.esriFDAgainstFlow) { determinateFolwArrow.Angle = ((180.0 * ((double)this.m_angle[i])) / num) + 180.0; screenDisplay.SetSymbol(determinateFolwArrow as ISymbol); } else if (direction == esriFlowDirection.esriFDIndeterminate) { screenDisplay.SetSymbol(NetworkAnalyst.m_pFlowSymbol.IndeterminateFolwArrow); } else { screenDisplay.SetSymbol(NetworkAnalyst.m_pFlowSymbol.UninitializedFolwArrow); } IPoint point = this.m_pPointcol.get_Point(i); screenDisplay.DrawPoint(point); } screenDisplay.FinishDrawing(); } }
public void FlashElement(IMap pMap, IElement pElement, long lFlashRate, bool bDoubleFlag) { try { if ((pMap != null) && (pElement != null)) { if (lFlashRate <= 0L) { lFlashRate = 200L; } IActiveView view = pMap as IActiveView; IScreenDisplay screenDisplay = view.ScreenDisplay; screenDisplay.StartDrawing(screenDisplay.hDC, Convert.ToInt16(esriScreenCache.esriNoScreenCache)); if (pElement is ILineElement) { this.FlashLine(screenDisplay, pElement.Geometry, true, lFlashRate, bDoubleFlag); } else { IPolygon outline = new PolygonClass(); pElement.QueryOutline(screenDisplay, outline); this.FlashPolygon(screenDisplay, outline, true, lFlashRate, bDoubleFlag); } screenDisplay.FinishDrawing(); } } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.FlashFun", "FlashElement", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } }
private void RefreshDataWfs() { try { lock (_getDataLock) { IActiveView activeView = ArcUtils.ActiveView; if (activeView != null) { activeView.PartialRefresh(esriViewDrawPhase.esriViewForeground, Layer, null); } } IActiveView view = ArcUtils.ActiveView; IScreenDisplay display = view.ScreenDisplay; display.StartDrawing(display.hDC, (short)esriScreenCache.esriNoScreenCache); ITrackCancel cancel = new TrackCancelClass(); Layer.Draw(esriDrawPhase.esriDPGeography, display, cancel); display.FinishDrawing(); Viewer.Redraw(); } catch (Exception ex) { Trace.WriteLine(ex.Message, "CycloMediaLayer.RefreshDataWfs"); } }
private void FlashPolygon(IScreenDisplay pScreenDisplay, IGeometry pGeometry, bool bFlashFlag, long lFlashRate, bool bDoubleFlag) { try { ISimpleFillSymbol symbol = new SimpleFillSymbolClass { Outline = null }; ISymbol symbol2 = symbol as ISymbol; symbol2.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pScreenDisplay.SetSymbol(symbol as ISymbol); pScreenDisplay.DrawPolygon(pGeometry); if (bFlashFlag) { Thread.Sleep((int)lFlashRate); pScreenDisplay.DrawPolygon(pGeometry); } if (bDoubleFlag) { Thread.Sleep((int)(((int)lFlashRate) / 2)); pScreenDisplay.DrawPolygon(pGeometry); Thread.Sleep((int)(((int)lFlashRate) / 2)); pScreenDisplay.DrawPolygon(pGeometry); } } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.FlashFun", "FlashPolygon", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } }
public void Flash(IScreenDisplay pDisplay) { if(null == m_propset) return; long zipCode = Convert.ToInt64(m_propset.GetProperty("ZIPCODE")); m_weatherLayer.Flash(zipCode); }
//private void GetLongLat(float jing, float wei, out float Long, float lat) //{ //} private void GotoXY_Load(object sender, EventArgs e) { activeview = pAxMapControl.Map as IActiveView; map = activeview.FocusMap; pScreenDisplay = activeview.ScreenDisplay; pGraphicsContainer = map as IGraphicsContainer; IGraphicsContainerSelect pGraphconSel = map as IGraphicsContainerSelect; }
//��˸�� public static void FlashPoint(IMapControlDefault mapControl, IScreenDisplay iScreenDisplay, IGeometry iGeometry) { ISimpleMarkerSymbol iMarkerSymbol; ISymbol iSymbol; IRgbColor iRgbColor; iMarkerSymbol = new SimpleMarkerSymbol(); iMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; iRgbColor = new RgbColor(); iRgbColor.RGB = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb(); iMarkerSymbol.Color = iRgbColor; iSymbol = (ISymbol)iMarkerSymbol; iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; mapControl.FlashShape(iGeometry, 5, 300, iSymbol); }
//��˸�� public static void FlashLine(IMapControlDefault mapControl, IScreenDisplay iScreenDisplay, IGeometry iGeometry) { ISimpleLineSymbol iLineSymbol; ISymbol iSymbol; IRgbColor iRgbColor; iLineSymbol = new SimpleLineSymbol(); iLineSymbol.Width = 4; iRgbColor = new RgbColor(); iRgbColor.Red = 255; iLineSymbol.Color = iRgbColor; iSymbol = (ISymbol)iLineSymbol; iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; mapControl.FlashShape(iGeometry, 5, 300, iSymbol); }
protected override void OnMouseDown(MouseEventArgs Args) { //initialize all the variables. feedbackEnv = new EnvelopeClass(); feedbackStartPoint = new ESRI.ArcGIS.Geometry.PointClass(); feedbackMovePoint = new ESRI.ArcGIS.Geometry.PointClass(); feedbackLineSymbol = new SimpleLineSymbolClass(); feedbackScreenDisplay = ArcMap.Document.ActiveView.ScreenDisplay; feedbackLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; //initialize a new Envelope feedback class and pass it the symbol and display NewEnvelopeFeedback = new NewEnvelopeFeedbackClass(); NewEnvelopeFeedback.Display = feedbackScreenDisplay; NewEnvelopeFeedback.Symbol = feedbackLineSymbol as ISymbol; //pass the start point from the mouse position, transforming it to an appropriate map point. feedbackStartPoint = feedbackScreenDisplay.DisplayTransformation.ToMapPoint(Args.X, Args.Y) as ESRI.ArcGIS.Geometry.Point; NewEnvelopeFeedback.Start(feedbackStartPoint); }
//��˸�������� public static void FlashPoint(IScreenDisplay pDisplay, IGeometry pGeometry) { ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 150; pRgbColor.Green = 100; pRgbColor.Blue = 100; pMarkerSymbol.Color = pRgbColor as IColor; pMarkerSymbol.Outline = true; ISymbol pSymbol = pMarkerSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPoint(pGeometry); Thread.Sleep(300); pDisplay.DrawPoint(pGeometry); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { //m_Cursor = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream(GetType(), "AopenMap.cur")); if (Button == 1) { if (m_InUse == true) { m_pAV = m_HookHelper.ActiveView; m_pScrD = m_pAV.ScreenDisplay; IMap pMap = m_HookHelper.FocusMap; IPoint pPnt; pPnt = (IPoint)m_pScrD.DisplayTransformation.ToMapPoint(X, Y); if (m_pNewPolygonFeedback == null) { m_pNewPolygonFeedback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSLnSym; IRgbColor pRGB = new RgbColorClass(); pSLnSym = (ISimpleLineSymbol)m_pNewPolygonFeedback.Symbol; pRGB.Red = 140; pRGB.Green = 140; pRGB.Blue = 255; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLnSym.Width = 2; m_pNewPolygonFeedback.Display = m_pScrD; m_pNewPolygonFeedback.Start(pPnt); } else { m_pNewPolygonFeedback.AddPoint(pPnt); } } } else if (Button == 2) { IPolygon pGeomLn; pGeomLn = m_pNewPolygonFeedback.Stop(); m_pNewPolygonFeedback = null; IMap pMap = m_HookHelper.FocusMap; ISpatialReference spatialReference = pMap.SpatialReference; //IBorder pBorder = new SymbolBorderClass(); //*****************************************88888888 if (pFirstGeom == null) { pFirstGeom = pGeomLn; } if (mGeomln != null) { pFirstGeom = mGeomln; } if (pFirstGeom != pGeomLn) { IPolygon mFirstGeom; mFirstGeom = pFirstGeom; IRelationalOperator pROperator = (IRelationalOperator)mFirstGeom; if (pROperator.Disjoint((IGeometry)pGeomLn) == false) { //先定义一个IGeometrycollection的多边形,将每个画出来的IgeometryCollection添加进去 //先添一个构成一个IPolygon,转化为ITopo_ ,再同样构成另一个,进行Union IGeometryCollection pcGeometry = new PolygonClass(); object o = System.Type.Missing; IPolygon cFirstGeom = new PolygonClass(); cFirstGeom = pFirstGeom; ITopologicalOperator tempTopo = (ITopologicalOperator)cFirstGeom; tempTopo.Simplify(); ITopologicalOperator pTopo = (ITopologicalOperator)pGeomLn; pTopo.Simplify(); IGeometry kGeom; kGeom = pTopo.Union((IGeometry)cFirstGeom); mGeomln = (IPolygon)kGeom; mGeomln.SpatialReference = spatialReference; m_pAV.FocusMap.ClipGeometry = mGeomln; //IBorder pBorder = new SymbolBorderClass(); //m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = mGeomln.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; //layVisbleExceptMap(); } } else { //*************************************************8 //mGeomln = pGeomLn; pGeomLn.SpatialReference = spatialReference; LayerControl.LyrPolygon = pGeomLn; m_HookHelper.FocusMap.ClipGeometry = pGeomLn; IBorder pBorder = new SymbolBorderClass(); m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = pGeomLn.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; pGeomLn = null; } } }
/// <summary> /// ����Բ�ĺͰ뾶����Բ /// </summary> /// <params name="pLayer"></params> /// <params name="pPoint"></params> /// <params name="circleRadius"></params> /// <params name="pScreenDisplay"></params> private void DrawCircleByCenterAndRadius(ILayer pLayer, IPoint pPoint, double circleRadius, IScreenDisplay pScreenDisplay) { if (pLayer != null) { ISegmentCollection pSegmentCollection = null; if (pLayer is IFeatureLayer) { IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; if (pFeatureClass != null) { if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { pSegmentCollection = new PolylineClass(); } else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { pSegmentCollection = new PolygonClass(); } //��ʼ��Բ pSegmentCollection.SetCircle(pPoint, circleRadius); IFeature pCircleFeature = pFeatureClass.CreateFeature(); pCircleFeature.Shape = pSegmentCollection as IGeometry; pCircleFeature.Store(); //�ֲ�ˢ�� IInvalidArea pInvalidArea = new InvalidAreaClass(); pInvalidArea.Add(pSegmentCollection); pInvalidArea.Display = pScreenDisplay; pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches); } } } }
private void btnOpnMap_Click(object sender, EventArgs e) { double dobX, dobY; string txtCoodX, txtCoodY; if (lstVwCood.Items.Count < 3) { MessageBox.Show("请输入三个以上的点!"); return; } else { for (int i = 0; i < lstVwCood.Items.Count; i++) { txtCoodX = lstVwCood.Items[i].SubItems[1].Text; txtCoodY = lstVwCood.Items[i].SubItems[2].Text; dobX = Convert.ToDouble(txtCoodX); dobY = Convert.ToDouble(txtCoodY); pPnt.PutCoords(dobX, dobY); if (pNPolFeback == null) { pNPolFeback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSLnSym; IRgbColor pRGB = new RgbColorClass(); pSLnSym = (ISimpleLineSymbol)pNPolFeback.Symbol; pRGB.Red = 140; pRGB.Green = 140; pRGB.Blue = 255; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLnSym.Width = 2; pNPolFeback.Display = pScreen; pNPolFeback.Start(pPnt); } else { pNPolFeback.AddPoint(pPnt); } } pActivew = pMapControl.ActiveView; pScreen = pActivew.ScreenDisplay; IGeometry pGeomLn; pGeomLn = (IGeometry)pNPolFeback.Stop(); IMap pMap = pMapControl.Map; ISpatialReference spatialReference = pMap.SpatialReference; pGeomLn.SpatialReference = spatialReference; IBorder pBorder = new SymbolBorderClass(); LayerControl.LyrPolygon = pGeomLn; pMapControl.Map.ClipBorder = pBorder; pMapControl.Map.ClipGeometry = pGeomLn; pActivew.Extent = pGeomLn.Envelope; //pActivew.Refresh(); this.DialogResult = DialogResult.OK; ////打开地形图图层 //layVisbleExceptMap(); this.Close(); pActivew.Refresh(); } }
public override bool Deactivate() { if (m_polygonFeedback != null) { m_polygonFeedback.Stop(); m_polygonFeedback = null; } m_screenDisplay = null; return true; }
public static void FlashPolygon(IScreenDisplay pDisplay, IGeometry pGeometry, int nTimer, int time) { ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Green = 60; pRGBColor.Red = 255; pRGBColor.Blue = 0; pFillSymbol.Outline = null; pFillSymbol.Color = pRGBColor; ISymbol pSymbol = (ISymbol)pFillSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.StartDrawing(0, (short)esriScreenCache.esriNoScreenCache); pDisplay.SetSymbol(pSymbol); for (int i = 0; i < nTimer; i++) { pDisplay.DrawPolygon(pGeometry); System.Threading.Thread.Sleep(time); } pDisplay.FinishDrawing(); }
/// <summary> /// ����¼� /// </summary> public override void OnClick() { DataEditCommon.InitEditEnvironment(); DataEditCommon.CheckEditState(); m_pCurrentLayer = DataEditCommon.g_pLayer; IFeatureLayer featureLayer = m_pCurrentLayer as IFeatureLayer; if (featureLayer == null) { MessageBox.Show(@"��ѡ�����ͼ�㡣", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); DataEditCommon.g_pMyMapCtrl.CurrentTool = null; return; } else { if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline && featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon || featureLayer.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) { MessageBox.Show(@"��ѡ����״ͼ�����״ͼ�㡣", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); DataEditCommon.g_pMyMapCtrl.CurrentTool = null; return; } } m_pMap = m_hookHelper.FocusMap; m_pScrD = m_hookHelper.ActiveView.ScreenDisplay; m_pNewCircleFeedback = null; }
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); } } } }
/// <summary> /// Flashes the identified object on the screen. /// </summary> /// <param name="pDisplay"></param> public void Flash(IScreenDisplay pDisplay) { }
private IPolyline GetSmashedLine(IScreenDisplay pDisplay, ISymbol pSymbol, IPoint pPoint, IPolyline pPolyline) { IPolygon pBoundry = new PolygonClass(); pSymbol.QueryBoundary(pDisplay.hDC, pDisplay.DisplayTransformation, pPoint, pBoundry); ITopologicalOperator pTopo = pBoundry as ITopologicalOperator; IPolyline pIntersect = pTopo.Intersect(pPolyline, esriGeometryDimension.esriGeometry1Dimension) as IPolyline; pTopo = pPolyline as ITopologicalOperator; return pTopo.Difference(pIntersect) as IPolyline; }
////////////protected override void OnNotifyMessage(System.Windows.Forms.Message m) ////////////{ //////////// /*This method of suppressing resize drawing works by examining the windows messages //////////// sent to the form. When a form starts resizing, windows sends the WM_ENTERSIZEMOVE //////////// Windows(messge). At this point we suppress drawing to the MapControl and //////////// PageLayoutControl and draw using a "stretchy bitmap". When windows sends the //////////// WM_EXITSIZEMOVE the form is released from resizing and we resume with a full //////////// redraw at the new extent. //////////// Note in DotNet forms we can not simply use the second parameter in a Form_Load //////////// event to automatically detect when a form is resized as follows: //////////// AxPageLayoutControl1.SuppressResizeDrawing(False, Me.Handle.ToInt32) //////////// This results in a System.NullException when the form closes (after layers have been //////////// loaded). This is a limitation caused by .Net's particular implementation of its //////////// windows message pump which conflicts with "windows subclassing" used to watch the //////////// forms window.*/ //////////// base.OnNotifyMessage (m); //////////// if (m.Msg == WM_ENTERSIZEMOVE) //////////// { //////////// axMapControl1.SuppressResizeDrawing(true, 0); //////////// } //////////// else if (m.Msg == WM_EXITSIZEMOVE) //////////// { //////////// axMapControl1.SuppressResizeDrawing(false, 0); //////////// } ////////////} private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { //On Error GoTo ErrorHandler if (MDIApplication.ParentForm.pyBtn == 1) { if (this.axMapControl1.ActiveView.FocusMap.SelectionCount >= 1) { //////////IGeometry pGeometry ; //////////IPoint pPoint ; //////////IEnvelope pEnvelope ; m_pScreenDisplay = this.axMapControl1.ActiveView.ScreenDisplay; //'目前对第一层的要素 pMap = this.axMapControl1.ActiveView.FocusMap; pSR = pMap.SpatialReference; // '当前参考系为图层坐标系统WGS84 //'Dim name As String //'name = pSR.name //'MsgBox "name is" & name if (this.axMapControl1.ActiveView.FocusMap.LayerCount == 0) { MessageBox.Show("当前工程没有可操作图层"); return; } //'得到鼠标点击的起点坐标 pPoint = m_pScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); X_First = pPoint.X; Y_First = pPoint.Y; IEnumFeature pEnumFeat = (IEnumFeature)this.axMapControl1.ActiveView.FocusMap.FeatureSelection; pEnumFeat.Reset(); if (pEnumFeat == null) { return; } m_pFeature = pEnumFeat.Next(); IPolygon polygon = (IPolygon)m_pFeature.Shape; //'Feature类型为Polygon m_pDisplayFeedback = new MovePolygonFeedback(); m_pDisplayFeedback.Display = m_pScreenDisplay; IMovePolygonFeedback pMovePolygonF = (IMovePolygonFeedback)m_pDisplayFeedback; //pMovePolygonF.Start( m_pFeature.Shape, pPoint); pMovePolygonF.Start(polygon, pPoint); this.axMapControl1.ActiveView.Refresh(); // '设置鼠标外观,鼠标形状作为判断标志 // 'Dim m_pMouseCursor As esriFramework.MouseCursor // 'Set m_pMouseCursor = New MouseCursor // 'm_pMouseCursor.SetCursor 5 //'ErrorHandler: // 'MsgBox Err.Description } else { return; } } else { return; } }
private void Form1_Load(object sender, EventArgs e) { this.pGraphicContainer = this.axMapControl1.ActiveView.FocusMap as IGraphicsContainer; this.pActiveView = this.axMapControl1.ActiveView; this.pScreenDisplay = this.axMapControl1.ActiveView.ScreenDisplay; }
public static void FlashPolygon(IScreenDisplay pDisplay, IGeometry pGeometry) { ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass(); IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pRgbColor.Green = 0; pRgbColor.Blue = 0; pFillSymbol.Color = pRgbColor as IColor; ISymbol pSymbol = pFillSymbol as ISymbol; //pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPolygon(pGeometry); Thread.Sleep(300); pDisplay.DrawPolygon(pGeometry); }
private void MainForm_Load(object sender, EventArgs e) { if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.ArcReader)) { if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop)) { MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down."); return; } } //get the MapControl m_mapControl = (IMapControl3)axMapControl1.Object; //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; activeview = axMapControl1.Map as IActiveView; map = activeview.FocusMap; pScreenDisplay = activeview.ScreenDisplay; pGraphicsContainer = map as IGraphicsContainer; IGraphicsContainerSelect pGraphconSel = map as IGraphicsContainerSelect; }
public static void FlashPolyline(IScreenDisplay pDisplay, IGeometry pGeometry) { ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Width = 4; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Green = 100; pRgbColor.Red = 150; pRgbColor.Blue = 100; pLineSymbol.Color = pRgbColor as IColor; ISymbol pSymbol = pLineSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPolyline(pGeometry); Thread.Sleep(300); pDisplay.DrawPolyline(pGeometry); }
/// <summary> /// Flash a point feature on the map /// <param name="pDisplay">The map screen</param> /// <param name="pGeometry">The geometry of the feature to be flashed</param> /// </summary> private void FlashPoint(IScreenDisplay pDisplay, IGeometry pGeometry) { // for a point, we only flash a simple circle ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; // Set up the Raster Op-Code to help the flash mechanism ISymbol pSymbol = pMarkerSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; // Flash the point // Two calls are made to Draw. Since the ROP2 setting is NotXOrPen, the first call // draws the symbol with our new symbology and the second call redraws what was originally // in the place of the symbol pDisplay.SetSymbol(pSymbol); pDisplay.DrawPoint(pGeometry); System.Threading.Thread.Sleep(300); pDisplay.DrawPoint(pGeometry); }
//闪烁面 static void FlashPolygon(AxMapControl mapControl, IScreenDisplay iScreenDisplay, IGeometry iGeometry) { ISimpleFillSymbol iFillSymbol; ISymbol iSymbol; IRgbColor iRgbColor; iFillSymbol = new SimpleFillSymbol(); iFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; iFillSymbol.Outline.Width = 12; iRgbColor = new RgbColor(); iRgbColor.RGB = System.Drawing.Color.FromArgb(100, 180, 180).ToArgb(); iFillSymbol.Color = iRgbColor; iSymbol = (ISymbol)iFillSymbol; iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; iScreenDisplay.SetSymbol(iSymbol); mapControl.FlashShape(iGeometry, 3, 200, iSymbol); }
public void FlashGeometry(IGeometry Geom, IScreenDisplay Display, IColor Color, int Size, int Interval) { if (Geom == null) return; short Cache = Display.ActiveCache; Display.ActiveCache = (short)esriScreenCache.esriNoScreenCache; Display.StartDrawing(0, Cache); if (Geom.GeometryType == esriGeometryType.esriGeometryLine || Geom.GeometryType == esriGeometryType.esriGeometryCircularArc) { ILineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); ISymbol pSymbol = (ISymbol)pSimpleLineSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; //erase itself when drawn twice pSimpleLineSymbol.Width = Size; pSimpleLineSymbol.Color = Color; Display.SetSymbol((ISymbol)pSimpleLineSymbol); ISegmentCollection pPath = new PathClass(); pPath.AddSegment((ISegment)Geom); IGeometryCollection pPolyL = new PolylineClass(); pPolyL.AddGeometry((IGeometry)pPath); Display.DrawPolyline((IGeometry)pPolyL); System.Threading.Thread.Sleep(Interval); Display.DrawPolyline((IGeometry)pPolyL); } else if (Geom.GeometryType == esriGeometryType.esriGeometryPolyline) { ILineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); ISymbol pSymbol = (ISymbol)pSimpleLineSymbol; //'QI pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; //erase itself when drawn twice pSimpleLineSymbol.Width = Size; pSimpleLineSymbol.Color = Color; Display.SetSymbol((ISymbol)pSimpleLineSymbol); Display.DrawPolyline(Geom); System.Threading.Thread.Sleep(Interval); Display.DrawPolyline(Geom); } else if (Geom.GeometryType == esriGeometryType.esriGeometryPolygon) { ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); ISymbol pSymbol = (ISymbol)pSimpleFillSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; //erase itself when drawn twice pSimpleFillSymbol.Color = Color; Display.SetSymbol((ISymbol)pSimpleFillSymbol); Display.DrawPolygon(Geom); System.Threading.Thread.Sleep(Interval); Display.DrawPolygon(Geom); } else if (Geom.GeometryType == esriGeometryType.esriGeometryPoint) { ISimpleMarkerSymbol pSimpleMarkersymbol = new SimpleMarkerSymbolClass(); ISymbol pSymbol = (ISymbol)pSimpleMarkersymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pSimpleMarkersymbol.Color = Color; pSimpleMarkersymbol.Size = Size; Display.SetSymbol((ISymbol)pSimpleMarkersymbol); Display.DrawPoint(Geom); System.Threading.Thread.Sleep(Interval); Display.DrawPoint(Geom); } Display.FinishDrawing(); //reset the cache Display.ActiveCache = Cache; }
///<summary>Flash geometry on the display.</summary> ///<param name="geometry"> The input IGeometry to flash. Supported geometry types are GeometryBag, Polygon, Polyline, Point and Multipoint.</param> ///<param name="screenDisplay">An IScreenDisplay reference</param> ///<param name="delay">An integer that is the time in milliseconds to wait.</param> public static void FlashGeometry(IGeometry geometry, IScreenDisplay screenDisplay, int delay, int times) { if (geometry == null || screenDisplay == null) { return; } bool continueFlashing = true; using (ComReleaser comReleaser = new ComReleaser()) { ITrackCancel cancelTracker = new CancelTrackerClass(); comReleaser.ManageLifetime(cancelTracker); screenDisplay.CancelTracker = cancelTracker; short cacheID = screenDisplay.AddCache(); int cacheMemDC = screenDisplay.get_CacheMemDC(cacheID); IRgbColor fillColor = new RgbColorClass(); comReleaser.ManageLifetime(fillColor); fillColor.Green = 128; IRgbColor lineColor = new RgbColorClass(); comReleaser.ManageLifetime(lineColor); screenDisplay.StartDrawing(cacheMemDC, cacheID); DrawGeometry(geometry, fillColor, lineColor, (IDisplay)screenDisplay, cancelTracker); ESRI.ArcGIS.esriSystem.tagRECT RECT = new tagRECT(); screenDisplay.FinishDrawing(); for (int j = 0; j < times; j++) { if (continueFlashing == true) { screenDisplay.DrawCache(screenDisplay.hDC, cacheID, ref RECT, ref RECT); if (delay > 0) { System.Threading.Thread.Sleep(delay); screenDisplay.Invalidate(null, true, cacheID); screenDisplay.UpdateWindow(); System.Threading.Thread.Sleep(delay); } } } //--------------------------------------------------------------------- screenDisplay.RemoveCache(cacheID); cancelTracker.Reset(); } }
/// <summary> /// Flash a line feature on the map /// <param name="pDisplay">The map screen</param> /// <param name="pGeometry">The geometry of the feature to be flashed</param> /// <param name="direction">The digitized direction of the barrier with respect to the underlying source feature</param> /// </summary> private void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry, esriNetworkEdgeDirection direction) { // The flash will be on a line symbol with an arrow on it ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbolClass(); // the line color will be red IRgbColor ipRgbRedColor = new RgbColorClass(); ipRgbRedColor.Red = 192; // the arrow will be black IRgbColor ipRgbBlackColor = new RgbColorClass(); ipRgbBlackColor.RGB = 0; // set up the arrow that will be displayed along the line IArrowMarkerSymbol ipArrowMarker = new ArrowMarkerSymbolClass(); ipArrowMarker.Style = esriArrowMarkerStyle.esriAMSPlain; ipArrowMarker.Length = 18; ipArrowMarker.Width = 12; ipArrowMarker.Color = ipRgbBlackColor; // set up the line itself ipArrowLineSymbol.Width = 4; ipArrowLineSymbol.Color = ipRgbRedColor; // Set up the Raster Op-Code to help the flash mechanism ((ISymbol)ipArrowMarker).ROP2 = esriRasterOpCode.esriROPNotXOrPen; ((ISymbol)ipArrowLineSymbol).ROP2 = esriRasterOpCode.esriROPNotXOrPen; // decorate the line with the arrow symbol ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass(); ipSimpleLineDecorationElement.Rotate = true; ipSimpleLineDecorationElement.PositionAsRatio = true; ipSimpleLineDecorationElement.MarkerSymbol = ipArrowMarker; ipSimpleLineDecorationElement.AddPosition(0.5); ILineDecoration ipLineDecoration = new LineDecorationClass(); ipLineDecoration.AddElement(ipSimpleLineDecorationElement); ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration; // the arrow is initially set to correspond to the digitized direction of the line // if the barrier direction is against digitized, then we need to flip the arrow direction if (direction == esriNetworkEdgeDirection.esriNEDAgainstDigitized) ipSimpleLineDecorationElement.FlipAll = true; // Flash the line // Two calls are made to Draw. Since the ROP2 setting is NotXOrPen, the first call // draws the symbol with our new symbology and the second call redraws what was originally // in the place of the symbol pDisplay.SetSymbol(ipArrowLineSymbol as ISymbol); pDisplay.DrawPolyline(pGeometry); System.Threading.Thread.Sleep(300); pDisplay.DrawPolyline(pGeometry); }
/// <summary> /// ���ݻ��Ƶ�Բ�δ���Ҫ�� /// </summary> /// <params name="pLayer"></params> /// <params name="pCircuArc"></params> /// <params name="pScreenDisplay"></params> private void DrawCircleFeature(ILayer pLayer, ICircularArc pCircuArc, IScreenDisplay pScreenDisplay) { if (pLayer == null) return; ISegmentCollection pSegmentCollection = null; if (pLayer is IFeatureLayer) { IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; if (pFeatureClass != null) { IPolyline pPolyline = null; IPolygon pPolygon = null; if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { pSegmentCollection = new PolylineClass(); pSegmentCollection.AddSegment(pCircuArc as ISegment); pPolyline = pSegmentCollection as IPolyline; } else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { pSegmentCollection = new PolygonClass(); pSegmentCollection.AddSegment(pCircuArc as ISegment); pPolygon = pSegmentCollection as IPolygon; } else return; IFeature pFeature = null; if (pPolyline != null) pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolyline); else if (pPolygon != null) pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolygon); else return; m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null); } } }
public void OnMouseDown(int button, int shift, int x, int y) { if (button != 1) return; IActiveView activeView = m_pHookHelper.ActiveView; IPoint point; //If in PageLayout view, find the closest map if(!(activeView is IMap)) { point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x,y); IMap hitMap = activeView.HitTestMap(point); //Exit if no map found if(hitMap == null) return; if(activeView != m_pHookHelper.FocusMap) activeView.FocusMap = hitMap; } //Start the pan operation m_focusScreenDisplay = getFocusDisplay(); point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x,y); m_focusScreenDisplay.PanStart(point); m_PanOperation = true; }
/// <summary> /// Occurs when this tool is clicked /// </summary> public override void OnClick() { IMxDocument mxDoc = m_application.Document as IMxDocument; m_screenDisplay = mxDoc.ActiveView.ScreenDisplay; }