ITextElement : ArcObject C# Visual Studio 10 - Arcgis 10.1

3565
3
Jump to solution
04-22-2015 07:44 AM
Jose_LuisGarcinuno-Oporto
New Contributor III

                 The Idea is add a Text to the map, it is working fine except the COLOR, it does not take the Color defined in pRGBcolor object.  

                    IRgbColor pRgbcolor = new RgbColorClass();

                    pRgbcolor.Blue = 0;

                    pRgbcolor.Green = 255;

                    pRgbcolor.Red = 0;

                    IMask pMask = new TextSymbolClass();

                    pMask.MaskStyle = esriMaskStyle.esriMSHalo;

                    pMask.MaskSize = 2;

                    ITextElement pTextElement = new TextElementClass();

                    IElement pElement = pTextElement as IElement;

                    pElement.Geometry = pPagePt;

                    ITextSymbol pTextSymbol = new TextSymbolClass();

                    pTextSymbol.Color = pRgbcolor;

                    pTextSymbol = pMask as ITextSymbol;

                    pTextElement.Symbol = pTextSymbol as ITextSymbol;

                    pTextElement.Text = "Test";

                    pGraphicCont.AddElement(pElement, 0);

                    pMxDoc.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

0 Kudos
1 Solution

Accepted Solutions
ChrisKushnir
New Contributor III

You are creating two TextSymbols, setting the color on the second, then throwing the second away with:

pTextSymbol = pMask as ITextSymbol;

View solution in original post

3 Replies
ChrisKushnir
New Contributor III

You are creating two TextSymbols, setting the color on the second, then throwing the second away with:

pTextSymbol = pMask as ITextSymbol;

Jose_LuisGarcinuno-Oporto
New Contributor III

IRgbColor pRgbcolor = new RgbColorClass();               
pRgbcolor.Blue = 0;
               
pRgbcolor.Green = 0;
               
pRgbcolor.Red = 255;

               
IMask pMask = new TextSymbolClass();
               
pMask.MaskStyle = esriMaskStyle.esriMSHalo;
               
pMask.MaskSize = 2;

               
ITextSymbol pTextSymbol = new TextSymbolClass();        

pTextSymbol = pMask as ITextSymbol;               
pTextSymbol.Color = pRgbcolor;

ITextElement pTextElement = new TextElementClass();

               
pTextElement.Symbol = pTextSymbol;
               
pTextElement.Text = a;
               
IElement pElement = pTextElement as IElement;
               
pElement.Geometry = pLoc;
               
pGraphicCont.AddElement(pElement, 0);
               
pMxDoc.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,
null, null);

Thanks Chris, I ended up with this code and its works.

0 Kudos
ChrisKushnir
New Contributor III

You're still creating then throwing away the second instance.

Change::

ITextSymbol pTextSymbol = new TextSymbolClass();       

pTextSymbol = pMask as ITextSymbol; 

To:

ITextSymbol pTextSymbol = pMask as ITextSymbol; 

0 Kudos