Exemplo n.º 1
0
        public async override void Execute(object parameter)
        {
            long id = long.Parse((string)parameter);
            var  vm = Locator.ViewModels.ThreadPageVm;

            if (vm == null)
            {
                return;
            }
            Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity;

            App.RootFrame.Navigate(typeof(NewThreadReplyPage));
            Locator.ViewModels.NewThreadReplyVm.IsLoading = true;
            try
            {
                var replyManager = new ReplyManager();
                Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity =
                    await replyManager.GetReplyCookies(id);

                Locator.ViewModels.NewThreadReplyVm.PostBody =
                    Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity.Quote;
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex);
                App.RootFrame.GoBack();
            }
            Locator.ViewModels.NewThreadReplyVm.IsLoading = false;
        }
Exemplo n.º 2
0
        public async override void Execute(object parameter)
        {
            var args = parameter as ItemClickEventArgs;

            if (args == null)
            {
                AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null"));
                return;
            }
            var thread = args.ClickedItem as PrivateMessageEntity;

            if (thread == null)
            {
                return;
            }

            var vm = Locator.ViewModels.PrivateMessagePageVm;

            vm.IsLoading            = true;
            vm.PrivateMessageEntity = thread;
            try
            {
                await vm.GetPrivateMessageHtml();
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", ex);
                App.RootFrame.GoBack();
            }
        }
Exemplo n.º 3
0
 protected override void OnError(Exception ex)
 {
     this.IsRunning = false;
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
     Notification.ShowError("Rating request failed.", "Rate Thread");
     PostAction(false);
 }
Exemplo n.º 4
0
        public async Task Initialize()
        {
            IsLoading = true;
            IsEmpty   = false;
            try
            {
                TabThreads = new ObservableCollection <ForumThreadEntity>();
                var tabs = await _tabManager.GetAllTabThreads();

                if (tabs != null && tabs.Any())
                {
                    TabThreads = tabs.ToObservableCollection();
                }
                else
                {
                    IsEmpty = true;
                }
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Failed to get Tabs", ex);
            }

            IsLoading = false;
        }
Exemplo n.º 5
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="Common.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)
        {
            if (e.NavigationParameter == null)
            {
                return;
            }
            try
            {
                var threadId     = (long)e.NavigationParameter;
                var bookmarkdata = new BookmarkDataSource();
                _lastSelectedItem = await
                                    bookmarkdata.BookmarkForumRepository.Items.Where(node => node.ThreadId == threadId).FirstOrDefaultAsync();

                if (_lastSelectedItem != null)
                {
                    Locator.ViewModels.BookmarksPageVm.NavigateToThreadPageViaToastCommand.Execute(_lastSelectedItem);

                    if (AdaptiveStates.CurrentState == NarrowState)
                    {
                        Frame.Navigate(typeof(ThreadPage), null, new DrillInNavigationTransitionInfo());
                    }
                }
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Failed to load Bookmarks page", ex);
            }
        }
        public async override void Execute(object parameter)
        {
            var args = parameter as ItemClickEventArgs;

            if (args == null)
            {
                AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null"));
                return;
            }
            var thread = args.ClickedItem as SearchEntity;

            if (thread == null)
            {
                return;
            }
            App.RootFrame.Navigate(typeof(ThreadPage));
            Locator.ViewModels.ThreadPageVm.IsLoading = true;
            var newThreadEntity = new ForumThreadEntity()
            {
                Location          = Constants.BaseUrl + thread.ThreadLink,
                ImageIconLocation = "/Assets/ThreadTags/noicon.png"
            };

            Locator.ViewModels.ThreadPageVm.ForumThreadEntity = newThreadEntity;
            await Locator.ViewModels.ThreadPageVm.GetForumPostsAsync();
        }
        public async override void Execute(object parameter)
        {
            var args = parameter as ItemClickEventArgs;

            if (args == null)
            {
                AwfulDebugger.SendMessageDialogAsync("Navigation failed", new Exception("Arguments are null"));
                return;
            }
            Locator.ViewModels.SaclopediaPageVm.IsLoading = true;
            try
            {
                var navEntity = (SaclopediaNavigationTopicEntity)args.ClickedItem;
                var result    =
                    await Locator.ViewModels.SaclopediaPageVm.SaclopediaManager.GetSaclopediaEntity(Constants.BaseUrl + navEntity.Link);

                Locator.ViewModels.SaclopediaPageVm.Title = result.Title;
                var platformIdentifier = PlatformIdentifier.Windows8;
                //App.RootFrame.Navigate(typeof (SaclopediaEntryPage));

                Locator.ViewModels.SaclopediaPageVm.Body = await HtmlFormater.FormatSaclopediaEntry(result.Body, platformIdentifier);
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Navigation failed", ex);
            }
            Locator.ViewModels.SaclopediaPageVm.IsLoading = false;
        }
        public async Task CreateThreadPreview(NewThreadEntity newThreadEntity)
        {
            IsLoading = true;
            NewThreadEntity = newThreadEntity;
            try
            {
                string result = await _threadManager.CreateNewThreadPreview(NewThreadEntity);
                if (string.IsNullOrEmpty(result))
                {
                    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.Ascii2);
                    await AwfulDebugger.SendMessageDialogAsync(messageText, new Exception("No text in reply box"));
                    return;
                }

                Html = result;

            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Failed to get the preview html", ex);
            }
            IsLoading = false;
        }
