ICSharpCode.AvalonEdit.Document.TextDocument.BeginUpdate C# (CSharp) Method

BeginUpdate() public method

Begins a group of document changes.

Some events are suspended until EndUpdate is called, and the UndoStack will group all changes into a single action.

Calling BeginUpdate several times increments a counter, only after the appropriate number of EndUpdate calls the events resume their work.

public BeginUpdate ( ) : void
return void
        public void BeginUpdate()
        {
            VerifyAccess();
            if (inDocumentChanging)
                throw new InvalidOperationException("Cannot change document within another document change.");
            beginUpdateCount++;
            if (beginUpdateCount == 1) {
                undoStack.StartUndoGroup();
                if (UpdateStarted != null)
                    UpdateStarted(this, EventArgs.Empty);
            }
        }

Usage Example

Esempio n. 1
0
        public void RawlyIndentLine(int tabsToInsert, TextDocument document, DocumentLine line)
        {
            if (!_doBeginUpdateManually)
                document.BeginUpdate();
            /*
             * 1) Remove old indentation
             * 2) Insert new one
             */

            // 1)
            int prevInd = 0;
            int curOff = line.Offset;
            if (curOff < document.TextLength)
            {
                char curChar = '\0';
                while (curOff < document.TextLength && ((curChar = document.GetCharAt(curOff)) == ' ' || curChar == '\t'))
                {
                    prevInd++;
                    curOff++;
                }

                document.Remove(line.Offset, prevInd);
            }

            // 2)
            string indentString = "";
            for (int i = 0; i < tabsToInsert; i++)
                indentString += dEditor.Editor.Options.IndentationString;

            document.Insert(line.Offset, indentString);
            if (!_doBeginUpdateManually)
                document.EndUpdate();
        }
All Usage Examples Of ICSharpCode.AvalonEdit.Document.TextDocument::BeginUpdate