コード例 #1
0
        private async void CheckPlaces()
        {
            if (mCacheService.CurrentLat == 0 && mCacheService.CurrentLng == 0)
            {
                if (View != null)
                {
                    View.StartGetLocation();
                }

                //do get the location in view, then please call this command again, it should query the 'places'
            }
            else
            {
                Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, true));
                var result = await mApiService.CheckPlaces(string.Format("{0} {1}", StrNumber, Street), mCacheService.CurrentLat, mCacheService.CurrentLng);

                Places.Clear();
                if (result != null && result.Response != null && result.Response.View.Count > 0)
                {
                    Places = new ObservableCollection <HereMapView>(result.Response.View);
                }
                else
                {
                    Mvx.Resolve <IMvxMessenger>().Publish(new ToastMessage(this, "No places found!"));
                }
                Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, false));
            }
        }
コード例 #2
0
ファイル: SearchViewModel.cs プロジェクト: zanecodes/Mobile
 private void SearchResultsAvailable(object sender, SearchEventArgs e)
 {
     People.Clear();
     Places.Clear();
     foreach (RhitLocation location in e.Places)
     {
         Places.Add(location);
     }
 }
コード例 #3
0
ファイル: MVVM.cs プロジェクト: freezpl/NP_Street_Indexes
        void SearchPlaces()
        {
            cts   = new CancellationTokenSource();
            token = cts.Token;
            t     = new Task(() =>
            {
                //grab data from google\
                string req = REQ_AUTOCOMP + searchText;
                try
                {
                    request  = WebRequest.Create(req);
                    response = request.GetResponse();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }

                if (token.IsCancellationRequested)
                {
                    return;
                }
            }, token);

            t.Start();
            t.Wait();

            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                try
                {
                    string responseText = reader.ReadToEnd();
                    all = JsonConvert.DeserializeObject <AllPlaces>(responseText);
                    Places.Clear();
                    if (all.predictions.Count > 0)
                    {
                        foreach (var pl in all.predictions)
                        {
                            Places.Add(pl);
                        }
                    }
                    IsDropdOpen = Convert.ToBoolean(Places.Count);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message + "\n" + e.StackTrace);
                }
            }
        }
コード例 #4
0
ファイル: PathNode.cs プロジェクト: RikkiRu/ParkingModel
    public void MakePlaces()
    {
        foreach (var i in Places)
        {
            i.GetComponent <ParkingPlace>().RemoveShapeNow();
            Destroy(i);
        }

        Places.Clear();

        foreach (var node in OutNodes)
        {
            MakePlacesOnWayTo(node);
        }
    }
コード例 #5
0
ファイル: GeoDB.cs プロジェクト: gdegeneve/GeoSharp
 /// <summary>
 /// All the geocoding data can be gotten from: http://download.geonames.org/export/dump/
 /// </summary>
 /// <param name="input"></param>
 public void SetPlaces(Stream input)
 {
     Places.Clear();
     using (StreamReader db = new StreamReader(input))
     {
         string line;
         while (!db.EndOfStream && (line = db.ReadLine()) != null)
         {
             if (line.StartsWith("#"))
             {
                 continue;
             }
             var place = new GeoName(line, CountryInfos);
             Places.Add(place);
         }
     }
 }
コード例 #6
0
        public async void SearchByClient(string query)
        {
            Places.Clear();
            string url        = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=";
            Char   delimiter  = ' ';
            var    substrings = query.Split(delimiter);

            for (int i = 0; i < substrings.Length; i++)
            {
                if (i != substrings.Length)
                {
                    System.Diagnostics.Debug.WriteLine(substrings[i]);
                    url += substrings[i];
                }
            }

            url += "&key=AIzaSyCK8SquzPry-orS9Lc80hXbPyVUhIyni_Y";
            System.Diagnostics.Debug.WriteLine(url);
            /* restaurants+in+Sydney";*/
            try
            {
                HttpClient client   = new HttpClient();
                var        response = await client.GetStringAsync(string.Format(url));

                System.Diagnostics.Debug.WriteLine(response);

                var result = JsonConvert.DeserializeObject <PlacesApiQueryResponse>(response.ToString());
                foreach (var item in result.results)
                {
                    PlaceViewModel place = new PlaceViewModel()
                    {
                        Name   = item.name,
                        Rating = item.rating,
                        Icon   = item.icon
                    };

                    Places.Add(place);

                    System.Diagnostics.Debug.WriteLine(place.Name);
                }
            }
            catch (Exception ex)
            { }
        }
コード例 #7
0
ファイル: MainPageViewModel.cs プロジェクト: rzee7/FindPlaces
        async void OnSearch(string nextPageToken)
        {
            //Ignoring if same query, This seems bug in SearchBar Command, It executing every time you clicks text field
            if (SearchQuery.Equals(PreviousSearchQuery, StringComparison.CurrentCultureIgnoreCase) && string.IsNullOrEmpty(nextPageToken) && Places.Count > 0)
            {
                return;
            }
            if (!string.IsNullOrEmpty(nextPageToken))
            {
                StatusMessage = Messages.LoadingMore;
            }
            else
            {
                StatusMessage = Messages.DefaultStatus;
                Places.Clear();
            }

            IsEmpty = false;
            IsBusy  = true;

            PreviousSearchQuery = SearchQuery;

            var fetchedPlaces = await _apiServuce.FetchData(SearchQuery.Trim());

            if (fetchedPlaces != null && fetchedPlaces.IsSuccess)
            {
                IsEmpty       = false;
                NextPageToken = fetchedPlaces.NextPageToken;
                foreach (var item in fetchedPlaces.Places)
                {
                    Places.Add(item); //I'm aware this is slow but List has some limitation with INotify.
                }
            }
            else
            {
                IsBusy = false;
                await _dialogService.DisplayAlertAsync(Constants.DialogTitle, !string.IsNullOrEmpty(fetchedPlaces.Message)?fetchedPlaces.Message : Messages.WentWrong, Constants.Ok);

                IsEmpty = true;
            }
            IsBusy = false;
        }
コード例 #8
0
ファイル: PathNode.cs プロジェクト: RikkiRu/ParkingModel
    private void CleanObjects()
    {
        foreach (var i in Objects)
        {
            Destroy(i);
        }

        foreach (var i in ObjectShapes)
        {
            MapCreatorLoader.Instance.ParkingZone.RemoveShape(i);
        }

        foreach (var i in Places)
        {
            i.GetComponent <ParkingPlace>().RemoveShapeNow();
            Destroy(i);
        }

        Objects.Clear();
        ObjectShapes.Clear();
        Places.Clear();
    }
コード例 #9
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Places.Clear();
                var places = await DataStore.GetItemsAsync(true);

                foreach (var place in places)
                {
                    Places.Add(place);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #10
0
 /// <summary>
 /// 清除排名相關資料,包含成績、排名結果。
 /// </summary>
 public void Clear()
 {
     Scores.Clear();
     Places.Clear();
 }