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;
}
}
}
获取图层的FeatureClass 把FeatureClass转为IGeoDataset,
这个GeoDataset是有个Extent属性呀! OK吧!
ILayerFile
: 提供方法控制图层文件的读写。
一个图层文件可以包含一个图层,是一对一的关系,图层另存为时用到的三个方法是 New() :创建并打开一个新的图层文件;ReplaceContents():替换文件层的内容,参数是要另存的图层;Save():保存文件。
IGeoFeatureLayer : 继承了ILayer和IFeatureLayer两个接口,用于控制要素图层中与地理相关的内容,如标注。其DisplayAnnotation属性用于设置要素是否出现标注。
IBasicOverposterLayerPro
perties:提供方法控制标注的布局并检测相关联要素冲突。主要用到它的
NumLabelsOption属性,表明标注显示方式,用一个枚举类型esriBasicNumLabelsOption
给它赋值。
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. 图层属性显示:
2.缩放致图层:
3.图层另存为:
4.图层标注:
应该是表示标注类型吧,如果是esriBasicNumLabelsOption
.esriOneLabelPerShape,应该是给Shape标注吧。
5.