Exemplo n.º 1
0
 private async void MyTripsItem_Loaded(object sender, RoutedEventArgs e)
 {
     tripItem = ((MyTripsItem)sender).DataContext as Trip;
     if (tripItem != null)
     {
         DateTime startTime = tripItem.StartPin.DateCreated.DateTime;
         DateTime endTime = DateTime.Now;
         if (tripItem.EndPin != null)
             endTime = tripItem.EndPin.DateCreated.DateTime;
         bool result = await GetPinsForGivenDate(startTime, endTime);
         if (string.IsNullOrEmpty(tripItem.StartPin.Name))
         {
             await LocationHelper.TryUpdateMissingLocationInfoAsync(tripItem.StartPin, null);
         }
     }
 }
Exemplo n.º 2
0
 private async void submitButton_Click(object sender, RoutedEventArgs e)
 {
     if (App.PageName.Equals("Start Trip"))
     {
         var item = new Trip
         {
             Name = NameTb.Text,
             Description = DescTb.Text,
             ShareWith = shareTb.Text,
             Type = "On-going",
             StartPin = oldPin
         };
         await localData.CreateNewTrip(item);
     }
     else if (App.PageName.Equals("End Trip"))
     {
         tripItem.EndPin = oldPin;
         tripItem.Type = "Completed";
         await localData.EditTrip(tripItem);
     }
     this.Frame.GoBack();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the saved location data on first navigation, and 
        /// attaches a Geolocator.StatusChanged event handler. 
        /// </summary>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (App.PageName.Equals("Start Trip"))
            {
                bool getPins = await GetPinsForGivenDate();
                if (this.ViewModel.CheckedLocations.Count > 0)
                {
                    oldPin = this.ViewModel.CheckedLocations[0];
                    oldPin.IsSelected = true;
                    selectedImage.Source = await PhotoHelper.getImageSource(this.ViewModel.CheckedLocations[0].Photo.ImageName);
                }
                else if(this.ViewModel.PinnedLocations.Count>0)
                {
                    oldPin = this.ViewModel.PinnedLocations[0];
                }
                else
                {
                    oldPin = new LocationPin
                    {
                        DateCreated = HistoryDatePicker.Date,
                    };
                }
            }
            else if (App.PageName.Equals("End Trip"))
            {
                tripItem = e.Parameter as Trip;
                NameTb.Text = tripItem.Name;
                shareTb.Text = tripItem.ShareWith;
                DescTb.Text = tripItem.Description;
                startDateTb.Text = "End Date";
                startPointTb.Text = "End Point";
                submitButton.Content = "End Trip";
                bool getPins = await GetPinsForGivenDate();
                if (this.ViewModel.CheckedLocations.Count > 0)
                {
                    oldPin = this.ViewModel.CheckedLocations[this.ViewModel.CheckedLocations.Count - 1];
                    oldPin.IsSelected = true;
                    selectedImage.Source = await PhotoHelper.getImageSource(this.ViewModel.CheckedLocations[this.ViewModel.CheckedLocations.Count - 1].Photo.ImageName);
                }
                else if (this.ViewModel.PinnedLocations.Count > 0)
                {
                    oldPin = this.ViewModel.PinnedLocations[this.ViewModel.PinnedLocations.Count-1];
                }
                else
                {
                    oldPin = new LocationPin {
                        DateCreated = HistoryDatePicker.Date,
                    };
                }
            }

            if (e.NavigationMode == NavigationMode.New)
            {

            }
        }