Can a halo be added to a text element which is added to a graphic container?

2422
1
Jump to solution
04-30-2013 12:50 PM
GenaroGarcia
New Contributor III
Is there a way to programmatically add a halo to text elements that are being added to a graphic container?

Here's a sample of my code:

    //
    // --- Obtani the area of the polygon to get the centroid of it
    //
    IArea areaOfPolygon = (IArea)polygonEnvelope;
    IPoint TextPoint = new PointClass();
    TextPoint = areaOfPolygon.Centroid;
    //
    // --- Create text symbol
    //
    System.Drawing.Font textDrawFont = new System.Drawing.Font("Arial", 8F, FontStyle.Bold);
    ESRI.ArcGIS.Display.ITextSymbol textFontSymbol = new ESRI.ArcGIS.Display.TextSymbolClass() as ESRI.ArcGIS.Display.ITextSymbol;
    //
    // --- Supply font property values
    //
    textFontSymbol.Font = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(textDrawFont) as stdole.IFontDisp;
    textFontSymbol.Font.Size = 24;
    textFontSymbol.Font.Bold = true;
    textFontSymbol.Angle = 0.0;
    textFontSymbol.Color = rgbTextColor;
    //
    // --- Text to be added to the graphic container
    //
    String sPolygonText = "Need Halo around text";
    //
    // --- Add text element and set properties
    //
    ITextElement textElement = new TextElementClass();
    textElement.Text = sPolygonText;
    textElement.Symbol = textFontSymbol;
    //
    // --- Create element, set property & add to graphic container
    //
    element = textElement as IElement;
    element.Geometry = TextPoint;
    //
    // --- Cast Element to Element Property in order to give it a name
    //
    ESRI.ArcGIS.Carto.IElementProperties3 pTextElementProps = element as ESRI.ArcGIS.Carto.IElementProperties3;
    pTextElementProps.Name = "OKC_Search";
    //
    // --- Add graphic text element to graphic container
    //
    currentGraphicsContainer.AddElement(element, 0);
    //
0 Kudos
1 Solution

Accepted Solutions
GenaroGarcia
New Contributor III

Yes you can add halo around the text.

//

//-------------------------------------------------

// ---    Create halo symbology mask for text   ---

//-------------------------------------------------

//

// --- Set the Halo color - White

//

HaloColor.Red = 255;

HaloColor.Green = 255;

HaloColor.Blue = 255;

//

// --- Create Halo Font Symbol

//

HaloFontSymbol.Font =
ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(HaloDrawFont) as stdole.IFontDisp;

//

HaloFontSymbol.Font.Size = 24;

HaloFontSymbol.Font.Bold = true;

HaloFontSymbol.Angle = 0.0;

HaloFontSymbol.Color = HaloColor;

//

// --- Set the Simple Fill color

//

SimpleFill.Color = HaloColor;

SimpleFill.Style =
ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSSolid;

SimpleFill.Outline = null;

//

// --- Setup a mask

//

pMask = (IMask)HaloFontSymbol;

pMask.MaskSymbol = SimpleFill;

pMask.MaskSize = 2;

pMask.MaskStyle = esriMaskStyle.esriMSHalo;

//

// --- Create and add halo text to graphic container

//

//

// --- Add text element and set properties

//

HaloTextElement.Text = gPolygonText;

HaloTextElement.Symbol = HaloFontSymbol;

//

// --- Create element, set property & add to graphic container

//

HaloElement = HaloTextElement as IElement;

TextPoint.Y -= .5;

HaloElement.Geometry = TextPoint;

//

// --- Add graphic text element to graphic
container

//

if (cbDrawResults.Checked)

   {

      SearchGraphicsContainer.AddElement(HaloElement, 0);

   }

View solution in original post

0 Kudos
1 Reply
GenaroGarcia
New Contributor III

Yes you can add halo around the text.

//

//-------------------------------------------------

// ---    Create halo symbology mask for text   ---

//-------------------------------------------------

//

// --- Set the Halo color - White

//

HaloColor.Red = 255;

HaloColor.Green = 255;

HaloColor.Blue = 255;

//

// --- Create Halo Font Symbol

//

HaloFontSymbol.Font =
ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(HaloDrawFont) as stdole.IFontDisp;

//

HaloFontSymbol.Font.Size = 24;

HaloFontSymbol.Font.Bold = true;

HaloFontSymbol.Angle = 0.0;

HaloFontSymbol.Color = HaloColor;

//

// --- Set the Simple Fill color

//

SimpleFill.Color = HaloColor;

SimpleFill.Style =
ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSSolid;

SimpleFill.Outline = null;

//

// --- Setup a mask

//

pMask = (IMask)HaloFontSymbol;

pMask.MaskSymbol = SimpleFill;

pMask.MaskSize = 2;

pMask.MaskStyle = esriMaskStyle.esriMSHalo;

//

// --- Create and add halo text to graphic container

//

//

// --- Add text element and set properties

//

HaloTextElement.Text = gPolygonText;

HaloTextElement.Symbol = HaloFontSymbol;

//

// --- Create element, set property & add to graphic container

//

HaloElement = HaloTextElement as IElement;

TextPoint.Y -= .5;

HaloElement.Geometry = TextPoint;

//

// --- Add graphic text element to graphic
container

//

if (cbDrawResults.Checked)

   {

      SearchGraphicsContainer.AddElement(HaloElement, 0);

   }

0 Kudos