This document is archived and information here might be outdated. Recommended version. |
Symbol used to draw the snap location.
[Visual Basic .NET] Public Property SnapSymbol As IMarkerSymbol
[C#] public IMarkerSymbol SnapSymbol {get; set;}
///
public class SnapSymbol_Example { private IEditor m_editor; private IEditEvents_Event m_editorEvents; private IEditProperties m_editProperties; /// This example below uses the OnCurrentLayerChanged edit event to change the editor's snap symbol. /// If the current layer has a geometry of type point, the editor uses it as its snap symbol. /// If the geometry is of type polygon or polyline, the editor uses the default symbol. /// Note: An UniqueValueRender must be used for the point layer. ///
private IMarkerSymbol m_origsymbol; public SnapSymbol_Example(IEditor editor) { m_editor = editor; m_editorEvents = m_editor as IEditEvents_Event; m_editProperties = m_editor as IEditProperties;
m_origsymbol = m_editProperties.SnapSymbol;
//setup and register delegates IEditEvents_OnCurrentLayerChangedEventHandler editEvents_OnCurrentLayerChangedEventHandler = new IEditEvents_OnCurrentLayerChangedEventHandler(this.OnCurrentLayerChanged); m_editorEvents.OnCurrentLayerChanged += editEvents_OnCurrentLayerChangedEventHandler; } public void OnCurrentLayerChanged() { IEditLayers editLayers = m_editor as IEditLayers; //Check that the current layer contains point features if (editLayers.CurrentLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) { IGeoFeatureLayer geoFeatureLayer = editLayers.CurrentLayer as IGeoFeatureLayer; IFeatureRenderer renderer = geoFeatureLayer.Renderer; renderer.ToString(); //Make sure that a uniquevalue renderer is being used to display the points ISymbol symbol = null; if (renderer is IUniqueValueRenderer) { //Check if data has subtypes ISubtypes layerSubTypes = editLayers.CurrentLayer.FeatureClass as ISubtypes; IUniqueValueRenderer uniqueValueRenderer = geoFeatureLayer.Renderer as IUniqueValueRenderer; if (layerSubTypes.HasSubtype) { int value = editLayers.CurrentSubtype; symbol = uniqueValueRenderer.get_Symbol(value.ToString()); } symbol = uniqueValueRenderer.DefaultSymbol; } if (symbol == null) { System.Windows.Forms.MessageBox.Show("Renderer must be UniqueValueRenderer"); return; } //Set the ROP property so the symbol will clear itself on redraw symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; m_editProperties.SnapSymbol = symbol as IMarkerSymbol; } else { System.Windows.Forms.MessageBox.Show("Layer must be polyline or polygon");
m_editProperties.SnapSymbol = m_origsymbol; } } }
IEditProperties Interface | IEditor.InvertAgent Method | IEditProperties.SelectedVertexSymbol Property | IEditProperties.SketchVertexSymbol Property