AnsweredAssumed Answered

Tif Image Insert Problem in ArcMap

Question asked by ihuilcap on Oct 24, 2013
Latest reply on Oct 13, 2015 by SEria-esristaff
Hello everyone.
I have developed a tool with Visual Studio 2010, which inserts an image. Tif to give the user click in the area of view of ArcMap, the image is inserted into the TOC but no picture in the area of view, but to move your mouse to pan tool, you can view the picture but remains visible in the area of view.
I attached the script.

++++++ script
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
            IMxDocument mxdoc = ArcMap.Document;

            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = mxdoc.ActiveView.ScreenDisplay;
            punto = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
            string dir = @"\\Miserver\imagenes\";
            ESRI.ArcGIS.Carto.IActiveView activeView = mxdoc.ActivatedView;
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)
                ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit cast.
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new

            ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as
                ESRI.ArcGIS.Display.ISymbol; // Dynamic cast.
            ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation =


            IWorkspace espacio = VersionedArcSdeWorkspace("MiserverGis", "sde:sqlserver:MiserverGis", "MiBaseGis", "dbo.DEFAULT");
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)espacio;
            IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("MiBaseGis.dbo.Grilaimg");
            IGeometry queryGeometry = punto;           
            // Create the spatial filter. "highwayFeatureClass" is the feature class containing
            // the highway data. Set the SubFields property to "FULL_NAME", as only that field is
            // going to be displayed.
            ISpatialFilter spatialFilter = new SpatialFilterClass();
            spatialFilter.Geometry = queryGeometry;
            spatialFilter.GeometryField = featureClass.ShapeFieldName;
            spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;          
            spatialFilter.SubFields = "NH";
            // Find the position of the "FULL_NAME" field in the highway feature class.
            int nameNH = featureClass.FindField("NH");
            // Execute the query and iterate through the cursor's results.
            IFeatureCursor highwayCursor = featureClass.Search(spatialFilter, false);
            IFeature highwayFeature = null;
            string varNh = string.Empty;
            string hoja = string.Empty;
            if ((highwayFeature = highwayCursor.NextFeature()) != null)
                varNh = highwayFeature.get_Value(nameNH).ToString();  
                Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory");
                IWorkspaceFactory wsFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
                IRasterWorkspace2 rasterWS = (IRasterWorkspace2)wsFactory.OpenFromFile(dir,0);
                IRasterDataset rds = rasterWS.OpenRasterDataset("h"+varNh + ".tif");
                IRasterLayer rasterLayer = new RasterLayerClass();

                IMap mapa = activeView.FocusMap;

            else MessageBox.Show("image not found.");