Example #1
0
        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();
            }
        }
Example #2
0
        /// <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;
            var  jsonObjectString = (string)e.NavigationParameter;
            long threadId         = Convert.ToInt64(jsonObjectString);

            _forumReply = await _replyManager.GetReplyCookiesForEdit(threadId);

            if (_forumReply == null)
            {
                var msgDlg = new MessageDialog("You can't edit this post!");
                await msgDlg.ShowAsync();

                Frame.GoBack();
                return;
            }
            ReplyText.Text = _forumReply.Quote;
            PreviewLastPostWebView.NavigateToString(_forumReply.PreviousPostsRaw);
            LoadingProgressBar.Visibility = Visibility.Collapsed;
        }
Example #3
0
        private async void PreviousPostsWebView_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string stringJson = e.Value;
            var    command    = JsonConvert.DeserializeObject <ReplyView.ThreadCommand>(stringJson);

            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":
                Frame.Navigate(typeof(ReplyView), command.Id);
                break;

            case "edit":
                Frame.Navigate(typeof(EditReplyPage), command.Id);
                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 "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;
            }
        }
Example #4
0
 private void LastPostsButton_OnClick(object sender, RoutedEventArgs e)
 {
     PreviewLastPostWebView.NavigateToString(_forumReply.PreviousPostsRaw);
     ItemGridView.Visibility           = Visibility.Collapsed;
     PreviewLastPostWebView.Visibility = Visibility.Visible;
 }