public void Add(SnapshotSpan span, string text) { if (span.Length == 0) throw new ArgumentOutOfRangeException("span"); if (text == null) throw new ArgumentNullException("text"); //Create a post adornment given the span, and text. PostAdornment post = new PostAdornment(span, text); //Add it to the list of posts. this.posts.Add(post); //Raise the changed event. EventHandler<PostsChangedEventArgs> postsChanged = this.PostsChanged; if (postsChanged != null) postsChanged(this, new PostsChangedEventArgs(post, null)); }
private void DrawPost(PostAdornment post) { SnapshotSpan span = post.Span.GetSpan(this.view.TextSnapshot); Geometry g = this.view.TextViewLines.GetMarkerGeometry(span); if (g != null) { //Find the rightmost coordinate of all the lines that intersect the adornment. double maxRight = 0.0; foreach (ITextViewLine line in this.view.TextViewLines.GetTextViewLinesIntersectingSpan(span)) maxRight = Math.Max(maxRight, line.Right); //Create the visualization. PostInfoDisplay block = new PostInfoDisplay(maxRight, this.view.ViewportRight, g, post.Text); //Add it to the layer. this.layer.AddAdornment(span, post, block); } }
public PostsChangedEventArgs(PostAdornment added, PostAdornment removed) { this.PostAdded = added; this.PostRemoved = removed; }