Exemplo n.º 1
0
        private async void PostButton_Click(object sender, RoutedEventArgs e)
        {
            var position = App.currentLocation.Position;

            if (isRandomPhotoLocation)
            {
                position = LocationHelper.getRandomLocation(App.currentLocation.Position);
            }

            var item = new LocationPin
            {
                Position = position,
                Photo    = new SharedPhoto
                {
                    ShareWith   = contactPickerTb.Text,
                    ImageName   = imageName,
                    Description = DescriptionTb.Text,
                },
                IsCheckPoint = true,
                DateCreated  = App.currentLocation.DateCreated
            };
            await localData.InsertLocationDataAsync(item);

            App.PageName = "TripTrak";
            this.Frame.GoBack();
        }
Exemplo n.º 2
0
 private void Geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
 {
     var _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
     {
         if (args.Position.Coordinate.Accuracy < 55)
         {
             var item = new LocationPin
             {
                 Position = args.Position.Coordinate.Point.Position,
                 Speed    = args.Position.Coordinate.Speed
             };
             if (DateTime.Now.Date == HistoryDatePicker.Date.Date)
             {
                 if (this.ViewModel.CheckedLocations.Count > 0)
                 {
                     var currentLoc = this.ViewModel.CheckedLocations.FirstOrDefault(loc => loc.IsCurrentLocation == true);
                     if (currentLoc != null && currentLoc.IsCurrentLocation)
                     {
                         this.ViewModel.CheckedLocations.Remove(currentLoc);
                     }
                 }
                 this.ViewModel.PinnedLocations.Add(item);
                 this.ViewModel.CheckedLocations.Add(new LocationPin {
                     Position = item.Position, IsCurrentLocation = true
                 });
                 bool isInView = false;
                 this.InputMap.IsLocationInView(new Geopoint(item.Position), out isInView);
                 if (isInView)
                 {
                     this.InputMap.Center = new Geopoint(item.Position);
                 }
             }
             await localData.InsertLocationDataAsync(item);
         }
     });
 }