/// <summary> /// 通过符号选择器选择符号样式 /// </summary> /// <param name="geometryType">要素类型</param> /// <returns>返回 ISymbol 对象</returns> public static ISymbol GetSymbolBySymbolSelector(esriGeometryType geometryType) { ISymbol symbol = null; switch (geometryType) { case esriGeometryType.esriGeometryPoint: symbol = new SimpleMarkerSymbolClass(); break; case esriGeometryType.esriGeometryPolyline: symbol = new SimpleLineSymbolClass(); break; case esriGeometryType.esriGeometryPolygon: symbol = new SimpleFillSymbolClass(); break; } ESRI.ArcGIS.DisplayUI.ISymbolSelector pSymbolSelector = new ESRI.ArcGIS.DisplayUI.SymbolSelectorClass(); pSymbolSelector.AddSymbol(symbol); bool response = pSymbolSelector.SelectSymbol(0); if (response) { symbol = pSymbolSelector.GetSymbolAt(0); return(symbol); } return(null); }
// 双击 axTOCControl1 显示符号系统 private void axTOCControl1_OnDoubleClick(Object sender, ITOCControlEvents_OnDoubleClickEvent e) { esriTOCControlItem toccItem = esriTOCControlItem.esriTOCControlItemNone; ILayer iLayer = null; IBasicMap iBasicMap = null; object unk = null; object data = null; if (e.button == 1) { axTOCControl1.HitTest(e.x, e.y, ref toccItem, ref iBasicMap, ref iLayer, ref unk, ref data); new System.Drawing.Point(e.x, e.y); if (toccItem == esriTOCControlItem.esriTOCControlItemLegendClass) { ILegendClass pLC = new LegendClassClass(); ILegendGroup pLG = new LegendGroupClass(); if (unk is ILegendGroup) { pLG = (ILegendGroup)unk; } pLC = pLG.get_Class((int)data); ISymbol pSym; pSym = pLC.Symbol; ESRI.ArcGIS.DisplayUI.ISymbolSelector pSS = new ESRI.ArcGIS.DisplayUI.SymbolSelectorClass(); bool bOK; pSS.AddSymbol(pSym); bOK = pSS.SelectSymbol(0); if (bOK) { pLC.Symbol = pSS.GetSymbolAt(0); } axMapControl1.ActiveView.Refresh(); axTOCControl1.Refresh(); } } }