Exemple #1
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); }
 }
Exemple #2
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);
            }
        }
        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);
        }
        private IEnumerable <Data.ThreadDataSource> Refresh(UserMetadata user)
        {
            UpdateStatus("Loading bookmarks...");
            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Loading bookmarks from SA...");
            var bookmarks = user.LoadBookmarks();
            var data      = new UserBookmarksMetadata();

            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Load completed. Formatting...");
            UpdateStatus("Formatting...");
            var result = Data.ForumThreadCollection.CreateThreadSources(bookmarks, data);

            AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Format complete.");

            this._source.Bookmarks.LastUpdated = DateTime.Now;

            return(result);
        }
        public void ShowImageMenu(string url)
        {
            try
            {
                if (this.Menu != null)
                {
                    this.Menu.IsOpen = false;
                }

                this.Menu = ImageMenu;
                openInBrowser.CommandParameter = new Uri(url);
                this.Menu.IsOpen = true;
            }
            catch (Exception ex)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
            }
        }
Exemple #6
0
        private void AddOrUpdateItem(T item)
        {
            try
            {
                int index = Items.IndexOf(item);
                if (index != -1)
                {
                    Items[index].Update(item);
                }
                else
                {
                    Items.Add(item);
                }
            }

            catch (Exception ex)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
            }
        }
Exemple #7
0
        /// <summary>
        /// Notifies listeners that a property value has changed.
        /// </summary>
        /// <param name="propertyName">Name of the property used to notify listeners.  This
        /// value is optional and can be provided automatically when invoked from compilers
        /// that support <see cref="CallerMemberNameAttribute"/>.</param>
        protected void OnPropertyChanged(string propertyName = null)
        {
            var eventHandler = this.PropertyChanged;

            if (eventHandler != null)
            {
                try
                {
                    eventHandler(this, new PropertyChangedEventArgs(propertyName));
                }
                catch (UnauthorizedAccessException ex)
                {
                    AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, ex);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        eventHandler(this, new PropertyChangedEventArgs(propertyName));
                    });
                }
            }
        }
        private bool Log(string email, string pattern)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return(false);
            }

            bool inValue = !string.IsNullOrEmpty(email) && Regex.Match(email, pattern).Success;

            if (inValue)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Valid email.");
            }
            else
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Info, "Invalid email.");
            }

            return(inValue);
        }
        private void ProcessPagePosts(IEnumerable <Data.ThreadPostSource> source)
        {
            try
            {
                var unread = source
                             .Where(post => post.Data.IsNew)
                             .FirstOrDefault();

                if (unread == null)
                {
                    PageManager.ScrollToPost(source.First());
                }
                else
                {
                    PageManager.ScrollToPost(unread);
                }
            }

            catch (Exception ex) { AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex); }
            finally { this.IsLoading = false; }
        }
Exemple #10
0
        private void LoadPage(object source)
        {
            ThreadPageDataSource page = null;

            try
            {
                page = (source as ThreadPageDataSource).Refresh();

                if (page != null)
                {
                    this._page = page;
                }

                OnThreadPageUpdated(this);
            }
            catch (Exception ex)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
                OnThreadPageUpdated(null);
            }
        }
Exemple #11
0
        private static void AwfulWebClient_LoginRequired(object sender, LoginRequiredEventArgs e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (Instance.CurrentUser.CanLogIn)
                {
                    AwfulDebugger.AddLog(sender, AwfulDebugger.Level.Info, "Sending credentials to the WebClient...");
                    e.SetUserAndProceed(Instance.CurrentUser.Metadata);
                }

                else
                {
                    // TODO: Create settings page that has a login interface -- no need to restart the app.
                    // Notify users at this point that they need to head to settings and login from there.

                    AwfulDebugger.AddLog(sender, AwfulDebugger.Level.Info, "User is unabled to login with these credentials.");
                    e.Cancel = true;
                }

                e.Signal.Set();
            });
        }
Exemple #12
0
        public void SaveCurrentState()
        {
            try
            {
                ReplyViewModelState state = new ReplyViewModelState();
                state.Content       = this.Text;
                state.IsEditRequest = this.Request.RequestType == PostRequestType.Edit;
                if (state.IsEditRequest)
                {
                    state.PostId = (this.Request as ThreadPostEditRequest).Post.PostID;
                }
                else
                {
                    state.ThreadId = (this.Request as ThreadReplyRequest).Thread.ThreadID;
                }

                state.SaveToFile("reply.xml");

                Notification.Show("Draft saved.", "Save Draft");
            }

            catch (Exception ex) { AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex); }
        }
        public void ShowLinkMenu(string url)
        {
            try
            {
                var uri = new Uri(url, UriKind.Absolute);
                if (this.Menu != null)
                {
                    this.Menu.IsOpen = false;
                }

                foreach (var item in LinkMenu.Items)
                {
                    (item as RadContextMenuItem).CommandParameter = uri;
                }

                this.Menu        = LinkMenu;
                this.Menu.IsOpen = true;
            }
            catch (Exception ex)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
                Notification.ShowError(string.Format("Could not navigate to '{0}'", url), "Hyperlink");
            }
        }
Exemple #14
0
        private void UpdateButtonLabel(string text)
        {
            try
            {
                double value = -1;
                if (!double.TryParse(text, out value))
                {
                    value = 1;
                }

                value = Math.Max(value, 1);
                value = Math.Min(value, ThreadSource.PageCount);

                int rounded = Convert.ToInt32(Math.Round(value));
                if (this.CustomPageButton != null)
                {
                    this.CustomPageButton.Content = string.Format("Goto Page {0}", rounded);
                }
            }
            catch (Exception ex)
            {
                AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
            }
        }
Exemple #15
0
 protected override void OnError(Exception ex)
 {
     this.IsRunning = false;
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
     Notification.ShowError("The request failed.", "Unmark Thread");
 }
 private void OnSendMessageAsyncFailure(Exception ex)
 {
     IsRunning = false;
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
     Notification.ShowError("Send failed.", "Failure");
 }
 private void OnTagLoadError(Exception ex)
 {
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
     MessageBox.Show("Could not load message data; please try again.", "Error", MessageBoxButton.OK);
     InitCallback(false);
 }
 protected override void OnError(Exception exception)
 {
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, exception);
     Notification.ShowError("An error occurred while loading smilies.", "");
 }
Exemple #19
0
 protected override void OnError(Exception ex)
 {
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
     MessageBox.Show("Could not load the message.", "Error", MessageBoxButton.OK);
 }
Exemple #20
0
 protected override void OnError(Exception ex)
 {
     AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex);
     Notification.ShowError("The edit request failed.", "Edit Post");
 }