ARCEngine中符号选择器的实现

                private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
                {
                    esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
                    IBasicMap map = null; ILayer layer = null;
                    object other = null; object index = null;
                    this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                    if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
                    {
                        IFeatureLayer layerS;
                        layerS = layer as IFeatureLayer;
                        ILegendClass plc = new LegendClassClass();
                        ILegendGroup plg = new LegendGroupClass();

                        if (other is ILegendGroup)
                        {
                            plg = (ILegendGroup)other;
                        }
                        plc = plg.get_Class((int)index);
                        ISymbol pSym;
                        pSym = plc.Symbol;
                        ISymbolSelector pSymbolSelector = new SymbolSelectorClass();
                        pSymbolSelector.AddSymbol(pSym);
                        bool b = pSymbolSelector.SelectSymbol(0);
                        if (b)
                        {
                            plc.Symbol = pSymbolSelector.GetSymbolAt(0);
                        }
                        axMapControl1.ActiveView.Refresh();
                        axTOCControl1.Refresh();
                    }
            }

运行效果:

猜你喜欢

转载自blog.csdn.net/qq_40323256/article/details/85117352