예제 #1
0
        /// <summary>
        /// Replaces the text at the given region with the specified xml. After replacing
        /// the inserted text is indented and then selected.
        /// </summary>
        public void Replace(DomRegion region, string xml)
        {
            IDocument document = textAreaControl.Document;
            ISegment  segment  = WixDocument.ConvertRegionToSegment(document, region);

            // Replace the original xml with the new xml and indent it.
            int originalLineCount = document.TotalNumberOfLines;

            document.Replace(segment.Offset, segment.Length, xml);
            int addedLineCount = document.TotalNumberOfLines - originalLineCount;

            // Make sure the text inserted is visible.
            textAreaControl.ScrollTo(region.BeginLine);

            // Indent the xml.
            int insertedCharacterCount = IndentLines(textAreaControl.TextArea, region.BeginLine + 1, region.EndLine + addedLineCount, document.FormattingStrategy);

            // Select the text just inserted.
            SelectText(textAreaControl.SelectionManager, document, segment.Offset, xml.Length + insertedCharacterCount);
        }