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);
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);
相关文章推荐
- iOS中label设置属性字符串
- iOS - UILabel 的一些属性设置(间距、删除线等、计算文本label的size等)
- Search属性 关于 Featureclass 和 Featurelayer
- label指定位置文字属性设置
- MOSS 2007 爬网规则 Contentclass常用属性设置
- flex htmlText属性和Label设置鼠标手形状
- AE中如何由IFeature 如何获取所对应的FeatureClass
- Struts2 select标签 设置Class属性生成的html代码中select没有class属性问题
- AE CreateFeatureClass 创建shp. 删除shp. 向shp中添加要素
- Arcgis Engine(ae)接口详解(4):featureClass的feature插入
- AE CreateFeatureClass 创建shp. 删除shp. 向shp中添加要素
- ANT构建JAR包时设置MANIFEST.MF的Class-Path属性的技巧
- label中的attributedText属性,很强大的设置,以前用的弱爆了
- 使用js创建div、添加子div并给div设置在css中定义的class选择属性以及设置style属性
- jQuery选择器ID、CLASS、标签获取对象值、属性、设置css样式
- 同一labeltext设置不同的属性
- AE数据转换的代码(FeatureClass To Shape)
- ANT构建JAR包时设置MANIFEST.MF的Class-Path属性的技巧
- jQuery的属性与样式之.css()与.addClass()设置样式的区别
- HTML中设置多个class属性的优先级