private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          map   = new MapClass();
            ILayer             layer = new FeatureLayerClass();
            object             other = new object();
            object             index = new object();
            esriTOCControlItem item  = new esriTOCControlItem();

            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 2)
            {
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    m_controlsSynchronizer.MapControl.CustomProperty = map;
                    m_TocMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                else if (layer is IFeatureLayer)
                {
                    m_controlsSynchronizer.MapControl.CustomProperty = layer;
                    m_TocLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
            }
            if (e.button == 1)
            {
                if (layer == null)
                {
                    return;
                }
                IFeatureLayer featurelayer = layer as IFeatureLayer;
                if (featurelayer == null)
                {
                    return;
                }
                IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featurelayer;
                ILegendClass     legendClass     = new LegendClassClass();
                ISymbol          symbol          = null;
                if (other is ILegendGroup && (int)index != -1)
                {
                    legendClass = ((ILegendGroup)other).get_Class((int)index);
                    symbol      = legendClass.Symbol;
                }
                if (symbol == null)
                {
                    return;
                }
                symbol = GetSymbolByControl(symbol);
                if (symbol == null)
                {
                    return;
                }
                legendClass.Symbol = symbol;
                this.Activate();
                //((IActiveView)m_MapDocument.get_Map(0)).ContentsChanged();

                axMapControl1.ActiveView.ContentsChanged();
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                axMapControl1.Refresh();
                axTOCControl1.Update();
            }
        }
        /// <summary>
        /// Class default constructor
        /// </summary>
        public GlobeCustomLayerBase()
        {
            m_sName       = string.Empty;
            m_bVisible    = true;
            m_bValid      = true;
            m_bCached     = false;
            m_dblMaxScale = 0;
            m_dblMinScale = 0;
            m_table       = new DataTable("RECORDS");

            m_table.Columns.Add("ID", typeof(long));

            m_extensions = new ArrayList();

            ILegendClass legendClass = new LegendClassClass();

            legendClass.Label = "GlobeCustomLayer";

            m_legendGroup          = new LegendGroupClass();
            m_legendGroup.Heading  = "";
            m_legendGroup.Editable = false;
            m_legendGroup.AddClass(legendClass);

            m_sName = "GlobeCustomLayer";

            //call CreateControl in order to create the handle
            this.CreateControl();
        }
Beispiel #3
0
//        双击 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();
                }
            }
        }
