当前位置: 首页>>代码示例>>C#>>正文


C# DataObjectPastingEventArgs.CancelCommand方法代码示例

本文整理汇总了C#中System.Windows.DataObjectPastingEventArgs.CancelCommand方法的典型用法代码示例。如果您正苦于以下问题:C# DataObjectPastingEventArgs.CancelCommand方法的具体用法?C# DataObjectPastingEventArgs.CancelCommand怎么用?C# DataObjectPastingEventArgs.CancelCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.DataObjectPastingEventArgs的用法示例。


在下文中一共展示了DataObjectPastingEventArgs.CancelCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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();
 }
开发者ID:GandziukVI,项目名称:BreakJunctionsExperiment,代码行数:9,代码来源:HandlingUserInput.cs

示例2: 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();
 }
开发者ID:ruisebastiao,项目名称:WPF-MVVM-With-Entity-Framework,代码行数:9,代码来源:TextBoxMaskBehavior.cs

示例3: 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();
 }
开发者ID:trbielec,项目名称:hospipal,代码行数:9,代码来源:App.xaml.cs

示例4: textBoxNumeric_Pasting

 private void textBoxNumeric_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     string input = string.Empty;
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         if (!this.isNumericInput((string)e.DataObject.GetData(typeof(string))))
             e.CancelCommand();
     }
     else
         e.CancelCommand();
 }
开发者ID:Nefarin,项目名称:DadmProject,代码行数:11,代码来源:ECG_BASELINE.xaml.cs

示例5: TextBoxPasting

 private void TextBoxPasting(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();
     }
 }
开发者ID:faisal-nstu,项目名称:WeightCalculatorWpfApp,代码行数:15,代码来源:MainWindow.xaml.cs

示例6: TextBoxPaste_CheckNumbers

 private void TextBoxPaste_CheckNumbers(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!StringHelpers.IsTextAllowed(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
开发者ID:killerrin,项目名称:Frontier-The-Void-GMTools,代码行数:15,代码来源:RollDicePage.xaml.cs

示例7: TextBoxPasting

 // Use the DataObject.Pasting Handler
 private void TextBoxPasting(object sender, DataObjectPastingEventArgs e)
 {
     int value;
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         string text = (string)e.DataObject.GetData(typeof(string));
         if (int.TryParse(text, out value))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
开发者ID:PedersenThomas,项目名称:Nonogram,代码行数:17,代码来源:CustomGameWindow.xaml.cs

示例8: 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();
     }
 }
开发者ID:skilldrill,项目名称:MCBattleShip,代码行数:8,代码来源:SingleDigitBehavior.cs

示例9: 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();
 }
开发者ID:unbearab1e,项目名称:FlattyTweet,代码行数:9,代码来源:SearchUserView.cs

示例10: OnPaste

        /// <summary>
        /// Method checks if pasted string contains input that is invalid and cancels
        /// past command if string is not conforming to regular expression.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnPaste(object sender, DataObjectPastingEventArgs e)
        {
            if (e.DataObject.GetDataPresent(DataFormats.Text))
            {
                var RegularExpression = AllowableCharactersTextBoxBehavior.GetRegularExpressionProperty(sender as TextBox);

                string text = System.Convert.ToString(e.DataObject.GetData(DataFormats.Text));

                if (!IsValid(text, true, RegularExpression))
                {
                    e.CancelCommand();
                }
            }
            else
            {
                e.CancelCommand();
            }
        }
开发者ID:ohnx,项目名称:ColorPick,代码行数:24,代码来源:AllowableCharactersTextBoxBehavior+.cs

示例11: 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();
     }
 }
开发者ID:ashfordl,项目名称:cipher-solver,代码行数:9,代码来源:MainWindow.xaml.cs

示例12: 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();
 }
开发者ID:unbearab1e,项目名称:FlattyTweet,代码行数:9,代码来源:SettingsView.cs

示例13: OnPaste

        private void OnPaste(object sender, DataObjectPastingEventArgs e)
        {
            var pastedText = (string) e.SourceDataObject.GetData(DataFormats.UnicodeText);

            if (ProductIdIsNotValid(pastedText))
            {
                e.CancelCommand();
            }
        }
开发者ID:Havret,项目名称:CeneoETL,代码行数:9,代码来源:ETLView.xaml.cs

示例14: 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();
 }
开发者ID:nlafourcade,项目名称:OGP,代码行数:16,代码来源:NumericTextBoxBehavior.cs

示例15: NumberBox_Pasting

        private void NumberBox_Pasting(object sender, DataObjectPastingEventArgs e)
        {
            if (e.DataObject.GetDataPresent(typeof(string)))
            {
                string paste = (string)e.DataObject.GetData(typeof(string));

                Trace.WriteLine("Parsing paste: '" + paste + "'");

                Trace.WriteLineIf(Regex.IsMatch(paste, "^[0-9]+$"), "Paste is matching :)");
                Trace.WriteLineIf(!Regex.IsMatch(paste, "^[0-9]+$"), "Paste is not matching :(");

                if (!Regex.IsMatch(paste, "^[0-9]+$"))
                    e.CancelCommand();
            }
            else
            {
                Trace.WriteLine("Paste was not text :(");
                e.CancelCommand();
            }
        }
开发者ID:Papzi,项目名称:Legends-Email-Spammer,代码行数:20,代码来源:NumberInput.xaml.cs


注:本文中的System.Windows.DataObjectPastingEventArgs.CancelCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。