Exemplo n.º 1
0
        private void AddComment(Commentable post)
        {
            if (post == null)
            {
                if (SelectedPost == null)
                {
                    return;
                }
                else
                {
                    post = SelectedPost as Commentable;
                }
            }

            var dlg = EditPostWindow.CreateForComment(api, post);

            dlg.Owner = window;

            dlg.ShowDialog();

            if (!dlg.Cancelled)
            {
                post.IncrementComments();
            }
        }
Exemplo n.º 2
0
        internal static async Task <bool> HandleButtons(Window window, ButtonClickedEventArgs args)
        {
            EditPostWindow editPost;

            switch (args.Type)
            {
            case ButtonType.Up:
            case ButtonType.Down:
                await Utilities.Vote(args);

                break;

            case ButtonType.Reply:
                if (args.SelectedItem is Commentable)
                {
                    Commentable ctbl = args.SelectedItem as Commentable;
                    editPost       = EditPostWindow.CreateForComment(AppManager.Instance.API, ctbl);
                    editPost.Owner = window;
                    editPost.ShowDialog();

                    if (!editPost.Cancelled)
                    {
                        ctbl.IncrementComments();
                    }
                }
                break;

            case ButtonType.Delete:
                switch (args.SelectedItem.Type)
                {
                case FeedItem.FeedItemType.Post:
                    AppManager.Instance.API.User.DeleteRant(args.SelectedItem.AsRant().ID);
                    break;

                case FeedItem.FeedItemType.Comment:
                    AppManager.Instance.API.User.DeleteComment(args.SelectedItem.AsComment().ID);
                    break;
                }
                break;

            case ButtonType.Edit:
                TimeSpan timespan = DateTime.Now.ToUniversalTime() - FromUnixTime(args.SelectedItem.RawCreateTime);
                if (timespan > MaxModifyMinutes)
                {
                    throw new Exception(args.SelectedItem.Type + " can no longer be edited.");
                }

                editPost       = EditPostWindow.CreateForEdit(AppManager.Instance.API, args.SelectedItem);
                editPost.Owner = window;
                editPost.ShowDialog();
                break;
            }

            return(true);
        }