private void OnCurrentMapLayer(MapLayersHandler s, LayerEventArg e)
 {
     _currentMapLayer = _mapLayersHandler.get_MapLayer(e.LayerHandle);
     _dropDownContext = "";
     if (_currentMapLayer.Name == "Fishing grid boundaries")
     {
         _dropDownContext = "FishingGridBoundary";
     }
 }
        public static int MapGPX(GPXFile gpxFile, out int shpIndex, out List <int> handles, bool showInMap = true)
        {
            shpIndex = -1;
            handles  = new List <int>();
            var utils       = new MapWinGIS.Utils();
            var shpfileName = "";

            if (showInMap)
            {
                if (gpxFile != null)
                {
                    Shapefile sf = null;
                    if (gpxFile.TrackCount > 0)
                    {
                        //sf = ShapefileFactory.TrackFromGPX(gpxFile,out shpIndex);
                        sf = ShapefileFactory.TracksFromGPXFiles(gpxFile, out handles);
                        //var result = ShapefileFactory.CreateTripAndHaulsFromGPX(gpxFile);
                        //sf = result.Shapefile;
                        //handles.Add(result.Handle);
                        //Console.WriteLine($"shapefile with {sf.Shape[0].numPoints} created. Handle is {result.Handle}");
                        shpfileName = "GPX tracks";
                    }
                    else if (gpxFile.WaypointCount > 0)
                    {
                        sf          = ShapefileFactory.NamedPointsFromGPX(gpxFile, out handles);
                        shpfileName = "GPX waypoints";
                    }
                    //MapWindowForm.Title =$"Number of layers:{MapControl.NumLayers}";
                    MapLayersHandler.AddLayer(sf, shpfileName, uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true);

                    if (gpxFile.TrackCount > 0)
                    {
                        GPXTracksLayer = MapLayersHandler.CurrentMapLayer;
                    }
                    else if (gpxFile.WaypointCount > 0)
                    {
                        GPXWaypointsLayer = MapLayersHandler.CurrentMapLayer;
                    }

                    return(MapLayersHandler.CurrentMapLayer.Handle);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                var ly = MapLayersHandler.get_MapLayer(gpxFile.FileName);
                MapLayersHandler.RemoveLayer(ly.Handle);
                return(-1);
            }
        }
        private static string InsertCustomSettingToMapState(string xml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            var mapstate = doc.GetElementsByTagName("MapState").Item(0);

            var          coastlineLayer = MapLayersHandler.get_MapLayer("Coastline");
            XmlAttribute attr           = doc.CreateAttribute("HasCoastline");

            attr.Value = coastlineLayer != null ? "1" : "0";
            mapstate.Attributes.SetNamedItem(attr);

            if (coastlineLayer != null)
            {
                attr       = doc.CreateAttribute("CoastlineVisible");
                attr.Value = coastlineLayer.Visible ? "1" : "0";
                mapstate.Attributes.SetNamedItem(attr);
            }
            return(doc.OuterXml);
        }