예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
파일: WuClient.cs 프로젝트: blparr/XWeather
        public async Task AddLocation(WuAcLocation location)
        {
            LocationAdded?.Invoke(this, EventArgs.Empty);

            var wuLocation = await getWuLocation(location);

            AddLocation(wuLocation);
        }
예제 #4
0
파일: WuClient.cs 프로젝트: blparr/XWeather
        public async Task AddLocation(LocationCoordinates coordnates)
        {
            LocationAdded?.Invoke(this, EventArgs.Empty);

            var wuAcLocation = await lookupLocation(coordnates);

            var wuLocation = await getWuLocation(wuAcLocation);

            AddLocation(wuLocation);
        }
예제 #5
0
파일: WuClient.cs 프로젝트: blparr/XWeather
        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);
        }
예제 #6
0
파일: WuClient.cs 프로젝트: blparr/XWeather
        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();
            }
        }