ICSharpCode.TextEditor.Document.SelectionManager.ClearSelection C# (CSharp) Method

ClearSelection() public method

Clears the selection.
public ClearSelection ( ) : void
return void
        public void ClearSelection()
        {
            Point mousepos;
            mousepos = textArea.mousepos;
            // this is the most logical place to reset selection starting
            // positions because it is always called before a new selection
            selectFrom.first = selectFrom.where;
            selectionStart = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);
            if(selectFrom.where == WhereFrom.Gutter)
                selectionStart.X = 0;

            ClearWithoutUpdate();
            document.CommitUpdate();
        }

Usage Example

コード例 #1
0
		/// <summary>
		/// Selects the specified text range.
		/// </summary>
		static void SelectText(SelectionManager selectionManager, IDocument document, int startOffset, int length)
		{
			selectionManager.ClearSelection();
			TextLocation selectionStart = document.OffsetToPosition(startOffset);
			TextLocation selectionEnd = document.OffsetToPosition(startOffset + length);
			selectionManager.SetSelection(selectionStart, selectionEnd);
		}