private void gotoCurpos_MouseDown(object sender, MouseButtonEventArgs e)
 {
     MapControl.Marker m = curposMarker.DataContext as MapControl.Marker;
     if (m != null)
     {
         this.tileCanvas.Center(m.Latitude, m.Longitude, this.tileCanvas.Zoom);
     }
 }
 public void SetCacheMarker(MapControl.Marker marker)
 {
     if (marker == null)
     {
         this.cacheMarker.Visibility = Visibility.Hidden;
     }
     else
     {
         this.tileCanvas.Center(marker.Latitude, marker.Longitude, this.tileCanvas.Zoom);
         this.cacheMarker.Visibility = Visibility.Visible;
     }
     this.cacheMarker.DataContext = marker;
 }
Beispiel #3
0
        private void clusterGeocaches(bool recluster)
        {
            List <MapControl.Marker> mlist = new List <MapControl.Marker>();

            if (!radioButtonActive.Checked)
            {
                double lat1     = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(0, this.mapContainerControl1.MapCanvas.Zoom);
                double lat2     = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(1, this.mapContainerControl1.MapCanvas.Zoom);
                double deltaLat = 200 * (lat1 - lat2) / 256.0; //200px
                double lon1     = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(0, this.mapContainerControl1.MapCanvas.Zoom);
                double lon2     = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(1, this.mapContainerControl1.MapCanvas.Zoom);
                double deltaLon = 200 * (lon2 - lon1) / 256.0; //200px
                if (_clusterGeocaches == null || recluster)
                {
                    _clusterGeocaches = new MapControl.MarkerClusterer(deltaLat, deltaLon);

                    bool addAll    = radioButtonAll.Checked;
                    bool doCluster = this.mapContainerControl1.MapCanvas.Zoom < 12;
                    foreach (Framework.Data.Geocache gc in _core.Geocaches)
                    {
                        if (gc != _core.ActiveGeocache && (addAll || gc.Selected))
                        {
                            _clusterGeocaches.AddMarker(gc, doCluster);
                        }
                    }
                }
                //add markers
                foreach (var b in _clusterGeocaches.Buckets)
                {
                    MapControl.Marker m = new MapControl.Marker();
                    m.Latitude  = b.Latitude;
                    m.Longitude = b.Longitude;
                    if (b.Count == 1)
                    {
                        m.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, b.Geocache.GeocacheType, b.Geocache.ContainsCustomLatLon);
                        m.Tag       = b.Geocache;
                    }
                    else
                    {
                        m.ImagePath = "";
                        m.Tag       = b.Count;
                    }
                    mlist.Add(m);
                }
            }
            this.mapContainerControl1.SetGeocacheMarkers(mlist);
        }
Beispiel #4
0
        void _core_ActiveGeocacheChanged(object sender, Framework.EventArguments.GeocacheEventArgs e)
        {
            if (this.Visible)
            {
                if (_activeGeocache != _core.ActiveGeocache)
                {
                    if (_core.ActiveGeocache != null)
                    {
                        MapControl.Marker m = new MapControl.Marker();
                        if (_core.ActiveGeocache.ContainsCustomLatLon)
                        {
                            this.mapContainerControl1.MapCanvas.Center((double)_core.ActiveGeocache.CustomLat, (double)_core.ActiveGeocache.CustomLon, this.mapContainerControl1.MapCanvas.Zoom);
                            m.Latitude  = (double)_core.ActiveGeocache.CustomLat;
                            m.Longitude = (double)_core.ActiveGeocache.CustomLon;
                        }
                        else
                        {
                            this.mapContainerControl1.MapCanvas.Center(_core.ActiveGeocache.Lat, _core.ActiveGeocache.Lon, this.mapContainerControl1.MapCanvas.Zoom);
                            m.Latitude  = _core.ActiveGeocache.Lat;
                            m.Longitude = _core.ActiveGeocache.Lon;
                        }
                        m.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, _core.ActiveGeocache.GeocacheType, _core.ActiveGeocache.ContainsCustomLatLon);

                        List <Framework.Data.Waypoint> wps       = Utils.DataAccess.GetWaypointsFromGeocache(_core.Waypoints, _core.ActiveGeocache.Code);
                        List <MapControl.Marker>       wpmarkers = new List <MapControl.Marker>();
                        foreach (Framework.Data.Waypoint wp in wps)
                        {
                            if (wp.Lat != null && wp.Lon != null)
                            {
                                MapControl.Marker wpm = new MapControl.Marker();
                                wpm.Latitude  = (double)wp.Lat;
                                wpm.Longitude = (double)wp.Lon;
                                wpm.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, wp.WPType);
                                wpmarkers.Add(wpm);
                            }
                        }
                        this.mapContainerControl1.SetWaypointMarkers(wpmarkers);
                        this.mapContainerControl1.SetCacheMarker(m);
                    }
                    else
                    {
                        this.mapContainerControl1.SetCacheMarker(null);
                    }
                }
                UpdateView(false);
            }
        }
 void rootElement_MouseDown(object sender, MouseButtonEventArgs e)
 {
     MapControl.Marker m = (sender as Grid).DataContext as MapControl.Marker;
     if (m.Tag is Framework.Data.Geocache)
     {
         if (GeocacheClick != null)
         {
             GeocacheClick(this, new Framework.EventArguments.GeocacheEventArgs(m.Tag as Framework.Data.Geocache));
         }
     }
     else
     {
         if (tileCanvas.Zoom < _mapControlFactory.TileGenerator.MaxZoom)
         {
             tileCanvas.Center(m.Latitude, m.Longitude, tileCanvas.Zoom + 1);
         }
     }
 }
