Ejemplo n.º 1
0
        //TOCControl1鼠标点击事件,左键 符号变更,右键菜单
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            this.axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex);
            axMapControl1.CustomProperty = pLayer;
            if (e.button == 1)  //符号变更
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    ILegendClass pLegend = new LegendClassClass();          //首先获取图例,然后赋值过去
                    ISymbol      symbol  = null;                            //新建 symbol,从符号窗体中最后就是获得这个东西
                    if (oLegendGroup is ILegendGroup && (int)oIndex != -1)
                    {
                        pLegend = ((ILegendGroup)oLegendGroup).get_Class((int)oIndex) as ILegendClass;
                    }
                                                                                               //给上面建的图例类赋值

                    FormSymbology frm = new FormSymbology(pLegend, pLayer);                    //新建符号窗体,并将该赋值的赋值过去
                    frm.ShowDialog();                                                          //显示对话框,之后就获得了 symbol 了
                        symbol     = frm.pStyleGalleryItem.Item as ISymbol;                    //调用窗体的 public 字段
                    pLegend.Symbol = symbol;                                                   //将 symbol 赋值给图例
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);    //刷新地图
                }
            }
            else if (e.button == 2) //加载右键菜单
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                }
                else if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                    ITOCControl toc = axTOCControl1.Object as ITOCControl;
                    toc.Update();
                }
            }
        }
        //TOCControl1鼠标点击事件,左键 符号变更,右键菜单
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            this.axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex);
            axMapControl1.CustomProperty = pLayer;
            if (e.button == 1)  //符号变更
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    ILegendClass pLegend = new LegendClassClass();        //首先获取图例,然后赋值过去
                    ISymbol symbol = null;                    //新建 symbol,从符号窗体中最后就是获得这个东西
                    if (oLegendGroup is ILegendGroup && (int)oIndex != -1)
                        pLegend = ((ILegendGroup)oLegendGroup).get_Class((int)oIndex) as ILegendClass;  //给上面建的图例类赋值

                    FormSymbology frm = new FormSymbology(pLegend, pLayer);      //新建符号窗体,并将该赋值的赋值过去
                    frm.ShowDialog();                             //显示对话框,之后就获得了 symbol 了
                    symbol = frm.pStyleGalleryItem.Item as ISymbol;              //调用窗体的 public 字段
                    pLegend.Symbol = symbol;                        //将 symbol 赋值给图例
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);  //刷新地图
                }
            }
            else if (e.button == 2) //加载右键菜单
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemMap)
                {

                }
                else if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                    ITOCControl toc = axTOCControl1.Object as ITOCControl;
                    toc.Update();
                }
            }
        }