private async void ThreadWebView_ScriptNotify(object sender, NotifyEventArgs e) { string stringJson = e.Value; var command = JsonConvert.DeserializeObject <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 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; } }