ICSharpCode.AvalonEdit.Editing.Selection.CreateDataObject C# (CSharp) Method

CreateDataObject() public method

Creates a data object containing the selection's text.
public CreateDataObject ( TextArea textArea ) : System.Windows.DataObject
textArea TextArea
return System.Windows.DataObject
        public virtual DataObject CreateDataObject(TextArea textArea)
        {
            string text = GetText(textArea.Document);
            // Ensure we use the appropriate newline sequence for the OS
            DataObject data = new DataObject(NewLineFinder.NormalizeNewLines(text, Environment.NewLine));
            // we cannot use DataObject.SetText - then we cannot drag to SciTe
            // (but dragging to Word works in both cases)

            // Also copy text in HTML format to clipboard - good for pasting text into Word
            // or to the SharpDevelop forums.
            HtmlClipboard.SetHtml(data, CreateHtmlFragment(textArea, new HtmlOptions(textArea.Options)));
            return data;
        }