private void ParseRAWPayload(Stream e) { XDocument document; using (var reader = new StreamReader(e)) { string payload = reader.ReadToEnd().Replace('\0', ' '); document = XDocument.Parse(payload); } XElement updateElement = document.Root; string locationName = updateElement.Element("Location").Value; LocationInformation locationInfo = Locations[locationName]; App.Trace("Got location: " + locationName); string temperature = updateElement.Element("Temperature").Value; locationInfo.Temperature = temperature; App.Trace("Got temperature: " + temperature); string weather = updateElement.Element("WeatherType").Value; locationInfo.ImageName = weather; App.Trace("Got weather type: " + weather); }
private void UnpinItem_Click(object sender, RoutedEventArgs e) { LocationInformation locationInformation = (sender as MenuItem).DataContext as LocationInformation; ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault( t => t.NavigationUri.ToString().EndsWith(locationInformation.Name)); if (tile == null) { MessageBox.Show("Tile inconsistency detected. It is suggested that you restart the application."); return; } try { tile.Delete(); locationInformation.TilePinned = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error deleting tile", MessageBoxButton.OK); return; } }
private void PinItem_Click(object sender, RoutedEventArgs e) { LocationInformation locationInformation = (sender as MenuItem).DataContext as LocationInformation; Uri tileUri = MakeTileUri(locationInformation); StandardTileData initialData = new StandardTileData() { BackgroundImage = new Uri("Images/Clear.png", UriKind.Relative), Title = locationInformation.Name }; ((sender as MenuItem).Parent as ContextMenu).IsOpen = false; try { ShellTile.Create(tileUri, initialData); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error creating tile", MessageBoxButton.OK); return; } }
/// <summary> /// Creates a Uri leading to the location specified by the location information to be bound to a tile. /// </summary> /// <param name="locationInformation">The location information for which to generate the Uri.</param> /// <returns>Uri for the page displaying information about the provided location.</returns> private static Uri MakeTileUri(LocationInformation locationInformation) { return new Uri(Uri.EscapeUriString(String.Format("/CityPage.xaml?location={0}", locationInformation.Name)), UriKind.Relative); }
/// <summary> /// Creates a Uri leading to the location specified by the location information to be bound to a tile. /// </summary> /// <param name="locationInformation">The location information for which to generate the Uri.</param> /// <returns>Uri for the page displaying information about the provided location.</returns> private static Uri MakeTileUri(LocationInformation locationInformation) { return(new Uri(Uri.EscapeUriString(String.Format("/CityPage.xaml?location={0}", locationInformation.Name)), UriKind.Relative)); }