Exemplo n.º 1
0
        private void axTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e)//双击legend修改symbol
        {
            ILayer             pLayer       = null;
            IBasicMap          pBasicMap    = null;
            object             plegendGroup = null;
            object             pIndex       = null;
            esriTOCControlItem pTocItem     = esriTOCControlItem.esriTOCControlItemNone;

            axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer,
                                  ref plegendGroup, ref pIndex);
            if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass)
            {
                ILegendClass legendClass = (plegendGroup as ILegendGroup).get_Class((int)pIndex);
                if (!((pLayer is IRasterLayer &&
                       (pLayer as IRasterLayer).Renderer is IRasterStretchColorRampRenderer) ||
                      (pLayer is IFeatureLayer &&
                       (pLayer as IGeoFeatureLayer).Renderer is IProportionalSymbolRenderer)))
                {
                    ISymbolSelector selector = new SymbolSelectorClass();
                    selector.AddSymbol(legendClass.Symbol);
                    if (selector.SelectSymbol(0) == true)
                    {
                        legendClass.Symbol = selector.GetSymbolAt(0);
                    }
                    axMapControl1.Refresh();
                    axTOCControl1.Update();
                }
            }
        }
Exemplo n.º 2
0
        private ISymbol GetSymbolBySymbolSelector(esriGeometryType geometryType)
        {
            ISymbolSelector pSymbolSelector = new SymbolSelectorClass();
            ISymbol         symbol          = null;

            switch (geometryType)
            {
            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                symbol = new SimpleMarkerSymbolClass();
                break;

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                symbol = new SimpleLineSymbolClass();
                break;

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                symbol = new SimpleFillSymbolClass();
                break;

            default:
                break;
            }
            pSymbolSelector.AddSymbol(symbol);
            bool response = pSymbolSelector.SelectSymbol(0);

            if (response)
            {
                symbol = pSymbolSelector.GetSymbolAt(0);
                return(symbol);
            }
            return(null);
        }
Exemplo n.º 3
0
        private ISymbol GetSimpleSymbolBySelector(ISymbol symbolType)
        {
            ISymbolSelector pSymbolSelector = new SymbolSelectorClass();
            ISymbol         symbol          = null;

            if (symbolType is IMarkerSymbol)
            {
                symbol = new SimpleMarkerSymbolClass();
            }
            if (symbolType is ILineSymbol)
            {
                symbol = new SimpleLineSymbolClass();
            }
            if (symbolType is IFillSymbol)
            {
                symbol = new SimpleFillSymbolClass();
            }
            pSymbolSelector.AddSymbol(symbol);
            bool response = pSymbolSelector.SelectSymbol(0);

            if (response)
            {
                symbol = pSymbolSelector.GetSymbolAt(0);
                return(symbol);
            }
            return(null);
        }
