/// <summary>
        /// Executes the action on a certain <see cref="TextArea"/>.
        /// </summary>
        /// <param name="textArea">The text area on which to execute the action.</param>
        public override void Execute(TextArea textArea)
        {
            if (textArea.Document.ReadOnly)
            {
                return;
            }

            string commentStart = null;

            if (textArea.Document.HighlightingStrategy.Properties.ContainsKey("BlockCommentBegin"))
            {
                commentStart = textArea.Document.HighlightingStrategy.Properties["BlockCommentBegin"];
            }

            string commentEnd = null;

            if (textArea.Document.HighlightingStrategy.Properties.ContainsKey("BlockCommentEnd"))
            {
                commentEnd = textArea.Document.HighlightingStrategy.Properties["BlockCommentEnd"];
            }

            if (String.IsNullOrEmpty(commentStart) || String.IsNullOrEmpty(commentEnd))
            {
                return;
            }

            int selectionStartOffset;
            int selectionEndOffset;

            if (textArea.SelectionManager.HasSomethingSelected)
            {
                selectionStartOffset = textArea.SelectionManager.Selections[0].Offset;
                selectionEndOffset   = textArea.SelectionManager.Selections[textArea.SelectionManager.Selections.Count - 1].EndOffset;
            }
            else
            {
                selectionStartOffset = textArea.Caret.Offset;
                selectionEndOffset   = selectionStartOffset;
            }

            BlockCommentRegion commentRegion = FindSelectedCommentRegion(textArea.Document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);

            textArea.Document.UndoStack.StartUndoGroup();
            if (commentRegion != null)
            {
                RemoveComment(textArea.Document, commentRegion);
            }
            else if (textArea.SelectionManager.HasSomethingSelected)
            {
                SetCommentAt(textArea.Document, selectionStartOffset, selectionEndOffset, commentStart, commentEnd);
            }
            textArea.Document.UndoStack.EndUndoGroup();

            textArea.Document.CommitUpdate();
            textArea.AutoClearSelection = false;
        }
        /// <summary>
        /// Determines whether the specified <see cref="Object"></see> is equal to the current <see cref="Object"></see>.
        /// </summary>
        /// <param name="obj">The <see cref="Object"></see> to compare with the current <see cref="Object"></see>.</param>
        /// <returns>
        /// true if the specified <see cref="Object"></see> is equal to the current <see cref="Object"></see>; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            BlockCommentRegion other = obj as BlockCommentRegion;

            if (other == null)
            {
                return(false);
            }

            return(commentStart == other.commentStart &&
                   commentEnd == other.commentEnd &&
                   startOffset == other.startOffset &&
                   endOffset == other.endOffset);
        }
 static void RemoveComment(IDocument document, BlockCommentRegion commentRegion)
 {
     document.Remove(commentRegion.EndOffset, commentRegion.CommentEnd.Length);
     document.Remove(commentRegion.StartOffset, commentRegion.CommentStart.Length);
 }
 static void RemoveComment(IDocument document, BlockCommentRegion commentRegion)
 {
     document.Remove(commentRegion.EndOffset, commentRegion.CommentEnd.Length);
       document.Remove(commentRegion.StartOffset, commentRegion.CommentStart.Length);
 }