Exemplo n.º 9
0
 protected override void OnError(Exception ex)
 {
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
     Notification.ShowError(NotificationMethod.MessageBox, "Could not load the requested page. Please try again.", "View Thread");
     IsReady = false;
     OnUpdateFailed();
 }
Exemplo n.º 10
0
        public async override void Execute(object parameter)
        {
            var thread = (ForumThreadEntity)parameter;

            if (!thread.IsBookmark)
            {
                await
                AwfulDebugger.SendMessageDialogAsync(
                    "In order to be notified of thread updates, the thread must be a bookmark.",
                    new Exception("Not a bookmark"));

                return;
            }
            var mfd = new MainForumsDatabase();

            try
            {
                await mfd.SetThreadNotified(thread);
            }
            catch (Exception ex)
            {
                await
                AwfulDebugger.SendMessageDialogAsync(
                    "Failed to save thread to notifications table",
                    ex);
            }
        }
Exemplo n.º 11
0
 protected override void OnError(Exception exception)
 {
     this.IsRunning = false;
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, exception);
     Notification.ShowError(NotificationMethod.MessageBox, "Could not retrieve bookmarks from SA. Please try again.", "Pinned");
     UpdateStatus(EMPTY_STATUS);
 }
 public async Task CreateReplyPreview(ForumReplyEntity forumReplyEntity, bool isEdit)
 {
     IsLoading = true;
     var replyManager = new ReplyManager();
     string result;
     if (isEdit)
     {
         result = await replyManager.CreatePreviewEditPost(forumReplyEntity);
     }
     else
     {
         result = await replyManager.CreatePreviewPost(forumReplyEntity);
     }
     try
     {
         if (!string.IsNullOrEmpty(result))
         {
             Html = result;
         }
         else
         {
             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.Ascii2);
             var msgDlg = new MessageDialog(messageText);
             await msgDlg.ShowAsync();
         }
     }
     catch (Exception ex)
     {
         AwfulDebugger.SendMessageDialogAsync("Failed to get the preview html", ex);
     }
     IsLoading = false;
 }
Exemplo n.º 13
0
        protected override IEnumerable <Data.ForumDataSource> LoadDataInBackground()
        {
            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Loading forum body...");

            IEnumerable <Data.ForumDataSource> result = null;

            if (this._forums != null)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Forum body found in iso storage!");

                // Removing this cache, so future refreshes will pull from forums
                UpdateStatus("Formatting...");
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Formatting Data...");
                result       = Data.ForumCollection.GroupForums(_forums);
                this._forums = null;
            }

            else
            {
                var user   = _source.CurrentUser;
                var forums = Refresh(user);
                this._source.Forums = new Data.ForumCollection(forums);
                UpdateStatus("Formatting...");
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Formatting Data...");
                result = Data.ForumCollection.GroupForums(forums);
            }

            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Format Complete.");
            return(result);
        }
        internal async void AttachImage(Microsoft.Phone.Tasks.PhotoResult e)
        {
            this.IsRunning = true;

            try
            {
                List <ImgurUploader.DataUploadItem> items = new List <ImgurUploader.DataUploadItem>();
                items.Add(new ImgurUploader.DataUploadItem(e));
                var request  = ImgurUploader.ImgurUploadRequest.CreateUploadRequest(items, ImgurUploader.ImgurLinkType.Normal);
                var response = await request.UploadAsync();

                var result = response.CreateResult();

                if (result.ToClipboard())
                {
                    Notification.Show("Image link copied to clipboard.", "Success!");
                }

                else
                {
                    Notification.ShowError("Image upload failed.", "Error");
                }
            }

            catch (Exception ex)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
                Notification.ShowError("Image upload failed.", "Error");
            }

            this.IsRunning = false;
        }
 protected override void OnError(Exception exception)
 {
     IsRunning = false;
     Items.Clear();
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, exception);
     MessageBox.Show("Could not fetch private messages from the server.", "Error", MessageBoxButton.OK);
 }
