/// <summary>
        /// Toggles between direct rendering and proxy rendering for an image which visualizes a grid.
        /// </summary>
        public static void UpdateProxyMode(Image img, bool proxyNeeded)
        {
            var grid    = img.OpenAsGrid();
            var extents = axMap1.Extents as IExtents;

            if (extents != null)
            {
                Debug.Print(extents.ToDebugString());
            }
            grid.GlobalCallback = callback;
            axMap1.RemoveAllLayers();
            grid.PreferedDisplayMode = proxyNeeded ? tkGridProxyMode.gpmUseProxy : tkGridProxyMode.gpmNoProxy;
            axMap1.AddLayer(grid, true);
            axMap1.Extents = extents;
        }
Exemple #2
0
        private static bool DisplayAllLayers()
        {
            var ds = new OgrDatasource();

            if (!ds.Open(CONNECTION_STRING))
            {
                Debug.WriteLine("Failed to establish connection: " + ds.GdalLastErrorMsg);
            }
            else
            {
                map.RemoveAllLayers();

                // make sure it matches SRID of the layers (4326 in this case)
                map.Projection = tkMapProjection.PROJECTION_WGS84;

                for (int i = 0; i < ds.LayerCount; i++)
                {
                    var layer = ds.GetLayer(i);
                    if (layer != null)
                    {
                        int handle = map.AddLayer(layer, true);
                        if (handle == -1)
                        {
                            Debug.WriteLine("Failed to add layer to the map: " + map.get_ErrorMsg(map.LastErrorCode));
                        }
                        else
                        {
                            Debug.WriteLine("Layer was added the map: " + layer.Name);
                        }
                    }
                }
                map.ZoomToMaxVisibleExtents();
                ds.Close();
            }
            return(true);
        }
Exemple #3
0
        public static void StartMeasureingTool(tkMeasuringType toolType, string filename)
        {
            var sf = new Shapefile();

            if (!sf.Open(filename))
            {
                MessageBox.Show("Failed to open shapefile");
            }
            else
            {
                var ut = new Utils();
                axMap1.RemoveAllLayers();
                int handle = axMap1.AddLayer(sf, true);
                axMap1.ZoomToLayer(handle);
                axMap1.Measuring.MeasuringType = toolType;
                axMap1.CursorMode = tkCursorMode.cmMeasure;
            }
        }