/// <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="Common.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) { if (e.NavigationParameter == null) { return; } try { var threadId = (long)e.NavigationParameter; var bookmarkdata = new BookmarkDataSource(); _lastSelectedItem = await bookmarkdata.BookmarkForumRepository.Items.Where(node => node.ThreadId == threadId).FirstOrDefaultAsync(); if (_lastSelectedItem != null) { Locator.ViewModels.BookmarksPageVm.NavigateToThreadPageViaToastCommand.Execute(_lastSelectedItem); if (AdaptiveStates.CurrentState == NarrowState) { Frame.Navigate(typeof(ThreadPage), null, new DrillInNavigationTransitionInfo()); } } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to load Bookmarks page", ex); } }
public async override void Execute(object parameter) { var args = parameter as ItemClickEventArgs; if (args == null) { AwfulDebugger.SendMessageDialogAsync("Navigation failed", new Exception("Arguments are null")); return; } Locator.ViewModels.SaclopediaPageVm.IsLoading = true; try { var navEntity = (SaclopediaNavigationTopicEntity)args.ClickedItem; var result = await Locator.ViewModels.SaclopediaPageVm.SaclopediaManager.GetSaclopediaEntity(Constants.BaseUrl + navEntity.Link); Locator.ViewModels.SaclopediaPageVm.Title = result.Title; var platformIdentifier = PlatformIdentifier.Windows8; //App.RootFrame.Navigate(typeof (SaclopediaEntryPage)); Locator.ViewModels.SaclopediaPageVm.Body = await HtmlFormater.FormatSaclopediaEntry(result.Body, platformIdentifier); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Navigation failed", ex); } Locator.ViewModels.SaclopediaPageVm.IsLoading = false; }
public async Task Initialize() { IsLoading = true; IsEmpty = false; try { TabThreads = new ObservableCollection <ForumThreadEntity>(); var tabs = await _tabManager.GetAllTabThreads(); if (tabs != null && tabs.Any()) { TabThreads = tabs.ToObservableCollection(); } else { IsEmpty = true; } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get Tabs", ex); } IsLoading = false; }
public async Task CreateReplyPreview(ForumReplyEntity forumReplyEntity, bool isEdit) { IsLoading = true; var replyManager = new ReplyManager(); string result; if (isEdit) { result = await replyManager.CreatePreviewEditPost(forumReplyEntity); } else { result = await replyManager.CreatePreviewPost(forumReplyEntity); } try { if (!string.IsNullOrEmpty(result)) { Html = result; } else { string messageText = string.Format( "No text?! What good is showing you a preview then! Type something in and try again!{0}{1}", Environment.NewLine, Constants.Ascii2); var msgDlg = new MessageDialog(messageText); await msgDlg.ShowAsync(); } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get the preview html", ex); } IsLoading = false; }
public async override void Execute(object parameter) { var thread = (ForumThreadEntity)parameter; if (!thread.IsBookmark) { await AwfulDebugger.SendMessageDialogAsync( "In order to be notified of thread updates, the thread must be a bookmark.", new Exception("Not a bookmark")); return; } var mfd = new MainForumsDatabase(); try { await mfd.SetThreadNotified(thread); } catch (Exception ex) { await AwfulDebugger.SendMessageDialogAsync( "Failed to save thread to notifications table", ex); } }
public async override void Execute(object parameter) { var args = parameter as ItemClickEventArgs; if (args == null) { AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null")); return; } var thread = args.ClickedItem as PrivateMessageEntity; if (thread == null) { return; } var vm = Locator.ViewModels.PrivateMessagePageVm; vm.IsLoading = true; vm.PrivateMessageEntity = thread; try { await vm.GetPrivateMessageHtml(); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", ex); App.RootFrame.GoBack(); } }
public async override void Execute(object parameter) { long id = long.Parse((string)parameter); var vm = Locator.ViewModels.ThreadPageVm; if (vm == null) { return; } Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity; App.RootFrame.Navigate(typeof(NewThreadReplyPage)); Locator.ViewModels.NewThreadReplyVm.IsLoading = true; try { var replyManager = new ReplyManager(); Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity = await replyManager.GetReplyCookies(id); Locator.ViewModels.NewThreadReplyVm.PostBody = Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity.Quote; } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex); App.RootFrame.GoBack(); } Locator.ViewModels.NewThreadReplyVm.IsLoading = false; }
public async Task CreateThreadPreview(NewThreadEntity newThreadEntity) { IsLoading = true; NewThreadEntity = newThreadEntity; try { string result = await _threadManager.CreateNewThreadPreview(NewThreadEntity); if (string.IsNullOrEmpty(result)) { string messageText = string.Format( "No text?! What good is showing you a preview then! Type something in and try again!{0}{1}", Environment.NewLine, Constants.Ascii2); await AwfulDebugger.SendMessageDialogAsync(messageText, new Exception("No text in reply box")); return; } Html = result; } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get the preview html", ex); } IsLoading = false; }
public async override void Execute(object parameter) { var args = parameter as ItemClickEventArgs; if (args == null) { AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null")); return; } var thread = args.ClickedItem as SearchEntity; if (thread == null) { return; } App.RootFrame.Navigate(typeof(ThreadPage)); Locator.ViewModels.ThreadPageVm.IsLoading = true; var newThreadEntity = new ForumThreadEntity() { Location = Constants.BaseUrl + thread.ThreadLink, ImageIconLocation = "/Assets/ThreadTags/noicon.png" }; Locator.ViewModels.ThreadPageVm.ForumThreadEntity = newThreadEntity; await Locator.ViewModels.ThreadPageVm.GetForumPostsAsync(); }
public async override void Execute(object parameter) { var args = parameter as RoutedEventArgs; if (args == null) { await AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null")); return; } var appButton = args.OriginalSource as AppBarButton; if (appButton == null) { // TODO: If this is somehow null, throw an error and tell the user. return; } var vm = appButton.DataContext as ThreadListPageViewModel; if (vm == null) { return; } App.RootFrame.Navigate(typeof(NewThreadPage)); Locator.ViewModels.NewThreadVm.IsLoading = true; try { Locator.ViewModels.NewThreadVm.NewThreadEntity = await _threadManager.GetThreadCookiesAsync(vm.ForumEntity.ForumId); if (Locator.ViewModels.NewThreadVm.NewThreadEntity == null) { await AwfulDebugger.SendMessageDialogAsync("You can't post in this forum!", new Exception("Forum locked for new posts")); App.RootFrame.GoBack(); return; } } catch (Exception exception) { AwfulDebugger.SendMessageDialogAsync("Error getting thread cookies for this forum.", exception); App.RootFrame.GoBack(); return; } Locator.ViewModels.NewThreadVm.ForumEntity = vm.ForumEntity; Locator.ViewModels.NewThreadVm.PostBody = string.Empty; Locator.ViewModels.NewThreadVm.PostSubject = string.Empty; Locator.ViewModels.NewThreadVm.PostIcon = new PostIconEntity() { Id = 0, ImageUrl = "/Assets/ThreadTags/shitpost.png", Title = "Shit Post" }; Locator.ViewModels.NewThreadVm.IsLoading = false; }
private async void ReplyButton_OnClick(object sender, RoutedEventArgs e) { if (_vm.ForumThreadEntity == null) { await AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread, refresh and try again.", new Exception("ForumThreadEntitiy is Null")); return; } string jsonObjectString = JsonConvert.SerializeObject(_forumThread); Frame.Navigate(typeof(ReplyPage), jsonObjectString); }
public async Task GetSearchResults(List <int> forumIds) { IsLoading = true; try { SearchPageScrollingCollection = new SearchPageScrollingCollection(forumIds, SearchTerms); App.RootFrame.Navigate(typeof(SearchResultsPage)); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get results", ex); } IsLoading = false; }
public async Task Initialize(long userId) { ForumUserEntity = new ForumUserEntity(); IsLoading = true; try { ForumUserEntity = await _forumUserManager.GetUserFromProfilePage(userId); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get user info", ex); } IsLoading = false; }
public async override void Execute(object parameter) { var vm = Locator.ViewModels.NewPrivateMessagePageVm; var pmManager = new PrivateMessageManager(); if (string.IsNullOrEmpty(vm.PostSubject)) { AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Submit is empty")); return; } if (string.IsNullOrEmpty(vm.PostBody)) { AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Body is empty")); return; } if (string.IsNullOrEmpty(vm.PostRecipient)) { AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Recipient is empty")); return; } var pmEntity = new NewPrivateMessageEntity(); vm.IsLoading = true; pmEntity.Title = vm.PostSubject; pmEntity.Body = vm.PostBody; pmEntity.Icon = vm.PostIcon; pmEntity.Receiver = vm.PostRecipient; try { bool result = await pmManager.SendPrivateMessage(pmEntity); if (result) { App.RootFrame.GoBack(); } else { await AwfulDebugger.SendMessageDialogAsync("Error making the pm.", new Exception()); } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Error making the pm.", ex); } vm.IsLoading = false; }
public async override void Execute(object parameter) { var thread = parameter as ForumThreadEntity; if (thread == null) { AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null")); return; } Locator.ViewModels.ThreadPageVm.ForumThreadEntity = thread; Locator.ViewModels.ThreadPageVm.Html = null; await Locator.ViewModels.ThreadPageVm.GetForumPostsAsync(); }
public async void GetSmilies() { var smiliesManager = new SmileManager(); try { SmilieCategoryList = await smiliesManager.GetSmileList(); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Can't get smilies list. :(", ex); return; } FullSmileCategoryEntities = SmilieCategoryList; }
public async void Initialize() { IsLoading = true; try { ForumGroupList = await _forumManager.GetForumCategoryMainPage(); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to initialize the main forums list.", ex); IsLoading = false; return; } GetFavoriteForums(); IsLoading = false; }
public async Task Refresh() { IsLoading = true; try { var test = await _bookmarkManager.RefreshBookmarkedThreads(); BookmarkedThreads = test.ToObservableCollection(); _localSettings.Values["RefreshBookmarks"] = DateTime.UtcNow.ToString(); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get Bookmarks", ex); } IsLoading = false; }
public async void GetPostIcons() { PostIconManager postIconManager = new PostIconManager(); if (PostIconList.Any()) { return; } try { PostIconList = await postIconManager.GetPostIconList(_forumEntity); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Could not get post icons", ex); } }
public async Task <bool> InitializeEdit(string jsonObjectString) { IsLoading = true; long threadId = Convert.ToInt64(jsonObjectString);; try { var replyManager = new ReplyManager(); ForumReplyEntity = await replyManager.GetReplyCookiesForEdit(threadId); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("You can't edit this post!", ex); } IsLoading = false; return(ForumReplyEntity != null); }
/// <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; bool result = await _vm.Initialize(jsonObjectString); _vm.GetSmiliesPhone(); if (result) { ReplyTextBox.Text = _vm.ForumReplyEntity.Quote; } else { await AwfulDebugger.SendMessageDialogAsync("You can't post in this thread!", new Exception("Could not get reply cookies.")); Frame.GoBack(); } }
public async Task ClickLoginButton() { bool loginResult; IsLoading = true; try { loginResult = await _authManager.Authenticate(UserName, Password); } catch (LoginFailedException ex) { AwfulDebugger.SendMessageDialogAsync(ex.Message, ex); loginResult = false; } IsLoading = false; base.RaiseEvent(loginResult ? LoginSuccessful : LoginFailed, EventArgs.Empty); }
private async void ForwardButton_OnClick(object sender, RoutedEventArgs e) { if (_vm.ForumThreadEntity == null) { await AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread, refresh and try again.", new Exception("ForumThreadEntitiy is Null")); return; } if (_vm.ForumThreadEntity.CurrentPage >= _vm.ForumThreadEntity.TotalPages) { return; } _vm.ForumThreadEntity.CurrentPage++; _vm.ForumThreadEntity.ScrollToPost = 0; _vm.ForumThreadEntity.ScrollToPostString = string.Empty; _vm.GetForumPosts(_vm.ForumThreadEntity); }
private static async Task <bool> DownloadImageAsync(string url) { try { var fileName = Path.GetFileName(new Uri(url).AbsolutePath); var client = new HttpClient(); var stream = await client.GetStreamAsync(url); await FileAccessCommands.SaveStreamToCameraRoll(stream, fileName); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to download image", ex.InnerException); return(false); } return(true); }
public async Task GetForumPosts(ForumThreadEntity forumThreadEntity) { IsLoading = true; bool isSuccess; string errorMessage = string.Empty; ThreadTitle = forumThreadEntity.Name; PostManager postManager = new PostManager(); try { await postManager.GetThreadPosts(forumThreadEntity); isSuccess = true; } catch (Exception ex) { IsLoading = false; isSuccess = false; errorMessage = ex.Message; } if (!isSuccess) { await AwfulDebugger.SendMessageDialogAsync("Failed to get thread posts.", new Exception(errorMessage)); return; } #if WINDOWS_PHONE_APP forumThreadEntity.PlatformIdentifier = PlatformIdentifier.WindowsPhone; #else forumThreadEntity.PlatformIdentifier = PlatformIdentifier.Windows8; #endif try { GetDarkModeSetting(forumThreadEntity); Html = await HtmlFormater.FormatThreadHtml(forumThreadEntity); ForumThreadEntity = forumThreadEntity; PageNumbers = Enumerable.Range(1, forumThreadEntity.TotalPages).ToArray(); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("An error occured creating the thread HTML", ex); } }
public async Task <bool> GetPreviewEditPost(string replyText) { Html = string.Empty; IsLoading = true; ForumReplyEntity.MapMessage(replyText); var replyManager = new ReplyManager(); try { Html = await replyManager.CreatePreviewEditPost(ForumReplyEntity); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Could not create preview HTML", ex); } IsLoading = false; return(!string.IsNullOrEmpty(Html)); }
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 Initialize() { IsLoading = true; try { _searchManager = new SearchManager(); var forumCategoryEntities = await _forumManager.GetForumCategoryMainPage(); foreach (var forumCategoryEntity in forumCategoryEntities) { ForumGroupList.Add(forumCategoryEntity); } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get forums list", ex); } IsLoading = false; }
private void SetFontSize() { if (_localSettings.Values.ContainsKey("zoomSize")) { _zoomSize = Convert.ToInt32(_localSettings.Values["zoomSize"]); try { ThreadWebView.InvokeScriptAsync("ResizeWebviewFont", new[] { _zoomSize.ToString() }); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("A thread javascript command failed", ex); } } else { _zoomSize = 14; } }
public async override void Execute(object parameter) { var vm = Locator.ViewModels.NewThreadVm; var threadManager = new ThreadManager(); if (string.IsNullOrEmpty(vm.PostSubject)) { AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Submit is empty")); return; } if (string.IsNullOrEmpty(vm.PostBody)) { AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Body is empty")); return; } vm.IsLoading = true; vm.NewThreadEntity.Subject = vm.PostSubject; vm.NewThreadEntity.Content = vm.PostBody; vm.NewThreadEntity.PostIcon = vm.PostIcon; vm.NewThreadEntity.Forum = vm.ForumEntity; try { bool result = await threadManager.CreateNewThreadAsync(vm.NewThreadEntity); if (result) { App.RootFrame.GoBack(); Locator.ViewModels.ThreadListPageVm.Refresh(); } else { await AwfulDebugger.SendMessageDialogAsync("Error making the thread.", new Exception()); } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Error making the thread.", ex); } vm.IsLoading = false; }