Select to view content in your preferred language

Casting of TextSymbol in Graphics Layer

860
2
Jump to solution
03-27-2013 05:38 AM
LuisGarcia2
Deactivated User
I have a GraphicsLayer where I add several TextSymbols. I'd like to be able to have a List of TextSymbols returned by my layer, so I extended the GraphicsLayer class  and just added a simple function that retrieves the Graphics and cast them into TextSymbols. All good so far until I tried it. Here is the code:

public List<TextSymbol> TextSymbolList(){                           List<TextSymbol> l = new List<TextSymbol>();             foreach (Graphic g in this.Graphics)             {                 l.Add((TextSymbol)g); //THIS DOES NOT WORK             }                          return l;         }


So, my question is, how is it that I can add the TextSymbol object to the Graphics list but I cannot retrieve it or cast it back to TextSymbol? How can I accomplish this or something similar? Any suggestions?
Thanks!
0 Kudos
1 Solution

Accepted Solutions
LuisGarcia2
Deactivated User
Never mind, I just realized that the TextSymbol is actually being added to a graphics object as the symbol.

View solution in original post

0 Kudos
2 Replies
LuisGarcia2
Deactivated User
Never mind, I just realized that the TextSymbol is actually being added to a graphics object as the symbol.
0 Kudos
Andréde_Mattos_Ferraz
Deactivated User
        public List<TextSymbol> TextSymbolList(){

            
            List<TextSymbol> l = new List<TextSymbol>();
            foreach (Graphic g in this.Graphics)
            {
                g.symbol = l;
                // If you have a graphic layer 
                graphicLayer.add(g);
                //This is wrong!!!
                //l.Add((TextSymbol)g); //THIS DOES NOT WORK
            }
            
            return l;
        }
0 Kudos