示例#1
0
 private int ResetUI()
 {
     Refreshing.Visibility      = Visibility.Collapsed;
     ConnectionError.Visibility = Visibility.Collapsed;
     NoResults.Visibility       = Visibility.Collapsed;
     ProgressBar.Hide();
     SetApplicationBarEnabled(true);
     return(0);
 }
示例#2
0
        void GetDondeComprar()
        {
            ResetUI();
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ConnectionError.Visibility = Visibility.Visible;
                Dispatcher.BeginInvoke(() => MessageBox.Show("Ha habido un error intentando acceder a los nuevos datos o no hay conexiones de red disponibles.\nPor favor asegúrese de contar con acceso de red y vuelva a intentarlo."));
                return;
            }

            GeoPosition <GeoCoordinate> currentLocation = PositionService.GetCurrentLocation();

            if (!App.Configuration.IsLocationEnabled)
            {
                Dispatcher.BeginInvoke(() => MessageBox.Show("Para buscar, por favor, active la función de localización en la configuración de la aplicación."));
                return;
            }
            if (currentLocation == null)
            {
                Dispatcher.BeginInvoke(() => MessageBox.Show("Para buscar, por favor, active la función de localización."));
                return;
            }

            ProgressBar.Show("Buscando más cercanos...");

            if (App.Configuration.IsLocationEnabled && PositionService.GetCurrentLocation().Location != null)
            {
                var pushpin = new MapOverlay
                {
                    GeoCoordinate   = PositionService.GetCurrentLocation().Location,
                    ContentTemplate = Application.Current.Resources["locationPushpinTemplate"] as DataTemplate,
                };
                _pointsLayer.Add(pushpin);

                Mapa.SetView(Mapa.CreateBoundingRectangle());
            }
            if (ViewModel.Puntos.Count == 0)
            {
                Refreshing.Visibility = Visibility.Visible;
            }
            SetApplicationBarEnabled(false);
            CancelarRequest();

            var param = new Dictionary <string, object>
            {
                { "cant", 10 },
            };

            var client = new HttpClient();

            _httpReq = client.Get(string.Format("/api/{0}sube", ViewModel.Tipo).ToApiCallUri(param));
            _httpReq.BeginGetResponse(HTTPWebRequestCallBack, _httpReq);
        }
示例#3
0
        private int EndRequest()
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var applicationBarIconButton = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
                if (applicationBarIconButton != null)
                {
                    applicationBarIconButton.IsEnabled = true;
                }

                ProgressBar.Hide();
            });
            return(0);
        }
示例#4
0
        public void Cargar(bool refresh = false)
        {
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                ProgressBar.Show("Actualizando estado...");

                var client = new HttpClient();
                _httpReq = client.Get("/api/bicicleta".ToApiCallUri(refresh));
                _httpReq.BeginGetResponse(HTTPWebRequestCallBack, _httpReq);
            }
            else
            {
                ShowErrorConnection();
            }
        }
示例#5
0
        void GetColectivosCercanos()
        {
            ResetUI();
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ConnectionError.Visibility = Visibility.Visible;
                Dispatcher.BeginInvoke(() => MessageBox.Show("Ha habido un error intentando acceder a los nuevos datos o no hay conexiones de red disponibles.\nPor favor asegúrese de contar con acceso de red y vuelva a intentarlo."));
                return;
            }

            GeoPosition <GeoCoordinate> currentLocation = PositionService.GetCurrentLocation();

            if (!App.Configuration.IsLocationEnabled)
            {
                Dispatcher.BeginInvoke(() => MessageBox.Show("Para buscar colectivos cercanos, por favor, active la función de localización en la configuración de la aplicación."));
                return;
            }
            if (currentLocation == null)
            {
                Dispatcher.BeginInvoke(() => MessageBox.Show("Para buscar colectivos cercanos, por favor, active la función de localización."));
                return;
            }

            ProgressBar.Show("Buscando más cercanos...");
            if (ViewModel.Items.Count == 0)
            {
                Refreshing.Visibility = Visibility.Visible;
            }
            SetApplicationBarEnabled(false);
            CancelarRequest();

            var client = new HttpClient();

            _httpReq = client.Get("/transporte/cercano".ToApiCallUri());
            _httpReq.BeginGetResponse(HTTPWebRequestCallBack, _httpReq);
        }