예제 #1
0
        public void HandleVoiceCommand(string command, string timeFrame, string city)
        {
            Location location;

            if (city.Length != 0)
            {
                location = LocationService.GetLocationFromCity(city);
            }
            else
            {
                location = LocationService.GetDefaultLocation();
            }
            if (WeatherCommands.CMD_SHOW.Equals(command))
            {
                Debug.Write("Show ");
                switch (timeFrame)
                {
                case WeatherCommands.TIME_TODAY:
                    WeatherCurrent weather = WeatherService.FetchCurrentWeather(location);
                    break;

                case WeatherCommands.TIME_TOMORROW:
                    Debug.WriteLine("TIME_TOMORROW: " + timeFrame);
                    break;

                case WeatherCommands.TIME_WEEK:
                    Debug.WriteLine("TIME_WEEK: " + timeFrame);
                    break;
                }
            }
            else if (WeatherCommands.CMD_HIDE.Equals(command))
            {
                Debug.Write("Hide ");
                switch (timeFrame)
                {
                case WeatherCommands.TIME_TODAY:
                    Debug.WriteLine("TIME_TODAY: " + timeFrame);
                    break;

                case WeatherCommands.TIME_TOMORROW:
                    Debug.WriteLine("TIME_TOMORROW: " + timeFrame);
                    break;

                case WeatherCommands.TIME_WEEK:
                    Debug.WriteLine("TIME_WEEK: " + timeFrame);
                    break;
                }
            }
        }
예제 #2
0
        //--------------------------------------------------------------------------------
        //--------------------------------Current Weather---------------------------------
        //--------------------------------------------------------------------------------
        //TODO set this method up to handle issues where the read fails.
        public static WeatherCurrent FetchCurrentWeather(Location location)
        {
            //Read the weather then assign all the fields of Today
            WeatherData    today         = GetCurrentWeatherData(location);
            WeatherCurrent todaysWeather = new WeatherCurrent(DateTime.Now);

            if (today != null)
            {
                todaysWeather.Temperature     = today.main.temp;
                todaysWeather.WeatherType     = today.weather[0].main;
                todaysWeather.IconId          = today.weather[0].icon;
                todaysWeather.HighTemperature = today.main.temp_max;
                todaysWeather.LowTemperature  = today.main.temp_min;
                todaysWeather.City            = location.City;
                todaysWeather.State           = location.State;
                todaysWeather.Country         = location.Country;
                todaysWeather.Date            = UnixTimeStampToDateTime(today.dt);
            }
            return(todaysWeather);
        }