示例#1
0
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            if (gpsWatcherResponseMessage.Reason != Messages.Enums.GpsWatcherResponseMessageReason.Error)
            {
                if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    MapCenterPoint         = gpsWatcherResponseMessage.Coordinate.GeoCoordinate;
                    MapZoomLevel           = 15;
                    UserLocation           = gpsWatcherResponseMessage.Coordinate;
                    UserLocationVisibility = Visibility.Visible;
                }

                if (isStopSearch)
                {
                    AddStations();
                }
                else
                {
                    AddSearchResultsNearby();
                }
            }
            else if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                if (isStopSearch)
                {
                    AddStations();
                }
                else
                {
                    AddSearchResultsNearby();
                }
            }
        }
示例#2
0
        protected virtual void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            if (gpsWatcherResponseMessage.Reason == GpsWatcherResponseMessageReason.Error)
            {
                DeregisterWatcher();

                this.ShowPopup(CustomPopupMessageType.Error, AppResources.CustomPopupGenericGpsFailureMessage, AppResources.CustomPopupGenericOkMessage, null);

                return;
            }

            if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                DeregisterWatcher();

                if (user != null && !gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    user.UpdateLocation(gpsWatcherResponseMessage.Coordinate);
                    UnitOfWork.UserRepository.Update(user);
                    UnitOfWork.Save();
                }

                if (InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.ShowWeather).Value)
                {
                    if (weather == null || weather.LastRefreshedDate < DateTime.Now.AddHours(-1))
                    {
                        Action getWeather = async () =>
                        {
                            try
                            {
                                IWeatherApi weatherApi = SimpleIoc.Default.GetInstance<IWeatherApi>();

                                if (weatherApi != null)
                                {
                                    weather = await weatherApi.GetDataWeather(gpsWatcherResponseMessage.Coordinate);

                                    UnitOfWork.WeatherRepository.DeleteAll();
                                    UnitOfWork.WeatherRepository.Insert(weather);
                                    UnitOfWork.Save();
                                }
                            }
                            catch (Exception)
                            {

                            }
                        };

                        DispatcherHelper.CheckBeginInvokeOnUI(getWeather);
                    }
                }
            }
        }
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            if (gpsWatcherResponseMessage.Reason != Messages.Enums.GpsWatcherResponseMessageReason.Error)
            {
                AddStops();
            }
            else if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                AddStops();
            }
        }
示例#4
0
        private void WatcherPositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e)
        {
            // Send out coordinate to whoever registers to receive it:
            if (gpsWatcherStatus != GpsWatcherState.Stopped && gpsWatcherStatus != GpsWatcherState.Disabled)
            {
                GpsWatcherResponseMessage.Send(false, new Coordinate(e.Position.Location.Latitude, e.Position.Location.Longitude), GpsWatcherResponseMessageReason.Coordinate);
            }

            if (!runGpsWatcherContinuously)
            {
                StopGpsWatcher();
            }
        }
示例#5
0
        protected virtual void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            if (gpsWatcherResponseMessage.Reason == GpsWatcherResponseMessageReason.Error)
            {
                DeregisterWatcher();

                this.ShowPopup(CustomPopupMessageType.Error, AppResources.CustomPopupGenericGpsFailureMessage, AppResources.CustomPopupGenericOkMessage, null);

                return;
            }

            if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                DeregisterWatcher();

                if (user != null && !gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    user.UpdateLocation(gpsWatcherResponseMessage.Coordinate);
                    UnitOfWork.UserRepository.Update(user);
                    UnitOfWork.Save();
                }

                if (InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.ShowWeather).Value)
                {
                    if (weather == null || weather.LastRefreshedDate < DateTime.Now.AddHours(-1))
                    {
                        Action getWeather = async() =>
                        {
                            try
                            {
                                IWeatherApi weatherApi = SimpleIoc.Default.GetInstance <IWeatherApi>();

                                if (weatherApi != null)
                                {
                                    weather = await weatherApi.GetDataWeather(gpsWatcherResponseMessage.Coordinate);

                                    UnitOfWork.WeatherRepository.DeleteAll();
                                    UnitOfWork.WeatherRepository.Insert(weather);
                                    UnitOfWork.Save();
                                }
                            }
                            catch (Exception)
                            {
                            }
                        };

                        DispatcherHelper.CheckBeginInvokeOnUI(getWeather);
                    }
                }
            }
        }
