1) Get the weather update from google.
2) Prepare WebClient For Fetch the XML (using WCF or Silverlight) here i am doing using WCF Data contract Class:
<DataContract()>
Public Class WeatherReport
<DataMember()>
Public ForecastInformation As New ForecastInformation
<DataMember()>
Public CurrentWeather As New CurrentWeather
<DataMember()>
Public WeatherFullReport As New List(Of WeatherFullReport)
<DataMember()>
Public Status As String
End Class
<DataContract()>
Public Class ForecastInformation
<DataMember()>
Public City As String
<DataMember()>
Public PostalCode As String
<DataMember()>
Public ForecastDate As String
<DataMember()>
Public CurrentDateTime As String
End Class
<DataContract()>
Public Class CurrentWeather
<DataMember()>
Public Condition As String
<DataMember()>
Public Temp_Fahrenheit As String
<DataMember()>
Public Temp_Celsius As String
<DataMember()>
Public Humidity As String
<DataMember()>
Public icon As String
<DataMember()>
Public WindCondition As String
End Class
<DataContract()>
Public Class WeatherFullReport
<DataMember()>
Public DayOfWeek As String
<DataMember()>
Public Low As String
<DataMember()>
Public High As String
<DataMember()>
Public icon As String
<DataMember()>
Public WindCondition As String
End Class
Public Function GET_WEATHERREPORT(ByVal Location As String) As WeatherReport Implements IService.GET_WEATHERREPORT
Dim ReturnObj As New WeatherReport
Dim webClient As New WebClient()
webClient.Headers.Add("Content-Type", "application/xml")
webClient.Encoding = Encoding.UTF8
webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)")
Try
Dim Site As String = "http://www.google.com"
Dim Query As String = Site & "/ig/api?weather=" & Location
'Dim result As String = webClient.DownloadString(Query)
Dim reader As New XmlTextReader(Query)
' While reader.Read()
reader.Read()
reader.Read()
reader.Read()
reader.Read()
If reader.Name = "forecast_information" Then
reader.Read()
If reader.Name = "city" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.ForecastInformation.City = attribute
End If
End If
reader.Read()
If reader.Name = "postal_code" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.ForecastInformation.PostalCode = attribute
End If
End If
reader.Read()
reader.Read()
reader.Read()
reader.Read()
If reader.Name = "current_date_time" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.ForecastInformation.CurrentDateTime = attribute
End If
End If
reader.Read()
End If
reader.Read()
reader.Read()
If reader.Name = "current_conditions" Then
reader.Read()
If reader.Name = "condition" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.CurrentWeather.Condition = attribute
End If
End If
reader.Read()
If reader.Name = "temp_f" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.CurrentWeather.Temp_Fahrenheit = attribute
End If
End If
reader.Read()
If reader.Name = "temp_c" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.CurrentWeather.Temp_Celsius = attribute
End If
End If
reader.Read()
If reader.Name = "humidity" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.CurrentWeather.Humidity = attribute
End If
End If
reader.Read()
If reader.Name = "icon" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.CurrentWeather.icon = Site & attribute
End If
End If
reader.Read()
If reader.Name = "wind_condition" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
ReturnObj.CurrentWeather.WindCondition = attribute
End If
End If
End If
reader.Read()
While reader.Read()
If reader.Name = "forecast_conditions" Then
Dim forecast_conditions As New WeatherFullReport
reader.Read()
If reader.Name = "day_of_week" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
forecast_conditions.DayOfWeek = attribute
End If
End If
reader.Read()
If reader.Name = "low" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
forecast_conditions.Low = attribute
End If
End If
reader.Read()
If reader.Name = "high" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
forecast_conditions.High = attribute
End If
End If
reader.Read()
If reader.Name = "icon" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
forecast_conditions.icon = Site & attribute
End If
End If
reader.Read()
If reader.Name = "condition" Then
Dim attribute As String = reader("data")
If attribute IsNot Nothing Then
forecast_conditions.WindCondition = attribute
End If
End If
ReturnObj.WeatherFullReport.Add(forecast_conditions)
End If
reader.Read()
End While
reader.Read()
If reader.Name = "problem_cause" Then
ReturnObj.Status = "No Wearther Report Found For Location: " + Location
End If
'End While
Catch ex As Exception
ReturnObj.Status = "Weather Report is currently Unavilable"
End Try
Return ReturnObj
End Function
3) Call WCF In silverlight
XAML
<Canvas Height="33" Name="Canvas2" Width="458" Canvas.Left="251" Canvas.Top="20">
<sdk:Label Canvas.Left="0" Canvas.Top="0" Content="Location" Foreground="White" Height="28" Name="Label4" Width="49" />
<sdk:AutoCompleteBox Canvas.Left="58" Canvas.Top="2" IsTextCompletionEnabled="True" Name="SearchArea" Width="320" Text="Chennai, Tamil Nadu" />
<Button Canvas.Left="380" Canvas.Top="1" Content="Search" Height="27" Name="Find" TabIndex="3" Template="{StaticResource SearchButton}" Width="74" />
</Canvas>
<sdk:Label Content="Weather" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" Name="Label3" Width="63" Canvas.Left="61" Canvas.Top="20">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<Image Name="Image3" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" Canvas.Left="8" Canvas.Top="10" Height="59" Width="50" />
<Grid Height="254" Name="WeatherGrid" Width="848" Canvas.Left="11" Canvas.Top="59" Visibility="Visible">
<sdk:Label Content="Weather for Chennai, Tamil Nadu" FontFamily="Arial" FontSize="14" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="33,0,579,204" Name="lblocation" Width="236" VerticalAlignment="Bottom">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<Image Margin="33,69,681,30" Name="CurrentWeatherIcon" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<Rectangle Margin="357,16,488,18" Style="{StaticResource DividerStyle}" />
<Image Margin="393,69,378,98" Name="WeatherDayIcon1" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="393,40,378,191" Name="WeatherDay1" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" Foreground="#FFFFCC01" Height="28" Margin="404,162,421,64" Name="WeatherDayHigh1" FontWeight="Bold" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="438,162,389,64" Name="WeatherDayLow1" />
<Image Margin="510,69,261,98" Name="WeatherDayIcon2" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="510,40,261,191" Name="WeatherDay2" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="521,162,304,64" Name="WeatherDayHigh2" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="555,162,272,64" Name="WeatherDayLow2" />
<Image Margin="621,69,150,98" Name="WeatherDayIcon3" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="621,40,150,191" Name="WeatherDay3" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="632,162,193,64" Name="WeatherDayHigh3" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="666,162,161,64" Name="WeatherDayLow3" />
<Image Margin="738,69,33,98" Name="WeatherDayIcon4" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="738,40,33,191" Name="WeatherDay4" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="749,162,76,64" Name="WeatherDayHigh4" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="783,162,44,64" Name="WeatherDayLow4" />
<sdk:Label Content="36 C" FontWeight="Bold" Foreground="#FFFFCC01" Margin="190,69,0,134" Name="CurrentWeatherC" FontSize="16" HorizontalAlignment="Left" Width="40" />
<sdk:Label Content="36 F" FontSize="16" FontWeight="Bold" Foreground="White" Margin="267,69,541,134" Name="CurrentWeatherF" />
<Rectangle Margin="248,82,599,142" Style="{StaticResource DividerStyle}" Height="30" />
<TextBlock Height="98" HorizontalAlignment="Left" Margin="190,126,0,0" Name="CurrentWeather" Text="TextBlock" VerticalAlignment="Top" Width="154" Foreground="White" FontWeight="Bold" FontSize="14" FontFamily="Arial">
Scattered Clouds<LineBreak /><LineBreak />
Wind: SW at 13 km/h<LineBreak /><LineBreak />
Humidity: 62%<LineBreak /><LineBreak /></TextBlock>
</Grid>
<sdk:Label Canvas.Left="324" Canvas.Top="173" Content="Loading ..." FontFamily="Arial" FontSize="14" FontWeight="Bold" Foreground="#FFFFB100" Height="23" Name="lberror" Width="236">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
</Canvas>
<Canvas Height="322" Width="860">
<Canvas Height="33" Name="Canvas2" Width="458" Canvas.Left="251" Canvas.Top="20">
<sdk:Label Canvas.Left="0" Canvas.Top="0" Content="Location" Foreground="White" Height="28" Name="Label4" Width="49" />
<sdk:AutoCompleteBox Canvas.Left="58" Canvas.Top="2" IsTextCompletionEnabled="True" Name="SearchArea" Width="320" Text="Chennai, Tamil Nadu" />
<Button Canvas.Left="380" Canvas.Top="1" Content="Search" Height="27" Name="Find" TabIndex="3" Template="{StaticResource SearchButton}" Width="74" />
</Canvas>
<sdk:Label Content="Weather" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" Name="Label3" Width="63" Canvas.Left="61" Canvas.Top="20">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<Image Name="Image3" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" Canvas.Left="8" Canvas.Top="10" Height="59" Width="50" />
<Grid Height="254" Name="WeatherGrid" Width="848" Canvas.Left="11" Canvas.Top="59" Visibility="Visible">
<sdk:Label Content="Weather for Chennai, Tamil Nadu" FontFamily="Arial" FontSize="14" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="33,0,579,204" Name="lblocation" Width="236" VerticalAlignment="Bottom">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<Image Margin="33,69,681,30" Name="CurrentWeatherIcon" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<Rectangle Margin="357,16,488,18" Style="{StaticResource DividerStyle}" />
<Image Margin="393,69,378,98" Name="WeatherDayIcon1" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="393,40,378,191" Name="WeatherDay1" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" Foreground="#FFFFCC01" Height="28" Margin="404,162,421,64" Name="WeatherDayHigh1" FontWeight="Bold" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="438,162,389,64" Name="WeatherDayLow1" />
<Image Margin="510,69,261,98" Name="WeatherDayIcon2" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="510,40,261,191" Name="WeatherDay2" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="521,162,304,64" Name="WeatherDayHigh2" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="555,162,272,64" Name="WeatherDayLow2" />
<Image Margin="621,69,150,98" Name="WeatherDayIcon3" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="621,40,150,191" Name="WeatherDay3" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="632,162,193,64" Name="WeatherDayHigh3" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="666,162,161,64" Name="WeatherDayLow3" />
<Image Margin="738,69,33,98" Name="WeatherDayIcon4" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="738,40,33,191" Name="WeatherDay4" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="749,162,76,64" Name="WeatherDayHigh4" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="783,162,44,64" Name="WeatherDayLow4" />
<sdk:Label Content="36 C" FontWeight="Bold" Foreground="#FFFFCC01" Margin="190,69,0,134" Name="CurrentWeatherC" FontSize="16" HorizontalAlignment="Left" Width="40" />
<sdk:Label Content="36 F" FontSize="16" FontWeight="Bold" Foreground="White" Margin="267,69,541,134" Name="CurrentWeatherF" />
<Rectangle Margin="248,82,599,142" Style="{StaticResource DividerStyle}" Height="30" />
<TextBlock Height="98" HorizontalAlignment="Left" Margin="190,126,0,0" Name="CurrentWeather" Text="TextBlock" VerticalAlignment="Top" Width="154" Foreground="White" FontWeight="Bold" FontSize="14" FontFamily="Arial">
Scattered Clouds<LineBreak /><LineBreak />
Wind: SW at 13 km/h<LineBreak /><LineBreak />
Humidity: 62%<LineBreak /><LineBreak /></TextBlock>
</Grid>
<sdk:Label Canvas.Left="324" Canvas.Top="173" Content="Loading ..." FontFamily="Arial" FontSize="14" FontWeight="Bold" Foreground="#FFFFB100" Height="23" Name="lberror" Width="236">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
</Canvas>
<Canvas Height="322" Width="860">
<Canvas Height="33" Name="Canvas2" Width="458" Canvas.Left="251" Canvas.Top="20">
<sdk:Label Canvas.Left="0" Canvas.Top="0" Content="Location" Foreground="White" Height="28" Name="Label4" Width="49" />
<sdk:AutoCompleteBox Canvas.Left="58" Canvas.Top="2" IsTextCompletionEnabled="True" Name="SearchArea" Width="320" Text="Chennai, Tamil Nadu" />
<Button Canvas.Left="380" Canvas.Top="1" Content="Search" Height="27" Name="Find" TabIndex="3" Template="{StaticResource SearchButton}" Width="74" />
</Canvas>
<sdk:Label Content="Weather" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" Name="Label3" Width="63" Canvas.Left="61" Canvas.Top="20">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<Image Name="Image3" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" Canvas.Left="8" Canvas.Top="10" Height="59" Width="50" />
<Grid Height="254" Name="WeatherGrid" Width="848" Canvas.Left="11" Canvas.Top="59" Visibility="Visible">
<sdk:Label Content="Weather for Chennai, Tamil Nadu" FontFamily="Arial" FontSize="14" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="33,0,579,204" Name="lblocation" Width="236" VerticalAlignment="Bottom">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<Image Margin="33,69,681,30" Name="CurrentWeatherIcon" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<Rectangle Margin="357,16,488,18" Style="{StaticResource DividerStyle}" />
<Image Margin="393,69,378,98" Name="WeatherDayIcon1" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="393,40,378,191" Name="WeatherDay1" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" Foreground="#FFFFCC01" Height="28" Margin="404,162,421,64" Name="WeatherDayHigh1" FontWeight="Bold" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="438,162,389,64" Name="WeatherDayLow1" />
<Image Margin="510,69,261,98" Name="WeatherDayIcon2" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="510,40,261,191" Name="WeatherDay2" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="521,162,304,64" Name="WeatherDayHigh2" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="555,162,272,64" Name="WeatherDayLow2" />
<Image Margin="621,69,150,98" Name="WeatherDayIcon3" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="621,40,150,191" Name="WeatherDay3" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="632,162,193,64" Name="WeatherDayHigh3" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="666,162,161,64" Name="WeatherDayLow3" />
<Image Margin="738,69,33,98" Name="WeatherDayIcon4" Source="/app-name;component/Images/mostly_cloudy_1281.png" Stretch="Fill" />
<sdk:Label Content="Thu" FontFamily="Arial" FontSize="12" FontWeight="Bold" Foreground="White" Height="23" HorizontalAlignment="Center" Margin="738,40,33,191" Name="WeatherDay4" Width="77">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFFFCC01" Height="28" Margin="749,162,76,64" Name="WeatherDayHigh4" />
<sdk:Label Content="36" FontWeight="Bold" Foreground="#FFC7C0C0" Height="28" Margin="783,162,44,64" Name="WeatherDayLow4" />
<sdk:Label Content="36 C" FontWeight="Bold" Foreground="#FFFFCC01" Margin="190,69,0,134" Name="CurrentWeatherC" FontSize="16" HorizontalAlignment="Left" Width="40" />
<sdk:Label Content="36 F" FontSize="16" FontWeight="Bold" Foreground="White" Margin="267,69,541,134" Name="CurrentWeatherF" />
<Rectangle Margin="248,82,599,142" Style="{StaticResource DividerStyle}" Height="30" />
<TextBlock Height="98" HorizontalAlignment="Left" Margin="190,126,0,0" Name="CurrentWeather" Text="TextBlock" VerticalAlignment="Top" Width="154" Foreground="White" FontWeight="Bold" FontSize="14" FontFamily="Arial">
Scattered Clouds<LineBreak /><LineBreak />
Wind: SW at 13 km/h<LineBreak /><LineBreak />
Humidity: 62%<LineBreak /><LineBreak /></TextBlock>
</Grid>
<sdk:Label Canvas.Left="324" Canvas.Top="173" Content="Loading ..." FontFamily="Arial" FontSize="14" FontWeight="Bold" Foreground="#FFFFB100" Height="23" Name="lberror" Width="236">
<sdk:Label.Effect>
<DropShadowEffect Opacity="1" />
</sdk:Label.Effect>
</sdk:Label>
</Canvas> </canvas>
Fill Content in WCF Completed
1) Image is provided by google also but its GIF
2) Get Images from http://www.gettyicons.com/free-icon/126/weather-icon-set/free-sun-little-cloud-flash-rain-icon-png/
Dim WeatherReport = e.Result
Dim Dictionary As New Dictionary(Of String, String)
Dictionary.Add("http://www.google.com/ig/images/weather/sunny.gif", "sunny.png")
Dictionary.Add("http://www.google.com/ig/images/weather/mostly_sunny.gif", "mostly_sunny.png")
Dictionary.Add("http://www.google.com/ig/images/weather/partly_cloudy.gif", "partly_cloudy.png")
Dictionary.Add("http://www.google.com/ig/images/weather/mostly_cloudy.gif", "cloudy.png")
Dictionary.Add("http://www.google.com/ig/images/weather/chance_of_storm.gif", "chance_of_storm.png")
Dictionary.Add("http://www.google.com/ig/images/weather/rain.gif", "rain.png")
Dictionary.Add("http://www.google.com/ig/images/weather/chance_of_rain.gif", "chance_of_rain.png")
Dictionary.Add("http://www.google.com/ig/images/weather/chance_of_snow.gif", "chance_of_snow.png")
Dictionary.Add("http://www.google.com/ig/images/weather/cloudy.gif", "cloudy.png")
Dictionary.Add("http://www.google.com/ig/images/weather/mist.gif", "mist.png")
Dictionary.Add("http://www.google.com/ig/images/weather/storm.gif", "chance_of_storm.png")
Dictionary.Add("http://www.google.com/ig/images/weather/thunderstorm.gif", "mist.png")
Dictionary.Add("http://www.google.com/ig/images/weather/chance_of_tstorm.gif", "chance_of_storm.png")
Dictionary.Add("http://www.google.com/ig/images/weather/sleet.gif", "snow.png")
Dictionary.Add("http://www.google.com/ig/images/weather/snow.gif", "snow.png")
Dictionary.Add("http://www.google.com/ig/images/weather/flurries.gif", "chance_of_snow.png")
Dictionary.Add("http://www.google.com/ig/images/weather/icy.gif", "chance_of_snow.png")
Dictionary.Add("http://www.google.com/ig/images/weather/dust.gif", "haze.png")
Dictionary.Add("http://www.google.com/ig/images/weather/fog.gif", "cloudy.png")
Dictionary.Add("http://www.google.com/ig/images/weather/smoke.gif", "haze.png")
Dictionary.Add("http://www.google.com/ig/images/weather/haze.gif", "haze.png")
If Not e.Result.ForecastInformation.City Is Nothing Then
WeatherGrid.Visibility = Windows.Visibility.Visible
lblocation.Content = "Weather for " & e.Result.ForecastInformation.City
CurrentWeatherIcon.Source = New BitmapImage(New Uri("/applicationname;component/Images/Weather/" & Dictionary(e.Result.CurrentWeather.icon), UriKind.RelativeOrAbsolute))
CurrentWeatherC.Content = e.Result.CurrentWeather.Temp_Celsius & ChrW(176) & "C"
CurrentWeatherF.Content = e.Result.CurrentWeather.Temp_Fahrenheit & ChrW(176) & "F"
CurrentWeather.Text = e.Result.CurrentWeather.Condition & ChrW(13) & ChrW(13) & _
e.Result.CurrentWeather.WindCondition & ChrW(13) & ChrW(13) & _
e.Result.CurrentWeather.Humidity
WeatherDay1.Content = e.Result.WeatherFullReport(0).DayOfWeek
WeatherDayHigh1.Content = e.Result.WeatherFullReport(0).High & ChrW(176) & "F"
WeatherDayLow1.Content = e.Result.WeatherFullReport(0).Low & ChrW(176) & "F"
WeatherDayIcon1.Source = New BitmapImage(New Uri("/applicationname;component/Images/Weather/" & Dictionary(e.Result.WeatherFullReport(0).icon), UriKind.RelativeOrAbsolute))
WeatherDay2.Content = e.Result.WeatherFullReport(1).DayOfWeek
WeatherDayHigh2.Content = e.Result.WeatherFullReport(1).High & ChrW(176) & "F"
WeatherDayLow2.Content = e.Result.WeatherFullReport(1).Low & ChrW(176) & "F"
WeatherDayIcon2.Source = New BitmapImage(New Uri("/applicationname;component/Images/Weather/" & Dictionary(e.Result.WeatherFullReport(1).icon), UriKind.RelativeOrAbsolute))
WeatherDay3.Content = e.Result.WeatherFullReport(2).DayOfWeek
WeatherDayHigh3.Content = e.Result.WeatherFullReport(2).High & ChrW(176) & "F"
WeatherDayLow3.Content = e.Result.WeatherFullReport(2).Low & ChrW(176) & "F"
WeatherDayIcon3.Source = New BitmapImage(New Uri("/applicationname;component/Images/Weather/" & Dictionary(e.Result.WeatherFullReport(2).icon), UriKind.RelativeOrAbsolute))
WeatherDay4.Content = e.Result.WeatherFullReport(3).DayOfWeek
WeatherDayHigh4.Content = e.Result.WeatherFullReport(3).High & ChrW(176) & "F"
WeatherDayLow4.Content = e.Result.WeatherFullReport(3).Low & ChrW(176) & "F"
WeatherDayIcon4.Source = New BitmapImage(New Uri("/applicationname;component/Images/Weather/" & Dictionary(e.Result.WeatherFullReport(3).icon), UriKind.RelativeOrAbsolute))
lberror.Content = e.Result.Status
Else
WeatherGrid.Visibility = Windows.Visibility.Collapsed
lberror.Content = "Invalid location!"
End If
End Sub
instead of WCf You can prepare also Xlinq Directly.
ReplyDeleteSorry its not working, Google stops weather reports
ReplyDelete