Example #1
0
        private void AxTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          pMap     = null;
            ILayer             pLayer   = null;
            object             legendgp = null;
            object             index    = null;
            esriTOCControlItem pItem    = esriTOCControlItem.esriTOCControlItemNone;

            axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index);  //点击测试,点击图例打开符号选择器
            if (e.button == 1)
            {
                ILegendGroup pLegendGroup = new LegendGroup();
                ILegendClass pLegendClass = new LegendClass();
                pLegendGroup = (ILegendGroup)legendgp;
                if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(index.ToString()));
                    if (pLegendClass == null)
                    {
                        return;
                    }
                    FormSymbolSelector dlg = new FormSymbolSelector(pLegendClass, pLayer);
                    if (dlg != null)
                    {
                        dlg.ShowDialog();
                        m_pTocControl.Update();
                        m_mapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// 双击TOC修改符号系统
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axTOCControl1_OnDoubleClick(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnDoubleClickEvent e)
        {
            esriTOCControlItem pTocControlItem = esriTOCControlItem.esriTOCControlItemNone;
            ILayer             pLayer          = null;
            IBasicMap          pBasicMap       = null;
            object             unk             = null;
            object             data            = null;

            if (e.button == 1)
            {
                axTOCControl1.HitTest(e.x, e.y, ref pTocControlItem, ref pBasicMap, ref pLayer, ref unk, ref data);
                System.Drawing.Point pos = new System.Drawing.Point(e.x, e.y);
                if (pTocControlItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    ILegendClass pLegendClass = new LegendClass();
                    ILegendGroup pLegendGroup = new LegendGroup();
                    if (unk is ILegendGroup)
                    {
                        pLegendGroup = unk as ILegendGroup;
                    }
                    pLegendClass = pLegendGroup.get_Class((int)data);
                    ISymbol pSymbol;
                    pSymbol = pLegendClass.Symbol;
                    ISymbolSelector pSymbolSelector = new SymbolSelector();
                    bool            isOk            = false;
                    pSymbolSelector.AddSymbol(pSymbol);
                    isOk = pSymbolSelector.SelectSymbol(0);
                    if (isOk)
                    {
                        pLegendClass.Symbol = pSymbolSelector.GetSymbolAt(0);
                    }
                    this.axMapControl1.ActiveView.Refresh();
                    this.axTOCControl1.Refresh();
                }
            }
        }
Example #3
0
        //符号选择器
        private void AxTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e)
        {
            ILayer             pLayer   = null;
            IBasicMap          pMap     = null;
            object             legendgp = null;
            object             index    = null;
            esriTOCControlItem pItem    = esriTOCControlItem.esriTOCControlItemNone;

            ILegendGroup pLegendGroup = new LegendGroup();
            ILegendClass pLegendClass = new LegendClass();

            try
            {
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index);
            }
            catch (Exception)
            {
                throw;
            }
            pLegendGroup = (ILegendGroup)legendgp;

            if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass)
            {
                pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(index.ToString()));
                if (pLegendClass == null)
                {
                    return;
                }
                FrmSymbolLibrary dlg = new FrmSymbolLibrary(pLegendClass, pLayer);
                if (dlg != null)
                {
                    try
                    {
                        dlg.ShowDialog();
                        axTOCControl1.Update();
                        mainMapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            //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);
            //    System.Drawing.Point pos = 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 = pLC.Symbol;
            //        ISymbolSelector pSS = new SymbolSelectorClass();
            //        bool bOK = false;
            //        pSS.AddSymbol(pSym);
            //        bOK = pSS.SelectSymbol(0);
            //        if (bOK)
            //        {
            //            pLC.Symbol = pSS.GetSymbolAt(0);
            //        }
            //        mainMapControl.ActiveView.Refresh();
            //        axTOCControl1.Refresh();
            //    }
            //}
        }