Пример #1
0
        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);
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Called when the user clicks a command.
 /// </summary>
 /// <remarks>Note to inheritors: override OnClick and use this method to
 ///             perform the actual work of the custom command.</remarks>
 public override void OnClick()
 {
     if (this.m_currentLayer != null)
     {
         try
         {
             frmLayerRender frmLayerRender = new frmLayerRender(this.m_currentLayer);
             if (frmLayerRender.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
             {
                 GFS.BLL.EnviVars.instance.TOCControl.Update();
                 IViewRefresh viewRefresh = this.m_hookHelper.FocusMap as IViewRefresh;
                 viewRefresh.RefreshItem(this.m_currentLayer);
                 this.m_hookHelper.ActiveView.Refresh();
             }
         }
         catch (Exception ex)
         {
             XtraMessageBox.Show("渲染图层出错!原因如下:" + "\r\n" + ex.Message, "提示信息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
             GFS.BLL.Log.WriteLog(typeof(CmdRendererLayer), ex);
         }
     }
 }