public static void AddLocation(EDLocation location) { if (_locations == null) { LoadLocations(); } if (String.IsNullOrEmpty(location.Name)) { int count = 1; bool nameIsUnique = true; string locationName; do { nameIsUnique = true; locationName = $"Location {count}"; foreach (EDLocation l in _locations) { if (l.Name.Equals(locationName)) { nameIsUnique = false; break; } } count++; } while (!nameIsUnique); location.Name = locationName; } _locations.Add(location); SaveLocationsToFile(); LocationAdded?.Invoke(null, location); }
public static void AddLocation(EDLocation location) { if (_locations == null) { LoadLocations(); } if (String.IsNullOrEmpty(location.Name)) { // This is grossly inefficient, and is a hopefully temporary way to ensure names are present and unique int count = 1; bool nameIsUnique = true; string locationName; do { nameIsUnique = true; locationName = $"Location {count}"; foreach (EDLocation l in _locations) { if (l.Name.Equals(locationName)) { nameIsUnique = false; break; } } count++; } while (!nameIsUnique); location.Name = locationName; } _locations.Add(location); SaveLocationsToFile(); LocationAdded?.Invoke(null, location); }
public async Task AddLocation(WuAcLocation location) { LocationAdded?.Invoke(this, EventArgs.Empty); var wuLocation = await getWuLocation(location); AddLocation(wuLocation); }
public async Task AddLocation(LocationCoordinates coordnates) { LocationAdded?.Invoke(this, EventArgs.Empty); var wuAcLocation = await lookupLocation(coordnates); var wuLocation = await getWuLocation(wuAcLocation); AddLocation(wuLocation); }
public async Task AddLocation(string countryOrUsState, string city) { LocationAdded?.Invoke(this, EventArgs.Empty); var wuAcLocation = await lookupLocation(countryOrUsState, city); var wuLocation = await getWuLocation(wuAcLocation); AddLocation(wuLocation); }
public void AddLocation(WuLocation location, bool preventNotification = false) { Locations.Add(location); Locations.Sort(); if (!preventNotification) { LocationAdded?.Invoke(this, EventArgs.Empty); SettingsStudio.Settings.LocationsJson = Locations.GetLocationsJson(); } }