示例#1
0
        private async void ForwardButton_Click(object sender, RoutedEventArgs e)
        {
            _currentPage++;
            BackButton.IsEnabled = _currentPage >= 2 ? true : false;
            string html =
                await
                _rapSheetManager.GetRapSheet(Constants.BASE_URL + Constants.RAP_SHEET +
                                             string.Format(Constants.PAGE_NUMBER, _currentPage));

            RapSheetWebView.NavigateToString(html);
        }
示例#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)
        {
            ForwardButton.IsEnabled = true;
            BackButton.IsEnabled    = false;
            string html;

            if (e.NavigationParameter != null && !string.IsNullOrEmpty((string)e.NavigationParameter))
            {
                long userId = Convert.ToInt64(e.NavigationParameter);
                ForwardButton.IsEnabled = false;
                html = await
                       _rapSheetManager.GetRapSheet(Constants.BASE_URL +
                                                    string.Format(Constants.USER_RAP_SHEET, userId));

                NoRapSheetTextBlock.Text =
                    string.Format(
                        "This user has not done anything stupid yet.{0}Sorry to disappoint you, so look at this instead.{0}{1}", System.Environment.NewLine,
                        Constants.ASCII_3);
            }
            else
            {
                html = await _rapSheetManager.GetRapSheet(Constants.BASE_URL + Constants.RAP_SHEET);

                NoRapSheetTextBlock.Text =
                    string.Format(
                        "Everyone is perfect and has no flaws.{0}Sorry to disappoint you, so look at this instead.{0}{1}", System.Environment.NewLine,
                        Constants.ASCII_3);
            }
            RapSheetWebView.NavigateToString(html);
            if (!string.IsNullOrEmpty(html))
            {
                return;
            }
            ForwardButton.IsEnabled        = false;
            RapSheetWebView.Visibility     = Visibility.Collapsed;
            NoRapSheetTextBlock.Visibility = Visibility.Visible;
        }
示例#3
0
        private async void WebView_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 "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":
                if (_localSettings.Values.ContainsKey("zoomSize"))
                {
                    _zoomSize = Convert.ToInt32(_localSettings.Values["zoomSize"]);
                    RapSheetWebView.InvokeScriptAsync("ResizeWebviewFont", new[] { _zoomSize.ToString() });
                }
                else
                {
                    _zoomSize = 14;
                }
                break;

            default:
                var msgDlg = new MessageDialog("Not working yet!")
                {
                    DefaultCommandIndex = 1
                };
                await msgDlg.ShowAsync();

                break;
            }
        }