private void CreateBlockElements() { IGeometryCollection geometryCollection = new Multipoint() as IGeometryCollection; for (int i = 0; i < this._networkInfo.arrayList_0.Count; i++) { object missing = Type.Missing; IFeature feature = (IFeature)this._networkInfo.arrayList_0[i]; geometryCollection.AddGeometry(feature.ShapeCopy, ref missing, ref missing); } if (this._networkInfo.arrayList_0.Count > 0) { IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_iApp.ActiveView; IMarkerSymbol markerSymbol = this.GetMarkerSymbol(); markerSymbol.Size = (26.0); for (int j = 0; j < geometryCollection.GeometryCount; j++) { IMarkerElement markerElement = new MarkerElement() as IMarkerElement; IElement element = (IElement)markerElement; element.Geometry = (geometryCollection.get_Geometry(j)); markerElement.Symbol = (markerSymbol); graphicsContainer.AddElement(element, 0); } m_iApp.ActiveView.PartialRefresh((esriViewDrawPhase)8, null, null); } }
private IElement CreatePointElement(IPoint pt, IMarkerSymbol pSymbol, IFillSymbol pBackSymbol, string des) { IGroupElement groupElementClass = new GroupElement() as IGroupElement; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth / 2, pt.Y - this.m_itemheight / 2); IElement markerElementClass = new MarkerElement() { Geometry = pointClass }; (markerElementClass as IMarkerElement).Symbol = pSymbol; if (pBackSymbol != null) { groupElementClass.AddElement(this.CreatePolygonElement(pt, pBackSymbol)); } else if (this.m_ItemHasBorder) { groupElementClass.AddElement(this.CreatePolygonElement(pt)); } groupElementClass.AddElement(markerElementClass); if (des.Length > 0) { groupElementClass.AddElement(this.CreateTextElement(pt, des, 10)); } return(groupElementClass as IElement); }
protected override void OnMouseDown(MouseEventArgs arg) { base.OnMouseDown(arg); IMxDocument pMxdoc = ArcMap.Application.Document as IMxDocument; IPoint pPoint = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); IGraphicsContainer pGC = pMxdoc.ActiveView.GraphicsContainer; IElement pElement = new MarkerElement(); IMarkerElement pMarkerElement = pElement as IMarkerElement; ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbol(); pMarkerSymbol.Size = 10; IRgbColor pColor = new RgbColor(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pMarkerSymbol.Color = pColor; pMarkerElement.Symbol = pMarkerSymbol; pElement.Geometry = pPoint; pGC.AddElement(pElement, 0); pMxdoc.ActiveView.Refresh(); }
public ImportLibrary(string name) { m_nameElement = new VariableSizeStringElement(name); m_functions = new Dictionary <string, ImportFunction>(); m_originalFirstThunkMarker = new MarkerElement(); m_firstThunkMarker = new MarkerElement(); }
public void NewBasePointElement() { IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_context.ActiveView; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); IRgbColor rgbColor = new RgbColor(); rgbColor.Red = 255; rgbColor.Green = 0; rgbColor.Blue = 0; IRgbColor rgbColor2 = new RgbColor(); rgbColor2.Red = 0; rgbColor2.Green = 0; rgbColor2.Blue = 0; simpleMarkerSymbol.Style = (esriSimpleMarkerStyle)(3); simpleMarkerSymbol.Color = (rgbColor); simpleMarkerSymbol.Outline = (true); simpleMarkerSymbol.OutlineSize = (1.0); simpleMarkerSymbol.OutlineColor = (rgbColor2); simpleMarkerSymbol.Size = (12.0); IElement element = new MarkerElement(); IMarkerElement markerElement = element as IMarkerElement; markerElement.Symbol = (simpleMarkerSymbol); element.Geometry = m_pGeoFlash; graphicsContainer.AddElement(element, 0); }
public static void NewBasePointElement(IActiveView pView, IPoint pPoint) { IGraphicsContainer graphicsContainer = (IGraphicsContainer)pView; new RubberPoint(); ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); IRgbColor rgbColor = new RgbColor(); rgbColor.Red = (255); rgbColor.Green = (0); rgbColor.Blue = (0); IRgbColor rgbColor2 = new RgbColor(); rgbColor2.Red = (0); rgbColor2.Green = (0); rgbColor2.Blue = (0); simpleMarkerSymbol.Style = (esriSimpleMarkerStyle)(3); simpleMarkerSymbol.Color = (rgbColor); simpleMarkerSymbol.Outline = (true); simpleMarkerSymbol.OutlineSize = (1.0); simpleMarkerSymbol.OutlineColor = (rgbColor2); simpleMarkerSymbol.Size = (12.0); IElement element = new MarkerElement(); IMarkerElement markerElement = element as IMarkerElement; markerElement.Symbol = (simpleMarkerSymbol); element.Geometry = (pPoint); graphicsContainer.AddElement(element, 0); }
public override void OnMouseDown(int button, int shift, int x, int y) { IActiveView activeView = this._context.ActiveView; IPoint geometry = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IElement element = new MarkerElement(); element.Geometry = geometry; ISimpleMarkerSymbol symbol = new SimpleMarkerSymbol(); (element as IMarkerElement).Symbol = symbol; INewElementOperation newElementOperation = new NewElementOperation(); newElementOperation.ActiveView = this._context.ActiveView; newElementOperation.ContainHook = this.GetActiveView(); newElementOperation.Element = element; this._context.OperationStack.Do(newElementOperation); //if (this._context.Hook is IApplication) //{ // if ((this._context.Hook as IApplication).ContainerHook != null) // { // DocumentManager.DocumentChanged((this._context.Hook as IApplication).ContainerHook); // } // else // { // DocumentManager.DocumentChanged((this._context.Hook as IApplication).Hook); // } //} //else //{ // DocumentManager.DocumentChanged(this._context.Hook); //} }
public override GraphicsPath Path(ISvgRenderer renderer) { if (MarkerElement != null) { return(MarkerElement.Path(renderer)); } return(null); }
public ImportFunction(string name, UInt16 hint) { m_hint = hint; m_nameElement = new VariableSizeStringElement(name); m_importByNameMarker = new MarkerElement(); m_originalThunkMarker = new MarkerElement(); m_thunkMarker = new MarkerElement(); }
public override System.Drawing.Drawing2D.GraphicsPath Path(ISvgRenderer renderer) { if (MarkerElement != null) { return(MarkerElement.Path(renderer)); } return(null); }
void CreateMarkerElement(HexBufferSpan fullSpan, Geometry geo) { Debug.Assert(markerElement == null); RemoveAllAdornments(); markerElement = new MarkerElement(geo); markerElement.BackgroundBrush = backgroundBrush; if (!layer.AddAdornment(VSTE.AdornmentPositioningBehavior.TextRelative, fullSpan, null, markerElement, markerElementRemovedCallBack)) { OnMarkerElementRemoved(); } }
/// <summary> /// 设置点元素的样式 /// </summary> /// <param name="rgbColor">颜色</param> /// <param name="OutLineColor">轮廓颜色</param> private IElement createElement(IRgbColor rgbColor, IRgbColor OutLineColor) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbol(); pSimpleMarkerSymbol.Color = rgbColor; pSimpleMarkerSymbol.Outline = true; pSimpleMarkerSymbol.OutlineColor = OutLineColor; pSimpleMarkerSymbol.Size = 15; pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement pMElement = new MarkerElement() as IMarkerElement; pMElement.Symbol = pSimpleMarkerSymbol; IElement ele = (IElement)pMElement; return(ele); }
MarkerElement TryCreateMarkerElementCore(Geometry geo, HexBufferSpan span, HexMarkerTag tag) { if (geo == null) { return(null); } var type = tag.Type ?? string.Empty; var props = editorFormatMap.GetProperties(type); int zIndex = props[VSTC.MarkerFormatDefinition.ZOrderId] as int? ?? 0; var markerElement = new MarkerElement(span, type, zIndex, geo); markerElement.BackgroundBrush = GetBackgroundBrush(props); markerElement.Pen = GetPen(props); return(markerElement); }
public object ConvertToSupportedObject(esriArcGISVersion docVersion) { ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbol(); characterMarkerSymbol.Color = this.m_fillSymbol.Color; characterMarkerSymbol.Angle = this.m_rotation; characterMarkerSymbol.Size = this.m_size; // characterMarkerSymbol.Font = Converter.ToStdFont(new System.Drawing.Font("ESRI Default Marker", (float)this.m_size, System.Drawing.FontStyle.Regular)); characterMarkerSymbol.CharacterIndex = 184; IMarkerElement markerElement = new MarkerElement() as IMarkerElement; markerElement.Symbol = characterMarkerSymbol; IPoint geometry = ((IClone)this.m_pointGeometry).Clone() as IPoint; IElement element = (IElement)markerElement; element.Geometry = geometry; return(element); }
MarkerElement TryCreateMarkerElement(SnapshotSpan span, IGlyphTextMarkerTag tag) { Debug.Assert(tag.MarkerTypeName != null); var geo = TextView.TextViewLines.GetMarkerGeometry(span); if (geo == null) { return(null); } var type = tag.MarkerTypeName ?? string.Empty; var props = editorFormatMap.GetProperties(type); var markerElement = new MarkerElement(span, type, tag.ZIndex, geo); markerElement.BackgroundBrush = GetBackgroundBrush(props); markerElement.Pen = GetPen(props); return(markerElement); }
public void AddMarker(IPoint pt) { IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass(); pPicturemksb.Size = 20; string picturePath = getPath(path1) + "\\Image\\周边1.png"; pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, picturePath); IMarkerElement pMarkerEle = new MarkerElement() as IMarkerElement; pMarkerEle.Symbol = pPicturemksb as IMarkerSymbol; IElement pEle = (IElement)pMarkerEle; pEle.Geometry = pt; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; pGraphicsContainer.AddElement(pEle, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
MarkerElement TryCreateMarkerElement(SnapshotSpan span, ITextMarkerTag tag) { Debug.Assert(tag.Type != null); var geo = wpfTextView.TextViewLines.GetMarkerGeometry(span); if (geo == null) { return(null); } var type = tag.Type ?? string.Empty; var props = editorFormatMap.GetProperties(type); int zIndex = props[MarkerFormatDefinition.ZOrderId] as int? ?? 0; var markerElement = new MarkerElement(span, type, zIndex, geo); markerElement.BackgroundBrush = GetBackgroundBrush(props); markerElement.Pen = GetPen(props); return(markerElement); }
//创建element public ISymbol CreateMarkerElement(IPoint point, ILayer pLayer) { //获取当前图层feature类型 IFeatureLayer p_featureLayer = pLayer as IFeatureLayer; IFeatureClass p_featureClass = p_featureLayer.FeatureClass; //建立一个marker元素 IMarkerElement p_markerElement = new MarkerElement() as IMarkerElement; ISimpleMarkerSymbol p_simpleMarkerSymbol = new SimpleMarkerSymbol(); //符号化元素 p_simpleMarkerSymbol.Color = getRGB(255, 0, 0); p_simpleMarkerSymbol.Outline = true; p_simpleMarkerSymbol.OutlineColor = getRGB(0, 255, 0) as IColor; p_simpleMarkerSymbol.OutlineSize = 5; //分类设置 if (p_featureClass.ShapeType == esriGeometryType.esriGeometryPoint) { p_simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; } else if (p_featureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { p_simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare; } else if (p_featureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { p_simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare; } else { p_simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; } //设置m_element_snap的属性 p_markerElement.Symbol = p_simpleMarkerSymbol; m_element_snap = p_markerElement as IElement; m_element_snap.Geometry = point as IGeometry; //设置返回值 ISymbol symbol = p_simpleMarkerSymbol as ISymbol; symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; return(symbol); }
public object ConvertToSupportedObject(esriArcGISVersion docVersion) { ICharacterMarkerSymbol characterMarkerSymbolClass = new CharacterMarkerSymbol() { Color = this.m_fillSymbol.Color, Angle = this.m_rotation, Size = this.m_size, //Font = ESRI.ArcGIS.ADF.Local.Converter.ToStdFont(new Font("ESRI Default Marker", (float)this.m_size, FontStyle.Regular)), CharacterIndex = 184 }; IMarkerElement markerElement = new MarkerElement() as IMarkerElement; markerElement.Symbol = characterMarkerSymbolClass; IMarkerElement markerElementClass = markerElement as IMarkerElement; IPoint point = ((IClone)this.m_pointGeometry).Clone() as IPoint; IElement element = (IElement)markerElementClass; element.Geometry = point; return(element); }
public void CreateMarkerElement(IPoint point) { IActiveView activeView = this.axMapControl1.ActiveView; IGraphicsContainer graphicsContainer = axMapControl1.Map as IGraphicsContainer; //建立一个marker元素 IMarkerElement markerElement = new MarkerElement() as IMarkerElement; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); //符号化元素 IRgbColor rgbColor1 = new RgbColor(); rgbColor1.Red = 255; rgbColor1.Blue = 0; rgbColor1.Green = 0; simpleMarkerSymbol.Color = rgbColor1; IRgbColor rgbColor2 = new RgbColor(); rgbColor2.Red = 0; rgbColor2.Blue = 255; rgbColor2.Green = 0; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = rgbColor2 as IColor; simpleMarkerSymbol.OutlineSize = 1; simpleMarkerSymbol.Size = 5; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; ISymbol symbol = simpleMarkerSymbol as ISymbol; symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; markerElement.Symbol = simpleMarkerSymbol; m_element = markerElement as IElement; m_element.Geometry = point as IGeometry; graphicsContainer.AddElement(m_element, 0); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_element, null); IGeometry geometry = m_element.Geometry; movePointFeedback.Display = activeView.ScreenDisplay; movePointFeedback.Symbol = simpleMarkerSymbol as ISymbol; movePointFeedback.Start(geometry as IPoint, point); }
/// <summary> /// 插入带图片的地图注记 /// </summary> /// <param name="point"></param> /// <param name="mapControl"></param> /// <param name="pictureUri"></param> /// <returns></returns> public static IElement DrawSymbolWithPicture(IPoint point, AxMapControl mapControl, string pictureUri) { #region 注释 // IMap map = mapControl.Map; // IEnvelope envelop = new EnvelopeClass(); //// point.QueryEnvelope(envelop); // envelop.PutCoords(point.X - 50, point.Y - 50, point.X + 50, point.Y + 50); // //实例化注记 // IPictureElement pictureElement = new PictureElementClass(); // pictureElement.MaintainAspectRatio = true; // pictureElement.ImportPictureFromFile(pictureUri); // IElement elment = pictureElement as IElement; // elment.Geometry = envelop as IGeometry; // //添加地图注记 // IGraphicsContainer graphicsContainer = map as IGraphicsContainer; // graphicsContainer.AddElement(pictureElement as IElement, 0); // (map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, mapControl.Extent); #endregion IMap map = mapControl.Map; //实例化图片注记 IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass(); pPicturemksb.Size = 20; pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureJPG, pictureUri); // Image image=Image.FromFile(pictureUri); // IPictureDisp pictureDisp= IPictureConverter.ImageToIPictureDisp(image); // pPicturemksb.Picture = pictureDisp; IMarkerElement pMarkerEle = new MarkerElement() as IMarkerElement; //将注记添加到元素中 pMarkerEle.Symbol = pPicturemksb as IMarkerSymbol; //添加元素到对应位置 IElement pEle = (IElement)pMarkerEle; pEle.Geometry = point; //添加标注 InsertElement(mapControl, pEle, 1); return(pEle); }
void RemoveAllAdornments() { layer.RemoveAllAdornments(); markerElement = null; }
void OnMarkerElementRemoved() => markerElement = null;
void CreateMarkerElement(SnapshotSpan fullSpan, Geometry geo) { Debug.Assert(markerElement == null); RemoveAllAdornments(); markerElement = new MarkerElement(geo); markerElement.BackgroundBrush = backgroundBrush; if (!layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, fullSpan, null, markerElement, markerElementRemovedCallBack)) OnMarkerElementRemoved(); }
public void AddGraphic(IScene iscene_0, IGeometry igeometry_0, ISymbol isymbol_0, bool bool_1, bool bool_2, string string_0) { if (!igeometry_0.IsEmpty) { IGraphicsLayer basicGraphicsLayer = iscene_0.BasicGraphicsLayer; IElement element = null; esriGeometryType geometryType = igeometry_0.GeometryType; switch (geometryType) { case esriGeometryType.esriGeometryPoint: { element = new MarkerElement(); IMarkerElement markerElement = element as IMarkerElement; if (isymbol_0 != null) { markerElement.Symbol = (isymbol_0 as IMarkerSymbol); } else { markerElement.Symbol = new SimpleMarkerSymbol(); } break; } case esriGeometryType.esriGeometryMultipoint: break; case esriGeometryType.esriGeometryPolyline: { element = new LineElement(); ILineElement lineElement = element as ILineElement; if (isymbol_0 != null) { lineElement.Symbol = (isymbol_0 as ILineSymbol); } else { lineElement.Symbol = new SimpleLineSymbol(); } break; } case esriGeometryType.esriGeometryPolygon: { element = new PolygonElement(); IFillShapeElement fillShapeElement = element as IFillShapeElement; if (isymbol_0 != null) { fillShapeElement.Symbol = (isymbol_0 as IFillSymbol); } else { fillShapeElement.Symbol = new SimpleFillSymbol(); } break; } default: if (geometryType == esriGeometryType.esriGeometryMultiPatch) { element = new MultiPatchElement(); IFillShapeElement fillShapeElement = element as IFillShapeElement; if (isymbol_0 != null) { fillShapeElement.Symbol = (isymbol_0 as IFillSymbol); } else { fillShapeElement.Symbol = new SimpleFillSymbol(); } } break; } if (element != null) { element.Geometry = igeometry_0; if (string_0.Length > 0) { IElementProperties elementProperties = element as IElementProperties; elementProperties.Name = string_0; } IGraphicsContainer3D graphicsContainer3D = basicGraphicsLayer as IGraphicsContainer3D; graphicsContainer3D.AddElement(element); IGraphicsSelection graphicsSelection = graphicsContainer3D as IGraphicsSelection; if (bool_2) { if (!bool_1) { graphicsSelection.UnselectAllElements(); } graphicsSelection.SelectElement(element); } iscene_0.SceneGraph.RefreshViewers(); } } }
MarkerElement TryCreateMarkerElement(SnapshotSpan span, IGlyphTextMarkerTag tag) { Debug.Assert(tag.MarkerTypeName != null); var geo = TextView.TextViewLines.GetMarkerGeometry(span); if (geo == null) return null; var type = tag.MarkerTypeName ?? string.Empty; var selectedType = tag.SelectedMarkerTypeName; var propName = (selectedType != null && IsSelected(span) ? selectedType : type) ?? type; var props = editorFormatMap.GetProperties(propName); var markerElement = new MarkerElement(span, propName, type, selectedType, tag.ZIndex, geo); markerElement.BackgroundBrush = GetBackgroundBrush(props); markerElement.Pen = GetPen(props); return markerElement; }
public static void AddFlyByGraphic(ISceneGraph isceneGraph_0, IGeometry igeometry_0, FlyByUtils.FlyByElementType flyByElementType_0, System.Drawing.Color color_0, System.Drawing.Color color_1, System.Drawing.Color color_2, System.Drawing.Color color_3, bool bool_0) { if (!igeometry_0.IsEmpty) { IGraphicsContainer3D graphicsContainer3D = isceneGraph_0.Scene.BasicGraphicsLayer as IGraphicsContainer3D; if (!FlyByUtils.LayerIsExist(isceneGraph_0.Scene, graphicsContainer3D as ILayer)) { isceneGraph_0.Scene.AddLayer(graphicsContainer3D as ILayer, true); } switch (flyByElementType_0) { case FlyByUtils.FlyByElementType.FLYBY_PATH: if (FlyByUtils.pPathElem != null) { graphicsContainer3D.DeleteElement(FlyByUtils.pPathElem); } break; case FlyByUtils.FlyByElementType.FLYBY_OBSERVER: if (FlyByUtils.pObserverElem != null) { graphicsContainer3D.DeleteElement(FlyByUtils.pObserverElem); } break; case FlyByUtils.FlyByElementType.FLYBY_TARGET: if (FlyByUtils.pTargetElem != null) { graphicsContainer3D.DeleteElement(FlyByUtils.pTargetElem); } break; } ISymbol flyBySymbol = FlyByUtils.GetFlyBySymbol(color_0, color_1, color_2, color_3, flyByElementType_0); IElement element; switch (igeometry_0.GeometryType) { case esriGeometryType.esriGeometryPoint: { element = new MarkerElement(); IMarkerElement markerElement = element as IMarkerElement; markerElement.Symbol = (flyBySymbol as IMarkerSymbol); break; } case esriGeometryType.esriGeometryMultipoint: return; case esriGeometryType.esriGeometryPolyline: { element = new LineElement(); ILineElement lineElement = element as ILineElement; lineElement.Symbol = (flyBySymbol as ILineSymbol); break; } default: return; } switch (flyByElementType_0) { case FlyByUtils.FlyByElementType.FLYBY_ANCHORS: { IElementProperties elementProperties = element as IElementProperties; elementProperties.Name = "SceneFlyBy.AnchorPoint"; break; } case FlyByUtils.FlyByElementType.FLYBY_PATH: FlyByUtils.pPathElem = element; break; case FlyByUtils.FlyByElementType.FLYBY_OBSERVER: FlyByUtils.pObserverElem = element; break; case FlyByUtils.FlyByElementType.FLYBY_TARGET: FlyByUtils.pTargetElem = element; break; case FlyByUtils.FlyByElementType.FLYBY_STATIC: { IElementProperties elementProperties = element as IElementProperties; elementProperties.Name = "SceneFlyBy.StaticLoc"; break; } } element.Geometry = igeometry_0; graphicsContainer3D.AddElement(element); if (bool_0) { isceneGraph_0.RefreshViewers(); } } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { //get access to the document and the active view pMxDocument = (IMxDocument)clsAgrcArcMapExtension.m_application.Document; pMap = pMxDocument.FocusMap; pActiveView = pMxDocument.ActiveView; //pActiveView = (IActiveView)pMap; //get the map's graphics layer ICompositeGraphicsLayer2 pComGraphicsLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer2; ICompositeLayer pCompositeLayer = pComGraphicsLayer as ICompositeLayer; ILayer pLayer; //loop through all graphic layers in the map and check for the 'PolyVertices' layer, if found, delete it, in order to start fresh for (int i = 0; i < pCompositeLayer.Count; i++) { pLayer = pCompositeLayer.get_Layer(i); if (pLayer.Name == "PolyVertices") { pComGraphicsLayer.DeleteLayer("PolyVertices"); break; } } if (bolVerticesOn == false) { IGraphicsLayer pGraphicsLayer = pComGraphicsLayer.AddLayer("PolyVertices", null); pMap.ActiveGraphicsLayer = (ILayer)pGraphicsLayer; IGraphicsContainer pGraphicsContainer = pComGraphicsLayer.FindLayer("PolyVertices") as IGraphicsContainer; //make sure the user has selected a polygon or polyline layer if (pMxDocument.SelectedLayer == null) { MessageBox.Show("Please select a layer.", "Select Layer", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!(pMxDocument.SelectedLayer is IFeatureLayer)) { MessageBox.Show("Please select a polygon or line layer.", "Polygon or Line", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //cast the selected layer as a feature layer IGeoFeatureLayer pGFlayer = (IGeoFeatureLayer)pMxDocument.SelectedLayer; //check if the feaure layer is a polygon or line layer if (pGFlayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon & pGFlayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline) { MessageBox.Show("Please select a polygon or line layer.", "Polygon or Line", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //setup marker symbol ISimpleMarkerSymbol pSimpleMarker = new SimpleMarkerSymbol(); ISymbol pSymbolMarker = (ISymbol)pSimpleMarker; IRgbColor pRgbColor = new ESRI.ArcGIS.Display.RgbColorClass(); pRgbColor.Red = 223; pRgbColor.Green = 155; pRgbColor.Blue = 255; pSimpleMarker.Color = pRgbColor; pSimpleMarker.Style = esriSimpleMarkerStyle.esriSMSDiamond; pSimpleMarker.Size = 8; //setup line symbol ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol(); ISymbol pSymbolLine = (ISymbol)pSimpleLineSymbol; pRgbColor = new ESRI.ArcGIS.Display.RgbColor(); pRgbColor.Red = 0; pRgbColor.Green = 255; pRgbColor.Blue = 0; pSimpleLineSymbol.Color = pRgbColor; pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pSimpleLineSymbol.Width = 1; //setup simplefill symbol ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol(); ISymbol pSymbolPolygon = (ISymbol)pSimpleFillSymbol; pRgbColor = new ESRI.ArcGIS.Display.RgbColor(); pRgbColor.Red = 0; pRgbColor.Green = 0; pRgbColor.Blue = 255; pSimpleFillSymbol.Color = pRgbColor; pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; //get all the polygons in the current map extent ina cursor IEnvelope pMapExtent = pActiveView.Extent; ISpatialFilter pQFilter = new SpatialFilter(); pQFilter.GeometryField = "SHAPE"; pQFilter.Geometry = pMapExtent; pQFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor pFCursor = pGFlayer.Search(pQFilter, true); //draw each polygon and then each polygon's point collection IFeature pFeature = pFCursor.NextFeature(); IGeometry pGeometry; while (pFeature != null) { pGeometry = pFeature.Shape; //draw the polygon //draw each vertex on the polygon IPointCollection pPointCollection = pGeometry as IPointCollection; for (int i = 0; i < pPointCollection.PointCount; i++) { IGeometry pPtGeom = pPointCollection.get_Point(i); IElement pElement = new MarkerElement(); pElement.Geometry = pPtGeom; IMarkerElement pMarkerElement = pElement as IMarkerElement; pMarkerElement.Symbol = pSimpleMarker; pGraphicsContainer.AddElement(pElement, 0); } pFeature = pFCursor.NextFeature(); } bolVerticesOn = true; } else //if (bolVerticesOn == true) { bolVerticesOn = false; } //refresh the map pActiveView.Refresh(); pActiveView.Refresh(); } catch (Exception ex) { MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine + "Error Location:" + Environment.NewLine + ex.StackTrace, "AGRC Custom Tools ArcMap Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Adds a graphic element to the map graphics container /// </summary> /// <param name="geom">IGeometry</param> internal string AddGraphicToMap(IGeometry geom, IColor color, bool IsTempGraphic = false, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSCircle, int size = 5) { if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null) return string.Empty; IElement element = null; double width = 2.0; geom.Project(ArcMap.Document.FocusMap.SpatialReference); if (geom.GeometryType == esriGeometryType.esriGeometryPoint) { // Marker symbols var simpleMarkerSymbol = new SimpleMarkerSymbol() as ISimpleMarkerSymbol; simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = color; simpleMarkerSymbol.Size = size; simpleMarkerSymbol.Style = markerStyle; var markerElement = new MarkerElement() as IMarkerElement; markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; } else if (geom.GeometryType == esriGeometryType.esriGeometryPolyline) { // create graphic then add to map var le = new LineElementClass() as ILineElement; element = le as IElement; var lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = color; lineSymbol.Width = width; le.Symbol = lineSymbol; } else if (geom.GeometryType == esriGeometryType.esriGeometryPolygon) { // create graphic then add to map IPolygonElement pe = new PolygonElementClass() as IPolygonElement; element = pe as IElement; IFillShapeElement fe = pe as IFillShapeElement; var fillSymbol = new SimpleFillSymbolClass(); RgbColor selectedColor = new RgbColorClass(); selectedColor.Red = 0; selectedColor.Green = 0; selectedColor.Blue = 0; selectedColor.Transparency = (byte)0; fillSymbol.Color = selectedColor; fe.Symbol = fillSymbol; } if (element == null) return string.Empty; element.Geometry = geom; var mxdoc = ArcMap.Application.Document as IMxDocument; var av = mxdoc.FocusMap as IActiveView; var gc = av as IGraphicsContainer; // store guid var eprop = element as IElementProperties; eprop.Name = Guid.NewGuid().ToString(); if (IsTempGraphic) TempGraphicsList.Add(eprop.Name); else MapGraphicsList.Add(eprop.Name); gc.AddElement(element, 0); av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); RaisePropertyChanged(() => HasMapGraphics); return eprop.Name; }
public static IElement AddGraphic(IGeometry igeometry_0, ISymbol isymbol_0, string string_0, IGraphicsContainer3D igraphicsContainer3D_0) { IElement element = null; IElement result; try { if (igeometry_0.IsEmpty) { result = element; return(result); } if (modFacades.g_pGCon == null) { result = element; return(result); } IElement element2 = null; esriGeometryType geometryType = igeometry_0.GeometryType; switch (geometryType) { case esriGeometryType.esriGeometryPoint: element2 = new MarkerElement(); if (isymbol_0 != null) { IMarkerElement markerElement = element2 as IMarkerElement; markerElement.Symbol = (isymbol_0 as IMarkerSymbol); } break; case esriGeometryType.esriGeometryMultipoint: break; case esriGeometryType.esriGeometryPolyline: element2 = new LineElement(); if (isymbol_0 != null) { ILineElement lineElement = element2 as ILineElement; lineElement.Symbol = (isymbol_0 as ILineSymbol); } break; case esriGeometryType.esriGeometryPolygon: element2 = new PolygonElement(); if (isymbol_0 != null) { IFillShapeElement fillShapeElement = element2 as IFillShapeElement; fillShapeElement.Symbol = (isymbol_0 as IFillSymbol); } break; default: if (geometryType == esriGeometryType.esriGeometryMultiPatch) { element2 = new MultiPatchElement(); if (isymbol_0 != null) { IFillShapeElement fillShapeElement = element2 as IFillShapeElement; fillShapeElement.Symbol = (isymbol_0 as IFillSymbol); } } break; } if (string_0.Length > 0) { IElementProperties elementProperties = element2 as IElementProperties; elementProperties.Name = string_0; } element2.Geometry = igeometry_0; if (igraphicsContainer3D_0 != null) { igraphicsContainer3D_0.AddElement(element2); } element = element2; result = element; return(result); } catch { } result = element; return(result); }
/// <summary> /// Adds a graphic element to the map graphics container /// </summary> /// <param name="geom">IGeometry</param> internal void AddGraphicToMap(IGeometry geom, IColor color, bool IsTempGraphic = false, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSCircle, esriRasterOpCode rasterOpCode = esriRasterOpCode.esriROPNOP) { if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null) return; IElement element = null; double width = 2.0; geom.Project(ArcMap.Document.FocusMap.SpatialReference); if(geom.GeometryType == esriGeometryType.esriGeometryPoint) { // Marker symbols var simpleMarkerSymbol = new SimpleMarkerSymbol() as ISimpleMarkerSymbol; simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = color; simpleMarkerSymbol.Size = 5; simpleMarkerSymbol.Style = markerStyle; var markerElement = new MarkerElement() as IMarkerElement; markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; } else if(geom.GeometryType == esriGeometryType.esriGeometryPolyline) { // create graphic then add to map var lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = color; lineSymbol.Width = width; if (IsTempGraphic && rasterOpCode != esriRasterOpCode.esriROPNOP) { lineSymbol.Width = 1; lineSymbol.ROP2 = rasterOpCode; } var le = new LineElementClass() as ILineElement; element = le as IElement; le.Symbol = lineSymbol; } if (element == null) return; IClone clone = geom as IClone; element.Geometry = clone as IGeometry; var mxdoc = ArcMap.Application.Document as IMxDocument; var av = mxdoc.FocusMap as IActiveView; var gc = av as IGraphicsContainer; // store guid var eprop = element as IElementProperties; eprop.Name = Guid.NewGuid().ToString(); if (this is LinesViewModel) GraphicsList.Add(new Graphic(GraphicTypes.Line, eprop.Name, geom, IsTempGraphic)); else if (this is CircleViewModel) GraphicsList.Add(new Graphic(GraphicTypes.Circle, eprop.Name, geom, IsTempGraphic)); else if (this is EllipseViewModel) GraphicsList.Add(new Graphic(GraphicTypes.Ellipse, eprop.Name, geom, IsTempGraphic)); else if (this is RangeViewModel) GraphicsList.Add(new Graphic(GraphicTypes.RangeRing, eprop.Name, geom, IsTempGraphic)); gc.AddElement(element, 0); //refresh map av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); if (!IsTempGraphic) RaisePropertyChanged(() => HasMapGraphics); }
/// <summary> /// 添加图元 /// </summary> /// <param name="pGeometry"></param> /// <param name="pActiveView"></param> /// <param name="pSymbol"></param> /// <param name="key"></param> /// <returns></returns> public IElement AddElement(IGeometry pGeometry, ISymbol pSymbol, string key) { try { IActiveView pActiveView = mapControl.ActiveView; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; IElement pElement = null; ILineElement pLineElement = null; IFillShapeElement pFillShapeElement = null; IMarkerElement pMarkerElement = null; ICircleElement pCircleElement = null; IElementProperties pElmentProperties = null; switch (pGeometry.GeometryType) { case esriGeometryType.esriGeometryEnvelope: { pElement = new RectangleElement(); pElement.Geometry = pGeometry; pFillShapeElement = (IFillShapeElement)pElement; pFillShapeElement.Symbol = (IFillSymbol)pSymbol; break; } case esriGeometryType.esriGeometryPolyline: { pElement = new LineElement(); pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement; pLineElement.Symbol = (ILineSymbol)pSymbol; break; } case esriGeometryType.esriGeometryLine: { pElement = new LineElement(); pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement; pLineElement.Symbol = (ILineSymbol)pSymbol; break; } case esriGeometryType.esriGeometryPolygon: { pElement = new PolygonElement(); pElement.Geometry = pGeometry; pFillShapeElement = (IFillShapeElement)pElement; pFillShapeElement.Symbol = (IFillSymbol)pSymbol; break; } case esriGeometryType.esriGeometryMultipoint: case esriGeometryType.esriGeometryPoint: { pElement = new MarkerElement(); pElement.Geometry = pGeometry; pMarkerElement = (IMarkerElement)pElement; pMarkerElement.Symbol = (IMarkerSymbol)pSymbol; break; } case esriGeometryType.esriGeometryCircularArc: { pElement = new CircleElement(); pElement.Geometry = pGeometry; pCircleElement = (ICircleElement)pElement; break; } default: pElement = null; break; } if (pElement != null) { pElmentProperties = pElement as IElementProperties; pElmentProperties.Name = key; pGraphicsContainer.AddElement(pElement, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, pGeometry.Envelope); return(pElement); } else { return(null); } } catch (Exception ex) { return(null); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add BufferPointTool.OnMouseDown implementation pActiveView = m_hookHelper.ActiveView; pMap = m_hookHelper.FocusMap; pMap.ClearSelection(); IGraphicsContainer pGrap = pActiveView as IGraphicsContainer; pGrap.DeleteAllElements();//删除所添加的图片要素 string layerName = "points"; ILayer pLayer = null; for (int i = 0; i < pMap.LayerCount; i++) { pLayer = pMap.get_Layer(i); if (pLayer.Name == layerName) { mFeatureLayer = (IFeatureLayer)pLayer; break; } } IFeatureClass pFeatureClass = mFeatureLayer.FeatureClass; IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass(); pPicturemksb.Size = 30; string picturePath = getPath(path1) + "\\Image\\景点.png"; pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, picturePath); IMarkerElement pMarkerEle = new MarkerElement() as IMarkerElement; pMarkerEle.Symbol = pPicturemksb as IMarkerSymbol; IElement pEle = (IElement)pMarkerEle; pEle.Geometry = pPoint; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; pGraphicsContainer.AddElement(pEle, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); ITopologicalOperator pTopo; pTopo = pPoint as ITopologicalOperator; IGeometry pBuffer; pBuffer = pTopo.Buffer(bufferdis); IGeometry pGeometry = pBuffer.Envelope; ISpatialFilter pSpatialFilter; pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pGeometry; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains; IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, false); IFeature pFeature = pFeatureCursor.NextFeature(); bool featurenull = false; if (pFeature == null) { featurenull = true; String tip = "抱歉,在该点附近" + (bufferdis * 100000).ToString() + "米没有您要找的地点!"; MessageBox.Show(tip.ToString()); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } int count = 0; while (pFeature != null) { string fieldName = "type"; IFields fields = mFeatureLayer.FeatureClass.Fields; int fieldIndex = fields.FindField(fieldName); if (pFeature.get_Value(fieldIndex).ToString() == type) { count++; pMap.SelectFeature(mFeatureLayer, pFeature); IPoint POI = pFeature.Shape as IPoint; AddMarker(POI); } pFeature = pFeatureCursor.NextFeature(); } if (count == 0 && featurenull == false) { String tip = "抱歉,在该点附近" + (bufferdis * 100000).ToString() + "米没有您要找的地点!"; MessageBox.Show(tip.ToString()); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); }
MarkerElement TryCreateMarkerElementCore(Geometry geo, HexBufferSpan span, HexMarkerTag tag) { if (geo == null) return null; var type = tag.Type ?? string.Empty; var props = editorFormatMap.GetProperties(type); int zIndex = props[VSTC.MarkerFormatDefinition.ZOrderId] as int? ?? 0; var markerElement = new MarkerElement(span, type, zIndex, geo); markerElement.BackgroundBrush = GetBackgroundBrush(props); markerElement.Pen = GetPen(props); return markerElement; }
/// <summary> /// Adds a graphic element to the map graphics container /// Returns GUID /// </summary> /// <param name="geom">IGeometry</param> public static string AddGraphicToMap(IGeometry geom, IColor color, bool IsTempGraphic = false, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSCircle, int size = 5) { if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null) { return(string.Empty); } IElement element = null; double width = 2.0; geom.Project(ArcMap.Document.FocusMap.SpatialReference); if (geom.GeometryType == esriGeometryType.esriGeometryPoint) { // Marker symbols var simpleMarkerSymbol = new SimpleMarkerSymbol() as ISimpleMarkerSymbol; simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Outline = false; simpleMarkerSymbol.OutlineColor = color; simpleMarkerSymbol.Size = size; simpleMarkerSymbol.Style = markerStyle; var markerElement = new MarkerElement() as IMarkerElement; markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; } else if (geom.GeometryType == esriGeometryType.esriGeometryPolyline) { // create graphic then add to map var le = new LineElementClass() as ILineElement; element = le as IElement; var lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = color; lineSymbol.Width = width; le.Symbol = lineSymbol; } else if (geom.GeometryType == esriGeometryType.esriGeometryPolygon) { // create graphic then add to map IPolygonElement pe = new PolygonElementClass() as IPolygonElement; element = pe as IElement; IFillShapeElement fe = pe as IFillShapeElement; var fillSymbol = new SimpleFillSymbolClass(); RgbColor selectedColor = new RgbColorClass(); selectedColor.Red = 0; selectedColor.Green = 0; selectedColor.Blue = 0; selectedColor.Transparency = (byte)0; fillSymbol.Color = selectedColor; fe.Symbol = fillSymbol; } if (element == null) { return(string.Empty); } element.Geometry = geom; var mxdoc = ArcMap.Application.Document as IMxDocument; var av = mxdoc.FocusMap as IActiveView; var gc = av as IGraphicsContainer; // store guid var eprop = element as IElementProperties; eprop.Name = Guid.NewGuid().ToString(); gc.AddElement(element, 0); av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); return(eprop.Name); }
/// <summary> /// 设置点元素的样式 /// </summary> /// <param name="rgbColor">颜色</param> /// <param name="OutLineColor">轮廓颜色</param> private IElement createElement(IRgbColor rgbColor, IRgbColor OutLineColor) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbol(); pSimpleMarkerSymbol.Color = rgbColor; pSimpleMarkerSymbol.Outline = true; pSimpleMarkerSymbol.OutlineColor = OutLineColor; pSimpleMarkerSymbol.Size = 15; pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement pMElement = new MarkerElement() as IMarkerElement; pMElement.Symbol = pSimpleMarkerSymbol; IElement ele = (IElement)pMElement; return ele; }
//this method is called when the user clicks the "Compare Vertices" button at the bottom of the form private void cmdCompare_Click(object sender, EventArgs e) { try { if (cboLayer1.SelectedItem.ToString() == "" || cboLayer2.SelectedItem.ToString() == "" || txtOID1.Text == "" || txtOID2.Text == "") //the double pipe is an or operator that "short circuts", meaning that it will bail out early if the condition is true, whereas the single pipe evaluates all conditions { MessageBox.Show("Choose polygon layer, or specify OBJECTID.", "Verify Selections...", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //show busy mouse System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; IFeatureLayer pFeatureLayer1 = null; IFeatureLayer pFeatureLayer2 = null; IPointCollection pPtnCollMissingVertices = new MultipointClass(); //point collection for missing vertices and used for graphics layer IPoint pPointMissing = new PointClass(); //used for graphics layer //get access to polygon layer 1 for (int i = 0; i < pMap.LayerCount; i++) { if (pMap.get_Layer(i) is IFeatureLayer) { if (pMap.get_Layer(i).Name.ToString() == cboLayer1.SelectedItem.ToString()) { pFeatureLayer1 = pMap.get_Layer(i) as IFeatureLayer; break; } } } //get access to polygon layer 2 for (int i = 0; i < pMap.LayerCount; i++) { if (pMap.get_Layer(i) is IFeatureLayer) { if (pMap.get_Layer(i).Name.ToString() == cboLayer2.SelectedItem.ToString()) { pFeatureLayer2 = pMap.get_Layer(i) as IFeatureLayer; break; } } } //clear the x,y report list box lstMissingVertices.Items.Clear(); //get vertices for feature 1 //set up query filter for feature 1 IQueryFilter pQueryFilter = new QueryFilter(); pQueryFilter.WhereClause = "OBJECTID = " + txtOID1.Text; //set up feature cursor for feature 1 IFeatureCursor pFeatureCursor = pFeatureLayer1.Search(pQueryFilter, false); //get feature 1 IFeature pFeature1 = pFeatureCursor.NextFeature(); //if no objectid is found if (pFeature1 == null) { MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //get feature 1 as a polygon IPolygon pPolygon1 = pFeature1.Shape as IPolygon; //get the point collection for feature 1 IPointCollection pPointColl1 = pPolygon1 as IPointCollection; //get vertices for feature 2 //set up query filter for feature 2 pQueryFilter = new QueryFilter(); pQueryFilter.WhereClause = "OBJECTID = " + txtOID2.Text; //set up feature cursor for feature 2 pFeatureCursor = null; //reuse the feature cursor from above pFeatureCursor = pFeatureLayer2.Search(pQueryFilter, false); //get feature 2 IFeature pFeature2 = pFeatureCursor.NextFeature(); //if no objectid is found if (pFeature2 == null) { MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //get feature 1 as a polygon IPolygon pPolygon2 = pFeature2.Shape as IPolygon; //get the point collection for feature 1 IPointCollection pPointColl2 = pPolygon2 as IPointCollection; //loop through point collection and check for missing vertices IPoint pPoint1; IPoint pPoint2; Boolean blnFound; //loop through each point in the first collection and check for missing for (int i = 0; i < pPointColl1.PointCount; i++) { pPoint1 = pPointColl1.get_Point(i); //loop through all the points in the second collection and check for the point from the above collection blnFound = false; for (int j = 0; j < pPointColl2.PointCount; j++) { pPoint2 = pPointColl2.get_Point(j); //check for overlapping points if (pPoint1.X == pPoint2.X && pPoint1.Y == pPoint2.Y) { blnFound = true; } } //if no overlapping points were found, report the missing x,y location to the listbox if (blnFound == false) { lstMissingVertices.Items.Add(pPoint1.X + " " + pPoint1.Y + " " + " Feet" + " (missing from polygon 2)"); //add the missing point to a new collection for display on map pPtnCollMissingVertices.AddPoint(pPoint1); } } //loop through each point in the first collection and check for missing for (int i = 0; i < pPointColl2.PointCount; i++) { pPoint2 = pPointColl2.get_Point(i); //loop through all the points in the second collection and check for the point from the above collection blnFound = false; for (int j = 0; j < pPointColl1.PointCount; j++) { pPoint1 = pPointColl1.get_Point(j); //check for overlapping points if (pPoint2.X == pPoint1.X && pPoint2.Y == pPoint1.Y) { blnFound = true; } } //if no overlapping points were found, report the missing x,y location to the listbox if (blnFound == false) { lstMissingVertices.Items.Add(pPoint2.X + " " + pPoint2.Y + " " + " Feet" + " (missing from polygon 1)"); //add the missing point to a new collection for display on map pPtnCollMissingVertices.AddPoint(pPoint2); } } //if no missing vertices were found, inform the user if (lstMissingVertices.Items.Count < 1) { lstMissingVertices.Items.Add("No Missing Vertices Found"); } //display vertices if checkbox is checked if (chkDisplayVertices.Checked == true) { //show busy mouse System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; //set up the graphics layer for the display of vertices ICompositeGraphicsLayer2 pCompositeGraphicLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer2; ICompositeLayer pCompositeLayer = pCompositeGraphicLayer as ICompositeLayer; ILayer pLayer; IGraphicsLayer pGraphicsLayer; IGraphicsContainer pGraphicsContainer; //loop through the graphics layer and check for the missing vertices layer. if found, delete it for (int i = 0; i < pCompositeLayer.Count; i++) { pLayer = pCompositeLayer.Layer[i]; if (pLayer.Name == "MissingVertices") { pCompositeGraphicLayer.DeleteLayer("MissingVertices"); break; } } //set up a new 'missing vertices' graphics layer pGraphicsLayer = pCompositeGraphicLayer.AddLayer("MissingVertices", null); pMap.ActiveGraphicsLayer = pGraphicsLayer as ILayer; pGraphicsContainer = pCompositeGraphicLayer.FindLayer("MissingVertices") as IGraphicsContainer; //define the color ESRI.ArcGIS.Display.IRgbColor rgbColorCls = new ESRI.ArcGIS.Display.RgbColorClass(); rgbColorCls.Red = 250; rgbColorCls.Green = 0; rgbColorCls.Blue = 0; //define the font stdole.IFontDisp stdFontCls = new stdole.StdFontClass() as stdole.IFontDisp; stdFontCls.Name = "ESRI Surveyor Marker"; //this one has a thin-line hollow circle stdFontCls.Name = "ESRI Surveyor"; //this one has a bold-line hollow circle stdFontCls.Size = 16; //set the character marker symbol's properties ESRI.ArcGIS.Display.ICharacterMarkerSymbol charMarkerSymb = new ESRI.ArcGIS.Display.CharacterMarkerSymbolClass(); charMarkerSymb.Angle = 0; charMarkerSymb.CharacterIndex = 47; charMarkerSymb.Color = rgbColorCls; charMarkerSymb.Font = stdFontCls; charMarkerSymb.Size = 16; charMarkerSymb.XOffset = 0; charMarkerSymb.YOffset = 0; //place the graphics on the map for (int i = 0; i < pPtnCollMissingVertices.PointCount; i++) { pPointMissing = pPtnCollMissingVertices.Point[i]; IElement pElement = new MarkerElement(); pElement.Geometry = pPointMissing; IMarkerElement pMarkerElement = pElement as IMarkerElement; pMarkerElement.Symbol = charMarkerSymb; pGraphicsContainer.AddElement(pElement, 0); } //refresh the map, in order to see the newly added graphics pActiveView.Refresh(); } } catch (Exception ex) { MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine + "Error Location:" + Environment.NewLine + ex.StackTrace, "AGRC Custom Tools ArcMap Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }