private async void PreviewButton_Click(object sender, RoutedEventArgs e) { ItemGridView.Visibility = Visibility.Collapsed; PreviewLastPostWebView.Visibility = Visibility.Visible; _forumReply.MapMessage(ReplyText.Text); var replyManager = new ReplyManager(); string result = await replyManager.CreatePreviewEditPost(_forumReply); if (!string.IsNullOrEmpty(result)) { PreviewLastPostWebView.NavigateToString(result); PreviewLastPostWebView.Visibility = Visibility.Visible; } else { LoadingProgressBar.Visibility = Visibility.Collapsed; 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.ASCII_2); var msgDlg = new MessageDialog(messageText); await msgDlg.ShowAsync(); } }
public async Task<bool> GetPreviewEditPost(string replyText) { Html = string.Empty; IsLoading = true; ForumReplyEntity.MapMessage(replyText); var replyManager = new ReplyManager(); Html = await replyManager.CreatePreviewEditPost(ForumReplyEntity); IsLoading = false; return !string.IsNullOrEmpty(Html); }
private async void EditButton_Click(object sender, RoutedEventArgs e) { LoadingProgressBar.Visibility = Visibility.Visible; _forumReply.MapMessage(ReplyText.Text); var replyManager = new ReplyManager(); bool result = await replyManager.SendUpdatePost(_forumReply); if (result) { Frame.GoBack(); } else { LoadingProgressBar.Visibility = Visibility.Collapsed; var msgDlg = new MessageDialog("Error making reply!"); await msgDlg.ShowAsync(); } }
public async Task<bool> Initialize(string jsonObjectString) { IsLoading = true; long threadId = 0; var replyManager = new ReplyManager(); try { _forumThread = JsonConvert.DeserializeObject<ForumThreadEntity>(jsonObjectString); } catch (Exception) { threadId = Convert.ToInt64(jsonObjectString); } if (_forumThread != null) { ForumReplyEntity = await replyManager.GetReplyCookies(_forumThread); } else { ForumReplyEntity = await replyManager.GetReplyCookies(threadId); } IsLoading = false; return ForumReplyEntity != null; }
public async Task<bool> InitializeEdit(string jsonObjectString) { IsLoading = true; long threadId = Convert.ToInt64(jsonObjectString); ; var replyManager = new ReplyManager(); ForumReplyEntity = await replyManager.GetReplyCookiesForEdit(threadId); IsLoading = false; return ForumReplyEntity != null; }
private async void PreviousPostsWebView_ScriptNotify(object sender, NotifyEventArgs e) { string stringJson = e.Value; var command = JsonConvert.DeserializeObject<ReplyView.ThreadCommand>(stringJson); var replyManager = new ReplyManager(); switch (command.Command) { case "profile": Frame.Navigate(typeof(UserProfileView), command.Id); break; case "post_history": Frame.Navigate(typeof(UserPostHistoryPage), command.Id); break; case "rap_sheet": Frame.Navigate(typeof(RapSheetView), command.Id); break; case "quote": loadingProgressBar.Visibility = Visibility.Visible; string quoteString = await replyManager.GetQuoteString(Convert.ToInt64(command.Id)); quoteString = string.Concat(Environment.NewLine, quoteString); string replyText = string.IsNullOrEmpty(ReplyText.Text) ? string.Empty : ReplyText.Text; if (replyText != null) ReplyText.Text = replyText.Insert(ReplyText.Text.Length, quoteString); loadingProgressBar.Visibility = Visibility.Collapsed; break; case "setFont": if (_localSettings.Values.ContainsKey("zoomSize")) { _zoomSize = Convert.ToInt32(_localSettings.Values["zoomSize"]); PreviewLastPostWebView.InvokeScriptAsync("ResizeWebviewFont", new[] { _zoomSize.ToString() }); } else { _zoomSize = 14; } break; case "edit": Frame.Navigate(typeof(EditReplyPage), command.Id); break; case "openThread": // Because we are coming from an existing thread, rather than the thread lists, we need to get the thread information beforehand. // However, right now the managers are not set up to support this. The thread is getting downloaded twice, when it really only needs to happen once. var threadManager = new ThreadManager(); var thread = await threadManager.GetThread(new ForumThreadEntity(), command.Id); if (thread == null) { var error = new MessageDialog("Specified post was not found in the live forums.") { DefaultCommandIndex = 1 }; await error.ShowAsync(); break; } string jsonObjectString = JsonConvert.SerializeObject(thread); Frame.Navigate(typeof(ThreadPage), jsonObjectString); break; default: var msgDlg = new MessageDialog("Not working yet!") { DefaultCommandIndex = 1 }; await msgDlg.ShowAsync(); break; } }
private async void ThreadWebView_ScriptNotify(object sender, NotifyEventArgs e) { string stringJson = e.Value; var command = JsonConvert.DeserializeObject<EditPage.ThreadCommand>(stringJson); var replyManager = new ReplyManager(); switch (command.Command) { case "quote": LoadingProgressBar.Visibility = Visibility.Visible; string quoteString = await replyManager.GetQuoteString(Convert.ToInt64(command.Id)); quoteString = string.Concat(Environment.NewLine, quoteString); string replyText = string.IsNullOrEmpty(ReplyTextBox.Text) ? string.Empty : ReplyTextBox.Text; if (replyText != null) ReplyTextBox.Text = replyText.Insert(ReplyTextBox.Text.Length, quoteString); LoadingProgressBar.Visibility = Visibility.Collapsed; break; case "edit": //Frame.Navigate(typeof(EditReplyPage), command.Id); break; case "openThread": // Because we are coming from an existing thread, rather than the thread lists, we need to get the thread information beforehand. // However, right now the managers are not set up to support this. The thread is getting downloaded twice, when it really only needs to happen once. var threadManager = new ThreadManager(); var thread = await threadManager.GetThread(new ForumThreadEntity(), command.Id); if (thread == null) { var error = new MessageDialog("Specified post was not found in the live forums.") { DefaultCommandIndex = 1 }; await error.ShowAsync(); break; } string jsonObjectString = JsonConvert.SerializeObject(thread); Frame.Navigate(typeof(ThreadPage), jsonObjectString); break; case "setFont": break; default: var msgDlg = new MessageDialog("Not working yet!") { DefaultCommandIndex = 1 }; await msgDlg.ShowAsync(); break; } }
private async void PreviewButton_Click(object sender, RoutedEventArgs e) { PostPreviewRaw.Visibility = Visibility.Collapsed; PreviewPostGrid.Visibility = Visibility.Visible; _forumReply.MapMessage(ReplyText.Text); var replyManager = new ReplyManager(); string result = await replyManager.CreatePreviewEditPost(_forumReply); if (!string.IsNullOrEmpty(result)) { PostPreviewRaw.NavigateToString(result); PostPreviewRaw.Visibility = Visibility.Visible; } else { var msgDlg = new MessageDialog( "No text?! What the f**k good is showing you a preview then! Type some shit in and try again!"); await msgDlg.ShowAsync(); PreviewPostGrid.Visibility = Visibility.Collapsed; } }
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 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; }