Class ClipboardEx
A class providing additional methods for working with the clipboard.
Inheritance
Namespace: Telerik.Windows.Documents.Base
Assembly: Telerik.Windows.Controls.RichTextBox.dll
Syntax
public static class ClipboardEx : Object
Properties
ClipboardHandlers
Collection of ClipboardHandlers that will be used when getting rich-text content from the clipboard.
Declaration
public static List<ClipboardHandler> ClipboardHandlers { get; }
Property Value
System.Collections.Generic.List<ClipboardHandler>
The clipboard handlers. |
Methods
ContainsDocument()
Determines whether the clipboard contains supported rich-text data.
Declaration
public static bool ContainsDocument()
Returns
System.Boolean
|
ContainsDocument(KeyEventArgs)
Determines whether the clipboard contains supported rich-text data.
Declaration
public static bool ContainsDocument(KeyEventArgs pasteKeyEventArgs)
Parameters
System.Windows.Input.KeyEventArgs
pasteKeyEventArgs
The System.Windows.Input.KeyEventArgs instance containing the event data. The method can be safely invoked with null value for this parameter. |
Returns
System.Boolean
|
ContainsText(KeyEventArgs)
Determines whether the clipboard contains plain text.
Declaration
public static bool ContainsText(KeyEventArgs pasteKeyEventArgs)
Parameters
System.Windows.Input.KeyEventArgs
pasteKeyEventArgs
The System.Windows.Input.KeyEventArgs instance containing the event data. Use null if such is not present./> |
Returns
System.Boolean
|
GetDocument()
Obtains a DocumentFragment from the clipboard using the registered ClipboardHandlers.
Declaration
public static DocumentFragment GetDocument()
Returns
DocumentFragment
a DocumentFragment instance representing the document created from the content inside the clipboard. If the operation is not successful, the method returns null. |
GetDocument(out Nullable<PasteSource>)
Obtains a DocumentFragment from the clipboard using the registered ClipboardHandlers.
Declaration
public static DocumentFragment GetDocument(out Nullable<PasteSource> pasteSource)
Parameters
System.Nullable<PasteSource>
pasteSource
The PasteSource that is resolved during clipboard processing. |
Returns
DocumentFragment
a DocumentFragment instance representing the document created from the content inside the clipboard. If the operation is not successful, the method returns null. |
GetDocumentFromClipboard(String, Func<String, String>)
Gets a DocumentFragment from clipboard using the specified data format.
Declaration
public static DocumentFragment GetDocumentFromClipboard(string dataFormat, Func<string, string> clipboardStringFilter = null)
Parameters
System.String
dataFormat
The data format. You can use the set of formats provided in the System.Windows.DataFormats class. |
System.Func<System.String, System.String>
clipboardStringFilter
A function to filter the string inside the clipboard. This function is used when the content needs to be formatted additionally before creating a document from it. HTML content inserted by MS Word can be stripped using StripHtmlClipboardFormatHeaders(String). |
Returns
DocumentFragment
A DocumentFragment instance representing the content. If the operation did not succeed, the method return null. |
GetDocumentFromClipboard(String, out Nullable<PasteSource>, Func<String, String>)
Gets a DocumentFragment from clipboard using the specified data format.
Declaration
public static DocumentFragment GetDocumentFromClipboard(string dataFormat, out Nullable<PasteSource> pasteSource, Func<string, string> clipboardStringFilter = null)
Parameters
System.String
dataFormat
The data format. You can use the set of formats provided in the System.Windows.DataFormats class. |
System.Nullable<PasteSource>
pasteSource
The PasteSource that is resolved during clipboard processing. |
System.Func<System.String, System.String>
clipboardStringFilter
A function to filter the string inside the clipboard. This function is used when the content needs to be formatted additionally before creating a document from it. HTML content inserted by MS Word can be stripped using StripHtmlClipboardFormatHeaders(String). |
Returns
DocumentFragment
A DocumentFragment instance representing the content. If the operation did not succeed, the method return null. |
GetDocumentFromClipboard(String, String, Func<String, String>)
Gets a DocumentFragment from clipboard using the specified data format.
Declaration
public static DocumentFragment GetDocumentFromClipboard(string dataFormat, string formatExtension, Func<string, string> clipboardStringFilter = null)
Parameters
System.String
dataFormat
The data format. You can use the set of formats provided in the System.Windows.DataFormats class. |
System.String
formatExtension
This parameter is not used. |
System.Func<System.String, System.String>
clipboardStringFilter
A function to filter the string inside the clipboard. This function is used when the content needs to be formatted additionally before creating a document from it. |
Returns
DocumentFragment
A DocumentFragment instance representing the content. If the operation did not succeed, the method return null. |
GetText()
Gets the clipboard data of type System.Windows.DataFormats.UnicodeText.
Declaration
public static string GetText()
Returns
System.String
The string representing the content or System.String.Empty if there is no text in the clipboard. |
GetText(KeyEventArgs)
Gets the clipboard data of type System.Windows.DataFormats.UnicodeText.
Declaration
public static string GetText(KeyEventArgs e)
Parameters
System.Windows.Input.KeyEventArgs
e
The System.Windows.Input.KeyEventArgs instance containing the event data. Use null if such is not present./> |
Returns
System.String
The string representing the content or System.String.Empty if there is no text in the clipboard. |
SetDataObject(IDataObject)
Places a specified data object in the system Clipboard.
Declaration
public static void SetDataObject(IDataObject dataObject)
Parameters
System.Windows.IDataObject
dataObject
A data object (an object that implements System.Windows.IDataObject) to place on the system Clipboard. |
SetDocument(DocumentFragment)
Sets a document represented by a DocumentFragment instance to the system clipboard.
Declaration
public static void SetDocument(DocumentFragment documentFragment)
Parameters
DocumentFragment
documentFragment
The document fragment. |
SetDocument(DocumentFragment, IDataObject)
Sets a document represented by a DocumentFragment instance to the specified data object.
Declaration
public static void SetDocument(DocumentFragment documentFragment, IDataObject dataObject)
Parameters
DocumentFragment
documentFragment
The document fragment. |
System.Windows.IDataObject
dataObject
The object the document fragment should be inserted into. |
SetText(String)
Stores System.Windows.DataFormats.UnicodeText data, specified as a string, in the system clipboard.
Declaration
public static void SetText(string textData)
Parameters
System.String
textData
The text data. |
SetText(String, DataObject)
Stores System.Windows.DataFormats.UnicodeText data, specified as a string, in the specified data object.
Declaration
public static void SetText(string textData, DataObject dataObject)
Parameters
System.String
textData
The string representing the text data. |
System.Windows.DataObject
dataObject
The data object. |
SetText(KeyEventArgs, String)
Stores System.Windows.DataFormats.UnicodeText data, specified as a string, in the system clipboard.
Declaration
public static void SetText(KeyEventArgs e, string textData)
Parameters
System.Windows.Input.KeyEventArgs
e
The System.Windows.Input.KeyEventArgs instance containing the event data. The method can be safely invoked with null value for this parameter. |
System.String
textData
The text data. |
SetText(KeyEventArgs, String, DataObject)
Stores System.Windows.DataFormats.UnicodeText data, specified as a string, in the specified data object.
Declaration
public static void SetText(KeyEventArgs e, string textData, DataObject dataObject)
Parameters
System.Windows.Input.KeyEventArgs
e
The System.Windows.Input.KeyEventArgs instance containing the event data. The method can be safely invoked with null value for this parameter. |
System.String
textData
The string representing the text data. |
System.Windows.DataObject
dataObject
The data object. |
StripHtmlClipboardFormatHeaders(String)
Strips the clipboard format headers from the HTML content inserted in the clipboard by MS Word. Skips all lines in the beginning containing ':'.
Declaration
public static string StripHtmlClipboardFormatHeaders(string clipboardText)
Parameters
System.String
clipboardText
The clipboard text. |
Returns
System.String
The stripped HTML string. |