Ejemplo n.º 1
0
        private async void OnAddGeocacheClickAsync(object sender, RoutedEventArgs args)
        {
            if (activePinPerson == null)
            {
                MessageBox.Show("Select Person First", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var dialog = new GeocacheDialog
            {
                Owner = this
            };

            dialog.ShowDialog();
            if (dialog.DialogResult == false)
            {
                return;
            }

            string contents = dialog.GeocacheContents;
            string message  = dialog.GeocacheMessage;

            string tooltip = $"Latitude:\t\t{latestClickLocation.Latitude}\r\nLongitude:\t{latestClickLocation.Longitude}\r\n" +
                             $"Made by:\t{activePinPerson.FirstName + " " + activePinPerson.LastName}\r\n" +
                             $"Contents:\t{contents}\r\nMessage:\t{message}";


            // Add geocache to map and database here.
            Pushpin pin = AddPin(latestClickLocation, tooltip, Colors.Black);

            pin.MouseLeftButtonDown += OnCachePinClick;

            var geocache = new Geocache()
            {
                Contents    = contents,
                Coordinates = latestClickLocation,
                Message     = message
            };

            await _db.AddGeocacheAsync(geocache, activePinPerson.ID);

            pin.Tag = new Dictionary <string, ITag> {
                ["Person"] = activePinPerson, ["Geocache"] = geocache
            };
            cachePins.Add(pin);
        }