Example #1
0
        private void PostView_SelectedItemChanged(object sender, EventArgs e)
        {
            if (PostView.SelectedNodes.Count == 0)
            {
                ShowTips();
                return;
            }

            PostViewNode node = PostView.SelectedNodes[0] as PostViewNode;

            if (node == null)
            {
                return;
            }

            PostViewNode parent = node.ParentNode() as PostViewNode;

            OpPost parentPost = null;

            if (parent != null)
            {
                parentPost = parent.Post;
            }

            ShowMessage(node.Post, parentPost);
        }
Example #2
0
        private void PostView_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            PostViewNode node = PostView.GetNodeAt(e.Location) as PostViewNode;

            if (node == null)
            {
                return;
            }

            PostViewNode parent = node.ParentNode() as PostViewNode;

            OpPost replyTo = node.Post;

            if (parent != null)
            {
                replyTo = parent.Post;
            }

            ContextMenuStripEx menu = new ContextMenuStripEx();

            if (!replyTo.Header.Archived)
            {
                menu.Items.Add(new PostMenuItem("Reply", replyTo, (s, a) => ReplyPost(replyTo)));
            }

            if (node.Post.Header.SourceID == Core.UserID)
            {
                if (!replyTo.Header.Archived)
                {
                    menu.Items.Add(new PostMenuItem("Edit", node.Post, (s, a) => EditPost(node.Post)));
                    menu.Items.Add("-");
                }

                if (parent == null)
                {
                    if (node.Post.Header.Archived)
                    {
                        menu.Items.Add(new PostMenuItem("Restore", node.Post, (s, a) => Boards.Archive(node.Post, false)));
                    }
                    else
                    {
                        menu.Items.Add(new PostMenuItem("Archive", node.Post, (s, a) => Boards.Archive(node.Post, true)));
                    }
                }
            }

            menu.Show(PostView, e.Location);
        }
Example #3
0
        private void PostHeader_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            string url = e.Url.OriginalString;

            if (GuiUtils.IsRunningOnMono() && url.StartsWith("wyciwyg"))
            {
                return;
            }

            url = url.Replace("http://", "");
            url = url.TrimEnd('/');

            string[] parts = url.Split('/');

            if (parts.Length < 1)
            {
                return;
            }

            if (parts[0] == "about")
            {
                return;
            }

            if (PostView.SelectedNodes.Count == 0)
            {
                return;
            }

            PostViewNode node = PostView.SelectedNodes[0] as PostViewNode;

            if (node == null || node.Post == null)
            {
                return;
            }

            OpPost post = node.Post;

            if (parts[0] == "reply")
            {
                // replies are directed at parent
                PostViewNode parent = node.ParentNode() as PostViewNode;

                if (parent != null)
                {
                    post = parent.Post;
                }

                ReplyPost(post);
            }
            if (parts[0] == "edit")
            {
                EditPost(post);
            }

            if (parts[0] == "archive")
            {
                Boards.Archive(post, true);
            }

            if (parts[0] == "restore")
            {
                Boards.Archive(post, false);
            }

            if (parts[0] == "attach" && parts.Length > 1)
            {
                int index = int.Parse(parts[1]);

                if (index < post.Attached.Count)
                {
                    string path = Core.User.RootPath + Path.DirectorySeparatorChar +
                                  "Downloads" + Path.DirectorySeparatorChar + post.Attached[index].Name;

                    try
                    {
                        if (!File.Exists(path))
                        {
                            Utilities.ExtractAttachedFile(Boards.GetPostPath(post.Header),
                                                          post.Header.FileKey,
                                                          post.Header.FileStart,
                                                          post.Attached.Select(a => a.Size).ToArray(),
                                                          index,
                                                          path);
                        }

                        Process.Start(path);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, "Error Opening Attachment: " + ex.Message);
                    }
                }
            }

            e.Cancel = true;
        }