public async void RefreshForum(ForumEntity forumEntity) { if (ForumPageScrollingCollection == null) return; if (forumEntity.Name.Equals("Bookmarks")) { await ForumPageScrollingCollection.RefreshBookmarkedThreads(); } }
public void MapTo(string subject, string content, ForumEntity forumEntity, PostIconEntity postIconEntity) { Subject = subject; Content = content; Forum = forumEntity; PostIcon = postIconEntity; ParseUrl = true; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { var jsonObjectString = (string)e.NavigationParameter; _forumEntity = JsonConvert.DeserializeObject<ForumEntity>(jsonObjectString); if (_forumEntity == null) return; if (_vm.ForumEntity == null || _vm.ForumEntity.ForumId != _forumEntity.ForumId) _vm.Initialize(_forumEntity); }
public async Task<ObservableCollection<ForumCategoryEntity>> GetForumCategoryMainPage() { var forumGroupList = new ObservableCollection<ForumCategoryEntity>(); var result = await _webManager.GetData(Constants.FORUM_LIST_PAGE); HtmlDocument doc = result.Document; HtmlNode forumNode = doc.DocumentNode.Descendants("select") .FirstOrDefault(node => node.GetAttributeValue("name", string.Empty).Equals("forumid")); if (forumNode != null) { try { IEnumerable<HtmlNode> forumNodes = forumNode.Descendants("option"); foreach (HtmlNode node in forumNodes) { string value = node.Attributes["value"].Value; int id; if (!int.TryParse(value, out id) || id <= -1) continue; if (node.NextSibling.InnerText.Contains("--")) { string forumName = WebUtility.HtmlDecode(node.NextSibling.InnerText.Replace("-", string.Empty)); bool isSubforum = node.NextSibling.InnerText.Count(c => c == '-') > 2; var forumSubCategory = new ForumEntity { Name = forumName.Trim(), Location = string.Format(Constants.FORUM_PAGE, value), IsSubforum = isSubforum }; forumSubCategory.SetForumId(); forumGroupList.LastOrDefault().ForumList.Add(forumSubCategory); } else { string forumName = WebUtility.HtmlDecode(node.NextSibling.InnerText); var forumGroup = new ForumCategoryEntity(forumName, string.Format(Constants.FORUM_PAGE, value)); forumGroupList.Add(forumGroup); } } } catch (Exception ex) { throw new Exception("Main Forum Parsing Error: " + ex.StackTrace); } } #if DEBUG if (forumGroupList.Any()) forumGroupList[3].ForumList.Add(AddDebugForum()); #endif return forumGroupList; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper" /> /// </param> /// <param name="e"> /// Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)" /> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited. /// </param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { loadingProgressBar.Visibility = Visibility.Visible; // TODO: Assign a bindable collection of items to this.DefaultViewModel["Items"] _forumEntity = (ForumEntity) e.NavigationParameter; pageTitle.Text = _forumEntity.Name; pageSnapTitle.Text = _forumEntity.Name; await GetForumThreads(); loadingProgressBar.Visibility = Visibility.Collapsed; }
private async Task Update(IBackgroundTaskInstance taskInstance) { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; var forumCategory = new ForumEntity("Bookmarks", Constants.USER_CP, string.Empty, false); List<ForumThreadEntity> forumThreadEntities = await _threadManager.GetBookmarks(forumCategory); CreateBookmarkLiveTiles(forumThreadEntities); if (localSettings.Values.ContainsKey("_threadIds")) { DeserializeXmlToList((string)localSettings.Values["_threadIds"]); var list = forumThreadEntities.Where(thread => _threadIds.Contains(thread.ThreadId)).ToList(); CreateToastNotifications(list); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { _localSettings = ApplicationData.Current.LocalSettings; if (_localSettings.Values.ContainsKey(Constants.BOOKMARK_STARTUP)) { var bookmarks = (bool) _localSettings.Values[Constants.BOOKMARK_STARTUP]; if (bookmarks) { ForumsPivot.SelectedIndex = 1; } } var forum = new ForumEntity("Bookmarks", Constants.USER_CP, string.Empty, false); _threadVm.Initialize(forum); }
public async Task<IEnumerable<PostIconEntity>> GetPostIconList(ForumEntity forum) { string url = string.Format(Constants.NEW_THREAD, forum.ForumId); WebManager.Result result = await _webManager.GetData(url); HtmlDocument doc = result.Document; HtmlNode[] pageNodes = doc.DocumentNode.Descendants("div").Where(node => node.GetAttributeValue("class", string.Empty).Equals("posticon")).ToArray(); var postIconEntityList = new List<PostIconEntity>(); foreach (var pageNode in pageNodes) { var postIconEntity = new PostIconEntity(); postIconEntity.Parse(pageNode); postIconEntityList.Add(postIconEntity); } return postIconEntityList; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper" /> /// </param> /// <param name="e"> /// Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)" /> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited. /// </param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Assign a bindable collection of items to this.DefaultViewModel["Items"] //loadingProgressBar.Visibility = Visibility.Visible; var jsonObjectString = (string) e.NavigationParameter; _forumEntity = JsonConvert.DeserializeObject<ForumEntity>(jsonObjectString); if (_forumEntity == null) return; if (_vm.ForumEntity == null || _vm.ForumEntity.ForumId != _forumEntity.ForumId || _forumEntity.IsBookmarks) _vm.Initialize(_forumEntity); // TODO: This is stupid shit that should be removed. ViewStateStringFullScreen = "FullScreen" + GetViewStateString(_forumEntity.ForumId); ViewStateStringSnapped = "Snapped" + GetViewStateString(_forumEntity.ForumId); }
public async void Initialize(ForumEntity forumEntity) { this.ForumEntity = forumEntity; IsBookmarks = forumEntity.IsBookmarks; ForumTitle = forumEntity.Name; SubForumEntities = new ObservableCollection<ForumEntity>(); if (forumEntity.IsBookmarks) { _localSettings = ApplicationData.Current.LocalSettings; ForumPageScrollingCollection = new PageScrollingCollection(forumEntity, 1); } else { ForumPageScrollingCollection = new PageScrollingCollection(forumEntity, 1); SubForumEntities = await _forumManager.GetSubForums(forumEntity); } }
public async Task<List<ForumThreadEntity>> GetForumThreads(ForumEntity forumCategory, int page) { // TODO: Remove parsing logic from managers. I don't think they have a place here... var url = forumCategory.Location + string.Format(Constants.PAGE_NUMBER, page); HtmlDocument doc = (await _webManager.DownloadHtml(url)).Document; HtmlNode forumNode = doc.DocumentNode.Descendants().FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("threadlist")); var forumThreadList = new List<ForumThreadEntity>(); foreach (HtmlNode threadNode in forumNode.Descendants("tr").Where(node => node.GetAttributeValue("class", string.Empty).StartsWith("thread"))) { var threadEntity = new ForumThreadEntity(); threadEntity.Parse(threadNode); forumThreadList.Add(threadEntity); } return forumThreadList; }
public async Task<List<ForumCategoryEntity>> GetForumCategoryMainPage() { var forumGroupList = new List<ForumCategoryEntity>(); HtmlDocument doc = (await _webManager.DownloadHtml(Constants.FORUM_LIST_PAGE)).Document; HtmlNode forumNode = doc.DocumentNode.Descendants("select") .FirstOrDefault(node => node.GetAttributeValue("name", string.Empty).Equals("forumid")); if (forumNode != null) { IEnumerable<HtmlNode> forumNodes = forumNode.Descendants("option"); foreach (HtmlNode node in forumNodes) { string value = node.Attributes["value"].Value; int id; if (!int.TryParse(value, out id) || id <= -1) continue; if (node.NextSibling.InnerText.Contains("--")) { string forumName = WebUtility.HtmlDecode(node.NextSibling.InnerText.Replace("-", string.Empty)); bool isSubforum = node.NextSibling.InnerText.Count(c => c == '-') > 2; var forumSubCategory = new ForumEntity(forumName, string.Format(Constants.FORUM_PAGE, value), string.Empty, isSubforum); forumGroupList.LastOrDefault().ForumList.Add(forumSubCategory); } else { string forumName = WebUtility.HtmlDecode(node.NextSibling.InnerText); var forumGroup = new ForumCategoryEntity(forumName, string.Format(Constants.FORUM_PAGE, value)); forumGroupList.Add(forumGroup); } } } #if DEBUG forumGroupList[3].ForumList.Add(AddDebugForum()); #endif return forumGroupList; }
private async Task Update(IBackgroundTaskInstance taskInstance) { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; var forumCategory = new ForumEntity() { Name = "Bookmarks", IsSubforum = false, IsBookmarks = true, Location = Constants.USER_CP }; ObservableCollection<ForumThreadEntity> forumThreadEntities = await _threadManager.GetBookmarks(forumCategory, 1); CreateBookmarkLiveTiles(forumThreadEntities); if (localSettings.Values.ContainsKey("_threadIds") && !string.IsNullOrEmpty((string)localSettings.Values["_threadIds"])) { DeserializeXmlToList((string) localSettings.Values["_threadIds"]); List<ForumThreadEntity> list = forumThreadEntities.Where(thread => _threadIds.Contains(thread.ThreadId)).ToList(); CreateToastNotifications(list); } }
public async Task<List<ForumThreadEntity>> GetBookmarks(ForumEntity forumCategory) { var forumSubcategoryList = new List<ForumEntity>(); var forumThreadList = new List<ForumThreadEntity>(); String url = forumCategory.Location; if (forumCategory.CurrentPage > 0) { url = forumCategory.Location + string.Format(Constants.PAGE_NUMBER, forumCategory.CurrentPage); } HtmlDocument doc = (await _webManager.DownloadHtml(url)).Document; HtmlNode forumNode = doc.DocumentNode.Descendants().FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("threadlist")); foreach (HtmlNode threadNode in forumNode.Descendants("tr").Where(node => node.GetAttributeValue("class", string.Empty).StartsWith("thread"))) { var threadEntity = new ForumThreadEntity(); threadEntity.Parse(threadNode); forumThreadList.Add(threadEntity); } return forumThreadList; }
public async void Initialize(ForumEntity forumEntity) { this.ForumEntity = forumEntity; IsBookmarks = forumEntity.IsBookmarks; ForumTitle = forumEntity.Name; SubForumEntities = new ObservableCollection<ForumEntity>(); try { if (forumEntity.IsBookmarks) { _localSettings = ApplicationData.Current.LocalSettings; ForumPageScrollingCollection = new PageScrollingCollection(forumEntity, 1); } else { ForumPageScrollingCollection = new PageScrollingCollection(forumEntity, 1); SubForumEntities = await _forumManager.GetSubForums(forumEntity); } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to initialize threads", ex); } }
public async Task<ObservableCollection<ForumThreadEntity>> GetBookmarks(ForumEntity forumCategory, int page) { var forumThreadList = new ObservableCollection<ForumThreadEntity>(); String url = Constants.BOOKMARKS_URL; if (forumCategory.CurrentPage > 0) { url = Constants.BOOKMARKS_URL + string.Format(Constants.PAGE_NUMBER, page); } HtmlDocument doc = (await _webManager.GetData(url)).Document; HtmlNode forumNode = doc.DocumentNode.Descendants() .FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("threadlist")); foreach ( HtmlNode threadNode in forumNode.Descendants("tr") .Where(node => node.GetAttributeValue("class", string.Empty).StartsWith("thread"))) { var threadEntity = new ForumThreadEntity(); threadEntity.Parse(threadNode); threadEntity.IsBookmark = true; forumThreadList.Add(threadEntity); } return forumThreadList; }
public async Task<List<ForumEntity>> GetSubForums(ForumEntity forumCategory) { var subforumList = new List<ForumEntity>(); var url = forumCategory.Location; var doc = (await _webManager.DownloadHtml(url)).Document; if ( !doc.DocumentNode.Descendants() .Any(node => node.GetAttributeValue("id", string.Empty).Contains("subforums"))) return subforumList; var forumNode = doc.DocumentNode.Descendants().FirstOrDefault(node => node.GetAttributeValue("id", string.Empty).Contains("subforums")); subforumList.AddRange(from subforumNode in forumNode.Descendants("tr") where subforumNode.Descendants("a").Any() select new ForumEntity(WebUtility.HtmlDecode(subforumNode.Descendants("a").FirstOrDefault().InnerText), subforumNode.Descendants("a").FirstOrDefault().GetAttributeValue("href", string.Empty), string.Empty, true)); return subforumList; }
private void RefreshButton_OnClick(object sender, RoutedEventArgs e) { var forum = new ForumEntity("Bookmarks", Constants.USER_CP, string.Empty, false); _threadVm.Initialize(forum); }
private ForumEntity AddDebugForum() { var forum = new ForumEntity() { Name = "Apps In Developmental States", Location = Constants.BASE_URL + "forumdisplay.php?forumid=261", IsSubforum = false }; forum.SetForumId(); return forum; }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters DebugSettings.EnableFrameRateCounter = true; } #endif var rootFrame = Window.Current.Content as Frame; SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManager_CommandsRequested; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active TileUpdateManager.CreateTileUpdaterForApplication().Clear(); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); //Associate the frame with a SuspensionManager key SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { //Something went wrong restoring state. //Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter var localStorageManager = new LocalStorageManager(); CookieContainer cookieTest = await localStorageManager.LoadCookie(Constants.COOKIE_FILE); if (cookieTest.Count <= 0) { if (!rootFrame.Navigate(typeof (LoginPage))) { throw new Exception("Failed to create initial page"); } } else { var localSettings = ApplicationData.Current.LocalSettings; if (localSettings.Values.ContainsKey(Constants.BOOKMARK_STARTUP) && (bool)localSettings.Values[Constants.BOOKMARK_STARTUP]) { var forum = new ForumEntity() { Name = "Bookmarks", IsSubforum = false, Location = Constants.USER_CP }; string jsonObjectString = JsonConvert.SerializeObject(forum); rootFrame.Navigate(typeof(ThreadListPage), jsonObjectString); } else { if (!rootFrame.Navigate(typeof(MainForumsPage))) { throw new Exception("Failed to create initial page"); } } } } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { _localSettings = ApplicationData.Current.LocalSettings; if (_localSettings.Values.ContainsKey(Constants.BOOKMARK_STARTUP)) { var bookmarks = (bool) _localSettings.Values[Constants.BOOKMARK_STARTUP]; if (bookmarks) { ForumsPivot.SelectedIndex = 1; } } var forum = new ForumEntity() { Name = "Bookmarks", IsSubforum = false, Location = Constants.USER_CP, IsBookmarks = true }; if (_vm.ThreadListPageViewModel != null) return; _vm.ThreadListPageViewModel = new ThreadListPageViewModel(); _vm.ThreadListPageViewModel.Initialize(forum); BookmarksPivotItem.DataContext = _vm.ThreadListPageViewModel; }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { // TODO: Move to seperate method. if (_vm.ThreadListPageViewModel != null && _vm.ThreadListPageViewModel.ForumPageScrollingCollection.Any()) { if (_localSettings.Values.ContainsKey(Constants.AUTO_REFRESH)) { var autoRefresh = (bool)_localSettings.Values[Constants.AUTO_REFRESH]; if (autoRefresh) { var forum = new ForumEntity() { Name = "Bookmarks", IsSubforum = false, Location = Constants.USER_CP, IsBookmarks = true }; _vm.ThreadListPageViewModel.RefreshForum(forum); } } } this.navigationHelper.OnNavigatedTo(e); }
public void BookmarkButton_Click(object sender, RoutedEventArgs e) { var forum = new ForumEntity() { Name = "Bookmarks", IsBookmarks = true, IsSubforum = false, Location = Constants.USER_CP }; string jsonObjectString = JsonConvert.SerializeObject(forum); Frame.Navigate(typeof (ThreadListPage), jsonObjectString); }
public async void RefreshForum(ForumEntity forumEntity) { if (ForumPageScrollingCollection == null) return; if (!forumEntity.Name.Equals("Bookmarks")) return; try { await ForumPageScrollingCollection.RefreshBookmarkedThreads(); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to refresh bookmarks", ex); } }
public async Task<ObservableCollection<ForumEntity>> GetSubForums(ForumEntity forumCategory) { var subforumList = new List<ForumEntity>(); string url = forumCategory.Location; HtmlDocument doc = (await _webManager.GetData(url)).Document; if ( !doc.DocumentNode.Descendants() .Any(node => node.GetAttributeValue("id", string.Empty).Contains("subforums"))) return null; HtmlNode forumNode = doc.DocumentNode.Descendants() .FirstOrDefault(node => node.GetAttributeValue("id", string.Empty).Contains("subforums")); subforumList.AddRange(from subforumNode in forumNode.Descendants("tr") where subforumNode.Descendants("a").Any() select new ForumEntity(WebUtility.HtmlDecode(subforumNode.Descendants("a").FirstOrDefault().InnerText), Constants.BASE_URL + subforumNode.Descendants("a").FirstOrDefault().GetAttributeValue("href", string.Empty), string.Empty, true)); var obSubforumList = new ObservableCollection<ForumEntity>(); foreach (var forum in subforumList) { obSubforumList.Add(forum); } return obSubforumList; }
public void BookmarkButton_Click(object sender, RoutedEventArgs e) { var forum = new ForumEntity("Bookmarks", Constants.USER_CP, string.Empty, false); string jsonObjectString = JsonConvert.SerializeObject(forum); Frame.Navigate(typeof (ThreadListPage), jsonObjectString); }
private void RefreshButton_OnClick(object sender, RoutedEventArgs e) { if (_vm.ForumGroupList == null || _vm.ForumGroupList.Any()) { _vm.Initialize(); } var forum = new ForumEntity() { Name = "Bookmarks", IsSubforum = false, IsBookmarks = true, Location = Constants.USER_CP }; _vm.ThreadListPageViewModel.RefreshForum(forum); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper" /> /// </param> /// <param name="e"> /// Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)" /> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited. /// </param> private void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { _forum = (ForumEntity) e.NavigationParameter; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var jsonObjectString = (string)e.NavigationParameter; var forumInfo = JsonConvert.DeserializeObject<ForumEntity>(jsonObjectString); if (forumInfo == null) return; pageTitle.Text = string.Format("New Thread - {0}", forumInfo.Name); _forumEntity = forumInfo; _newThreadEntity = await _threadManager.GetThreadCookies(forumInfo.ForumId); if (_newThreadEntity == null) { var msgDlg = new MessageDialog("You can't make a new thread in this forum!"); await msgDlg.ShowAsync(); Frame.GoBack(); return; } var blankPostIconEntity = new PostIconEntity {Id = 0, Title = "Shit"}; PostIconImage.Source = new BitmapImage(new Uri("ms-appx://Assets/shitpost.gif")); _postIcon = blankPostIconEntity; }
public void BookmarkButton_Click(object sender, RoutedEventArgs e) { var forum = new ForumEntity("Bookmarks", Constants.USER_CP, string.Empty, false); this.Frame.Navigate(typeof (ThreadListPage), forum); }