private async void MarkAsRead(PFeedItem item) { if (App.Read.Contains(item.GetTileId())) { return; } Button button = VisualTreeHelper.GetChild((FrameworkElement)Display.ContainerFromItem(item), 0) as Button; await FileIO.AppendTextAsync(await ApplicationData.Current.LocalFolder.GetFileAsync("read.txt"), item.GetTileId() + ";"); App.Read = App.Read + item.GetTileId() + ";"; button.Opacity = 0.5; }
private void CompareAddTimeRead(PFeedItem item) { item.dateoffset = (DateTime.Now.Date == item.PublishedDate.Date) ? item.PublishedDate.DateTime.ToString("HH:mm") : item.dateoffset = item.PublishedDate.DateTime.ToString("MM.dd"); item.opacity = App.Read.Contains(item.GetTileId()) ? 0.5 : 1; Display.Items.Add(item); }
private void SavedItem_Holding(object sender, RoutedEventArgs e) { PFeedItem feeditem = (PFeedItem)((FrameworkElement)sender).DataContext; MenuFlyout menu = FlyoutBase.GetAttachedFlyout((Button)sender) as MenuFlyout; MenuFlyoutItem itempin = menu.Items[2] as MenuFlyoutItem; MenuFlyoutItem itemunpin = menu.Items[3] as MenuFlyoutItem; if (!SecondaryTile.Exists(feeditem.GetTileId())) { itempin.Visibility = Visibility.Collapsed; itemunpin.Visibility = Visibility.Visible; } else { itemunpin.Visibility = Visibility.Collapsed; itempin.Visibility = Visibility.Visible; } FlyoutBase.ShowAttachedFlyout(sender as FrameworkElement); }
private async void PinToStart_Click(object sender, RoutedEventArgs e) { PFeedItem feeditem = (PFeedItem)((FrameworkElement)sender).DataContext; string TileId = feeditem.GetTileId(); SecondaryTile secondaryTile = new SecondaryTile( TileId, "myFeed Article", feeditem.link, new Uri("ms-appx:///Assets/Square150x150Logo.scale-200.png"), TileSize.Square150x150 ); await secondaryTile.RequestCreateAsync(); string contents = string.Format(@" <tile> <visual> <binding template='TileMedium'> <text hint-wrap='true' hint-maxLines='2' hint-style='caption'>{0}</text> <text hint-style='captionSubtle'>{1}</text> <text hint-style='captionSubtle'>{2}</text> </binding> <binding template='TileWide'> <text hint-wrap='true' hint-maxLines='3' hint-style='caption'>{0}</text> <text hint-style='captionSubtle'>{1}</text> <text hint-style='captionSubtle'>{3}</text> </binding> </visual> </tile> ", feeditem.title, feeditem.feed, feeditem.PublishedDate.ToString("dd.MM.yyyy"), feeditem.PublishedDate.ToString("dd.MM.yyyy HH: mm")); Windows.Data.Xml.Dom.XmlDocument xmlDoc = new Windows.Data.Xml.Dom.XmlDocument(); xmlDoc.LoadXml(contents); TileNotification notifyTile = new TileNotification(xmlDoc); TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId).Update(notifyTile); }
private async void UnpinFromStart_Click(object sender, RoutedEventArgs e) { PFeedItem feeditem = (PFeedItem)((FrameworkElement)sender).DataContext; IReadOnlyList <SecondaryTile> sTiles = await SecondaryTile.FindAllAsync(); SecondaryTile tile = (await SecondaryTile.FindAllAsync()).FirstOrDefault((t) => t.TileId == feeditem.GetTileId()); if (tile != null) { await tile.RequestDeleteAsync(); } }
private async void DeleteItem_Click(object sender, RoutedEventArgs e) { MenuFlyoutItem stack = (MenuFlyoutItem)sender; PFeedItem p = (PFeedItem)stack.DataContext; int index = Display.Items.IndexOf(p); StorageFile saved_cache = await ApplicationData.Current.LocalFolder.GetFileAsync("saved_cache"); string cache = await FileIO.ReadTextAsync(saved_cache); await FileIO.WriteTextAsync(saved_cache, cache.Replace(p.link + ';', string.Empty)); StorageFolder filefolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("favorites"); IReadOnlyList <StorageFile> files = await filefolder.GetFilesAsync(); int filecount = files.Count; await files[index].DeleteAsync(); Display.Items.Remove(p); if ((filecount > 1) && (filecount - 1 != index)) { for (int x = index + 1; x < filecount; x++) { await files[x].RenameAsync((x - 1).ToString()); } } if (filecount - 1 < 1) { WelcomeEnabling.Begin(); } IReadOnlyList <SecondaryTile> sTiles = await SecondaryTile.FindAllAsync(); SecondaryTile tile = (await SecondaryTile.FindAllAsync()).FirstOrDefault((t) => t.TileId == p.GetTileId()); if (tile != null) { await tile.RequestDeleteAsync(); } }