示例#1
0
        private async void GoToLastPostButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await ThreadFullView.InvokeScriptAsync("ScrollToBottom", null);

                await ThreadSnapView.InvokeScriptAsync("ScrollToBottom", null);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
示例#2
0
 private async void ThreadSnapView_OnDOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
 {
     try
     {
         if (_forumThread.ScrollToPost > 0)
         {
             await ThreadSnapView.InvokeScriptAsync("ScrollToDiv", new[] { _forumThread.ScrollToPostString });
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Webview Failer {0}", ex);
     }
 }
示例#3
0
        private async void RemoveStyle_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _zoomSize = 14;
                await ThreadFullView.InvokeScriptAsync("RemoveCustomStyle", null);

                await ThreadSnapView.InvokeScriptAsync("RemoveCustomStyle", null);

                _localSettings.Values["zoomSize"] = null;
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
示例#4
0
        private async void FontDecrease_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _zoomSize -= 1;
                await ThreadFullView.InvokeScriptAsync("ResizeWebviewFont", new[] { _zoomSize.ToString() });

                await ThreadSnapView.InvokeScriptAsync("ResizeWebviewFont", new[] { _zoomSize.ToString() });

                _localSettings.Values["zoomSize"] = _zoomSize;
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
示例#5
0
        private async void WebView_ScriptNotify(object sender, NotifyEventArgs e)
        {
            try
            {
                string stringJson = e.Value;
                var    command    = JsonConvert.DeserializeObject <ReplyView.ThreadCommand>(stringJson);
                switch (command.Command)
                {
                case "profile":
                    Frame.Navigate(typeof(UserProfileView), command.Id);
                    break;

                case "openPost":
                    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 "scrollToPost":
                    if (command.Id != null)
                    {
                        await ThreadFullView.InvokeScriptAsync("ScrollToDiv", new[] { string.Concat("#postId", command.Id) });

                        await ThreadSnapView.InvokeScriptAsync("ScrollToDiv", new[] { string.Concat("#postId", command.Id) });
                    }
                    else if (!string.IsNullOrEmpty(_vm.ForumThreadEntity.ScrollToPostString))
                    {
                        ThreadFullView.InvokeScriptAsync("ScrollToDiv", new[] { _vm.ForumThreadEntity.ScrollToPostString });
                        ThreadSnapView.InvokeScriptAsync("ScrollToDiv", new[] { _vm.ForumThreadEntity.ScrollToPostString });
                    }
                    break;

                case "markAsLastRead":
                    await _threadManager.MarkPostAsLastRead(_forumThread, Convert.ToInt32(command.Id));

                    int nextPost = Convert.ToInt32(command.Id) + 1;
                    await ThreadFullView.InvokeScriptAsync("ScrollToDiv", new[] { string.Concat("#postId", nextPost.ToString()) });

                    await ThreadSnapView.InvokeScriptAsync("ScrollToDiv", new[] { string.Concat("#postId", nextPost.ToString()) });

                    NotifyStatusTile.CreateToastNotification("Post marked as last read! Now smash this computer and live your life!");
                    break;

                case "setFont":
                    if (_localSettings.Values.ContainsKey("zoomSize"))
                    {
                        _zoomSize = Convert.ToInt32(_localSettings.Values["zoomSize"]);
                        ThreadFullView.InvokeScriptAsync("ResizeWebviewFont", new[] { _zoomSize.ToString() });
                        ThreadSnapView.InvokeScriptAsync("ResizeWebviewFont", new[] { _zoomSize.ToString() });
                    }
                    else
                    {
                        // _zoomSize = 20;
                    }
                    break;

                case "openThread":
                    var query = Extensions.ParseQueryString(command.Id);
                    if (query.ContainsKey("action") && query["action"].Equals("showPost"))
                    {
                        var postManager = new PostManager();
                        var html        = await postManager.GetPost(Convert.ToInt32(query["postid"]));

                        return;
                    }
                    var threadManager = new ThreadManager();
                    var threadEntity  = new ForumThreadEntity();
                    var thread        = await threadManager.GetThread(threadEntity, 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(threadEntity);
                    Frame.Navigate(typeof(ThreadPage), jsonObjectString);
                    break;

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

                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }