예제 #1
0
 public Weather(CityInfomaition cityInfo, TodayWeather today, DayWeather tomorrow, DayWeather third, DayWeather fourth)
 {
     _cityInfo = cityInfo;
     _today    = today;
     _fourth   = fourth;
     _third    = third;
     _tomorrow = tomorrow;
 }
예제 #2
0
 public Weather(CityInfomaition cityInfo, TodayWeather today, DayWeather tomorrow, DayWeather third, DayWeather fourth)
 {
     _cityInfo = cityInfo;
     _today = today;
     _fourth = fourth;
     _third = third;
     _tomorrow = tomorrow;
 }
예제 #3
0
        public WeatherPage()
        {
            this.InitializeComponent();
            todayWeather   = new TodayWeather();
            LastHourOfTime = System.DateTime.Now.Date.Hour;
            ImageBrush imageBrush = new ImageBrush()
            {
                ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/HomePaper/Win101.jpg"))
            };

            WeatherPageGrid.Background = imageBrush;
        }
예제 #4
0
        private TodayWeather[] GetTodayWeather()
        {
            string htmlStr = RequestData("http://www.weather.com.cn/weather1d/101300106.shtml");
            var    htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(htmlStr);
            var res   = htmlDoc.DocumentNode.SelectNodes("//div[@id='today']/div[@class='t']/ul/li");
            var model = new List <TodayWeather>();

            foreach (var li in res)
            {
                var liHtmlDoc = new HtmlDocument();
                liHtmlDoc.LoadHtml(li.InnerHtml);
                var day          = liHtmlDoc.DocumentNode.SelectSingleNode("//h1").InnerText;
                var wea          = liHtmlDoc.DocumentNode.SelectSingleNode("//p[@class='wea']").InnerText;
                var tem          = liHtmlDoc.DocumentNode.SelectSingleNode("//p[@class='tem']/span").InnerText + liHtmlDoc.DocumentNode.SelectSingleNode("//p[@class='tem']/em").InnerText;
                var win          = liHtmlDoc.DocumentNode.SelectSingleNode("//p[@class='win']/span").Attributes["title"].Value + liHtmlDoc.DocumentNode.SelectSingleNode("//p[@class='win']/span").InnerText;
                var sky          = liHtmlDoc.DocumentNode.SelectSingleNode("//div[@class='sky']/span[@class='txt lv3']")?.InnerText ?? "";
                var date         = DateTime.Today;
                var todayWeather = new TodayWeather()
                {
                    Id          = Guid.NewGuid().ToString(),
                    Day         = day,
                    Weather     = wea,
                    Temperature = tem,
                    Wind        = win,
                    Sky         = sky,
                    Today       = date,
                    UpdateTime  = DateTime.Now
                };
                if (day.Contains(DateTime.Now.Day + "日白天"))
                {
                    todayWeather.DayType = DayType.CurrentDay;
                }
                else if (day.Contains(DateTime.Now.Day + "日夜间"))
                {
                    todayWeather.DayType = DayType.CurrentNight;
                }
                else
                {
                    todayWeather.DayType = DayType.NewCurrentDay;
                }
                model.Add(todayWeather);
            }
            return(model.ToArray());
        }
예제 #5
0
 /// <summary>
 /// Weather
 /// </summary>
 /// <param name="cityInfo"></param>
 /// <param name="today"></param>
 /// <param name="dayWeathers"></param>
 public Weather(CityInfomaition cityInfo, TodayWeather today, DayWeather[] dayWeathers)
 {
     _cityInfo = cityInfo;
     _today = today;
     _dayWeathers = dayWeathers;
 }
예제 #6
0
 /// <summary>
 /// Weather
 /// </summary>
 /// <param name="cityInfo"></param>
 /// <param name="today"></param>
 /// <param name="dayWeathers"></param>
 public Weather(CityInfomaition cityInfo, TodayWeather today, DayWeather[] dayWeathers)
 {
     _cityInfo    = cityInfo;
     _today       = today;
     _dayWeathers = dayWeathers;
 }