示例#6
0
        private void WatcherStatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
        {
            switch (e.Status)
            {
            case GeoPositionStatus.Disabled:
                // The Location Service is disabled or unsupported.
                // Check to see whether the user has disabled the Location Service.
                StopGpsWatcher();

                if (watcher.Permission == GeoPositionPermission.Denied)
                {
                    // The user has disabled the Location Service on their device.
                    MessageBoxResult locationServiceDisabled = MessageBox.Show(AppResources.LocationPhoneDisabledHelpAlert, AppResources.LocationPhoneDisabledHelpCaption, MessageBoxButton.OKCancel);
                    if (locationServiceDisabled == MessageBoxResult.OK)
                    {
                        // TODO windows phone 7 version of this
                        //Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-location:"));
                    }
                }
                else
                {
                    DisplayCustomPopupMessage(new CustomPopupMessage(CustomPopupMessageType.Error, AppResources.LocationPhoneErrorHelpAlert, AppResources.CustomPopupGenericOkMessage, null));
                }

                GpsWatcherResponseMessage.SendError();

                break;

            case GeoPositionStatus.Initializing:
                // The Location Service is initializing.
                // Disable the Start Location button.
                //startLocationButton.IsEnabled = false;
                break;

            case GeoPositionStatus.NoData:
                // The Location Service is working, but it cannot get location data.
                // Alert the user and enable the Stop Location button.
                //statusTextBlock.Text = "location data is not available.";
                //stopLocationButton.IsEnabled = true;
                break;

            case GeoPositionStatus.Ready:
                // The Location Service is working and is receiving location data.
                // Show the current position and enable the Stop Location button.
                //statusTextBlock.Text = "location data is available.";
                //stopLocationButton.IsEnabled = true;
                break;
            }
        }
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            if (gpsWatcherResponseMessage.Reason != Messages.Enums.GpsWatcherResponseMessageReason.Error)
            {
                if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    MapCenterPoint = gpsWatcherResponseMessage.Coordinate.GeoCoordinate;
                    MapZoomLevel = 15;
                    UserLocation = gpsWatcherResponseMessage.Coordinate.GeoCoordinate;
                    UserLocationVisibility = Visibility.Visible;
                }
            }

            base.UserLocationFound(gpsWatcherResponseMessage);
        }
示例#8
0
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            if (gpsWatcherResponseMessage.Reason != Messages.Enums.GpsWatcherResponseMessageReason.Error)
            {
                if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    MapCenterPoint         = gpsWatcherResponseMessage.Coordinate.GeoCoordinate;
                    MapZoomLevel           = 15;
                    UserLocation           = gpsWatcherResponseMessage.Coordinate.GeoCoordinate;
                    UserLocationVisibility = Visibility.Visible;
                }
            }

            base.UserLocationFound(gpsWatcherResponseMessage);
        }
示例#9
0
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            if (gpsWatcherResponseMessage.Reason == GpsWatcherResponseMessageReason.Error)
            {
                this.LocationSearchBoxModel.GpsError();
                this.DestinationSearchBoxModel.GpsError();
            }
            else
            {
                this.LocationSearchBoxModel.UserLocationFound(gpsWatcherResponseMessage.Coordinate);
                this.DestinationSearchBoxModel.UserLocationFound(gpsWatcherResponseMessage.Coordinate);
            }
        }
示例#10
0
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            if (gpsWatcherResponseMessage.Reason == GpsWatcherResponseMessageReason.Error)
            {
                this.LocationSearchBoxModel.GpsError();
                this.DestinationSearchBoxModel.GpsError();
            }
            else
            {
                this.LocationSearchBoxModel.UserLocationFound(gpsWatcherResponseMessage.Coordinate);
                this.DestinationSearchBoxModel.UserLocationFound(gpsWatcherResponseMessage.Coordinate);
            }
        } 
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            if (gpsWatcherResponseMessage.Reason != Messages.Enums.GpsWatcherResponseMessageReason.Error)
            {
                AddStops();
            }
            else if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                AddStops();
            }
        }
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            MapCenterPoint = gpsWatcherResponseMessage.Coordinate;
        }
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            MapCenterPoint = gpsWatcherResponseMessage.Coordinate;
        }
        protected override void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            base.UserLocationFound(gpsWatcherResponseMessage);

            if (gpsWatcherResponseMessage.Reason != Messages.Enums.GpsWatcherResponseMessageReason.Error)
            {
                if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    MapCenterPoint = gpsWatcherResponseMessage.Coordinate.GeoCoordinate;
                    MapZoomLevel = 15;
                    UserLocation = gpsWatcherResponseMessage.Coordinate;
                    UserLocationVisibility = Visibility.Visible;
                }

                if (isStopSearch)
                {
                    AddStations();
                }
                else
                {
                    AddSearchResultsNearby();
                }
            }
            else if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                if (isStopSearch)
                {
                    AddStations();
                }
                else
                {
                    AddSearchResultsNearby();
                }
            }
        }