Exemplo n.º 4
0
 private ISymbol GetSymbolBySymbolSelector(esriGeometryType geometryType)
 {
     try
     {
         ISymbolSelector pSymbolSelector = new SymbolSelectorClass();
         ISymbol symbol = null;
         switch (geometryType)
         {
             case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                 symbol = new SimpleMarkerSymbolClass();
                 break;
             case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                 symbol = new SimpleLineSymbolClass();
                 break;
             case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                 symbol = new SimpleFillSymbolClass();
                 break;
             default:
                 break;
         }
         pSymbolSelector.AddSymbol(symbol);
         bool response = pSymbolSelector.SelectSymbol(0);
         if (response)
         {
             symbol = pSymbolSelector.GetSymbolAt(0);
             return symbol;
         }
         return null;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         ISymbol symbol = null;
         switch (geometryType)
         {
             case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                 symbol = new SimpleMarkerSymbolClass();
                 break;
             case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                 symbol = new SimpleLineSymbolClass();
                 break;
             case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                 symbol = new SimpleFillSymbolClass();
                 break;
             default:
                 break;
         }
         return symbol;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        ///     右键弹出图层管理菜单,进行图层管理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tocControl_WM_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return; //左键则跳出
            }
            var       item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map   = null;
            ILayer    layer = null;
            object    unk   = null;
            object    data  = null;

            //判断选择类型,确定右键菜单的位置
            tocControl_WM.HitTest(e.x, e.y, ref item, ref map, ref layer, ref unk, ref data);
            if (layer == null)
            {
                return;
            }
            //确认所选项
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                tocControl_WM.SelectItem(map, null);
            }
            else
            {
                tocControl_WM.SelectItem(layer, null); //20140224 有bug
            }
            //设置图层的CustomProperty(在自定义图层命令中使用)
            mapControl_WM.CustomProperty = layer;

            //弹出菜单
            var menuMap = new LayersManagerMap();

            menuMap.SetHook(mapControl_WM);
            var menuLayer = new LayersManagerLayer();

            menuLayer.SetHook(mapControl_WM);
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                //选中的为地图
                menuMap.PopupMenu(e.x, e.y, tocControl_WM.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                //选中的为图层
                menuLayer.PopupMenu(e.x, e.y, tocControl_WM.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLegendClass) //选中的为图例
            {
                return;

                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;
                ISymbolSelector pSS = new
                                      SymbolSelectorClass();
                var bOK = false;
                pSS.AddSymbol(pSym);
                bOK = pSS.SelectSymbol(0);
                if (bOK)
                {
                    pLC.Symbol = pSS.GetSymbolAt(0);
                }
                mapControl_WM.ActiveView.Refresh();
                tocControl_WM.Refresh();
            }
        }
Exemplo n.º 6
0
        //TOCControl控件的鼠标单击事件
        public void m_tocControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            //判断所选菜单的类型
            m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            if (e.button == 1)
            {
                if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    try
                    {
                        ESRI.ArcGIS.Carto.ILegendClass pLC = new LegendClassClass();
                        ESRI.ArcGIS.Carto.ILegendGroup pLG = new LegendGroupClass();
                        if (other is ILegendGroup)
                        {
                            pLG = (ILegendGroup)other;
                        }
                        pLC = pLG.get_Class((int)index);
                        ISymbol pSym;
                        pSym = pLC.Symbol;


                        ISymbolSelector pSS = new SymbolSelectorClass();

                        bool bOK = false;
                        pSS.AddSymbol(pSym);
                        bOK = pSS.SelectSymbol(0);
                        if (bOK)
                        {
                            pLC.Symbol = pSS.GetSymbolAt(0);
                        }
                        this.m_mapControl.ActiveView.Refresh();
                        this.m_tocControl.Refresh();
                    }
                    catch (Exception exce)
                    { }
                }
            }
            if (e.button == 2)
            {
                //设置CustomProperty为layer (用于自定义的Layer命令)
                m_mapControl.CustomProperty = layer;
                //弹出右键菜单
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                }
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    #region

                    /*                 this.LoadMenu(layer);
                     * m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                     * m_menuLayer.RemoveAll();      */
                    #endregion
                    m_CurrentLayer = layer;
                    m_pGeoFeaLayer = m_CurrentLayer as IGeoFeatureLayer;
                    this.ChangeItemText();
                    Rectangle rect = new Rectangle();
                    rect = m_tocControl.RectangleToScreen(rect);
                    m_contextMemuLayer.Show(e.x + rect.Left, e.y + rect.Top);
                }
            }
        }
Exemplo n.º 7
0
 private void axTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e)
 {
     IBasicMap map = null;//设置要素符号
     object other = null;
     object index = null;
     esriTOCControlItem item = new esriTOCControlItem();
     this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref m_layer, ref other, ref index);
     if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
     {
         ILegendGroup legendGroup = other as ILegendGroup;
         ILegendClass legendClass = legendGroup.get_Class(Convert.ToInt32(index));
         ISymbol symbol = legendClass.Symbol;
         ISymbolSelector pSS = new SymbolSelectorClass();
         pSS.AddSymbol(symbol);
         Boolean bOK = pSS.SelectSymbol(0);
         if (bOK == true)
         {
             legendClass.Symbol = pSS.GetSymbolAt(0);
         }
         axTOCControl1.Update();
         this.mapCtlMain.Refresh();
     }
 }