public WeatherModel(WeatherCurrentViewModel current, WeatherDayViewModel today, WeatherDayViewModel tomorrow, WeatherWeekViewModel week) { currentWeather = current; todaysWeather = today; tomorrowsWeather = tomorrow; weeksWeather = week; currentlyVisible = currentWeather; VoiceController = new WeatherVoiceController("Grammar\\weatherGrammar.xml", this); }
private void ConvertWeatherDayToWeatherDayViewModel(WeatherDay model, WeatherDayViewModel viewModel) { List <WeatherHourViewModel> hoursList = new List <WeatherHourViewModel>(); foreach (WeatherHour hour in model.WeatherDays) { string temp = hour.Temperature.ToString("F0"); string time = hour.Time.ToString("h:mm tt"); BitmapImage icon = new BitmapImage(new Uri("ms-appx:/Assets/Weather/" + hour.IconId + ".png")); WeatherHourViewModel hourVM = new WeatherHourViewModel(time, temp, icon); hoursList.Add(hourVM); } viewModel.WeatherHours = hoursList; viewModel.Location = model.WeatherLocation.City + ", " + model.WeatherLocation.State; viewModel.Date = model.Date.ToString("M"); viewModel.ReadTime = model.ReadTime.ToString("g"); }
private void InitWeather() { //Create all necessary view models for weather CurrentWeather = new WeatherCurrentViewModel(); TodaysWeather = new WeatherDayViewModel(); TomorrowsWeather = new WeatherDayViewModel(); WeeksWeather = new WeatherWeekViewModel(); //Init the weather model and give it a reference to all view models Weather = new WeatherModel(CurrentWeather, TodaysWeather, TomorrowsWeather, WeeksWeather); Weather.InitWeather(locationService.DefaultLocation); //Set the interval, tick handler, and then start the timer. weatherTimer.Interval = TimeSpan.FromMilliseconds(WeatherRefreshRate); weatherTimer.Tick += WeatherTick; weatherTimer.Start(); todaysWeatherCounter = 0; tomorrowsWeatherCounter = 0; weeksWeatherCounter = 0; voiceControlledModules.Add(Weather); }