Example #1
0
        //</Snippet29>

        //<Snippet30>
        private CommentAdornmentManager(IWpfTextView view)
        {
            this.view = view;
            this.view.LayoutChanged += OnLayoutChanged;
            this.view.Closed        += OnClosed;

            this.layer = view.GetAdornmentLayer("CommentAdornmentLayer");

            this.provider = CommentAdornmentProvider.Create(view);
            this.provider.CommentsChanged += OnCommentsChanged;
        }
Example #2
0
        //</Snippet12>

        //<Snippet13>
        static public void Execute(IWpfTextViewHost host)
        {
            IWpfTextView view = host.TextView;

            //Add a comment on the selected text.
            if (!view.Selection.IsEmpty)
            {
                //Get the provider for the comment adornments in the property bag of the view.
                CommentAdornmentProvider provider = view.Properties.GetProperty <CommentAdornmentProvider>(typeof(CommentAdornmentProvider));

                //Add some arbitrary author and comment text.
                string author  = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                string comment = "Four score....";

                //Add the comment adornment using the provider.
                provider.Add(view.Selection.SelectedSpans[0], author, comment);
            }
        }