public PostViewModel(Post p) { _post = p; IsSticky = p.IsSticky; IsClosed = p.IsClosed; IsMod = p.IsMod; IsAdmin = p.IsAdmin; IsDeveloper = p.IsDeveloper; FileDeleted = p.FileDeleted; Subject = p.Subject; AuthorName = p.DisplayName; HtmlComment = new HtmlDocument(); if (p.Comment != null) HtmlComment.LoadHtml(p.Comment.Replace("<wbr>", "")); if (Subject != null) { SimpleComment = Subject; } else { SimpleComment = WebUtility.HtmlDecode(HtmlComment.DocumentNode.InnerText).Replace("'", "'").Replace(",", ","); } PrettyTime = p.PrettyTime; CapCode = p.CapCode; ThumbHeight = p.ThumbHeight; ThumbWidth = p.RenamedFileName != 0 ? 100 : 0; RenamedFileName = p.RenamedFileName; ImageWidth = p.ImageWidth; ImageHeight = p.ImageHeight; string posts = p.PostCount != 1 ? "posts" : "post"; string images = p.ImageCount != 1 ? "images" : "image"; CounterText = p.PostCount + " " + posts + " and " + p.ImageCount + " " + images + "."; TruncatedCounterText = p.PostCount + " / " + p.ImageCount; Number = p.Number; NumberQuotes = p.Number + (p.Quotes.Count == 0 ? "" : " (" + p.Quotes.Count + ")"); LongNumber = p.LongNumber; HasImage = _post.RenamedFileName != 0; if (HasImage) { ThumbnailSrc = p.ThumbnailSrc; ImageSrc = p.ImageSrc; } ThreadNavigated = new ModelCommand(DoThreadNavigated); ImageNavigated = new ModelCommand(DoImageNavigated); CopyToClipboard = new ModelCommand(DoCopyToClipboard); }
public ImageViewerPostViewModel(Post p) { Number = p.Number; RenamedFileName = p.RenamedFileName; ThumbnailSrc = p.ThumbnailSrc; ImageSrc = p.ImageSrc; AspectRatio = p.ImageWidth / (double)p.ImageHeight; FileType = p.FileType; UpdateProgress = new ModelCommand<int>(DoUpdateProgress); IsDownloading = true; }
/// <summary> /// Merge a post into the thread. If the post is already in the thread, it will be updated /// in-place with the new information, otherwise the post is inserted in the correct position. /// /// This is only used by the serialization consturcts to create fake thread views for watchlist /// and history, since all other merged info comes from the API and is thus an APIPost object. /// </summary> /// <param name="op">The post to merge into the thread.</param> public void Merge(Post op) { if (Posts.ContainsKey(op.Number)) { Posts[op.Number].Merge(op); } else { Posts[op.Number] = op; } }
/// <summary> /// Merge a new set of information retrieved from serialization into this post. /// </summary> /// <param name="post">The post to update this with.</param> public void Merge(Post post) { Number = post.Number; IsSticky = post.IsSticky; IsClosed = post.IsClosed; FileDeleted = post.FileDeleted; Time = post.Time; Subject = post.Subject; Tripcode = post.Tripcode; CapCode = post.CapCode; RenamedFileName = post.RenamedFileName; FileName = post.FileName; FileType = post.FileType; Comment = post.Comment; PostCount = post.PostCount; ImageCount = post.ImageCount; ImageWidth = post.ImageWidth; ImageHeight = post.ImageHeight; FindQuotes(); }
/// <summary> /// Construct a new ThreadID ready to be serialized. Should only be used by save/restore code. /// </summary> /// <param name="boardName">The name of the board this thread is on.</param> /// <param name="number">The ID of the thread.</param> /// <param name="initial">The first post of the thread.</param> public ThreadID(string boardName, ulong number, Post initial) { BoardName = boardName; Number = number; Initial = initial; }