public void FlashObjects() { screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); //注意其先后顺序 //画面 screenDisplay.SetSymbol(regionSymbol); for (int i = 0; i < polygonsFlashObject.Count; i++) { screenDisplay.DrawPolygon(polygonsFlashObject[i]); } //画线 screenDisplay.SetSymbol(lineSymbol); for (int i = 0; i < polylinesFlashObject.Count; i++) { screenDisplay.DrawPolyline(polylinesFlashObject[i]); } //画点 screenDisplay.SetSymbol(pointSymbol); for (int i = 0; i < pointsFlashObject.Count; i++) { screenDisplay.DrawPoint(pointsFlashObject[i]); } Thread.Sleep(500); screenDisplay.FinishDrawing(); mapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); }
/// <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); }
private void FlashLine(IScreenDisplay pScreenDisplay, IGeometry pGeometry, bool bFlashFlag, long lFlashRate, bool bDoubleFlag) { try { ISimpleLineSymbol symbol = new SimpleLineSymbolClass { Width = 4.0 }; ISymbol symbol2 = symbol as ISymbol; symbol2.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pScreenDisplay.SetSymbol(symbol as ISymbol); pScreenDisplay.DrawPolyline(pGeometry); if (bFlashFlag) { Thread.Sleep((int)lFlashRate); pScreenDisplay.DrawPolyline(pGeometry); } if (bDoubleFlag) { Thread.Sleep((int)(((int)lFlashRate) / 2)); pScreenDisplay.DrawPolyline(pGeometry); Thread.Sleep((int)(((int)lFlashRate) / 2)); pScreenDisplay.DrawPolyline(pGeometry); } } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.FlashFun", "FlashLine", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } }
/// <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); }
private static void FlashLine(IScreenDisplay iscreenDisplay_0, IGeometry igeometry_0) { ISymbol simpleLineSymbolClass = (ISymbol)(new SimpleLineSymbol() { Width = 4 }); simpleLineSymbolClass.ROP2 = esriRasterOpCode.esriROPNotXOrPen; iscreenDisplay_0.SetSymbol(simpleLineSymbolClass); iscreenDisplay_0.DrawPolyline(igeometry_0); Thread.Sleep(300); iscreenDisplay_0.DrawPolyline(igeometry_0); }
/// <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(); }
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(); }
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(); }
//ÉÁ˸Ïß²¢¸ßÁÁÏÔʾ private static void FlashLineAndHiLight(IActiveView pActiveView, IGeometry pGeometry, int interval) { IScreenDisplay pDisplay = pActiveView.ScreenDisplay; ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass(); ISymbol pSymbol; IRgbColor pRGBColor; tagPOINT tagPOINT = new tagPOINT(); WKSPoint WKSPoint = new WKSPoint(); tagPOINT.x = (int)1; tagPOINT.y = (int)1; pDisplay.DisplayTransformation.TransformCoords(ref WKSPoint, ref tagPOINT, 1, 6); pLineSymbol = new SimpleLineSymbolClass(); //if (pActiveView.FocusMap.MapScale != 0) //{ // pLineSymbol.Width = WKSPoint.X * 10000 / pActiveView.FocusMap.MapScale; //} //else //{ // pLineSymbol.Width = WKSPoint.X / 2; //} pLineSymbol.Width = WKSPoint.X; pRGBColor = new RgbColorClass(); pRGBColor.Green = 148; //148 pRGBColor.Red = 32; //32 pRGBColor.Blue = 0; pSymbol = pLineSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPolyline(pGeometry); System.Threading.Thread.Sleep(interval); pDisplay.DrawPolyline(pGeometry); pLineSymbol.Width = 3; IElement pEle = new LineElementClass();//yjl¸ßÁÁÏÔʾ pEle.Geometry = pGeometry; (pEle as ILineElement).Symbol = pSymbol as ILineSymbol; (pEle as IElementProperties).Name = _FlashTagName; (pActiveView as IGraphicsContainer).AddElement(pEle, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pEle, null); //pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, pEle, null); }
private void method_2(IScreenDisplay iscreenDisplay_0, IGeometry igeometry_0) { iscreenDisplay_0.SetSymbol((ISymbol)(new SimpleLineSymbol() { Width = 4 })); iscreenDisplay_0.DrawPolyline(igeometry_0); }
public void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry) { ISimpleLineSymbol symbol = new SimpleLineSymbolClass { Width = 4.0 }; IRgbColor color = new RgbColorClass { Green = 128 }; ISymbol sym = (ISymbol)symbol; sym.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(sym); pDisplay.DrawPolyline(pGeometry); Thread.Sleep(300); pDisplay.DrawPolyline(pGeometry); }
private void ActiveViewEventsOnAfterDraw(IDisplay display, esriViewDrawPhase phase) { if (!_drawFence) { return; } if (_fenceArray == null || _fenceArray.Count == 0) { return; } IScreenDisplay paramScreenDisplay = ((IActiveView)_context.FocusMap).ScreenDisplay; paramScreenDisplay.StartDrawing(paramScreenDisplay.hDC, -2); for (int i = 0; i < _fenceArray.Count; i++) { IGeometry fence = _fenceArray.Element[i]; if (fence.IsEmpty) { continue; } if (fence is IPolyline) { paramScreenDisplay.SetSymbol(_lineSymbol); paramScreenDisplay.DrawPolyline(fence); } else if (fence is IPolygon) { paramScreenDisplay.SetSymbol(_fillSymbol); paramScreenDisplay.DrawPolygon(fence); } } if (_drawPage && _pageInfos != null && _pageInfos.Count > 0) { IFontDisp disp = new StdFont() as IFontDisp; disp.Name = "Arial"; disp.Size = new decimal(16); foreach (IPrintPageInfo pageInfo in _pageInfos) { IGeometry pageBoundary = pageInfo.Boundary; paramScreenDisplay.SetSymbol(_fillSymbol); paramScreenDisplay.DrawPolygon(pageBoundary); _textSymbol = SymbolHelper.CreateTextSymbol(Color.Red, disp, 16, pageInfo.PageName); paramScreenDisplay.SetSymbol(_textSymbol as ISymbol); if (!string.IsNullOrEmpty(pageInfo.PageName)) { IPoint centerPoint = new ESRI.ArcGIS.Geometry.Point(); IEnvelope pEnv = pageBoundary.Envelope; centerPoint.PutCoords((pEnv.XMin + pEnv.Width / 2.0), pEnv.YMin + pEnv.Height / 2.0); paramScreenDisplay.DrawText(centerPoint, pageInfo.PageName); } } } paramScreenDisplay.FinishDrawing(); }
public override void OnMouseMove(int x, int y) { if (n < 1) { } else { double xmin = line.Envelop.Left; double ymin = line.Envelop.Lower; double w = line.Envelop.Width; double h = line.Envelop.Height; Rectangle invalidaterect = new Rectangle((int)xmin, (int)ymin, (int)w, (int)h); invalidaterect.Inflate(2, 2); (mScreenDisplay as ScreenDisplay).RepaintStatic(invalidaterect); PointF p1 = new PointF((float)line.P0.X, (float)line.P0.Y); PointF p2 = new PointF(x, y); mScreenDisplay.DrawPolyline(Pens.Blue, p1, p2); line.P1 = new RPoint(x, y, 0); } }
//ÉÁ˸Ïß private static void FlashLine(IActiveView pActiveView, IGeometry pGeometry, int interval) { IScreenDisplay pDisplay = pActiveView.ScreenDisplay; ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass(); ISymbol pSymbol; IRgbColor pRGBColor; tagPOINT tagPOINT = new tagPOINT(); WKSPoint WKSPoint = new WKSPoint(); tagPOINT.x = (int)1; tagPOINT.y = (int)1; pDisplay.DisplayTransformation.TransformCoords(ref WKSPoint, ref tagPOINT, 1, 6); pLineSymbol = new SimpleLineSymbolClass(); //if (pActiveView.FocusMap.MapScale != 0) //{ // pLineSymbol.Width = WKSPoint.X * 10000 / pActiveView.FocusMap.MapScale; //} //else //{ // pLineSymbol.Width = WKSPoint.X / 2; //} pLineSymbol.Width = WKSPoint.X; pRGBColor = new RgbColorClass(); pRGBColor.Green = 148; //148 pRGBColor.Red = 32; //32 pRGBColor.Blue = 0; pSymbol = pLineSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPolyline(pGeometry); System.Threading.Thread.Sleep(interval); pDisplay.DrawPolyline(pGeometry); }
private static void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry) { ISimpleLineSymbol pLineSymbol; ISymbol pSymbol; IRgbColor pRGBColor; pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 150; pRGBColor.Blue = 150; pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Width = 4; pLineSymbol.Color = pRGBColor; pSymbol = (ISymbol)pLineSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPolyline(pGeometry); System.Threading.Thread.Sleep(300); pDisplay.DrawPolyline(pGeometry); }
public void DrawDifferenceGeometry(IGeometry igeometry_0, IScreenDisplay iscreenDisplay_0) { IRgbColor color = new RgbColorClass { Red = 255 }; iscreenDisplay_0.StartDrawing(iscreenDisplay_0.hDC, -1); switch (igeometry_0.GeometryType) { case esriGeometryType.esriGeometryPoint: { ISimpleMarkerSymbol symbol = new SimpleMarkerSymbolClass { Color = color, Size = 10.0 }; iscreenDisplay_0.SetSymbol(symbol as ISymbol); iscreenDisplay_0.DrawPoint(igeometry_0); break; } case esriGeometryType.esriGeometryPolyline: { ISimpleLineSymbol symbol2 = new SimpleLineSymbolClass { Color = color, Width = 2.0 }; iscreenDisplay_0.SetSymbol(symbol2 as ISymbol); iscreenDisplay_0.DrawPolyline(igeometry_0); break; } case esriGeometryType.esriGeometryPolygon: { ISimpleFillSymbol symbol3 = new SimpleFillSymbolClass { Outline = { Color = color, Width = 2.0 }, Style = esriSimpleFillStyle.esriSFSForwardDiagonal }; iscreenDisplay_0.SetSymbol(symbol3 as ISymbol); iscreenDisplay_0.DrawPolygon(igeometry_0); break; } } iscreenDisplay_0.FinishDrawing(); }
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { IActiveView pActiveView = axMapControl1.ActiveView; IScreenDisplay screenDisplay = pActiveView.ScreenDisplay; ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; lineSymbol.Color = rgbColor; // IRubberBand rubberLine = new RubberLineClass(); // IPolyline pLine = (IPolyline)rubberLine.TrackNew(screenDisplay, (ISymbol)lineSymbol); IPolyline pLine = axMapControl1.TrackLine() as IPolyline; screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); screenDisplay.SetSymbol((ISymbol)lineSymbol); screenDisplay.DrawPolyline(pLine); screenDisplay.FinishDrawing(); }
public override void OnMouseDown(int x, int y) { n++; if (n == 1) { SharpMap.Geometries.Point P0 = new SharpMap.Geometries.Point(x, y); SharpMap.Geometries.Point P1 = new SharpMap.Geometries.Point(x, y); SharpMap.Geometries.Point P2 = new SharpMap.Geometries.Point(x, y); vertices.Add(P0); vertices.Add(P1); vertices.Add(P2); line = new LinearRing(vertices); } else if (n == 2) { vertices[1] = new SharpMap.Geometries.Point(x, y); PointF p1 = new PointF((float)vertices[0].X, (float)vertices[0].Y); PointF p2 = new PointF(x, y); mScreenDisplay.DrawPolyline(Pens.Blue, p1, p2); //n = 0; } else if (n == 3) { vertices[2] = new SharpMap.Geometries.Point(x, y); polygon.ExteriorRing = line; if (line != null) { SolidBrush brush = new SolidBrush(Color.Blue); Pen pen = new Pen(brush); // mScreenDisplay.DrawPolygon(polygon, brush, pen, false); mScreenDisplay.NewObject = polygon; } } else { SharpMap.Geometries.Point P4 = new SharpMap.Geometries.Point(x, y); vertices.Add(P4); SolidBrush brush = new SolidBrush(Color.Blue); Pen pen = new Pen(brush); // mScreenDisplay.DrawPolygon(polygon, brush, pen, false); mScreenDisplay.NewObject = polygon; } mMapCtrl.Refresh(); }
private void OnViewRefreshed(IActiveView view, esriViewDrawPhase phase, object data, IEnvelope envelope) { if (phase != esriViewDrawPhase.esriViewGraphics) { return; } if (view is IPageLayout) { return; } if (!_drawFence) { return; } if (_fenceArray == null || _fenceArray.Count == 0) { return; } IScreenDisplay paramScreenDisplay = ((IActiveView)_context.FocusMap).ScreenDisplay; paramScreenDisplay.StartDrawing(paramScreenDisplay.hDC, -2); for (int i = 0; i < _fenceArray.Count; i++) { IGeometry fence = _fenceArray.Element[i]; if (!fence.IsEmpty) { continue; } if (fence is IPolyline) { paramScreenDisplay.SetSymbol(_lineSymbol); paramScreenDisplay.DrawPolyline(fence); } else if (fence is IPolygon) { paramScreenDisplay.SetSymbol(_fillSymbol); paramScreenDisplay.DrawPolygon(fence); } } paramScreenDisplay.FinishDrawing(); }
public static void DrawGeometry(IScreenDisplay paramScreenDisplay, IGeometry paramGeom, ISymbol paramSymbol) { if ((paramScreenDisplay == null || paramGeom == null || paramGeom.IsEmpty ? false : paramSymbol != null)) { paramScreenDisplay.StartDrawing(paramScreenDisplay.hDC, -2); paramScreenDisplay.SetSymbol(paramSymbol); if (paramGeom is IPoint) { paramScreenDisplay.DrawPoint(paramGeom); } else if (paramGeom is IPolyline) { paramScreenDisplay.DrawPolyline(paramGeom); } else if (paramGeom is IPolygon) { paramScreenDisplay.DrawPolygon(paramGeom); } paramScreenDisplay.FinishDrawing(); } }
public static void DrawPolyline(IScreenDisplay pDisplay) { if (m_ipPolyline == null) { if ((m_ipEnumNetEID_Junctions != null) && (m_ipEnumNetEID_Junctions.Count == 1)) { IEIDHelper helper = new EIDHelperClass { GeometricNetwork = m_pAnalystGN, ReturnGeometries = true }; IEnumEIDInfo info = helper.CreateEnumEIDInfo(m_ipEnumNetEID_Junctions); info.Reset(); IGeometry point = info.Next().Geometry; ISimpleMarkerSymbol symbol = new SimpleMarkerSymbolClass { Style = esriSimpleMarkerStyle.esriSMSCircle, Size = 2.0, Color = ColorManage.Red }; pDisplay.StartDrawing(0, -1); pDisplay.SetSymbol(symbol as ISymbol); pDisplay.DrawPoint(point); pDisplay.FinishDrawing(); } } else { ISimpleLineSymbol symbol2 = new SimpleLineSymbolClass { Style = esriSimpleLineStyle.esriSLSSolid, Width = 2.0, Color = ColorManage.Red }; pDisplay.StartDrawing(0, -1); pDisplay.SetSymbol(symbol2 as ISymbol); pDisplay.DrawPolyline(m_ipPolyline); pDisplay.FinishDrawing(); } }
public override void Draw(IScreenDisplay display) { if (ShapeType == 0) { for (int i = 0; i < mGeometries.Count; i++) { RPoint pt = mGeometries[i] as RPoint; if (pt != null) { display.DrawPoint(new Pen(Color.Red), pt); } } } if (ShapeType == 1) { for (int i = 0; i < mGeometries.Count; i++) { RPolyline pt = mGeometries[i] as RPolyline; if (pt != null) { display.DrawPolyline(new Pen(Color.Red), pt); } } } if (ShapeType == 2) { for (int i = 0; i < mGeometries.Count; i++) { RPolygon pt = mGeometries[i] as RPolygon; if (pt != null) { display.DrawPolygon(new Pen(Color.Red), pt); } } } }
private void CutSelectedPolygon() { if (m_selectedFeature == null) { MessageBox.Show("请先选择要分割的面要素!!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); m_toolPhase = ToolPhase.SelectFeature; return; } //在屏幕上绘制用于分割的线要素 IScreenDisplay screenDisplay = m_activeView.ScreenDisplay; ISimpleLineSymbol sym = new SimpleLineSymbolClass(); IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 128; color.Blue = 128; sym.Color = color; sym.Style = esriSimpleLineStyle.esriSLSSolid; sym.Width = 2; IRubberBand cutBand = new RubberLineClass(); IGeometry cutGeometry = cutBand.TrackNew(screenDisplay, sym as ISymbol); screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); screenDisplay.SetSymbol(sym as ISymbol); screenDisplay.DrawPolyline(cutGeometry); screenDisplay.FinishDrawing(); IFeatureClass featureClass = m_selectedFeature.Class as IFeatureClass; IDataset dataset = featureClass as IDataset; IWorkspaceEdit workspaceEdit = dataset.Workspace as IWorkspaceEdit; if (!(workspaceEdit.IsBeingEdited())) { return; } //分割选择的面要素 if (cutGeometry.IsEmpty == true) { return; } try { workspaceEdit.StartEditOperation(); IFeatureEdit featureEdit = m_selectedFeature as IFeatureEdit; //分割产生新的面要素 ISet newFeaturesSet = featureEdit.Split(cutGeometry); //亮闪新要素 if (newFeaturesSet != null) { newFeaturesSet.Reset(); for (int featureCount = 0; featureCount < newFeaturesSet.Count; featureCount++) { IFeature newFeature = newFeaturesSet.Next() as IFeature; FlashGeometry(newFeature.Shape, 3, 20); } } workspaceEdit.StopEditOperation(); } catch (Exception ex) { workspaceEdit.AbortEditOperation(); //SysLogHelper.WriteOperationLog("要素分割错误", ex.Source, "数据编辑"); MessageBox.Show("分割面要素失败!!" + ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_activeView.Extent); m_toolPhase = ToolPhase.SelectFeature; }
/// <summary> /// 绘制线、矩形和面的函数 /// </summary> /// <param name="pGeometry"></param> /// <param name="pScrDisplay"></param> public static void DrawGeometryXOR(IGeometry pGeometry, IScreenDisplay pScrDisplay) { if (pGeometry == null || pScrDisplay == null || pGeometry.GeometryType == esriGeometryType.esriGeometryPoint) { return; } IFillSymbol pFillSymbol; ILineSymbol pLineSymbol; ISymbol pSymbol; IRgbColor pRGBColor; ISymbol pLSymbol; IPolygon pPolygon; IEnvelope pEnvelope; IPolyline pPolyline; try { pRGBColor = new RgbColorClass(); pRGBColor.UseWindowsDithering = false; pRGBColor.Red = 45; pRGBColor.Green = 45; pRGBColor.Blue = 45; pFillSymbol = new SimpleFillSymbolClass(); pSymbol = (ISymbol)pFillSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPXOrPen; pFillSymbol.Color = (IColor)pRGBColor; pLineSymbol = pFillSymbol.Outline; pLSymbol = (ISymbol)pLineSymbol; pLSymbol.ROP2 = esriRasterOpCode.esriROPXOrPen; pRGBColor.Red = 145; pRGBColor.Green = 145; pRGBColor.Blue = 145; pLineSymbol.Color = (IColor)pRGBColor; pLineSymbol.Width = 0.8; pFillSymbol.Outline = pLineSymbol; pScrDisplay.StartDrawing(0, -1); //esriScreenCache.esriNoScreenCache -1 if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline) { pScrDisplay.SetSymbol((ISymbol)pLineSymbol); pPolyline = (IPolyline)pGeometry; pScrDisplay.DrawPolyline(pPolyline); } else if (pGeometry.GeometryType == esriGeometryType.esriGeometryEnvelope) { pScrDisplay.SetSymbol(pSymbol); pEnvelope = (IEnvelope)pGeometry; pScrDisplay.DrawRectangle(pEnvelope); } else { pScrDisplay.SetSymbol(pSymbol); pPolygon = (IPolygon)pGeometry; pScrDisplay.DrawPolygon(pPolygon); } pScrDisplay.FinishDrawing(); } catch (Exception ex) { MessageBox.Show("绘制缓冲范围出错:" + ex.Message, "提示"); } finally { pFillSymbol = null; pLineSymbol = null; pSymbol = null; pRGBColor = null; pLSymbol = null; } }
/// <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); }
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); }
private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e) { switch (mTool) { case "Network": try { //路径计算 //注意权重名称与设置保持一致 SolvePath("LENGTH"); //路径转换为几何要素 IPolyline pPolyLineResult = PathToPolyLine(); //获取屏幕显示 IActiveView pActiveView = this.axMapControl1.ActiveView; IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay; //设置显示符号 ILineSymbol pLineSymbol = new CartographicLineSymbolClass(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; //设置线宽 pLineSymbol.Width = 4; //设置颜色 pLineSymbol.Color = pColor as IColor; //绘制线型符号 pScreenDisplay.StartDrawing(0, 0); pScreenDisplay.SetSymbol((ISymbol)pLineSymbol); pScreenDisplay.DrawPolyline(pPolyLineResult); pScreenDisplay.FinishDrawing(); } catch (System.Exception ex) { MessageBox.Show("路径分析出现错误:" + "\r\n" + ex.Message); } //点集设为空 mPointCollection = null; break; case "Edit": //判断是否鼠标左键 if (e.button != 1) { return; } ////判断是否处于编辑状态 if (mEdit != null && mEdit.IsEditing()) { switch (cboTasks.SelectedIndex) { case 0: mEdit.CreateDoubleClick(e.mapX, e.mapY); break; case 1: break; } } break; default: break; } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button != 1) { return; } IWorkspace workspace = null; #region……分割面 //根据已选择的要分割的要素的类型绘制分割线 if (((IFeatureLayer)mLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) {//分割线的样式 IScreenDisplay pScreenDisplay = pMapControl.ActiveView.ScreenDisplay; ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass(); IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pLineSymbol.Color = pRgbColor; IRubberBand pRubberBand = new RubberLineClass(); IPolyline pPolyline = (IPolyline)pRubberBand.TrackNew(pScreenDisplay, (ISymbol)pLineSymbol); pScreenDisplay.StartDrawing(pScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); pScreenDisplay.SetSymbol((ISymbol)pLineSymbol); pScreenDisplay.DrawPolyline(pPolyline); pScreenDisplay.FinishDrawing(); //清理将被分割的要素 ITopologicalOperator pTopoOpo; pTopoOpo = pPolyline as ITopologicalOperator; pTopoOpo.Simplify();//确保几何体的拓扑正确 //开始编辑 IFeatureLayer featureLayer = mLayer as IFeatureLayer; IFeatureClass pFeatureClass = featureLayer.FeatureClass; IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass(); if (pFeatureClass.FeatureDataset != null) { workspace = pFeatureClass.FeatureDataset.Workspace; mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; mEngineEditor.StartEditing(workspace, mMap); ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, -1); mEngineEditor.StartOperation(); } //分割方法 SplitPolygon(pFeatureClass, pPolyline); ReBackStates();//刷新返回修改工具 pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, pMapControl.ActiveView.Extent); // mEngineEditor.StopEditing(true); } #endregion #region……鼠标画线分割线 //根据分割要素的类型绘制分割线 if (((IFeatureLayer)mLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IScreenDisplay pScreenDisplay = pMapControl.ActiveView.ScreenDisplay; ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass(); IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pLineSymbol.Color = pRgbColor; IRubberBand pRubberBand = new RubberLineClass(); IPolyline pPolyline = (IPolyline)pRubberBand.TrackNew(pScreenDisplay, (ISymbol)pLineSymbol); pScreenDisplay.StartDrawing(pScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); pScreenDisplay.SetSymbol((ISymbol)pLineSymbol); pScreenDisplay.DrawPolyline(pPolyline); pScreenDisplay.FinishDrawing(); // mEngineEditor.StartOperation();//开启编辑 IFeatureLayer featureLayer = mLayer as IFeatureLayer; IFeatureClass pFeatureClass = featureLayer.FeatureClass; IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass(); if (pFeatureClass.FeatureDataset != null) { workspace = pFeatureClass.FeatureDataset.Workspace; mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; mEngineEditor.StartEditing(workspace, mMap); ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, -1); mEngineEditor.StartOperation(); } ISelectionSet pSelectionSet = pFeatureClass.Select(null, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, workspace); //分割方法 SplitPolyline(pSelectionSet, pPolyline); ReBackStates(); pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, pMapControl.ActiveView.Extent); } #endregion if (workspace != null) { mEngineEditor.StopEditing(true); } //mEngineEditor.StopOperation("ControlToolsEditing_CreateNewFeatureTask"); }
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; }
public void DrawDifferenceGeometry(IGeometry igeometry_0, IScreenDisplay iscreenDisplay_0) { IRgbColor rgbColorClass = new RgbColor() { Red = 255 }; iscreenDisplay_0.StartDrawing(iscreenDisplay_0.hDC, -1); switch (igeometry_0.GeometryType) { case esriGeometryType.esriGeometryPoint: { ISimpleMarkerSymbol simpleMarkerSymbolClass = new SimpleMarkerSymbol() { Color = rgbColorClass, Size = 10 }; iscreenDisplay_0.SetSymbol(simpleMarkerSymbolClass as ISymbol); iscreenDisplay_0.DrawPoint(igeometry_0); iscreenDisplay_0.FinishDrawing(); return; } case esriGeometryType.esriGeometryMultipoint: { iscreenDisplay_0.FinishDrawing(); return; } case esriGeometryType.esriGeometryPolyline: { ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol() { Color = rgbColorClass, Width = 2 }; iscreenDisplay_0.SetSymbol(simpleLineSymbolClass as ISymbol); iscreenDisplay_0.DrawPolyline(igeometry_0); iscreenDisplay_0.FinishDrawing(); return; } case esriGeometryType.esriGeometryPolygon: { ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); simpleFillSymbolClass.Outline.Color = rgbColorClass; simpleFillSymbolClass.Outline.Width = 2; simpleFillSymbolClass.Style = esriSimpleFillStyle.esriSFSForwardDiagonal; iscreenDisplay_0.SetSymbol(simpleFillSymbolClass as ISymbol); iscreenDisplay_0.DrawPolygon(igeometry_0); iscreenDisplay_0.FinishDrawing(); return; } default: { iscreenDisplay_0.FinishDrawing(); return; } } }
private void drawgeometryXOR(IGeometry pGeometry) { if (pGeometry == null)//如果窗体关闭或者取消 就不绘制 xisheng 2011.06.28 { return; } IScreenDisplay pScreenDisplay = m_pMapControl.ActiveView.ScreenDisplay; ISymbol pSymbol = null; //颜色对象 IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.UseWindowsDithering = false; pRGBColor = getRGB(255, 0, 0); pRGBColor.Transparency = 255; try { switch (pGeometry.GeometryType.ToString()) { case "esriGeometryPoint": //点要素 ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Size = 7.0; pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Color = pRGBColor; pSymbol = (ISymbol)pMarkerSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPCopyPen; break; case "esriGeometryPolyline": //线要素 ISimpleLineSymbol pPolyLineSymbol = new SimpleLineSymbolClass(); pPolyLineSymbol.Color = pRGBColor; pPolyLineSymbol.Width = 2.5; pPolyLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pSymbol = (ISymbol)pPolyLineSymbol; ///ZQ 20111117 modify pSymbol.ROP2 = esriRasterOpCode.esriROPCopyPen; break; case "esriGeometryPolygon": //面要素 ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass(); ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass(); pSymbol = (ISymbol)pFillSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPCopyPen; /// end pLineSymbol.Color = pRGBColor; pLineSymbol.Width = 1.5; pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pFillSymbol.Outline = pLineSymbol; pFillSymbol.Color = pRGBColor; pFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross; break; } pScreenDisplay.StartDrawing(pScreenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); //esriScreenCache.esriNoScreenCache -1 pScreenDisplay.SetSymbol(pSymbol); switch (pGeometry.GeometryType.ToString()) { case "esriGeometryPoint": //点要素 pScreenDisplay.DrawPoint(pGeometry); break; case "esriGeometryPolyline": //线要素 pScreenDisplay.DrawPolyline(pGeometry); break; case "esriGeometryPolygon": //面要素 pScreenDisplay.DrawPolygon(pGeometry); break; } pScreenDisplay.FinishDrawing(); } catch { } finally { pSymbol = null; pRGBColor = null; } }
public static void DrawWinkFeature(IScreenDisplay pDisplay, IGeometry pGeo) { IRgbColor rgbColorClass = new RgbColor() { Blue = 0, Green = 0, Red = 255, }; short activeCache = pDisplay.ActiveCache; pDisplay.ActiveCache = -1; pDisplay.StartDrawing(pDisplay.hDC, -1); switch (pGeo.GeometryType) { case esriGeometryType.esriGeometryPoint: { ISimpleMarkerSymbol simpleMarkerSymbolClass = new SimpleMarkerSymbol(); ((ISymbol)simpleMarkerSymbolClass).ROP2 = esriRasterOpCode.esriROPNotXOrPen; simpleMarkerSymbolClass.Color = rgbColorClass; simpleMarkerSymbolClass.Size = (double)9; pDisplay.SetSymbol((ISymbol)simpleMarkerSymbolClass); pDisplay.DrawPoint(pGeo); Thread.Sleep((int)1000); pDisplay.DrawPoint(pGeo); Thread.Sleep((int)1000); pDisplay.FinishDrawing(); pDisplay.ActiveCache = activeCache; //mUiCurrentCounter = this; //mUiCurrentCounter.m_uiCurrentCounter = mUiCurrentCounter.m_uiCurrentCounter + 1; return; } case esriGeometryType.esriGeometryMultipoint: { pDisplay.FinishDrawing(); pDisplay.ActiveCache = activeCache; //mUiCurrentCounter = this; //mUiCurrentCounter.m_uiCurrentCounter = mUiCurrentCounter.m_uiCurrentCounter + 1; return; } case esriGeometryType.esriGeometryPolyline: { ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol(); ((ISymbol)simpleLineSymbolClass).ROP2 = esriRasterOpCode.esriROPNotXOrPen; simpleLineSymbolClass.Color = rgbColorClass; simpleLineSymbolClass.Width = (double)3; pDisplay.SetSymbol((ISymbol)simpleLineSymbolClass); pDisplay.DrawPolyline(pGeo); Thread.Sleep((int)1000); pDisplay.DrawPolyline(pGeo); Thread.Sleep((int)1000); pDisplay.FinishDrawing(); pDisplay.ActiveCache = activeCache; //mUiCurrentCounter = this; //mUiCurrentCounter.m_uiCurrentCounter = mUiCurrentCounter.m_uiCurrentCounter + 1; return; } case esriGeometryType.esriGeometryPolygon: { ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); ((ISymbol)simpleFillSymbolClass).ROP2 = esriRasterOpCode.esriROPNotXOrPen; simpleFillSymbolClass.Color = rgbColorClass; pDisplay.SetSymbol((ISymbol)simpleFillSymbolClass); pDisplay.DrawPolygon(pGeo); Thread.Sleep((int)1000); pDisplay.DrawPolygon(pGeo); Thread.Sleep((int)1000); pDisplay.FinishDrawing(); pDisplay.ActiveCache = activeCache; //mUiCurrentCounter = this; //mUiCurrentCounter.m_uiCurrentCounter = mUiCurrentCounter.m_uiCurrentCounter + 1; return; } default: { pDisplay.FinishDrawing(); pDisplay.ActiveCache = activeCache; //mUiCurrentCounter = this; //mUiCurrentCounter.m_uiCurrentCounter = mUiCurrentCounter.m_uiCurrentCounter + 1; return; } } }
private void button2_Click(object sender, EventArgs e) { Form1 path1 = (Form1)this.Owner; //把查询到的点加入到点集中 if (mPointCollectionNet == null) { mPointCollectionNet = new MultipointClass(); } object before = Type.Missing; object after = Type.Missing; mPointCollectionNet.AddPoint(path1.pNewPointBegin, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointVia1, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointVia2, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointVia3, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointEnd, ref before, ref after); SolvePath("lenth"); pPolyLineResult = PathToPolyLine(); //mPointCollectionNet.AddPoint(path1.pNewPointVia1, ref before, ref after); //mPointCollectionNet.AddPoint(path1.pNewPointVia2, ref before, ref after); //mPointCollectionNet.AddPoint(path1.pNewPointVia3, ref before, ref after); //路径计算 //注意权重名称与设置保持一致 //SolvePath("lenth"); //路径转换为几何要素 //pPolyLineResult1 = PathToPolyLine(); //pPolyLineResult2 = PathToPolyLine(); //pPolyLineResult3 = PathToPolyLine(); //pPolyLineResult4 = PathToPolyLine(); path1._pPolyLine = this.pPolyLineResult; try { //获取屏幕显示 IActiveView pActiveView = this.axMapControl1.ActiveView; IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay; //设置显示符号 ILineSymbol pLineSymbol = new CartographicLineSymbolClass(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; //设置线宽 pLineSymbol.Width = 4; //设置颜色 pLineSymbol.Color = pColor as IColor; //绘制线型符号 pScreenDisplay.StartDrawing(0, 0); pScreenDisplay.SetSymbol((ISymbol)pLineSymbol); pScreenDisplay.DrawPolyline(pPolyLineResult); //注记 ITextElement te1 = createTextElement(path1.pNewPointBegin.X, path1.pNewPointBegin.Y, path1.pQueryFilterBegin.WhereClause); ITextElement te2 = createTextElement(path1.pNewPointVia1.X, path1.pNewPointVia1.Y, path1.pQueryFilterVia1.WhereClause); ITextElement te3 = createTextElement(path1.pNewPointVia2.X, path1.pNewPointVia2.Y, path1.pQueryFilterVia2.WhereClause); ITextElement te4 = createTextElement(path1.pNewPointVia3.X, path1.pNewPointVia3.Y, path1.pQueryFilterVia3.WhereClause); ITextElement te5 = createTextElement(path1.pNewPointEnd.X, path1.pNewPointEnd.Y, path1.pQueryFilterEnd.WhereClause); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te1 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te2 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te3 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te4 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te5 as IElement, 1); this.axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); pScreenDisplay.FinishDrawing(); } catch (System.Exception ex) { MessageBox.Show("路径分析出现错误:" + "\r\n" + ex.Message); } //点集设为空 mPointCollectionNet = null; }