Exemplo n.º 16
0
        protected override void OnSuccess(object arg)
        {
            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Edit Request was successful!");

            IThreadPostRequest request = arg as IThreadPostRequest;

            OnEditRequested(this, request);
        }
Exemplo n.º 17
0
        private static void AwfulLoginClient_LoginSuccessful(object sender, LoginEventArgs e)
        {
            AwfulDebugger.AddLog(sender, AwfulDebugger.Level.Info, "Login was successful! Saving user cookies to iso storage...");
            var user = new UserDataSource(e.User);

            user.SaveToFile("user.xml");
            Instance.CurrentUser = user;
        }
        public async override void Execute(object parameter)
        {
            var args = parameter as RoutedEventArgs;

            if (args == null)
            {
                await AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null"));

                return;
            }

            var appButton = args.OriginalSource as AppBarButton;

            if (appButton == null)
            {
                // TODO: If this is somehow null, throw an error and tell the user.
                return;
            }
            var vm = appButton.DataContext as ThreadListPageViewModel;

            if (vm == null)
            {
                return;
            }
            App.RootFrame.Navigate(typeof(NewThreadPage));
            Locator.ViewModels.NewThreadVm.IsLoading = true;
            try
            {
                Locator.ViewModels.NewThreadVm.NewThreadEntity = await _threadManager.GetThreadCookiesAsync(vm.ForumEntity.ForumId);

                if (Locator.ViewModels.NewThreadVm.NewThreadEntity == null)
                {
                    await AwfulDebugger.SendMessageDialogAsync("You can't post in this forum!",
                                                               new Exception("Forum locked for new posts"));

                    App.RootFrame.GoBack();
                    return;
                }
            }
            catch (Exception exception)
            {
                AwfulDebugger.SendMessageDialogAsync("Error getting thread cookies for this forum.", exception);
                App.RootFrame.GoBack();
                return;
            }

            Locator.ViewModels.NewThreadVm.ForumEntity = vm.ForumEntity;
            Locator.ViewModels.NewThreadVm.PostBody    = string.Empty;
            Locator.ViewModels.NewThreadVm.PostSubject = string.Empty;
            Locator.ViewModels.NewThreadVm.PostIcon    = new PostIconEntity()
            {
                Id       = 0,
                ImageUrl = "/Assets/ThreadTags/shitpost.png",
                Title    = "Shit Post"
            };
            Locator.ViewModels.NewThreadVm.IsLoading = false;
        }
Exemplo n.º 19
0
        protected override void OnSuccess(object arg)
        {
            Uri            uri  = arg as Uri;
            WebBrowserTask task = new WebBrowserTask();

            task.Uri = uri;
            try { task.Show(); }
            catch (Exception ex) { AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex); }
        }
Exemplo n.º 20
0
        protected override bool PreCondition(Data.ThreadPostSource item)
        {
            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Edit Request Made, Confirming...");

            var  response = MessageBox.Show("Are you sure you wish to edit this post? Any current text in the reply window will be erased.", ":o", MessageBoxButton.OKCancel);
            bool proceed  = response == MessageBoxResult.OK;

            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, string.Format("Edit Request {0}.", proceed ? "Confirmed" : "Cancelled"));

            return(proceed);
        }
Exemplo n.º 21
0
 public void RefreshCurrentPage()
 {
     try
     {
         LoadPageCommandArgs args = new LoadPageCommandArgs();
         args.LoadPage = RefreshCurrentPageDelegate;
         args.State    = CurrentThreadPage.Data;
         Execute(args);
     }
     catch (Exception ex) { AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex); }
 }
