How can I access pictures drawn by ControlsNewFreeHandToolClass?

611
1
06-08-2012 04:56 AM
SergioMunoz
New Contributor
Hello everyone,

I need to allow user to draw anything on the map. I have achieved this with the ControlsNewFreeHandToolClass, so when user click on the button and after that he clicks and drag, a new picture is drawn:

ICommand pCommand = new ControlsNewFreeHandToolClass();
pCommand.OnCreate(map.Object);
map.CurrentTool = pCommand as ITool;


The problem now is, how can I access the picture? I mean, what if I want to resize it, or remove it, or move it? It has to exist an object anywhere representing that picture... Actually, after drawing the picture, a square appears surrounding the picture, with eight points, as if I could drag and click on them...

[ATTACH=CONFIG]15059[/ATTACH]

Besides that, what if I want to change the line color, or size, before drawing? Is it possible?

Thank you very much in advance, the API is not very useful, at least in this case...
0 Kudos
1 Reply
SergioMunoz
New Contributor
Ok, I have achieved to access the object, but I still don't know how to modify it. The way to get the object is the following:

               
                List<IGraphicsContainer> graphicsContainers = GISUtil.layers.get_LayerSymbols_graphicContainerAll(ref map);
                graphicsContainers.Add(((IGraphicsContainer)(IActiveView)map.Map));
                for (int i = 0; i < graphicsContainers.Count; i++)
                {
                    graphicsContainers.Reset();
                    IElement element = graphicsContainers.Next();

                    while (element != null)
                    {
                        element = graphicsContainers.Next();
                    }
                }

        public List<IGraphicsContainer> get_LayerSymbols_graphicContainerAll(ref AxMapControl map) {

            List<IGraphicsContainer> result = new List<IGraphicsContainer>();

            //Try to get the requested symbols layer as a graphics layer. If none was found, return the map's main one.
            try {
                ICompositeLayer mainGraphicsLayer = (ICompositeLayer)map.get_Layer(0);
                for (int i = 0; i < mainGraphicsLayer.Count; i++) {
                    result.Add((IGraphicsContainer)mainGraphicsLayer.get_Layer(i));
                }
            } 
            catch (Exception e) {
                LogFile.appendLine_error(e);
            }

            return result;
        }


The problem of this object is that I cannot cast it to anything, when I see information in Intellisense about the object, it is a System.__ComObject. Other objects in the map are ESRI.ArcGIS.Carto.MarkerElementClass or ESRI.ArcGIS.Carto.TextElementClass. Also, I don't know programatically if the object I am accessing to is the picture drawn, or another type of object. I know that its geometry type is esriGeometryType.esriGeometryPolyline, but I have more polylines in the map, so I cannot differentiate it...
0 Kudos