private void OnCommentAdornerDeleted(ReportCommentAdorner commentAdorner)
        {
            AdornerLayer commentAdornerLayer = AdornerLayer.GetAdornerLayer(this._textArea);

            commentAdornerLayer.Remove(commentAdorner);
            TextRange range = new TextRange(commentAdorner.CommentedSelectionStart, commentAdorner.CommentedSelectionEnd);

            range.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.White);
            this._commentAdorners.Remove(commentAdorner);
        }
        private void ImportComment(EjpLib.BaseClasses.ejpCAComment comment)
        {
            TextPointer commentStart = this._textArea.GetPositionFromPoint(
                new Point(comment.OriginalPositionX, comment.OriginalPositionY), true);

            TextPointer commentEnd = commentStart.GetPositionAtOffset(comment.CommentedTextInDocument.Length);

            TextRange range = new TextRange(commentStart, commentEnd);

            range.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(Color.FromArgb(80, 0, 255, 0)));

            ReportCommentAdorner comAd =
                new ReportCommentAdorner(
                    this._textArea, commentStart, commentEnd, comment.AuthorName, comment.AuthorId, comment.Messages,
                    comment.CommentId);

            AdornerLayer commentAdornerLayer = AdornerLayer.GetAdornerLayer(this._textArea);

            comAd.OnCommentAdornerDeleted += new CommentAdornerDeleted(OnCommentAdornerDeleted);
            commentAdornerLayer.Add(comAd);
            this._commentAdorners.Add(comAd);
        }
        /// <summary>
        /// Insert a Comment (Commented Assignment Only) for the
        /// current selection in the TextArea.
        /// </summary>
        private void OnAddCommentToSelection(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this._textArea.Selection.IsEmpty)
                {
                    return;
                }

                TextPointer tp1   = this._textArea.Selection.Start;
                TextPointer tp2   = this._textArea.Selection.End;
                TextRange   range = new TextRange(tp1, tp2);
                range.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(Color.FromArgb(80, 0, 255, 0)));

                ReportCommentAdorner comAd =
                    new ReportCommentAdorner(
                        this._textArea, tp1, tp2, this.CurrentOwnerName, this.CurrentOwnerId, new List <EjpLib.BaseClasses.ejpCACommentMessage>(),
                        EjpLib.Helpers.IdManipulation.GetNewGuid());

                AdornerLayer commentAdornerLayer = AdornerLayer.GetAdornerLayer(this._textArea);
                comAd.OnCommentAdornerDeleted += new CommentAdornerDeleted(OnCommentAdornerDeleted);
                commentAdornerLayer.Add(comAd);
                this._commentAdorners.Add(comAd);
            }
            catch (Exception ex)
            {
                SiliconStudio.DebugManagers.DebugReporter.Report(
                    SiliconStudio.DebugManagers.MessageType.Error,
                    "EjpControls - Report Editor",
                    "Failed to Add Comment to Selection" +
                    "\nParent Study ID: " + this.ParentStudyId.ToString() +
                    "\nReport ID: " + this._reportObject.Id.ToString() +
                    "\nError: " + ex.Message);
                throw;
            }
        }