Beispiel #6
0
 void GPSLocation_Updated(object sender, Framework.EventArguments.GPSLocationEventArgs e)
 {
     if (this.Visible)
     {
         if (e.Location.Valid)
         {
             MapControl.Marker wpm = new MapControl.Marker();
             wpm.Latitude  = e.Location.Position.Lat;
             wpm.Longitude = e.Location.Position.Lon;
             wpm.ImagePath = System.IO.Path.Combine(new string[] { System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "Images", "Map", "curpos.png" });
             this.mapContainerControl1.SetCurposMarker(wpm);
         }
         else
         {
             this.mapContainerControl1.SetCurposMarker(null);
         }
     }
 }
 public void SetCurposMarker(MapControl.Marker marker)
 {
     if (marker == null)
     {
         this.curposMarker.Visibility = Visibility.Hidden;
         this.gotoCurpos.Visibility   = Visibility.Hidden;
     }
     else
     {
         if (this.curposMarker.Visibility != Visibility.Visible)
         {
             this.curposMarker.Visibility = Visibility.Visible;
         }
         if (this.gotoCurpos.Visibility != Visibility.Visible)
         {
             this.gotoCurpos.Visibility = Visibility.Visible;
         }
     }
     this.curposMarker.DataContext = marker;
 }
Beispiel #8
0
 void Waypoints_ListDataChanged(object sender, EventArgs e)
 {
     if (this.Visible && _core.ActiveGeocache != null)
     {
         List <Framework.Data.Waypoint> wps       = Utils.DataAccess.GetWaypointsFromGeocache(_core.Waypoints, _core.ActiveGeocache.Code);
         List <MapControl.Marker>       wpmarkers = new List <MapControl.Marker>();
         foreach (Framework.Data.Waypoint wp in wps)
         {
             if (wp.Lat != null && wp.Lon != null)
             {
                 MapControl.Marker wpm = new MapControl.Marker();
                 wpm.Latitude  = (double)wp.Lat;
                 wpm.Longitude = (double)wp.Lon;
                 wpm.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, wp.WPType);
                 wpmarkers.Add(wpm);
             }
         }
         this.mapContainerControl1.SetWaypointMarkers(wpmarkers);
         this.mapContainerControl1.MapCanvas.RepositionChildren();
     }
 }
Beispiel #9
0
 void Waypoints_ListDataChanged(object sender, EventArgs e)
 {
     if (this.Visible && _core.ActiveGeocache!=null)
     {
         List<Framework.Data.Waypoint> wps = Utils.DataAccess.GetWaypointsFromGeocache(_core.Waypoints, _core.ActiveGeocache.Code);
         List<MapControl.Marker> wpmarkers = new List<MapControl.Marker>();
         foreach (Framework.Data.Waypoint wp in wps)
         {
             if (wp.Lat != null && wp.Lon != null)
             {
                 MapControl.Marker wpm = new MapControl.Marker();
                 wpm.Latitude = (double)wp.Lat;
                 wpm.Longitude = (double)wp.Lon;
                 wpm.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, wp.WPType);
                 wpmarkers.Add(wpm);
             }
         }
         this.mapContainerControl1.SetWaypointMarkers(wpmarkers);
         this.mapContainerControl1.MapCanvas.RepositionChildren();
     }            
 }
