private void RemoveMarker(RouteMarker rm)
 {
     RouteCreatorMap.Markers.Remove(rm.Marker);
     rm.Marker.Clear();
     _mapPoints.Remove(rm);
     UpdateMarkerCounter();
     CheckRouteServicePreffer();
 }
        private void CreateNewMarker(PointLatLng mapPos, bool starter)
        {
            var markerShape = starter ? Properties.Resources.force_move.ToImage("Route Marker - START") :
                              Properties.Resources.wp.ToImage("Route Marker - Waypoint");
            var marker = new GMapMarker(mapPos)
            {
                Shape    = markerShape,
                Offset   = starter ? new Point(-24, -48) : new Point(-16, -32),
                ZIndex   = int.MaxValue,
                Position = mapPos
            };
            var rm = new RouteMarker
            {
                IsStart  = starter,
                Location = new GeoCoordinate(mapPos.Lat, mapPos.Lng),
                Marker   = marker
            };

            markerShape.MouseLeftButtonDown += delegate { RemoveMarker(rm); };
            AddMarker(rm, starter);
        }
 internal void AddMarker(RouteMarker marker, bool starter)
 {
     if (starter)
     {
         try
         {
             while (_mapPoints.Any(x => x.IsStart))
             {
                 var mark = _mapPoints.First(x => x.IsStart);
                 RemoveMarker(mark);
             }
         }
         catch (Exception)
         {
             //ignore
         }
     }
     _mapPoints.Add(marker);
     RouteCreatorMap.Markers.Add(marker.Marker);
     UpdateMarkerCounter();
     CheckRouteServicePreffer();
 }
        private void CreateNewMarker(PointLatLng mapPos, bool starter)
        {
            var marker = new GMapMarker(mapPos)
            {
                Offset   = starter ? new Point(-24, -48) : new Point(-16, -32),
                ZIndex   = int.MaxValue,
                Position = mapPos
            };

            var imgSource = starter
                ? Properties.Resources.force_move.LoadBitmap()
                : Properties.Resources.wp.LoadBitmap();

            var tooltipText = starter
                ? TranslationEngine.GetDynamicTranslationString("%ROUTE_MARKER_START%", "Route Marker - START")
                : TranslationEngine.GetDynamicTranslationString("%ROUTE_MARKER_WP%", "Route Marker - Waypoint") +
                              $" {_currentIndex++}";

            var rm = new RouteMarker(imgSource, tooltipText, RouteCreatorMap, this)
            {
                IsStart  = starter,
                Location = new GeoCoordinate(mapPos.Lat, mapPos.Lng),
                Marker   = marker
            };

            marker.Shape            = rm;
            rm.MouseLeftButtonDown += delegate
            {
                if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                {
                    RemoveMarker(rm);
                }
            };

            AddMarker(rm, starter);
        }