Exemplo n.º 22
0
 protected override void OnError(Exception ex)
 {
     try
     {
         AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
         string message = "Could not load the requested page.";
         Notification.ShowError(NotificationMethod.MessageBox, message, "View Page");
         this.CurrentState = ViewStates.Ready;
         this.Status       = string.Empty;
     }
     catch (Exception eex) { AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, eex); }
 }
Exemplo n.º 23
0
        private async void ReplyButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (_vm.ForumThreadEntity == null)
            {
                await AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread, refresh and try again.", new Exception("ForumThreadEntitiy is Null"));

                return;
            }
            string jsonObjectString = JsonConvert.SerializeObject(_forumThread);

            Frame.Navigate(typeof(ReplyPage), jsonObjectString);
        }
        public async override void Execute(object parameter)
        {
            var vm        = Locator.ViewModels.NewPrivateMessagePageVm;
            var pmManager = new PrivateMessageManager();

            if (string.IsNullOrEmpty(vm.PostSubject))
            {
                AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Submit is empty"));
                return;
            }

            if (string.IsNullOrEmpty(vm.PostBody))
            {
                AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Body is empty"));
                return;
            }

            if (string.IsNullOrEmpty(vm.PostRecipient))
            {
                AwfulDebugger.SendMessageDialogAsync("Can't post the thread yet!", new Exception("Recipient is empty"));
                return;
            }

            var pmEntity = new NewPrivateMessageEntity();

            vm.IsLoading      = true;
            pmEntity.Title    = vm.PostSubject;
            pmEntity.Body     = vm.PostBody;
            pmEntity.Icon     = vm.PostIcon;
            pmEntity.Receiver = vm.PostRecipient;

            try
            {
                bool result = await pmManager.SendPrivateMessage(pmEntity);

                if (result)
                {
                    App.RootFrame.GoBack();
                }
                else
                {
                    await AwfulDebugger.SendMessageDialogAsync("Error making the pm.", new Exception());
                }
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Error making the pm.", ex);
            }
            vm.IsLoading = false;
        }
 public async Task Initialize(long userId)
 {
     ForumUserEntity = new ForumUserEntity();
     IsLoading       = true;
     try
     {
         ForumUserEntity = await _forumUserManager.GetUserFromProfilePage(userId);
     }
     catch (Exception ex)
     {
         AwfulDebugger.SendMessageDialogAsync("Failed to get user info", ex);
     }
     IsLoading = false;
 }
        public async override void Execute(object parameter)
        {
            var thread = parameter as ForumThreadEntity;

            if (thread == null)
            {
                AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null"));
                return;
            }

            Locator.ViewModels.ThreadPageVm.ForumThreadEntity = thread;
            Locator.ViewModels.ThreadPageVm.Html = null;
            await Locator.ViewModels.ThreadPageVm.GetForumPostsAsync();
        }
Exemplo n.º 27
0
 public async Task GetSearchResults(List <int> forumIds)
 {
     IsLoading = true;
     try
     {
         SearchPageScrollingCollection = new SearchPageScrollingCollection(forumIds, SearchTerms);
         App.RootFrame.Navigate(typeof(SearchResultsPage));
     }
     catch (Exception ex)
     {
         AwfulDebugger.SendMessageDialogAsync("Failed to get results", ex);
     }
     IsLoading = false;
 }
Exemplo n.º 28
0
        public void SendThreadRequestAsync()
        {
            if (Request != null && !IsRunning)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Sending thread request.");
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "RequestType: " + RequestType);
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Debug, "----------------------BeginMessage--------------------");
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Debug, Text);
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Debug, "-----------------------EndMessage---------------------");

                Request.Content = Text;
                SendRequestCommand.Execute(Request);
            }
        }
Exemplo n.º 29
0
        private IEnumerable <Data.ForumDataSource> Refresh(Data.UserDataSource user)
        {
            UpdateStatus("Loading forums...");
            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Forum body missing. Pulling body from SA...");

            var forums = user.Metadata.LoadForums();
            IEnumerable <Data.ForumDataSource> result = null;

            if (forums != null)
            {
                result = forums.Select(forum => new Data.ForumDataSource(forum));
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Forum body request complete!");
            }
            return(result);
        }
Exemplo n.º 30
0
        public async void GetSmilies()
        {
            var smiliesManager = new SmileManager();

            try
            {
                SmilieCategoryList = await smiliesManager.GetSmileList();
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Can't get smilies list. :(", ex);
                return;
            }
            FullSmileCategoryEntities = SmilieCategoryList;
        }