Esempio n. 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            wardrobe = e?.Parameter as Wardrobe;

            // Populate available type list
            var types = wardrobe.Garments.Select(g => g.Type.ToString())
                        .Distinct()
                        .Select(t => new TypeWrapper
            {
                TypeName            = t,
                TypeSelectCommand   = new TypeSelectCommand(this),
                TypeUnselectCommand = new TypeUnselectCommand(this)
            });

            UnselectedList.ItemsSource = types;

            // Populate weather info, if available
            DataContext = new WeatherWrapper();

            // Populate weather advice
            var advices = WeatherUtil.GenerateAdvice()
                          .Select(a => new CodeToLocalizedWeatherAdviceConverter().Convert(a))
                          .ToList();

            WeatherAdvice.ItemsSource = advices.Select(a => (WeatherAdviceWrapper)a);
        }
Esempio n. 2
0
        public void Handle(string message)
        {
            Execute.OnUIThreadSync(async() =>
            {
                WeatherItemViewModels?.Clear();
                LowValues?.Clear();
                HighValues?.Clear();
                GC.Collect();

                WeaResModel = await WeatherUtil.GetWeathers(message);

                if (WeaResModel?.Data?.Forecast != null)
                {
                    ChartVisibility = Visibility.Visible;
                    foreach (var item in WeaResModel.Data.Forecast)
                    {
                        var ivm         = _container.Get <WeatherItemViewModel>();
                        ivm.WeatherInfo = item;
                        await Task.Delay(200);
                        WeatherItemViewModels.Add(ivm);
                        LowValues.Add(item.LowNum);
                        HighValues.Add(item.HighNum);
                    }
                }
                else
                {
                    ChartVisibility = Visibility.Hidden;
                }
            });
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            User curUser = userService.findById(int.Parse(User.Identity.GetUserId()));

            if (curUser == null)
            {
                return(View("error"));
            }
            ViewBag.curUser  = curUser;
            ViewBag.curHouse = curUser.House;
            weatherResult weatherResult = WeatherUtil.getWeatherResult();

            ViewBag.weather      = weatherResult;
            ViewBag.notifiations = notificationService.getAllNotificationChange(curUser.Id);
            return(View());
        }
 public IActionResult GetWeather(string city = "shanghai")
 {
     return(ApiResult.Ok(WeatherUtil.Get(city)));
 }