예제 #1
0
 private void Object_Count_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!isNumberic(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #2
0
 private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         string text = (string)e.DataObject.GetData(typeof(string));
         if (!IsTextAllowed(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
 private void PastingHandler(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(DataFormats.Text))
     {
         var text = Convert.ToString(e.DataObject.GetData(DataFormats.Text));
         if (!ValidateText(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #4
0
 private void firstImageSpinButton_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!IsNumberic(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #5
0
 private void TextBoxPastingOnlyNumbers(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (Extensions.IsTextAllowed(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #6
0
 private void TextBox_PastingHandler(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         string text = (string)e.DataObject.GetData(typeof(string));
         if (IsPastedTextNotNumeric(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #7
0
 private void SendAmountTextBox_OnPasting(object sender, DataObjectPastingEventArgs e)
 {
     if (!e.DataObject.GetDataPresent(typeof(string)))
     {
         return;
     }
     if (!IsTextAllowed((string)e.DataObject.GetData(typeof(string))))
     {
         e.CancelCommand();
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #8
0
 private void tbFontSize_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String Text1 = (String)e.DataObject.GetData(typeof(String));
         if (!TextBoxTextAllowed(Text1))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
 private void TextBoxCodigoBarras_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         string entrada = (string)e.DataObject.GetData(typeof(string));
         if (!ServiciosDeValidacion.ValidarEntero(entrada))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #10
0
 /// <summary>
 /// Constrains the text pasted in a container to something that can be parsed as an integer.
 /// </summary>
 public static void InputValidationOnPaste_ConstrainToInt(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         int num;
         if (!int.TryParse((string)e.DataObject.GetData(typeof(string)), out num))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #11
0
 private void TextBoxPasting(object sender, DataObjectPastingEventArgs e)
 {
     /*if (e.DataObject.GetDataPresent(typeof(String)))
      * {
      *  String text = (String)e.DataObject.GetData(typeof(String));
      *  if (!IsTextAllowed(text))
      *  {
      *      e.CancelCommand();
      *  }
      * }
      * else
      * {
      *  e.CancelCommand();
      * }*/
 }
예제 #12
0
 private void PasteOnlyInts(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!IsInt(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
 private static void OnPaste(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(DataFormats.Text))
     {
         var text = Convert.ToString(e.DataObject.GetData(DataFormats.Text)).Trim();
         if (!IsValueValid(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
 public static void FloatingPointPastingHandler(ref object sender, ref DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!HandlingUserInput.IsFloatingPointText(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
 /// <summary>
 /// Permite que solo se puedan pegar caracteres numericos
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TextBoxPaste(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!Extensor.ValidarNumeros(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #16
0
 private static void OnPaste(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(DataFormats.Text))
     {
         var text = Convert.ToString(e.DataObject.GetData(DataFormats.Text)).Trim();
         if (text.Any(c => !char.IsDigit(c)))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
 private static void OnPaste(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         if (NumericBehavior.IsTextAllowed((string)e.DataObject.GetData(typeof(string))))
         {
             return;
         }
         e.CancelCommand();
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #18
0
 private static void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         string text = GetFullText((TextBox)sender, (string)e.DataObject.GetData(typeof(string)));
         if (!IsTextValid(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #19
0
        protected void OnPaste(object sender, DataObjectPastingEventArgs e)
        {
            if (e.SourceDataObject.GetDataPresent(DataFormats.Text, true))
            {
                var text = e.SourceDataObject.GetData(DataFormats.Text) as string;
                if (text != null)
                {
                    text = text.Replace("\r\n", "\r");

                    ProcessTextInput(text);
                    Write(text);
                }
            }
            e.CancelCommand();
        }
예제 #20
0
 private void TbStartValue_OnPasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         string input = (string)e.DataObject.GetData(typeof(string));
         if (!TextIsNumeric(input))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #21
0
 private void Text_Pasting(object sender, DataObjectPastingEventArgs args)
 {
     if (args.DataObject.GetDataPresent(typeof(string)))
     {
         string text = (string)args.DataObject.GetData(typeof(string));
         if (!IsTextAllowed(text))
         {
             args.CancelCommand();
         }
     }
     else
     {
         args.CancelCommand();
     }
 }
예제 #22
0
 private void BinaryStringPasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (IsBinaryString(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #23
0
 private void TbDuration_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!IsValidDuration(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #24
0
 private void HeightTextBox_TextBoxPasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!IsNumbersOnly(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #25
0
 /// <summary>
 /// Restricts pasting into textboxes to text that can be parsed as float
 /// </summary>
 private void TextBoxPasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!isTextValidFloat(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #26
0
 private void CheckNumeric_Pasting(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         string text = (string)e.DataObject.GetData(typeof(string));
         if (NonNumeric.IsMatch(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
 /// <summary>
 /// Gestion du changement du texte numérique
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NumberTextBox_TextChanged(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         String text = (String)e.DataObject.GetData(typeof(String));
         if (!IsTextAllowed(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #28
0
        private static void NumericBox_PastingEventHandler(object sender, DataObjectPastingEventArgs e)
        {
            var    numericBox = (sender as AppNumericBox);
            string clipboard  = e.DataObject.GetData(typeof(string)) as string;

            clipboard = ValidateValue(numericBox.Mask, clipboard, numericBox.MinValue, numericBox.MaxValue);

            if (!string.IsNullOrEmpty(clipboard))
            {
                numericBox.Text = clipboard;
            }

            e.CancelCommand();
            e.Handled = true;
        }
 /// <summary>
 /// Sees to that the textboxes only accepts numbers when something is pasted
 /// </summary>
 /// <param name="sender">autogenerated</param>
 /// <param name="e">autogenerated</param>
 private void PastingHandler(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(String)))
     {
         var text = (String)e.DataObject.GetData(typeof(String));
         if (!IsNumeric(text))
         {
             e.CancelCommand();
         }
     }
     else
     {
         e.CancelCommand();
     }
 }
예제 #30
0
        private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
        {
            if (!e.DataObject.GetDataPresent(typeof(string)))
            {
                e.CancelCommand();
                return;
            }

            string text = (string)e.DataObject.GetData(typeof(string));

            if (numberRegex.IsMatch(text))
            {
                e.CancelCommand();
            }
        }
        internal static bool _DoPaste(TextEditor This, IDataObject dataObject, bool isDragDrop)
        {
            // Don't try anything if the caller doesn't have the rights to read from the clipboard...
            //
            if (!SecurityHelper.CallerHasAllClipboardPermission()) return false;

            Invariant.Assert(dataObject != null);

            // Choose what format we are going to paste
            string formatToApply;
            bool pasted;

            pasted = false;

            // Get the default paste content applying format
            formatToApply = GetPasteApplyFormat(This, dataObject);

            DataObjectPastingEventArgs dataObjectPastingEventArgs;

            try
            {
                // Let the application to participate in Paste process
                dataObjectPastingEventArgs = new DataObjectPastingEventArgs(dataObject, isDragDrop, formatToApply);
            }
            catch (ArgumentException)
            {
                // Clipboard can be changed by set new or empty data during creating
                // DataObjectPastingEvent that check the representing of the
                // formatToApply. Do nothing if we encounter AgrumentException.
                return pasted;
            }

            // Public event call - could raise recoverable exception.
            This.UiScope.RaiseEvent(dataObjectPastingEventArgs);

            if (!dataObjectPastingEventArgs.CommandCancelled)
            {
                // When custom handler decides to suggest its own data,
                // it must create a new instance of DataObject and put it
                // into DataObjectPastingEventArgs.DataObject property.
                // Exisiting DataObject is on global Clipboard and can not be changed.
                // Here we need to get this potentially changed instance
                // of DataObject
                IDataObject dataObjectToApply = dataObjectPastingEventArgs.DataObject;

                formatToApply = dataObjectPastingEventArgs.FormatToApply;

                // Paste the content data(Text, Unicode, Xaml and Rtf) to the current text selection
                pasted = PasteContentData(This, dataObject, dataObjectToApply, formatToApply);
            }

            return pasted;
        }