标签:
1.创建一个字体
/// <summary>
/// 字体设置
/// </summary>
/// <param name="size">The size.</param>
/// <param name="fontname">The fontname.</param>
/// <returns>
/// IFontDisp
/// </returns>
public static stdole.IFontDisp GetIFontDisp(float size, string fontname)
{
string fontFamilyName = fontname;
FontStyle fontStyle = FontStyle.Regular;
Font font = new Font(fontFamilyName, size, fontStyle);
return OLE.GetIFontDispFromFont(font) as stdole.IFontDisp;
}
2.创建文本注记样式
/// <summary>
///文本注记样式
/// </summary>
/// <param name="geometry">标注点,一个点即可</param>
/// <param name="text">标注内容</param>
/// <returns>
/// IElement
/// </returns>
public static ITextSymbol GetTextElement(IGeometry geometry, string text)
{
ITextSymbol textSymbol = new TextSymbolClass();
textSymbol.Color = ColorCustom(0, 0, 0);
////不可以直接修改textSymbol.Font.Bold等属性,无效
stdole.IFontDisp font = GetIFontDisp(9F, "宋体");
font .Bold = false;
font .Italic = false;
font .Strikethrough = false;
font .Underline = false;
textSymbol.Font = font;
textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; ////水平
textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; ; ////垂直
return textSymbol ;
}
3.创建文本注记
ITextElement textElement = new TextElementClass();
textElement.ScaleText = true;
textElement.Symbol = GetTextElement();
textElement.Text = text;
IElement element = textElement as IElement;
element.Geometry = geometry;
标签:
原文地址:http://www.cnblogs.com/jhlong/p/5394329.html