/// <summary>
        /// Opens specified grid layer using MapWinGIS global settings
        /// </summary>
        public static void OpenGridLayer(string filename, bool useFileManager)
        {
            axMap1.RemoveAllLayers();

            if (useFileManager)
            {
                //FileManager fm = new FileManager();
                //Image img = fm.OpenRaster(filename, tkFileOpenStrategy.fosProxyForGrid);
                //axMap1.AddLayer(img, true);
                axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosAutoDetect, true);
            }
            else
            {
                if (!File.Exists(filename))
                {
                    MessageBox.Show("Failed to find grid: " + filename);
                }
                else
                {
                    Grid grid = new Grid {
                        GlobalCallback = callback
                    };

                    if (grid.Open(filename, GridDataType.UnknownDataType, false, GridFileType.UseExtension, null))
                    {
                        int layerHandle = axMap1.AddLayer(grid, true);
                        if (layerHandle != -1)
                        {
                            var img = axMap1.get_Image(layerHandle);
                            if (img != null)
                            {
                                Debug.Print("Number of bands: " + img.NoBands);
                                Debug.Print("Allow external color scheme: " + img.AllowGridRendering);
                                MessageBox.Show("Layer was added to the map");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Failed to load layer: " + axMap1.get_ErrorMsg(axMap1.LastErrorCode));
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to open grid");
                    }

                    //grid.Close();
                }
            }
        }
        public static Image GetActiveLayer(this AxMapWinGIS.AxMap map)
        {
            int handle = map.GetLayerHandle();

            return(map.get_Image(handle));
        }