您的位置:首页 > Web前端

AE中FeatureClass的Label的属性设置

2011-05-24 14:43 513 查看
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;

namespace BLL
{
/// <summary>
/// 航路名称的属性设置
/// </summary>
public class RouteNameLabelSet
{
private IFeatureLayer pFeatureLayer;

/// <summary>
/// 构造函数
/// </summary>
/// <param name="pFeatureLayer">要设置的要素层</param>
public RouteNameLabelSet(IFeatureLayer pFeatureLayer)
{
this.pFeatureLayer = pFeatureLayer;
}

/// <summary>
/// FeatureClass的Label属性设置具体方法
/// </summary>
/// <param name="fontSize">字体大小</param>
/// <param name="fontColor">字体颜色</param>
/// <param name="fontStyle">字体样式</param>
/// <param name="boldBool">粗体</param>
/// <param name="italicBool">斜体</param>
public void LabelStyleSet(string fontSize, Color fontColor, string fontStyle, bool boldBool, bool italicBool)
{
IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
IAnnotateLayerPropertiesCollection pAnnoLayerPropsColl = new AnnotateLayerPropertiesCollectionClass();
pAnnoLayerPropsColl = pGeoFeatureLayer.AnnotationProperties;
IAnnotateLayerProperties pAnnoLayerProps = null;
IElementCollection placedElements = null;
IElementCollection unplacedElements = null;

pAnnoLayerPropsColl.QueryItem(0, out pAnnoLayerProps, out placedElements, out unplacedElements);

ILabelEngineLayerProperties aLELayerProps = pAnnoLayerProps as ILabelEngineLayerProperties;
ITextSymbol pTextSymbol = aLELayerProps.Symbol;

stdole.IFontDisp pFontDisp = pTextSymbol.Font;
pFontDisp.Size = decimal.Parse(fontSize);
pFontDisp.Bold = boldBool;
pFontDisp.Italic = italicBool;
pFontDisp.Name= fontStyle;

IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = int.Parse(fontColor.R.ToString());
pRgbColor.Blue = int.Parse(fontColor.B.ToString());
pRgbColor.Green = int.Parse(fontColor.G.ToString());

pTextSymbol.Font = pFontDisp;
pTextSymbol.Color = pRgbColor;

aLELayerProps.Symbol = pTextSymbol;

pAnnoLayerProps = aLELayerProps as IAnnotateLayerProperties;
pAnnoLayerProps.FeatureLayer = pGeoFeatureLayer;
pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;

pAnnoLayerPropsColl.Add(pAnnoLayerProps);
}
}
}
注:要刷新才能看见结果

// pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: