Create a text annotation textelement

Source: Internet
Author: User

1. Create a font

<summary>

Font settings

</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. Create a text annotation style

<summary>

Text annotation Style

</summary>

<param name= "Geometry" > Callout point, one point </param>

<param name= "text" > Label content </param>

<returns>

IElement

</returns>

public static Itextsymbol gettextelement (igeometry geometry, string text)

{

Itextsymbol Textsymbol = new Textsymbolclass ();

Textsymbol.color = colorcustom (0, 0, 0);

you can not directly modify The properties such as TextSymbol.Font.Bold, invalid

Stdole. IFontDisp font = GETIFONTDISP (9F, " Arial ");

Font. Bold = false;

Font. Italic = false;

Font. Strikethrough = false;

Font. underline = false;

Textsymbol.font = Font;

Textsymbol.horizontalalignment = Esritexthorizontalalignment.esrithaleft; level

Textsymbol.verticalalignment = Esritextverticalalignment.esritvatop;; Vertical

return textsymbol;

}

3. Create a text annotation

Itextelement textelement = new Textelementclass ();

Textelement.scaletext = true;

Textelement.symbol = Gettextelement ();

Textelement.text = Text;

ielement element = TextElement as ielement;

Element. Geometry = Geometry;

Create a text annotation textelement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.