private void CompareAddTimeRead(PFeedItem item, ItemsControl display, bool checkRead) { item.dateoffset = (DateTime.Now.Date == item.PublishedDate.Date) ? item.PublishedDate.DateTime.ToString("HH:mm") : item.dateoffset = item.PublishedDate.DateTime.ToString("MM.dd"); display.Items.Add(item); }
private void ListTapped(object sender, TappedRoutedEventArgs e) { Button stack = (Button)sender; PFeedItem p = (PFeedItem)stack.DataContext; ArticleFrame.Navigate(typeof(PArticle), p); }
private void ListTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { PFeedItem item = (PFeedItem)((Button)sender).DataContext; bag.frame.Navigate(typeof(PArticle), item); MarkAsRead(item); }
private void ReadItem_Click(object sender, RoutedEventArgs e) { PFeedItem item = (PFeedItem)((MenuFlyoutItem)sender).DataContext; bag.frame.Navigate(typeof(PArticle), item); MarkAsRead(item); }
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 ReadItem_Click(object sender, RoutedEventArgs e) { MenuFlyoutItem stack = (MenuFlyoutItem)sender; PFeedItem p = (PFeedItem)stack.DataContext; ArticleFrame.Navigate(typeof(PArticle), p); }
private void CopyLink_Click(object sender, RoutedEventArgs e) { PFeedItem item = (PFeedItem)((MenuFlyoutItem)sender).DataContext; DataPackage dataPackage = new DataPackage(); dataPackage.SetText(item.link); Clipboard.SetContent(dataPackage); }
private async Task SearchArticleFromNotification(string theid, string website) { SyndicationFeed feed = await SyndicationConverter.RetrieveFeedAsync(website); foreach (SyndicationItem item in feed.Items) { try { string itemid = (int)item.Title.Text.First() + item.PublishedDate.Second.ToString() + item.PublishedDate.Minute.ToString() + item.PublishedDate.Hour.ToString() + item.PublishedDate.Day.ToString(); if (theid == itemid) { PFeedItem target = new PFeedItem(); target.title = Regex.Replace(item.Title.Text, @"(&.*?;)", " "); target.link = item.Links.FirstOrDefault().Uri.ToString(); target.feed = feed.Title.Text; target.PublishedDate = item.PublishedDate; target.opacity = 0.5; App.Read = App.Read + itemid + ';'; await FileIO.AppendTextAsync(await ApplicationData.Current.LocalFolder.GetFileAsync("read.txt"), itemid + ';'); try { target.content = item.Summary.Text; if (App.config.DownloadImages) { Match match = Regex.Match(target.content, @"<img(.*?)>", RegexOptions.Singleline); if (match.Success) { string val = match.Groups[1].Value; Match match2 = Regex.Match(val, @"src=\""(.*?)\""", RegexOptions.Singleline); if (match2.Success) { target.image = match2.Groups[1].Value; target.iconopacity = 0; } } } } catch { target.content = string.Empty; } ArticleFrame.Navigate(typeof(PArticle), target); } } catch (Exception ex) { Debug.Write(ex.ToString()); } } }
private async Task Go(List <Website> sites) { await Task.Delay(300); List <PFeedItem> fullfeed = new List <PFeedItem>(); foreach (Website website in sites) { SyndicationFeed feed = new SyndicationFeed(); try { feed = await SyndicationConverter.RetrieveFeedAsync(website.url); } catch { continue; } foreach (SyndicationItem item in feed.Items) { PFeedItem target = new PFeedItem(); try { target.title = Regex.Replace(item.Title.Text, @"(&.*?;)", " "); target.feed = feed.Title.Text; target.PublishedDate = item.PublishedDate; target.content = item.Summary.Text; target.link = item.Links.FirstOrDefault().Uri.ToString(); if (App.config.DownloadImages) { Match match = Regex.Match(target.content, @"<img(.*?)>", RegexOptions.Singleline); if (match.Success) { string val = match.Groups[1].Value; Match match2 = Regex.Match(val, @"src=\""(.*?)\""", RegexOptions.Singleline); if (match2.Success) { target.image = match2.Groups[1].Value; target.iconopacity = 0; } } } } catch { target.content = string.Empty; target.link = string.Empty; } fullfeed.Add(target); } } Fullfeed = fullfeed.OrderByDescending(x => x.PublishedDate).ToList(); }
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 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 async void BarWeb_Click(object sender, RoutedEventArgs e) { PFeedItem item = (PFeedItem)((MenuFlyoutItem)sender).DataContext; ResourceLoader rl = new ResourceLoader(); try { await Windows.System.Launcher.LaunchUriAsync(new Uri(item.link)); } catch { await(new MessageDialog(rl.GetString("ArticleOpenEdgeError"))).ShowAsync(); } MarkAsRead(item); }
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(); } }
private async void Button_RightTapped(object sender, RoutedEventArgs e) { PFeedItem item = (PFeedItem)((Button)sender).DataContext; MenuFlyout menu = FlyoutBase.GetAttachedFlyout((Button)sender) as MenuFlyout; MenuFlyoutItem favbutton = menu.Items[4] as MenuFlyoutItem; MenuFlyoutSeparator favsep = menu.Items[3] as MenuFlyoutSeparator; StorageFile cache = await ApplicationData.Current.LocalFolder.GetFileAsync("saved_cache"); string favcache = await FileIO.ReadTextAsync(cache); if (favcache.Contains(item.link)) { favbutton.Visibility = Visibility.Collapsed; favsep.Visibility = Visibility.Collapsed; } FlyoutBase.ShowAttachedFlyout(sender as FrameworkElement); }
private async void AddToFavs_Click(object sender, RoutedEventArgs e) { PFeedItem item = (PFeedItem)((MenuFlyoutItem)sender).DataContext; StorageFile cache = await ApplicationData.Current.LocalFolder.GetFileAsync("saved_cache"); string favcache = await FileIO.ReadTextAsync(cache); if (!favcache.Contains(item.link)) { StorageFolder favoritesFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("favorites"); int filecount = (await favoritesFolder.GetFilesAsync()).Count; StorageFolder storageFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("favorites"); SerializerExtensions.SerializeObject(item, await storageFolder.CreateFileAsync(filecount.ToString())); await FileIO.AppendTextAsync(cache, item.link + ";"); } }
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); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { Value = (PFeedItem)e.Parameter; StorageFile saved_cache = await ApplicationData.Current.LocalFolder.GetFileAsync("saved_cache"); string cache = await FileIO.ReadTextAsync(saved_cache); if (cache.Contains(Value.link)) { FavBtn.IsEnabled = false; } Title.Text = Value.title; Feed.Text = Value.feed; Date.Text = Value.PublishedDate.DateTime.ToString(); Link = Value.link; ContentRTB.FontSize = App.config.FontSize; ContentRTB.LineHeight = App.config.FontSize * 1.5; string cleancontent = Regex.Replace(Value.content, @"(&.*?;)", " "); cleancontent = Regex.Replace(cleancontent, @"\r\n?|\n", ""); List <Block> blocks = HtmlToRichTextBlock.GenerateBlocksForHtml(cleancontent); ContentRTB.Blocks.Clear(); foreach (Block b in blocks) { ContentRTB.Blocks.Add(b); } DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += new Windows.Foundation.TypedEventHandler <DataTransferManager, DataRequestedEventArgs>(this.ShareTextHandler); }
private async void OpenInEdge_Click(object sender, RoutedEventArgs e) { MenuFlyoutItem stack = (MenuFlyoutItem)sender; PFeedItem p = (PFeedItem)stack.DataContext; await Windows.System.Launcher.LaunchUriAsync(new Uri(p.link)); }