Beispiel #10
0
        void _core_ActiveGeocacheChanged(object sender, Framework.EventArguments.GeocacheEventArgs e)
        {
            if (this.Visible)
            {
                if (_activeGeocache != _core.ActiveGeocache)
                {
                    if (_core.ActiveGeocache != null)
                    {
                        MapControl.Marker m = new MapControl.Marker();
                        if (_core.ActiveGeocache.ContainsCustomLatLon)
                        {
                            this.mapContainerControl1.MapCanvas.Center((double)_core.ActiveGeocache.CustomLat, (double)_core.ActiveGeocache.CustomLon, this.mapContainerControl1.MapCanvas.Zoom);
                            m.Latitude = (double)_core.ActiveGeocache.CustomLat;
                            m.Longitude = (double)_core.ActiveGeocache.CustomLon;
                        }
                        else
                        {
                            this.mapContainerControl1.MapCanvas.Center(_core.ActiveGeocache.Lat, _core.ActiveGeocache.Lon, this.mapContainerControl1.MapCanvas.Zoom);
                            m.Latitude = _core.ActiveGeocache.Lat;
                            m.Longitude = _core.ActiveGeocache.Lon;
                        }
                        m.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, _core.ActiveGeocache.GeocacheType, _core.ActiveGeocache.ContainsCustomLatLon);

                        List<Framework.Data.Waypoint> wps = Utils.DataAccess.GetWaypointsFromGeocache(_core.Waypoints, _core.ActiveGeocache.Code);
                        List<MapControl.Marker> wpmarkers = new List<MapControl.Marker>();
                        foreach (Framework.Data.Waypoint wp in wps)
                        {
                            if (wp.Lat != null && wp.Lon != null)
                            {
                                MapControl.Marker wpm = new MapControl.Marker();
                                wpm.Latitude = (double)wp.Lat;
                                wpm.Longitude = (double)wp.Lon;
                                wpm.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, wp.WPType);
                                wpmarkers.Add(wpm);
                            }
                        }
                        this.mapContainerControl1.SetWaypointMarkers(wpmarkers);
                        this.mapContainerControl1.SetCacheMarker(m);
                    }
                    else
                    {
                        this.mapContainerControl1.SetCacheMarker(null);
                    }
                }
                UpdateView(false);
            }
        }
Beispiel #11
0
        private void clusterGeocaches(bool recluster)
        {
            List<MapControl.Marker> mlist = new List<MapControl.Marker>();
            if (!radioButtonActive.Checked)
            {
                double lat1 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(0, this.mapContainerControl1.MapCanvas.Zoom);
                double lat2 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(1, this.mapContainerControl1.MapCanvas.Zoom);
                double deltaLat = 200 * (lat1 - lat2) / 256.0; //200px
                double lon1 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(0, this.mapContainerControl1.MapCanvas.Zoom);
                double lon2 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(1, this.mapContainerControl1.MapCanvas.Zoom);
                double deltaLon = 200 * (lon2 - lon1) / 256.0; //200px
                if (_clusterGeocaches == null || recluster)
                {
                    _clusterGeocaches = new MapControl.MarkerClusterer(deltaLat, deltaLon);

                    bool addAll = radioButtonAll.Checked;
                    bool doCluster = this.mapContainerControl1.MapCanvas.Zoom<12;
                    foreach (Framework.Data.Geocache gc in _core.Geocaches)
                    {
                        if (gc != _core.ActiveGeocache && (addAll || gc.Selected))
                        {
                            _clusterGeocaches.AddMarker(gc, doCluster);
                        }
                    }
                }
                //add markers
                foreach (var b in _clusterGeocaches.Buckets)
                {
                    MapControl.Marker m = new MapControl.Marker();
                    m.Latitude = b.Latitude;
                    m.Longitude = b.Longitude;
                    if (b.Count == 1)
                    {
                        m.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, b.Geocache.GeocacheType, b.Geocache.ContainsCustomLatLon);
                        m.Tag = b.Geocache;
                    }
                    else
                    {
                        m.ImagePath = "";
                        m.Tag = b.Count;
                    }
                    mlist.Add(m);
                }
            }
            this.mapContainerControl1.SetGeocacheMarkers(mlist);
        }
Beispiel #12
0
 void GPSLocation_Updated(object sender, Framework.EventArguments.GPSLocationEventArgs e)
 {
     if (this.Visible)
     {
         if (e.Location.Valid)
         {
             MapControl.Marker wpm = new MapControl.Marker();
             wpm.Latitude = e.Location.Position.Lat;
             wpm.Longitude = e.Location.Position.Lon;
             wpm.ImagePath = System.IO.Path.Combine(new string[] { System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "Images", "Map", "curpos.png" });
             this.mapContainerControl1.SetCurposMarker(wpm);
         }
         else
         {
             this.mapContainerControl1.SetCurposMarker(null);
         }
     }
 }