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);
Solved! Go to Solution.
You are creating two TextSymbols, setting the color on the second, then throwing the second away with:
pTextSymbol = pMask as ITextSymbol;
You are creating two TextSymbols, setting the color on the second, then throwing the second away with:
pTextSymbol = pMask as ITextSymbol;
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.
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;