本文整理汇总了C#中System.Windows.DataObjectPastingEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DataObjectPastingEventArgs类的具体用法?C# DataObjectPastingEventArgs怎么用?C# DataObjectPastingEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataObjectPastingEventArgs类属于System.Windows命名空间,在下文中一共展示了DataObjectPastingEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntegerTextBox_PastingHandler
private static void IntegerTextBox_PastingHandler(object sender, DataObjectPastingEventArgs e)
{
var Sender = sender as IntegerTextBox;
if (Sender == null)
return;
Sender.OnPaste(e);
}
示例2: OnPasted
private void OnPasted(object sender, DataObjectPastingEventArgs e)
{
myWordsAdded = true;
mySelectionStartPosition = Selection.Start;
mySelectionEndPosition = Selection.IsEmpty ? Selection.End.GetPositionAtOffset(0, LogicalDirection.Forward) : Selection.End;
// Hyperlink detection will be done in OnTextChanged()
}
示例3: tb_Pasting
private static void tb_Pasting(object sender, DataObjectPastingEventArgs e)
{
var pastedText = e.DataObject.GetData(typeof(string)) as string;
if (!IsTextAllowed(pastedText))
{
e.CancelCommand();
}
}
示例4: UcQuery_OnPaste
private void UcQuery_OnPaste(object sender, DataObjectPastingEventArgs e)
{
var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true);
if (!isText) return;
var text = e.SourceDataObject.GetData(DataFormats.UnicodeText) as string;
ucQuery.Tag = !string.IsNullOrWhiteSpace(text);
}
示例5: Key_Pasting
private void Key_Pasting(object sender, DataObjectPastingEventArgs e)
{
Regex r = new Regex("[^a-zA-Z]");
if (r.IsMatch(e.DataObject.GetData(typeof(string)).ToString()))
{
MessageBox.Show(this, "Keys can only contain alphabetic letters!");
e.CancelCommand();
}
}
示例6: RichTextBox_Pasting
private void RichTextBox_Pasting(object sender, DataObjectPastingEventArgs e)
{
RichTextBox richTextBox = sender as RichTextBox;
string textData = (e.DataObject.GetData(DataFormats.UnicodeText) as string).Replace("\n", " ").Replace("\r", "");
new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End).Text = string.Empty;
richTextBox.CaretPosition = richTextBox.CaretPosition.GetPositionAtOffset(0, LogicalDirection.Forward) ?? richTextBox.CaretPosition;
richTextBox.CaretPosition.InsertTextInRun(textData);
e.CancelCommand();
}
示例7: OnPaste
private void OnPaste(object sender, DataObjectPastingEventArgs e)
{
var isText = e.SourceDataObject.GetDataPresent(System.Windows.DataFormats.Text, true);
if (!isText)
return;
var text = e.SourceDataObject.GetData(DataFormats.Text) as string;
}
示例8: PastingHandler
private static void PastingHandler(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(typeof(String)))
{
var text = (String)e.DataObject.GetData(typeof(String));
if (!IsTextAllowed(text)) e.CancelCommand();
}
else e.CancelCommand();
}
示例9: IntegerPastingHandler
public static void IntegerPastingHandler(ref object sender, ref DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(typeof(String)))
{
String text = (String)e.DataObject.GetData(typeof(String));
if (!HandlingUserInput.IsIntegerText(text)) e.CancelCommand();
}
else e.CancelCommand();
}
示例10: OnPaste
private void OnPaste(object sender, DataObjectPastingEventArgs e)
{
var pastedText = (string) e.SourceDataObject.GetData(DataFormats.UnicodeText);
if (ProductIdIsNotValid(pastedText))
{
e.CancelCommand();
}
}
示例11: OnPaste
private void OnPaste(object sender, DataObjectPastingEventArgs e)
{
if (!(sender is RichTextBox))
return;
string textData = e.DataObject.GetData(DataFormats.Text) as string;
(sender as RichTextBox).Document.ContentEnd.InsertTextInRun(textData);
(sender as RichTextBox).CaretPosition = (sender as RichTextBox).Document.ContentEnd;
e.CancelCommand();
}
示例12: noPaste
private void noPaste(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(typeof(String)))
{
String text = (String)e.DataObject.GetData(typeof(String));
if (textAllowed(text)) e.CancelCommand();
}
else e.CancelCommand();
}
示例13: OnClipboardPaste
/// <summary>
/// This method handles paste and drag/drop events onto the TextBox. It restricts the character
/// set to numerics and ensures we have consistent behavior.
/// </summary>
/// <param name="sender">TextBox sender</param>
/// <param name="e">EventArgs</param>
private static void OnClipboardPaste(object sender, DataObjectPastingEventArgs e)
{
string text = e.SourceDataObject.GetData(e.FormatToApply) as string;
if (!string.IsNullOrEmpty(text))
{
if (text.Count(ch => !Char.IsNumber(ch)) == 0)
return;
}
e.CancelCommand();
}
示例14: IPTextBox_Paste
private void IPTextBox_Paste(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(typeof(string)))
{
string value = e.DataObject.GetData(typeof(string)).ToString();
setIP(value);
}
e.CancelCommand();
}
示例15: OnPaste
protected virtual void OnPaste(DataObjectPastingEventArgs e)
{
var IsTextPresent = e.SourceDataObject.GetDataPresent(System.Windows.DataFormats.Text, true);
if (IsTextPresent)
{
var TextValue = e.SourceDataObject.GetData(DataFormats.Text) as string;
if (CheckTextFormat(TextValue))
return;
}
e.CancelCommand();
}