/// <summary>
/// (重載)圖層標註
/// </summary>
/// <param name="pFeaturelayer">標註圖層</param>
/// <param name="sLableField">標註欄位</param>
/// <param name="pRGB">顏色</param>
/// <param name="size">大小</param>
public static void FunLabelFeatureLayer(IFeatureLayer pFeaturelayer, string sLableField, IRgbColor pRGB, int size)
{
if (pFeaturelayer == null)
return;
IGeoFeatureLayer pGeoFeaturelayer = (IGeoFeatureLayer)pFeaturelayer;
IAnnotateLayerPropertiesCollection pAnnoLayerPropsCollection;
pAnnoLayerPropsCollection = pGeoFeaturelayer.AnnotationProperties;
pAnnoLayerPropsCollection.Clear();
//stdole.IFontDisp pFont; //字型
ITextSymbol pTextSymbol;
//pFont.Name = "新宋體";
//pFont.Size = 9;
if (pRGB == null)
{
pRGB = new RgbColorClass();
pRGB.Red = 0;
pRGB.Green = 0;
pRGB.Blue = 0;
}
pTextSymbol = new TextSymbolClass();
pTextSymbol.Color = (IColor)pRGB;
pTextSymbol.Size = size;
IBasicOverposterLayerProperties pBasicOverposterlayerProps = new BasicOverposterLayerPropertiesClass();
switch (pFeaturelayer.FeatureClass.ShapeType)
{
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
pBasicOverposterlayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
pBasicOverposterlayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
pBasicOverposterlayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
break;
}
ILabelEngineLayerProperties pLabelEnginelayerProps = new LabelEngineLayerPropertiesClass();
pLabelEnginelayerProps.Expression = "[" + sLableField + "]";
pLabelEnginelayerProps.Symbol = pTextSymbol;
pLabelEnginelayerProps.BasicOverposterLayerProperties = pBasicOverposterlayerProps;
pAnnoLayerPropsCollection.Add((IAnnotateLayerProperties)pLabelEnginelayerProps);
pGeoFeaturelayer.DisplayAnnotation = true;
//axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
}