/// <summary> /// Delegate called to disable the capability of dragging selected text of the text box. /// </summary> /// <param name="pSender">The modified text box.</param> /// <param name="pEventArgs">The event arguments.</param> private void DisableDragCopy(object pSender, DataObjectCopyingEventArgs pEventArgs) { if (pEventArgs.IsDragDrop) { pEventArgs.CancelCommand(); } }
private void DataObjectCopyingHandler(object sender, DataObjectCopyingEventArgs e) { try { Clipboard.SetText(RTBExtensions.GetSelectedInlineText(this.richTextBox)); if (SettingsData.Instance.CutIsTriggered) { this.richTextBox.Selection.Text = string.Empty; SettingsData.Instance.CutIsTriggered = false; } e.CancelCommand(); } catch { } }
private static void NoDragCopy(object sender, DataObjectCopyingEventArgs e) { if (e.IsDragDrop) { e.CancelCommand(); } }
private static void OnCopy(object sender, DataObjectCopyingEventArgs e) { var control = sender as System.Windows.Controls.TextBox; if (control == null) return; string html = GetHtmlCopyContent(control); html = HTMLClipboardHelper.GetHtmlDataString(html); e.DataObject.SetData(DataFormats.UnicodeText, control.Text.ToString(), true); e.DataObject.SetData(DataFormats.Text, control.Text.ToString(), true); e.DataObject.SetData(DataFormats.OemText, control.Text.ToString(), true); e.DataObject.SetData(DataFormats.Html, html, true); Clipboard.SetDataObject(e.DataObject, true); e.Handled = true; e.CancelCommand(); }