示例#1
0
        void GetWeatherReports(Int32 id)
        {
            //Initiates the request and display of weather reports based on a location woeid

            try
            {
                Windows.LoadingState(true, this);

                List <WeatherReport> weatherreports = Feeds.GetWeatherReports(id);

                EnableInterface(true);
                StringBuilder output = new StringBuilder();


                foreach (WeatherReport wr in weatherreports)
                {
                    if (wr.Applicable_Date.ToShortDateString() == DateTime.Now.ToShortDateString())
                    {
                        pictureboxWeatherIcon.Load(wr.WeatherState.Icon);
                        lblWeatherAdvice.Text = "The Weather in " + GlobalConfig.WeatherLocation.title + " today is " + wr.SwearyWeatherState.Name;
                        lblMinTemp.Text       = "Min Temp: " + wr.Min_Temp + "C";
                        lblMaxTemp.Text       = "Max Temp: " + wr.Max_Temp + "C";
                        lblTemp.Text          = "Temp: " + wr.The_Temp + "C";
                        lblWindSpeed.Text     = "Wind Speed: " + Convert.ToDecimal(wr.Wind_Speed).ToString("0.00") + "Mph";
                        lblWindDirection.Text = "Wind Direction: " + WeatherFormatting.DegreesToCardinal(Convert.ToDouble(wr.Wind_Direction));
                        lblAirPressure.Text   = "Air Pressure: " + wr.Air_Pressure.ToString() + " mbar";
                        lblHumidity.Text      = "Humidity: " + wr.Humidity.ToString() + "%";
                        lblVisibility.Text    = "Visibility: " + wr.Visibility.ToString("0.00") + " miles";
                    }
                    else
                    {
                        output.AppendLine("<div style=\"position:relative; font-size:22px; width:50px; float:left; padding:20px;\">");
                        output.AppendLine("<b>" + wr.Applicable_Date.DayOfWeek + "</b><br />");
                        output.AppendLine("<img src=\"" + wr.WeatherState.Icon + "\" />");
                        output.AppendLine(wr.Weather_State_Name);
                        output.AppendLine("</div>");
                    }
                }

                DisplayHtml(output.ToString());
                Windows.LoadingState(false, this);
            }

            catch (Exception e) {
                EnableInterface(false);
                return;
            }
        }