Example #1
0
        public async void ExecuteStopCommand()
        {
            EndDialog dialog = new EndDialog();
            await dialog.ShowAsync();

            if (dialog.DiagResult == ContentDialogResult.Primary)
            {
                CurrentTripDataRepo.DriveValue = EnumHelper.DeParse(DriveStateStatus.TripCompleted);

                if (SelectedTripData.IsTripComplete != true)
                {
                    CurrentTripDataRepo.EndTime = DateTime.Now;
                    upTimer.Stop();
                    TripSummary.SetBusy(true);

                    SelectedTripData.TripEndTime    = CurrentTripDataRepo.EndTime;
                    SelectedTripData.IsTripComplete = true;
                    SelectedTripData.Pay            = CurrentTripDataRepo.SelectedPayStatus = dialog.SelectedPayStatus;
                    SelectedTripData.Mode           = CurrentTripDataRepo.SelectedPayMode = dialog.SelectedPayMode;
                    tripDataManager.SaveTrip(SelectedTripData);
                }

                geoLocationService.PositionChanged -= GeoLocationService_PositionChanged;
                geoLocationService.StopListening();
                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
                GotoHomeTaskCommand.RaiseCanExecuteChanged();
            }
        }
Example #2
0
        public async void ExecuteStartCommand()
        {
            BeginDialog dialog = new BeginDialog();
            await dialog.ShowAsync();

            if (dialog.DiagResult == ContentDialogResult.Primary)
            {
                CurrentTripDataRepo.DriveValue = EnumHelper.DeParse(DriveStateStatus.TripStarted);
                smartTimer.StopTimer();
                upTimer.Start();

                if (SelectedTripData.IsTripStarted != true)
                {
                    SelectedTripData.TripStartTime = CurrentTripDataRepo.StartTime = DateTime.Now;
                    SelectedTripData.IsTripStarted = CurrentTripDataRepo.IsTripStarted = true;
                    tripDataManager.SaveTrip(SelectedTripData);
                }

                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
            }
        }
Example #3
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState)
        {
            if (suspensionState.Any())
            {
                // use cache value(s)
                if (suspensionState.ContainsKey(nameof(SelectedTripData)))
                {
                    SelectedTripData = suspensionState[nameof(SelectedTripData)] as TripData;
                }
                // clear any cache
                suspensionState.Clear();
            }
            else
            {
                // use navigation parameter
                if (parameter.GetType().Equals(typeof(TripData)))
                {
                    SelectedTripData = parameter as TripData;
                }
            }

            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

            if (SelectedTripData.IsTripStarted == true)
            {
                CurrentTripDataRepo.DriveValue  = EnumHelper.DeParse(DriveStateStatus.TripStarted);
                CurrentTripDataRepo.StartTime   = SelectedTripData.TripStartTime;
                CurrentTripDataRepo.CurrentUser = SelectedTripData.CustomerName;
                smartTimer.StopTimer();
                upTimer.Start();
                CurrentTripDataRepo.IsTripStarted = true;
                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
            }
            else
            {
                CurrentTripDataRepo.CurrentUser          = SelectedTripData.CustomerName;
                CurrentTripDataRepo.CurrentPickupMunites = Math.Round((SelectedTripData.TripStartTime - DateTime.Now).TotalMinutes) <= 0 ?
                                                           0.0 : Math.Round((SelectedTripData.TripStartTime - DateTime.Now).TotalMinutes);

                smartTimer.StartTimer(() =>
                {
                    if (CurrentTripDataRepo.CurrentPickupMunites != 0)
                    {
                        CurrentTripDataRepo.CurrentPickupMunites--;
                    }
                    else
                    {
                        smartTimer.StopTimer();
                    }
                });
            }

            geoLocationService.DesiredAccuracyInMeters = 10;
            geoLocationService.MovementThreshold       = 5;
            var initializationSuccessful = await geoLocationService.InitializeAsync();

            if (initializationSuccessful)
            {
                await geoLocationService.StartListeningAsync();

                CurrentTripDataRepo.CurrentUserPosition = geoLocationService.CurrentPosition;
                if (geoLocationService.IsGeolocationAvailable)
                {
                    CurrentTripDataRepo.IsPositonAvailable = true;
                }
            }

            if (geoLocationService.IsListening)
            {
                geoLocationService.PositionChanged += GeoLocationService_PositionChanged;
            }

            NavigationService.FrameFacade.BackRequested += FrameFacade_BackRequested;
            await Task.CompletedTask;
        }