How to simulate a moving and resizing elements with transparency?

591
1
07-09-2012 08:36 PM
AnatoliiTerentiev
Occasional Contributor III
I need to provide an opportunity to drag on the map image with a transparent background with the ability to move and resize it as it can be done with element.
Ideal solution to moving and resizing is element, but it does not allow transparent background.
Is it possible to implement this with symbols  as easy as using the elements? Any ideas or reference?
0 Kudos
1 Reply
AnatoliiTerentiev
Occasional Contributor III
Problem solved with the next code:

        ///<summary>Draw a specified graphic on the map using the supplied colors.</summary>
        ///      
        ///<param name="map">An IMap interface.</param>
        ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param>
        ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param>
        ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param>
        ///      
        ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks>
        public void AddGraphicToMap(double x, double y)
        {
            ESRI.ArcGIS.Display.IRgbColor rgbColorCls = new ESRI.ArcGIS.Display.RgbColorClass();
            rgbColorCls.Red = 255;
            rgbColorCls.Green = 255;
            rgbColorCls.Blue = 255;

            ESRI.ArcGIS.Geometry.Point p = new ESRI.ArcGIS.Geometry.Point();
            p.X = x;
            p.Y = y;
            ESRI.ArcGIS.Geometry.IGeometry geometry = (IGeometry)p;

            ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)axMapControl1.Map; // Explicit Cast
            ESRI.ArcGIS.Carto.IElement element = null;

            IPictureMarkerSymbol MarkerSymbol = new ESRI.ArcGIS.Display.PictureMarkerSymbol();

            MarkerSymbol.Size = 50;
            MarkerSymbol.BitmapTransparencyColor = rgbColorCls;


            MarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, @"D:\__VS\�?конки\Новая папка\�?она пожа�?а с�?ема.bmp");

            ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass();
            markerElement.Symbol = MarkerSymbol;
            element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast

            element.Geometry = geometry;
            graphicsContainer.AddElement(element, 0);
            
            IActiveView activeView = axMapControl1.Map as IActiveView;
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, MarkerSymbol, null);            
        }
0 Kudos