TOCControl的常见右键操作

1.在TOCControls上时用esriTOCControlItem来控制右键菜单显示类型。
      代码:
      if (axMapControl1.LayerCount > 0)
            {
                esriTOCControlItem pItem = new esriTOCControlItem();     //就是这个
                       pGlobalFeatureLayer = new FeatureLayerClass();
                IBasicMap pBasicMap = new MapClass();
                object pOther = new object();
                object pIndex = new object();
                axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pGlobalFeatureLayer, ref pOther, ref pIndex);

                if (e.button == 2)
                {
                    switch (pItem)
                    {
                        case esriTOCControlItem.esriTOCControlItemLayer:
                                         contextMenuStripTOC.Show(axTOCControl1, e.x, e.y);
                            break;
                        case esriTOCControlItem.esriTOCControlItemMap:
                            contextMenuStripTOC2.Show(axTOCControl1,e.x,e.y );
                            break;
                    }
                }
            }


2.缩放致图层:
      获取图层的FeatureClass 把FeatureClass转为IGeoDataset,   这个GeoDataset是有个Extent属性呀! OK吧!


3.图层另存为:
    ILayerFile   : 提供方法控制图层文件的读写。
              一个图层文件可以包含一个图层,是一对一的关系,图层另存为时用到的三个方法是 New() :创建并打开一个新的图层文件;ReplaceContents():替换文件层的内容,参数是要另存的图层;Save():保存文件。


4.图层标注:
      IGeoFeatureLayer : 继承了ILayer和IFeatureLayer两个接口,用于控制要素图层中与地理相关的内容,如标注。其DisplayAnnotation属性用于设置要素是否出现标注。
        IBasicOverposterLayerPro perties:提供方法控制标注的布局并检测相关联要素冲突。主要用到它的 NumLabelsOption属性,表明标注显示方式,用一个枚举类型esriBasicNumLabelsOption 给它赋值。
应该是表示标注类型吧,如果是esriBasicNumLabelsOption .esriOneLabelPerShape,应该是给Shape标注吧。
      ITextSymbol: 控制标注样式,   可设置其颜色、大小、字体等属性。
      ILableEngineProperties: 控制着标记的主要属性:   标记类型,类型为IBasicOverposterLayerPro perties;标记样式,类型为ITextSymbol;标记表达式,也就是标记字段的字符串表示。
        代码:
  #region
            IBasicOverposterLayerPro perties pBasic = new BasicOverposterLayerProp ertiesClass();
            pBasic.NumLabelsOption = esriBasicNumLabelsOption .esriOneLabelPerShape;

            ITextSymbol pTextSymbol = new TextSymbol();
            pTextSymbol.Color.RGB = 255;
            pTextSymbol.Size = (int)comboBox2.SelectedItem;   //字号
            pTextSymbol.Font.Name = comboBox1.SelectedItem.ToString();   //字体
            pTextSymbol.Font.Size = (int)comboBox2.SelectedItem;
          //   pTextSymbol.Font.Underline = true;          

            // 需要标注的字段
            string pLabelField = "[" + comboBoxlableField.SelectedItem.ToString() + "]";

            ILabelEngineLayerPropert ies pLabelEngine = new LabelEngineLayerProperti esClass();
            pLabelEngine.BasicOverposterLayerProp erties = pBasic;
            pLabelEngine.Symbol = pTextSymbol;
            pLabelEngine.Expression = pLabelField;
            pLabelEngine.IsExpressionSimple = true;

            IGeoFeatureLayer pGeoFeatureLayer = _pLayer as IGeoFeatureLayer;   //标注图层

            // 清除原有的默认字段
            pGeoFeatureLayer.AnnotationProperties.Clear();

            pGeoFeatureLayer.AnnotationProperties.Add(pLabelEngine as IAnnotateLayerProperties );
            if (checkBoxShowLabel.Checked == true)
            {
                pGeoFeatureLayer.DisplayAnnotation = true;
            }
            else
            {
                pGeoFeatureLayer.DisplayAnnotation = false;
            }

            this.Dispose();
  #endregion

5.   图层属性显示:
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值