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); }
public void PostEdit(OpPost post, uint parentID, string rtf, bool plain) { EditPost = post; ParentID = parentID; SubjectTextBox.Text = post.Info.Subject; MessageBody.InputBox.Rtf = rtf; MessageBody.PlainTextMode = plain; if (post.Header.Scope == ScopeType.All) { ScopeAll.Checked = true; } else if (post.Header.Scope == ScopeType.High) { ScopeHigh.Checked = true; } else if (post.Header.Scope == ScopeType.Low) { ScopeLow.Checked = true; } if (parentID != 0) { SubjectTextBox.Text = post.Info.Subject; SubjectTextBox.Enabled = false; SetScopeInvisible(); } PostButton.Text = "Edit"; }
void EditPost(OpPost post) { PostMessage form = new PostMessage(Boards, post.Header.TargetID, post.Header.ProjectID); form.PostEdit(post, post.Header.ParentID, PostBody.Rtf, post.Info.Format == TextFormat.Plain); UI.ShowView(form, true); }
void ReplyPost(OpPost parent) { PostMessage form = new PostMessage(Boards, parent.Header.TargetID, parent.Header.ProjectID); form.PostReply(parent); UI.ShowView(form, true); }
public PostViewNode(BoardService boards, OpPost post, ScopeType position, ScopeType scope) { Post = post; Position = position; Scope = scope; SubItems.Add(new ContainerSubListViewItem()); SubItems.Add(new ContainerSubListViewItem()); Update(boards, post); }
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); }
public void Update(BoardService boards, OpPost post) { Post = post; // editing a post will build a new header, create a new object Text = boards.GetPostTitle(post); if (post.Header.ParentID == 0 && post.Replies > 0) { Text += " (" + post.Replies.ToString() + ")"; } SubItems[0].Text = boards.Core.GetName(post.Header.SourceID); SubItems[1].Text = Utilities.FormatTime(post.Header.Time); /* * 0 - PostView.OverlayImages.Add(PostImages.higher); * 1 - PostView.OverlayImages.Add(PostImages.lower); * 2 - PostView.OverlayImages.Add(PostImages.high_scope); * 3 - PostView.OverlayImages.Add(PostImages.low_scope);*/ ImageIndex = 0; if (Position == ScopeType.High) { ImageIndex = 1; } if (Position == ScopeType.Low) { ImageIndex = 2; } if (Overlays == null) { Overlays = new List <int>(); } if (Scope == ScopeType.High) { Overlays.Add(0); } if (Scope == ScopeType.Low) { Overlays.Add(1); } }
public void PostReply(OpPost parent) { Reply = true; ParentPost = parent; ParentID = parent.Header.PostID; SubjectTextBox.Text = parent.Info.Subject; SubjectTextBox.Enabled = false; SubjectTextBox.BackColor = Color.WhiteSmoke; SetScopeInvisible(); PostButton.Text = "Reply"; }
private void RefreshButton_Click(object sender, EventArgs e) { List <ulong> targets = Boards.GetBoardRegion(UserID, ProjectID, CurrentScope); foreach (ulong target in targets) { Boards.SearchBoard(target, ProjectID); } foreach (int parentHash in ActiveThreads.Keys) { if (ThreadMap.ContainsKey(parentHash)) { OpPost post = ThreadMap[parentHash].Post; Boards.ThreadSearch(post.Header.TargetID, post.Header.ProjectID, post.Header.PostID); } } }
public async Task <ActionResult <IEnumerable <Thread> > > PostNewThread(OpPost thread) { string route = Request.Path.Value; string boardName = route.Split('/').Last(); var board = await _boardService.GetBoardByName(boardName); Thread opPost = new Thread() { Content = thread.content, Subject = thread.subject, ImgUrl = thread.file.data, BoardId = board.Id, }; Thread createdThread = await _threadService.CreateThread(opPost); createdThread = await _threadService.UpdateThread(createdThread); //return CreatedAtAction(nameof(GetThreadsByBoard), new { boardName = boardName }, createdThread); return(StatusCode(201)); }
public PostMenuItem(string text, OpPost post, EventHandler onClick) : base(text, null, onClick) { Post = post; }
public PostMenuItem(OpPost post) { Post = post; }
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; }
private void ShowMessage(OpPost post, OpPost parent) { if (parent == null) { parent = post; } string responseTo = ""; if (parent != post) { responseTo = "Response to "; } // header string content = responseTo + "<b><font size=2>" + parent.Info.Subject + @"</font></b> posted by " + Core.GetName(post.Header.SourceID) + @" at " + Utilities.FormatTime(post.Header.Time) + @"<br>"; // edit time if (post.Header.EditTime > post.Header.Time) { content += "Edited at " + Utilities.FormatTime(post.Header.EditTime) + "<br>"; } // attached files if (post.Attached.Count > 1) { string attachHtml = ""; for (int i = 0; i < post.Attached.Count; i++) { if (post.Attached[i].Name == "body") { continue; } attachHtml += "<a href='http://attach/" + i.ToString() + "'>" + post.Attached[i].Name + "</a> (" + Utilities.ByteSizetoString(post.Attached[i].Size) + "), "; } attachHtml = attachHtml.TrimEnd(new char[] { ' ', ',' }); content += "<b>Attachments: </b> " + attachHtml; } content += "<br>"; // actions string actions = ""; if (!post.Header.Archived) { actions += @" <a href='http://reply'>Reply</a>"; } if (post.Header.SourceID == Core.UserID) { if (!post.Header.Archived) { actions += @", <a href='http://edit'>Edit</a>"; } if (post == parent) { if (post.Header.Archived) { actions += @", <a href='http://restore'>Restore</a>"; } else { actions += @", <a href='http://archive'>Remove</a>"; } } } content += "<b>Actions: </b>" + actions.Trim(',', ' '); SetHeader(content); // body try { using (TaggedStream stream = new TaggedStream(Boards.GetPostPath(post.Header), Core.GuiProtocol)) using (IVCryptoStream crypto = IVCryptoStream.Load(stream, post.Header.FileKey)) { int buffSize = 4096; byte[] buffer = new byte[4096]; long bytesLeft = post.Header.FileStart; while (bytesLeft > 0) { int readSize = (bytesLeft > (long)buffSize) ? buffSize : (int)bytesLeft; int read = crypto.Read(buffer, 0, readSize); bytesLeft -= (long)read; } // load file foreach (PostFile file in post.Attached) { if (file.Name == "body") { byte[] msgBytes = new byte[file.Size]; crypto.Read(msgBytes, 0, (int)file.Size); UTF8Encoding utf = new UTF8Encoding(); PostBody.Clear(); PostBody.SelectionFont = new Font("Tahoma", 9.75f); PostBody.SelectionColor = Color.Black; if (post.Info.Format == TextFormat.RTF) { PostBody.Rtf = utf.GetString(msgBytes); } else { PostBody.Text = utf.GetString(msgBytes); } PostBody.DetectLinksDefault(); } } } } catch (Exception ex) { MessageBox.Show(this, "Error Opening Post: " + ex.Message); } }
void Board_PostUpdate(OpPost post) { if (post == null) { RefreshBoard(); return; } if (post.Header.ProjectID != ProjectID) { return; } if (post.Header.Archived != ArchiveButton.Checked) { return; } ScopeType level = ScopeType.All; bool pass = false; // check if belongs in list if (post.Header.TargetID == UserID) { if ((post.Header.Scope == ScopeType.High && CurrentScope == ScopeType.Low) || (post.Header.Scope == ScopeType.Low && CurrentScope == ScopeType.High)) { return; // pass fail } pass = true; } else if (CurrentScope != ScopeType.None) // use else because local id is in highIDs { if (HighIDs.Contains(post.Header.TargetID) && // high user CurrentScope != ScopeType.Low && // view filter post.Header.Scope != ScopeType.High) // post meant for high user's highers, not us { pass = true; level = ScopeType.High; } else if (LowIDs.Contains(post.Header.TargetID) && // low user CurrentScope != ScopeType.High && // view filter post.Header.Scope != ScopeType.Low) // post meant for low user's lowers, not us { pass = true; level = ScopeType.Low; } } if (!pass) { return; } // parent thread if (post.Header.ParentID == 0) { PostViewNode node = null; if (!ThreadMap.ContainsKey(post.Ident)) { node = new PostViewNode(Boards, post, level, post.Header.Scope); ThreadMap[post.Ident] = node; AddPostNode(PostView.Nodes, node, false); } else { node = ThreadMap[post.Ident]; node.Update(Boards, post); } if (node.Selected) { ShowMessage(post, null); } } // reply - must be on active threads list to show else { OpBoard board = Boards.GetBoard(post.Header.TargetID); if (board == null) { return; } PostUID parentUid = new PostUID(post.Header.TargetID, post.Header.ProjectID, post.Header.ParentID); OpPost parentPost = Boards.GetPost(post.Header.TargetID, parentUid); if (parentPost == null) { return; } int parentIdent = parentPost.Ident; if (!ThreadMap.ContainsKey(parentIdent)) { return; } PostViewNode parent = ThreadMap[parentIdent]; parent.Update(Boards, parentPost); // if post has replies, add an empty item below so it has an expand option if (!ActiveThreads.ContainsKey(parentIdent)) { if (parent.Nodes.Count == 0) { parent.Nodes.Add(new TreeListNode()); } PostView.Invalidate(); return; } // else post is active PostViewNode replyNode = null; if (!ActiveThreads[parentIdent].ContainsKey(post.Ident)) { replyNode = new PostViewNode(Boards, post, ScopeType.All, ScopeType.All); ActiveThreads[parentIdent][post.Ident] = replyNode; AddPostNode(parent.Nodes, replyNode, true); } else { replyNode = ActiveThreads[parentIdent][post.Ident]; replyNode.Update(Boards, post); } if (replyNode.Selected) { ShowMessage(replyNode.Post, parent.Post); } PostView.Invalidate(); } }