public Int32 FindPlace() { int max = 0; for (Int32 i = 0; i < Places.Count; i++) { if (!Places.Contains(i)) { Places.Add(i); return(i); } if (max < i) { max = i; } } if (max < Capasity) { Places.Add(max); return(max); } else { throw new ArgumentException("Parking if out of free space"); } }
private void PopulatePlaces() { if (_selectedCategory == Categories.Bars.ToString() || _selectedCategory == Categories.Hotels.ToString() || _selectedCategory == Categories.Museums.ToString() || _selectedCategory == Categories.Restaurants.ToString()) { if (_selectedCategory == Categories.Hotels.ToString()) { _xmlElementOfInterrest = "quality"; } if (_selectedCategory == Categories.Museums.ToString()) { _xmlElementOfInterrest = "subtitle"; } } try { foreach (XElement place in xml) { string name = place.Attribute("name").Value; string subtitle = place.Element(_xmlElementOfInterrest).Value; string imagePath = place.Element("imageURL").Value; Places.Add(new GenericModel(name, subtitle, _selectedCategory, imagePath)); } } catch (Exception) { } }
void AddPlace(Place place) { MinLatitude = Math.Min(MinLatitude, place.location.lat); MinLongitude = Math.Min(MinLongitude, place.location.lon); MaxLatitude = Math.Max(MaxLatitude, place.location.lat); MaxLongitude = Math.Max(MaxLongitude, place.location.lon); if (place.title == null) { // Set the text between the <a> tags of urlhtml as the title of place if it is missing HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(place.urlhtml); place.title = doc.DocumentNode.SelectNodes("//a[@href]")[0].InnerText; } if (Places.Add(place)) { string placeName = place.title; if (!placesByName.ContainsKey(placeName)) { placesByName.Add(placeName, new List <Place>()); } placesByName[placeName].Add(place); if (tilesGenerated) { if (tiling == Tiling.City) { UpdatePlacesByCity(place); } else if (tiling == Tiling.Coordinates) { UpdatePlacesByArea(place); } } } }
/// <summary> /// Creates a new <see cref="Place"/> and adds it to the net. /// </summary> /// <param name="name">The Name of the new <see cref="Place"/>.</param> /// <param name="tokenNumber">The amount of tokens lying on the new <see cref="Place"/>.</param> /// <returns>Returns the new place for future reference.</returns> public Place AddPlace(String name = "", int tokenNumber = 0) { Place newPlace = new Place(name, tokenNumber); Places.Add(newPlace); return(newPlace); }
public List <PlacesRatingDomain> GetPlacesRatingSelectByplaceId(int placeId) { List <PlacesRatingDomain> Places = null; DataProvider.ExecuteCmd(GetConnection, "dbo.PlacesRatings_SelectByPlacesId" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@PlaceId", placeId); } , map : delegate(IDataReader reader, short set) { PlacesRatingDomain Place = new PlacesRatingDomain(); int startingIndex = 0; Place.Id = reader.GetSafeInt32(startingIndex++); Place.Created = reader.GetSafeDateTime(startingIndex++); Place.PlaceId = reader.GetSafeInt32(startingIndex++); Place.RatingType = reader.GetSafeEnum <RatingType>(startingIndex++); Place.Rating = reader.GetSafeDecimal(startingIndex++); Place.UserId = reader.GetSafeString(startingIndex++); Place.GroupId = reader.GetSafeInt32(startingIndex++); Place.AspectId = reader.GetSafeInt32(startingIndex++); if (Places == null) { Places = new List <PlacesRatingDomain>(); } Places.Add(Place); } ); return(Places); }
public async void LoadMore() { string url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=" + nextPageToken + "&key=AIzaSyCK8SquzPry-orS9Lc80hXbPyVUhIyni_Y"; try { HttpClient client = new HttpClient(); var response = await client.GetStringAsync(string.Format(url)); 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) { } }
private async void LoadData() { string url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&rankby=distance&types=food&key=AIzaSyCK8SquzPry-orS9Lc80hXbPyVUhIyni_Y"; try { HttpClient client = new HttpClient(); var response = await client.GetStringAsync(string.Format(url)); 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); } var result1 = JsonConvert.DeserializeObject <PlacesApiQueryResponse>(response.ToString()); nextPageToken = result1.next_page_token; System.Diagnostics.Debug.WriteLine(nextPageToken); } catch (Exception ex) { } }
private async void ExecuteLoadDataCommand(object obj) { IsBusy = true; try { Cars.Clear(); var task1 = CarsService.GetCarsAsync(); var task2 = PlacesService.GetPlacesAsync(); foreach (var car in await task1) { Cars.Add(car); } foreach (var place in await task2) { if (!place.occupied) { Places.Add(place); } } } catch (Exception ex) { Debug.WriteLine(ex); await Application.Current.MainPage.DisplayAlert("BŁĄD", "Nie udało się wczytać samochodów", "ANULUJ"); } finally { IsBusy = false; } }
public async Task AddPlaceToCollectionAsync(Place place) { if (Places.All(x => x.Id != place.Id)) { Places.Add(place); await _settingsService.SavePlacesAsync(Places); } }
public override async Task <ObservableCollection <Place> > GetPlaces() { string url = String.Empty; if (String.IsNullOrEmpty(NextPageToken) == true) { if (rankby == Rankby.DISTANCE) { url = api + "nearbysearch/" + "json" + "?" + "location=" + location + "&sensor=" + sensor + "&rankby=" + rankby + "&opennow=" + openNow.ToString(); } else { url = api + "nearbysearch/" + "json" + "?" + "location=" + location + "&radius=" + radius + "&sensor=" + sensor + "&rankby=" + rankby + "&opennow=" + openNow.ToString(); } if (String.IsNullOrEmpty(minprice) == false) { url += "&minprice=" + minprice; } if (String.IsNullOrEmpty(maxprice) == false) { url += "&maxprice=" + maxprice; } if (String.IsNullOrEmpty(keyword) == false) { url += "&keyword=" + keyword; } if (String.IsNullOrEmpty(name) == false) { url += "&name=" + name; } if (String.IsNullOrEmpty(types) == false) { url += "&types=" + types; } if (String.IsNullOrEmpty(language) == false) { url += "&language=" + language; } url += "&key=" + key; } else { url = api + "nearbysearch/" + "json" + "?" + "pagetoken=" + NextPageToken + "&sensor=" + sensor + "&key=" + key; } await GetData(url); GetToken(); var places = GetResult(jObject, searchStatus); foreach (Place plac in places) { Places.Add(plac); } return(Places); }
private void SearchResultsAvailable(object sender, SearchEventArgs e) { People.Clear(); Places.Clear(); foreach (RhitLocation location in e.Places) { Places.Add(location); } }
/// <summary> /// Populates the list with places. /// </summary> protected virtual void PopulatePlaces() { Places.Add(new FolderModel(Environment.SpecialFolder.Desktop)); Places.Add(new FolderModel(Environment.SpecialFolder.MyDocuments)); var drives = FolderModel.GetDrives(); foreach (var drive in drives) { Places.Add(drive); } }
/// <summary> /// Add a place to the data set. /// </summary> /// <param name="place">The place to be added.</param> public void AddPlace(PlaceDescription place) { if (place != null) { if (Places == null) { Places = new List <PlaceDescription>(); } Places.Add(place); } }
public void AddItemToList() { var place = new Place { Name = Name, Special = Description }; Places.Add(place); Name = ""; Description = ""; }
public void UpdateExistingEntries(List <DbTables.Place> entries) { foreach (var entry in entries) { //check existing entry, see if it requires being updated var existingData = Places.FirstOrDefault(md => md.SourceItemID == entry.SourceItemID && md.SourceItemType == entry.SourceItemType); if (existingData != null) { if (existingData.AreaSize != entry.AreaSize) { existingData.AreaSize = entry.AreaSize; } if (existingData.GameElementName != entry.GameElementName) { existingData.GameElementName = entry.GameElementName; } bool expireTiles = false; if (!existingData.ElementGeometry.EqualsTopologically(entry.ElementGeometry)) //TODO: this might need to be EqualsExact? { //update the geometry for this object. existingData.ElementGeometry = entry.ElementGeometry; expireTiles = true; } if (!existingData.Tags.OrderBy(t => t.Key).SequenceEqual(entry.Tags.OrderBy(t => t.Key))) { existingData.Tags = entry.Tags; var styleA = TagParser.GetStyleForOsmWay(existingData.Tags); var styleB = TagParser.GetStyleForOsmWay(entry.Tags); if (styleA != styleB) { expireTiles = true; //don't force a redraw on tags unless we change our drawing rules. } } if (expireTiles) //geometry or style has to change, otherwise we can skip expiring values. { SaveChanges(); //save before expiring, so the next redraw absolutely has the latest data. Can't catch it mid-command if we do this first. ExpireMapTiles(entry.ElementGeometry, "mapTiles"); ExpireSlippyMapTiles(entry.ElementGeometry, "mapTiles"); } } else { //We don't have this item, add it. Places.Add(entry); SaveChanges(); //again, necessary here to get tiles to draw correctly after expiring. ExpireMapTiles(entry.ElementGeometry, "mapTiles"); ExpireSlippyMapTiles(entry.ElementGeometry, "mapTiles"); } } SaveChanges(); //final one for anything not yet persisted. }
public void AddPlace(Place placeToAdd) { if (Places.Any(x => x.Id.Equals(placeToAdd.Id))) { throw new ArgumentException($"Id: {placeToAdd.Id} cannot be the same for two places"); } if (Places.Contains(placeToAdd)) { throw new ArgumentException($"You already add {placeToAdd}"); } Places.Add(placeToAdd); }
// Add a new place named 'placeTitle' if it was not found in the places database public List <Place> AddPlace(string placeTitle) { if (!placesByName.ContainsKey(placeTitle)) { Random random = new Random(); Place newPlace = new Place { id = random.Next(), title = placeTitle }; Places.Add(newPlace); placesByName[placeTitle] = new List <Place>(); placesByName[placeTitle].Add(newPlace); } return(placesByName[placeTitle]); }
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); } } }
public Place AddPlace(ObjectId placeId) { // Проверка нет ли уже такой площадки (по placeId) var place = FindPlace(placeId); if (place != null) { InsService.ShowMessage("Эта площадка уже добавлена - " + place.Name, System.Windows.MessageBoxImage.Information); return(null); } place = new Place(placeId, this); Places.Add(place); place.Update(); return(place); }
public void AddPlace(ObjectId plId, DicED dicPlace) { if (!plId.IsValidEx()) { return; } var place = FindPlace(plId); if (place != null) { return; // Такая площадка уже есть. } place = new Place(plId, dicPlace, this); Places.Add(place); }
public override async Task OnResume() { var location = await Geolocation.GetLastKnownLocationAsync(); List <PlaceItemSummary> Lieux = await GetAllPlaces(); PlaceItemSummary l = new PlaceItemSummary(); foreach (var lieu in Lieux) { Places.Add(lieu); l = lieu; } // Places.OrderBy(i => i.Latitude); }
/// <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); } } }
public void ParseJObjectResponse(JObject joResponse) { foreach (JToken bus in joResponse.SelectToken("businesses")) { string b = (string)bus.SelectToken("name"); string c = (string)bus.SelectToken("image_url"); string d = (string)bus.SelectToken("id"); if (c.Length < 2) { c = "filler.jpg"; } string e = (string)bus.SelectToken("rating"); Places.Add(new Place { name = b, image_url = c, id = d, rating = e }); } NumberOfPlaces = Places.Count; }
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) { } }
public DataContext() { for (uint i = 0; i < 256; i++) { BattleItems.Add(new Item(0x37590 + i * 8)); } for (uint i = 0; i < 1024; i++) { OtherItems.Add(new Item(0x37D90 + i * 8)); } for (uint i = 0; i < 200; i++) { Charactors.Add(new Charactor(0x700 + i * 1062)); } for (uint i = 0; i < 120; i++) { Jewels.Add(new Jewel(0x46380 + i * 8)); } for (uint i = 0; i < 12; i++) { Party.Add(new Member(0x6D0 + i * 4)); } foreach (var info in Info.Instance().Places) { Places.Add(new Place(info)); } foreach (var info in Info.Instance().Minds) { Minds.Add(new MindQuest(info)); } foreach (var info in Info.Instance().Medals) { Medals.Add(new Medal(info)); } }
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; }
public bool Attach(Place place) { if (Size <= Places.Count) { return(false); } if (PlaceAttached != null) { PlaceAttached(place); } var marker = place.GetComponent <SpaceMarker> (); if (marker == null) { marker = place.gameObject.AddComponent <SpaceMarker> (); } marker.CurrentSpace = this; Places.Add(place); return(true); }
public void BuildPlaces() { this.Places = new List <Entity>(); Places.Add(new Bank(this.Map.GetRandomLocation())); Places.Add(new Food(this.Map.GetRandomLocation())); Places.Add(new Goldmine(this.Map.GetRandomLocation())); Places.Add(new Home(this.Map.GetRandomLocation())); Places.Add(new Market(this.Map.GetRandomLocation())); Places.Add(new Nightclub(this.Map.GetRandomLocation())); Places.Add(new Saloon(this.Map.GetRandomLocation())); Places.Add(new School(this.Map.GetRandomLocation())); foreach (Entity item in Places) { Sprite tempVar = item; this.Map.Register(tempVar); } }
private void MakePlaceAt(Vector2 p, Vector2 direction) { var v = ParkingPlace.GetVertices(p, direction); bool can = true; foreach (var vert in v) { if (!CanPlaceAt(vert)) { return; } } ParkingPlace place = Instantiate(parkingPlacePrefab); MapCreatorLoader.Instance.Attach(place.gameObject); place.transform.position = new Vector3(p.x, 0, p.y); place.SpawnShape(v, can); Places.Add(place.gameObject); MapCreatorLoader.Instance.ParkingZone.PlaceAdded(); }
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; } }