|
|
|
|
@ -114,6 +114,7 @@ public class MultiFormatTextBox : Control |
|
|
|
|
this.richTextBox.PreviewKeyDown += RichTextBox_KeyDown; |
|
|
|
|
this.richTextBox.PreviewTextInput += RichTextBox_PreviewTextInput; |
|
|
|
|
this.richTextBox.SelectionChanged += RichTextBox_SelectionChanged; |
|
|
|
|
DataObject.AddPastingHandler(this.richTextBox, OnRtbPaste); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
@ -352,6 +353,24 @@ public class MultiFormatTextBox : Control |
|
|
|
|
this.InsertCharacterAtCaretPositionIntoCurrentMultiFormatString(e.Text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void OnRtbPaste(object sender, DataObjectPastingEventArgs e) |
|
|
|
|
{ |
|
|
|
|
// get pasted data |
|
|
|
|
if (e.DataObject.GetDataPresent(typeof(string))) |
|
|
|
|
{ |
|
|
|
|
// get data as string |
|
|
|
|
var text = (string)e.DataObject.GetData(typeof(string)); |
|
|
|
|
// insert each character seperately |
|
|
|
|
foreach (var character in text) |
|
|
|
|
{ |
|
|
|
|
this.InsertCharacterAtCaretPositionIntoCurrentMultiFormatString(character.ToString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// cancel pasting |
|
|
|
|
e.CancelCommand(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void InsertCharacterAtCaretPositionIntoCurrentMultiFormatString(string text) |
|
|
|
|
{ |
|
|
|
|
var caretPosition = this.GetRtbCaretPosition(); |
|
|
|
|
|