Create new elements and set the style

Source: Internet
Author: User
The general steps for creating new elements and setting styles are as follows:
1. Create a new graphic element (lineelement, markerelement, polygonelement, textelement, etc)
2. Create appropriate new symbols for new elements (such as linesymbol, textsymbol, and fillsymbol)
3. Create a new color object (rgbcolor, cmycolor, hlscolor, hsycolor)
4. Define the color value
5. Assign the color to the symbol
6. Define the symbolic style
7. assign a symbol to a Graphic Element

Ielement pelement;
Itextelement ptextelement = new textelementclass ();
Pelement = ptextelement as ielement;

Icolor ptextcolor = new rgbcolor ();
Ptextcolor. RGB = color. froma #000000. toargb ();

Stdole. ifontdisp pfont = new stdole. stdfontclass () as stdole. ifontdisp;
Pfont. size = 20;

Itextsymbol ptextsymbol = new textsymbol ();
Ptextsymbol. Color = ptextcolor;
Ptextsymbol. font = pfont;
Ptextsymbol. horizontalalignment = esritexthorizontalalignment. esrithacenter; // center horizontally
Ptextsymbol. verticalalignment = esritextverticalalignment. esritvatop; // vertically aligned

Ptextelement. Text = "Graphic Element ";
Ptextelement. symbol = ptextsymbol;

Ipoint PPT = new pointclass ();
PPT. x = (pmapframeelementenvelope. xmin + pmapframeelementenvelope. xmax)/2;
PPT. Y = pmapframeelementenvelope. ymin;
Pelement. Geometry = PPT;
Pelemprops = (ielementproperties) pelement;
Pelemprops. Name = "textelement"; // set the element name

Itransform2d ptransform2d = ptextelement as itransform2d;
Ptransform2d. Rotate (PPT, system. Math. PI/2); // Rotate 90 degrees

Igraphicscontainer pgraphicscont = (igraphicscontainer) axpagelayoutcontrol1.pagelayout; // axmapcontrol. Map
Pgraphicscont. addelement (ielement) ptextelement, 0 );

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.