private async void stack_Tapped(object sender, TappedRoutedEventArgs e) { if (MainBorder.Height == 46) { // Expand ExpandCollapse.Content = ""; ExpandItems(46, (cat.websites.Count * 66) + 46 + 80); if (!loaded) { SyndicationClient client = new SyndicationClient(); foreach (Website ws in cat.websites) { ListFeed feeditem = await GetItem(client, ws.url); Display.Items.Add(feeditem); } LoadStatus.IsIndeterminate = false; LoadStatus.Opacity = 0; loaded = true; } } else { // Collapse ExpandCollapse.Content = ""; ExpandItems((cat.websites.Count * 66) + 46 + 80, 46); } }
private void Grid_RightTapped(object sender, RoutedEventArgs e) { ListFeed feeditem = (ListFeed)((FrameworkElement)sender).DataContext; ResourceLoader rl = new ResourceLoader(); foreach (Website website in cat.websites) { if (website.url != feeditem.feedid) { continue; } MenuFlyout menu = FlyoutBase.GetAttachedFlyout((Grid)sender) as MenuFlyout; MenuFlyoutItem item = menu.Items[0] as MenuFlyoutItem; if (website.notify) { item.Text = rl.GetString("NotifyOff"); } else { item.Text = rl.GetString("NotifyOn"); } website_buffer = feeditem.feedid; break; } FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender); }
private void SearchItemCopy_Click(object sender, RoutedEventArgs e) { ListFeed feed = (ListFeed)((FrameworkElement)sender).DataContext; DataPackage dataPackage = new DataPackage(); dataPackage.SetText(feed.feedid); Clipboard.SetContent(dataPackage); }
private async void Delete_Button_Click(object sender, RoutedEventArgs e) { ListFeed p = (ListFeed)((FrameworkElement)sender).DataContext; string link = p.feedid; ResourceLoader rl = new ResourceLoader(); var dialog = new MessageDialog(rl.GetString("DeleteAction")); dialog.Title = rl.GetString("DeleteElement"); dialog.Commands.Add(new UICommand { Label = rl.GetString("Delete"), Id = 0 }); dialog.Commands.Add(new UICommand { Label = rl.GetString("Cancel"), Id = 1 }); var res = await dialog.ShowAsync(); if ((int)res.Id == 0) { Categories cats = await SerializerExtensions.DeSerializeObject <Categories>( await ApplicationData.Current.LocalFolder.GetFileAsync("sites")); foreach (Website wb in cat.websites) { if (wb.url != link) { continue; } cat.websites.Remove(wb); break; } foreach (Category c in cats.categories) { if (c.title != cat.title) { continue; } foreach (Website wb in c.websites) { if (wb.url != link) { continue; } c.websites.Remove(wb); break; } break; } SerializerExtensions.SerializeObject(cats, await ApplicationData.Current.LocalFolder.GetFileAsync("sites")); Display.Items.Remove(p); CountInCategory.Content = cat.websites.Count; ExpandItems(MainBorder.Height, MainBorder.Height - 66); } }
private async void SearchItemOpen_Click(object sender, RoutedEventArgs e) { ListFeed feed = (ListFeed)((FrameworkElement)sender).DataContext; try { await Windows.System.Launcher.LaunchUriAsync(new Uri(feed.feedlink)); } catch { } }
private async Task SearchForFeeds(string query) { try { WebRequest request = WebRequest.Create(query); request.ContentType = "application/json; charset=utf-8"; WebResponse response = await request.GetResponseAsync(); string responseString = string.Empty; using (Stream stream = response.GetResponseStream()) { StreamReader reader = new StreamReader(stream, Encoding.UTF8); responseString = reader.ReadToEnd(); } if (responseString != string.Empty) { dynamic stuff = JObject.Parse(responseString); Display.Items.Clear(); foreach (var item in stuff.responseData.entries) { ListFeed lf = new ListFeed(); lf.feedid = item.url; lf.feedlink = item.link; string content; content = Regex.Replace(item.title.ToString(), @"<[^>]*>", string.Empty); content = Regex.Replace(content, @"(&.*?;)", " "); content = Regex.Replace(content, @"\r|\n", string.Empty); lf.feedtitle = content; content = Regex.Replace(item.contentSnippet.ToString(), @"<[^>]*>", string.Empty); content = Regex.Replace(content, @"(&.*?;)", " "); content = Regex.Replace(content, @"\r|\n", string.Empty); lf.feedsubtitle = content; lf.feedimg = "http://www.google.com/s2/favicons?domain=" + lf.feedlink; Display.Items.Add(lf); } } if (Display.Items.Count < 1) { throw new Exception(); } } catch { NetworkError.Opacity = 0; NetworkError.Visibility = Visibility.Visible; ErrorEnabling.Begin(); } }
public static async Task <ListFeed> GetItem(SyndicationClient client, string website) { ResourceLoader rl = new ResourceLoader(); ListFeed list = new ListFeed(); try { SyndicationFeed feed = await SyndicationConverter.RetrieveFeedAsync(website); if (feed.Title != null) { list.feedimg = "http://www.google.com/s2/favicons?domain=" + website; if (feed.Subtitle != null) { list.feedtitle = feed.Title.Text; list.feedsubtitle = feed.Subtitle.Text; } else { list.feedtitle = feed.Title.Text; list.feedsubtitle = rl.GetString("SiteFeed") + list.feedtitle; } } else { list.feedtitle = website; list.feedsubtitle = rl.GetString("CanNotGetData"); } list.feedid = website; return(list); } catch { list.feedtitle = website; list.feedsubtitle = rl.GetString("CanNotGetData"); list.feedid = website; return(list); } }
private async void AddButton_Click(object sender, RoutedEventArgs e) { ListFeed feed = (ListFeed)((FrameworkElement)sender).DataContext; ResourceLoader rl = new ResourceLoader(); bool isEmpty = false; SearchAddDialog addsource = new SearchAddDialog(); Categories cats = new Categories(); ComboBox box = new ComboBox(); addsource.Loaded += async(s, a) => { cats = await SerializerExtensions.DeSerializeObject <Categories>( await ApplicationData.Current.LocalFolder.GetFileAsync("sites")); box = addsource.CategoriesComboBox; foreach (Category cat in cats.categories) { box.Items.Add(cat.title); } if (box.Items.Count < 1) { addsource.CategoriesTextBlock.Visibility = Visibility.Collapsed; addsource.CategoriesComboBox.Visibility = Visibility.Collapsed; addsource.Title = rl.GetString("SearchCreateNewCatTitleFL"); addsource.CategoriesTextBlockBox.Text = rl.GetString("SearchCreateNewCatTextFL"); isEmpty = true; return; } box.SelectedIndex = 0; }; if (await addsource.ShowAsync() == ContentDialogResult.Primary) { string name = addsource.CategoriesText.Text; if (string.IsNullOrWhiteSpace(name) && isEmpty) { return; } if (!string.IsNullOrWhiteSpace(name)) { foreach (Category c in cats.categories) { if (c.title == name) { await(new MessageDialog((new ResourceLoader()).GetString("CategoryExists")).ShowAsync()); return; } } Category newcat = new Category() { title = name, websites = new List <Website>() { new Website() { notify = true, url = feed.feedid } } }; cats.categories.Add(newcat); SerializerExtensions.SerializeObject(cats, await ApplicationData.Current.LocalFolder.GetFileAsync("sites")); addsource.Hide(); await(new MessageDialog(string.Format(rl.GetString("SearchAddMessage"), feed.feedtitle, name), rl.GetString("SearchAddSuccess"))).ShowAsync(); return; } name = (string)box.SelectedItem; foreach (Category cat in cats.categories) { if (cat.title != name) { continue; } Website wb = new Website(); wb.url = feed.feedid; cat.websites.Add(wb); break; } SerializerExtensions.SerializeObject(cats, await ApplicationData.Current.LocalFolder.GetFileAsync("sites")); addsource.Hide(); await(new MessageDialog(string.Format(rl.GetString("SearchAddMessage"), feed.feedtitle, name), rl.GetString("SearchAddSuccess"))).ShowAsync(); } }