Beispiel #4
0
        public VerySimpleCustomRenderer()
        {
            lg = new LegendGroupClass();
            ILegendClass lc = new LegendClassClass();

            sym       = new SimpleFillSymbolClass();
            lc.Label  = "A very simple custom renderer";
            lc.Symbol = sym;
            lg.AddClass(lc);
        }
        private void tocControl_OnDoubleClick(int button, int shift, int x, int y)
        {
            esriTOCControlItem esriTOCControlItem = esriTOCControlItem.esriTOCControlItemNone;
            object             obj      = null;
            object             obj2     = null;
            IBasicMap          basicMap = null;
            ILayer             layer    = null;

            this._tocControl.HitTest(x, y, ref esriTOCControlItem, ref basicMap, ref layer, ref obj, ref obj2);
            if (button == 1)
            {
                if (esriTOCControlItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    if (layer is IRasterLayer)
                    {
                        IRasterLayer rasterLayer = layer as IRasterLayer;
                        if (rasterLayer.Renderer is IRasterRGBRenderer)
                        {
                            this._mapControl.CustomProperty = layer;
                            this.AddPopMenuRGBItem(obj2, rasterLayer);
                        }
                        else if (rasterLayer.Renderer is IRasterUniqueValueRenderer)
                        {
                            IRasterUniqueValueRenderer rasterUniqueValueRenderer = rasterLayer.Renderer as IRasterUniqueValueRenderer;
                            ISymbol symbol = rasterUniqueValueRenderer.get_Symbol(0, (int)obj2);
                            this.RenderRasterUniqueValue(layer, rasterUniqueValueRenderer, symbol, 0, (int)obj2);
                        }
                        else if (rasterLayer.Renderer is IRasterStretchColorRampRenderer)
                        {
                            frmLayerRender frmLayerRender = new frmLayerRender(layer);
                            if (frmLayerRender.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                            {
                                EnviVars.instance.TOCControl.Update();
                                RefreshView(layer);
                            }
                        }
                    }
                    else
                    {
                        ESRI.ArcGIS.Carto.ILegendClass pLC = new LegendClassClass();
                        ESRI.ArcGIS.Carto.ILegendGroup pLG = new LegendGroupClass();
                        if (obj is ILegendGroup)
                        {
                            pLG = (ILegendGroup)obj;
                        }
                        pLC        = pLG.get_Class((int)obj2);
                        pLC.Symbol = this.ChangeSymbol(layer, pLC.Symbol);
                        RefreshView(layer);
                    }
                }
            }
        }
Beispiel #6
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();
                }
            }
        }
    /// <summary>
    /// Class default constructor
    /// </summary>
    public GlobeCustomLayerBase()
    {
      m_sName = string.Empty;
      m_bVisible = true;
      m_bValid = true;
      m_bCached = false;
      m_dblMaxScale = 0;
      m_dblMinScale = 0;
      m_table = new DataTable("RECORDS");

      m_table.Columns.Add("ID", typeof(long));

      m_extensions = new ArrayList();

      ILegendClass legendClass = new LegendClassClass();
      legendClass.Label = "GlobeCustomLayer";

      m_legendGroup = new LegendGroupClass();
      m_legendGroup.Heading = "";
      m_legendGroup.Editable = false;
      m_legendGroup.AddClass(legendClass);

      m_sName = "GlobeCustomLayer";

      //call CreateControl in order to create the handle
      this.CreateControl();
    }
Beispiel #9
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();
            }
        }
Beispiel #10
0
 public VerySimpleCustomRenderer()
 {
     lg = new LegendGroupClass();
     ILegendClass lc = new LegendClassClass();
     sym = new SimpleFillSymbolClass();
     lc.Label = "A very simple custom renderer";
     lc.Symbol = sym;
     lg.AddClass(lc);
 }
        //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);
                }
            }
        }
Beispiel #12
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          map   = new MapClass();
            ILayer             layer = new FeatureLayerClass();
            object             other = new object();
            object             index = new object();
            esriTOCControlItem item  = new esriTOCControlItem();

            //Determine what kind of item has been clicked on
            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            if (e.button == 1)
            {
                //QI to IFeatureLayer and IGeoFeatuerLayer interface
                if (layer == null)
                {
                    return;
                }
                IFeatureLayer featureLayer = layer as IFeatureLayer;
                if (featureLayer == null)
                {
                    return;
                }
                IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer;

                ILegendClass legendClass = new LegendClassClass();
                ISymbol      symbol      = null;
                if (other is ILegendGroup && (int)index != -1)
                {
                    legendClass = ((ILegendGroup)other).get_Class((int)index);
                    symbol      = legendClass.Symbol;
                }
                if (symbol == null)
                {
                    return;
                }

                symbol = GetSymbolByControl(symbol);
                //symbol = GetSymbolBySymbolSelector(symbol);
                if (symbol == null)
                {
                    return;
                }
                legendClass.Symbol = symbol;
                this.Activate();
                //Fire contents changed event that the TOCControl listens to
                axMapControl1.ActiveView.ContentsChanged();
                //Refresh the display
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                axTOCControl1.Update();
            }
            if (e.button == 2)
            {
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    m_mapControl.CustomProperty = map;
                    m_TocMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                else if (layer is IFeatureLayer)
                {
                    m_mapControl.CustomProperty = layer;
                    m_TocLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                else if (layer is INALayer)
                {
                    m_mapControl.CustomProperty = layer;

                    if (item == esriTOCControlItem.esriTOCControlItemLayer)
                    {
                        m_menuLayer.PopupMenu(e.x, e.y, axMapControl1.hWnd);
                        ITOCControl toc = axTOCControl1.Object as ITOCControl;
                        toc.Update();
                    }
                }
            }
        }