Ejemplo n.º 1
0
 void mTBNascimento_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         mtxbNascimento.Clear();
         mtxbNascimento.Focus();
     }
 } 
Ejemplo n.º 2
0
 public void maskedTextBox1_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         toolTip1.ToolTipTitle = "Invalid Date Value";
         toolTip1.Show("We're sorry, but the value you entered is not a valid date. Please change the value.", maskedTextBox1, 5000);
         e.Cancel = true;
     }
 }
        private void maskedTextBox1_TypeValidationCompleted(object sender, System.Windows.Forms.TypeValidationEventArgs e)
        {
            if (e.IsValidInput)
            {
                AppendLog("Type validation succeeded.  Message: " + e.Message);
                ip = e.ReturnValue as IPv5;
            }
            else
            {
                ip = IPv5.InvalidIPv5;

                AppendLog("Type validation failed.  Message: " + e.Message);
                this.eventLogTextBox.ScrollToCaret();
            }
        }
 private void OnMaskedTypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     OnTypeValidationCompleted(e);
 }
Ejemplo n.º 5
0
 private void maskedTextBoxFecha_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (maskedTextBoxFecha.Text.Trim() != "/  /")
     {
         if (!e.IsValidInput)
         {
             isValidDate = false;
             errorProvider.SetError(maskedTextBoxFecha, "La fecha debe tener el formato dd/mm/aaaa.");
         }
         else
         {
             isValidDate = true;
             errorProvider.SetError(maskedTextBoxFecha, null);
         }
     }
     else
     {
         isValidDate = true;
     }
 }
Ejemplo n.º 6
0
 /// <devdoc>
 ///     Raises the TypeValidationCompleted event.
 /// </devdoc>
 private void OnTypeValidationCompleted(TypeValidationEventArgs e)
 {
     TypeValidationEventHandler eh = Events[EVENT_VALIDATIONCOMPLETED] as TypeValidationEventHandler;
     if (eh != null)
     {
         eh(this, e);
     }
 }
Ejemplo n.º 7
0
 private void mTxtWeight_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (mtxtWeight.Text != "")
     {
         if (!e.IsValidInput)
         {
             mtxtWeight.BackColor = Color.Red;
             MessageBox.Show("El peso debe ser un número del 0 al 9999,99");
             e.Cancel = true;
         }
         else
         {
             SqlDecimal temp = Convert.ToDecimal(mtxtWeight.Text);
             if ((temp < 10000) && (temp >= 0))
             {
                 e.Cancel = false;
                 mtxtWeight.BackColor = SystemColors.Window;
             }
             else
             {
                 mtxtWeight.BackColor = Color.Red;
                 MessageBox.Show("El peso debe ser un número del 0 al 9999,99");
                 e.Cancel = true;
             }//else 2
         }//else 1
     }//if 1
     else
     {
         e.Cancel = false;
         mtxtWeight.BackColor = SystemColors.Window;
         mtxtWeight.Text = "0,000";
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Raises TypeValidationCompleted event.
 /// </summary>
 protected virtual void OnTypeValidationCompleted(TypeValidationEventArgs e)
 {
     TypeValidationEventHandler eh = TypeValidationCompleted;
     if (eh != null)
         eh(this, e);
 }
		public void TestTypeValidationEventArgs()
		{
			bool valid = true;
			string message = "This is a test.";
			object rv = (object) "MyObject";
			Type vt = typeof(int);
			
			TypeValidationEventArgs e = new TypeValidationEventArgs (vt, valid, rv, message);
			
			Assert.AreEqual(valid, e.IsValidInput, "A1");
			Assert.AreEqual(message, e.Message, "A2");
			Assert.AreEqual(rv, e.ReturnValue, "A3");
			Assert.AreEqual(vt, e.ValidatingType, "A4");
			Assert.AreEqual(false, e.Cancel, "A5");
			
			e.Cancel = true;
			
			Assert.AreEqual(true, e.Cancel, "A6");
		}
Ejemplo n.º 10
0
		private void tBoxSyncValue_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
		{
			try
			{
				if (!e.IsValidInput)
				{
					SyncValue = MaskValidationType.InvalidMask.ArrayValue;
					throw new Exception("Wrong Sync word entered.  Message: " + e.Message);
				}
				if (e.ReturnValue is MaskValidationType)
					SyncValue = (e.ReturnValue as MaskValidationType).ArrayValue;
			}
			catch (Exception exception)
			{
				OnError(1, exception.Message);
			}
		}
 private static void maskedTextBox1_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         MaskedTextBox box = sender as MaskedTextBox;
         box.Tag = e.Message;
     }
 }
 private void BasicMonitorPortTextBoxTypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
         ((MaskedTextBox)sender).Text = ((MaskedTextBox)sender).Tag.ToString();
 }
Ejemplo n.º 13
0
 private void maskedTextBoxNetworkIP_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         toolTip1.ToolTipTitle = "Invalid IP";
         toolTip1.Show("Not a valid IP.", maskedTextBoxNetworkIP, 0, 0, 5000);
     }
 }
Ejemplo n.º 14
0
 private void txtHorario_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (e.IsValidInput)
     {
         if (txtHorario.Text.Split(':')[1] != "00" && txtHorario.Text.Split(':')[1] != "30")
         {
             strHorarioFiltro = "";
             MessageBox.Show("Horário informado deve estar no intervalo de 30 minutos.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtHorario.Focus();
         }
         else
         {
             strHorarioFiltro = txtHorario.Text;
             CarregaGrid();
         }
     }
     else if (txtHorario.Text.Replace(":", "").Trim() != "")
     {
         MessageBox.Show("Horário Informado inválido", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
         strHorarioFiltro = "";
         txtHorario.Focus();
     }
     else if (txtHorario.Text.Replace(":", "").Trim() == "" && strHorarioFiltro != "")
     {
         strHorarioFiltro = "";
         CarregaGrid();
     }
 }
Ejemplo n.º 15
0
        void TCDatetime_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
        {
            try
            {
                if (this.Allow_Null == "Y") return;
                DateTime v_dat = new DateTime();
                bool v_b_result =false;
                switch (Format)
                {
                    case DinhDang.dd_MM_yyyy:
                        v_b_result = DateTime.TryParseExact(this.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.AssumeLocal, out v_dat);
                        break;
                    case DinhDang.MM_yyyy:
                        v_b_result = DateTime.TryParseExact(this.Text, "MM/yyyy", null, System.Globalization.DateTimeStyles.AssumeLocal, out v_dat);
                        break;
                }

                if (!v_b_result)
                {
                    MessageBox.Show("Bạn nhập sai định dạng!");
                    this.Focus();
                }
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 16
0
 private void maskedTextBox2_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         toolTip1.ToolTipTitle = "Неправильный формат даты";
         toolTip1.Show("Дата должна быть в формате день.месяц.год.", maskedTextBox2, 0, -20, 5000);
     }
     else
     {
         //Now that the type has passed basic type validation, enforce more specific type rules.
         DateTime userDate = (DateTime)e.ReturnValue;
         if (userDate < DateTime.Now)
         {
             toolTip1.ToolTipTitle = "Неправильная дата";
             toolTip1.Show("Дата в этом поле должна быть больше, чем сегодняшнее число.", maskedTextBox2, 0, -20, 5000);
             e.Cancel = true;
         }
     }
 }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// typevalidationeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this TypeValidationEventHandler typevalidationeventhandler, Object sender, TypeValidationEventArgs e, AsyncCallback callback)
        {
            if(typevalidationeventhandler == null) throw new ArgumentNullException("typevalidationeventhandler");

            return typevalidationeventhandler.BeginInvoke(sender, e, callback, null);
        }
Ejemplo n.º 18
0
 private void SecondNUmber_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
         e.Cancel = true;
 }
Ejemplo n.º 19
0
 private void txtCode_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (e.IsValidInput)
     return;
       int num = (int)MessageBox.Show(e.Message);
 }
Ejemplo n.º 20
0
 private void text_objTension_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (e.IsValidInput)
         drawPanel.Invalidate();
 }
Ejemplo n.º 21
0
 private void MtbDatanasc_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if(e.ReturnValue != null)
     {
         DateTime data = (DateTime)e.ReturnValue;
     }
     else
     {
         MessageBox.Show("Por favor verifique a data digitada.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void snapTolerance_TypeValidationEventHandler(object sender, TypeValidationEventArgs e)
 {
   try
   {
     snapEnvironment.SnapTolerance = Convert.ToDouble(snapTolerance.Text);
   }
   catch
   {
     snapTolerance.Text = snapEnvironment.SnapTolerance.ToString();
   }      
 }
Ejemplo n.º 23
0
		private void maskedTextBox_TypeValidationCompleted (object sender, TypeValidationEventArgs e)
		{
			MaskedTextBox mtp = sender as MaskedTextBox;
			if (mtp == null) return;
			lstEvents.Items.Add (mtp.Name + "." + System.Reflection.MethodInfo.GetCurrentMethod ().Name.Substring (14));
			lstEvents.TopIndex = lstEvents.Items.Count - 1;
		}
Ejemplo n.º 24
0
        void maskedTextBox1_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
        {
            // Create the ToolTip and associate with the Form container.
              ToolTip toolTip1 = new ToolTip();

              // Set up the delays for the ToolTip.
              toolTip1.AutoPopDelay = 1000;
              toolTip1.InitialDelay = 500;
              toolTip1.ReshowDelay = 200;
              // Force the ToolTip text to be displayed whether or not the form is active.
              toolTip1.ShowAlways = true;

              // Set up the ToolTip text for the Button.
              toolTip1.SetToolTip(this.button6, "My button6");

              if (!e.IsValidInput)
              {

              toolTip1.ToolTipTitle = "Invalid Date";
              toolTip1.Show("The data you supplied must be a valid date in the format mm/dd/yyyy.", maskedTextBox1, 0, -20, 5000);
              }
              else
              {
              //Now that the type has passed basic type validation, enforce more specific type rules.
              DateTime userDate = (DateTime)e.ReturnValue;
              if (userDate < DateTime.Now)
              {
                  toolTip1.ToolTipTitle = "Invalid Date";
                  toolTip1.Show("The date in this field must be greater than today's date.", maskedTextBox1, 0, -20, 5000);
                  e.Cancel = true;
              }
              }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Evénement lorsque le champ de Date de Début est validé ou non.
 /// S'il n'est pas valide une erreur ce lance et le focus est remis sur le champ.
 /// </summary>
 /// <param name="sender"> Contrôle de l'événement.</param>
 /// <param name="e">Arguments.</param>
 private void maskedTextBoxDateD_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         error.SetError(maskedTextBoxDateD, "Veuillez entrer une date correcte");
         maskedTextBoxDateD.Focus();
         buttonValider.Enabled = false;
     }
     else
     {
         error.SetError(maskedTextBoxDateD, "");
         buttonValider.Enabled = true;
     }
 }
Ejemplo n.º 26
0
        /// <devdoc>
        ///     Performs validation of the input string using the provided ValidatingType object (if any).
        ///     Returns an object created from the formatted text.
        ///     If the CancelEventArgs param is not null, it is assumed the control is leaving focus and
        ///     the validation event chain is being executed (TypeValidationCompleted - Validating - Validated...);
        ///     the value of the CancelEventArgs.Cancel property is the same as the TypeValidationEventArgs.Cancel
        ///     on output (Cancel provides proper handling of focus shifting at the Control class level).
        ///     Note: The text being validated does not include prompt chars.
        /// </devdoc>
        private object PerformTypeValidation(CancelEventArgs e)
        {
            object parseRetVal = null;

            if (this.validatingType != null)
            {
                string message = null;
                
                if (!this.flagState[IS_NULL_MASK]&& this.maskedTextProvider.MaskCompleted == false)
                {
                    message = SR.GetString(SR.MaskedTextBoxIncompleteMsg);
                }
                else
                {
                    string textValue;

                    if( !this.flagState[IS_NULL_MASK]) // replace prompt with space.
                    {
                        textValue = this.maskedTextProvider.ToString(/*includePrompt*/ false, this.IncludeLiterals);
                    }
                    else
                    {
                        textValue = base.Text;
                    }

                    try
                    {
                        parseRetVal = Formatter.ParseObject(
                            textValue,              // data
                            this.validatingType,    // targetType
                            typeof(string),         // sourceType
                            null,                   // targetConverter
                            null,                   // sourceConverter
                            this.formatProvider,    // formatInfo
                            null,                   // nullValue
                            Formatter.GetDefaultDataSourceNullValue(this.validatingType));   // dataSourceNullValue
                    }
                    catch (Exception exception)
                    {
                        if (ClientUtils.IsSecurityOrCriticalException(exception))
                        {
                            throw;
                        }

                        if (exception.InnerException != null) // Outer exception is a generic TargetInvocationException.
                        {
                            exception = exception.InnerException;
                        }

                        message = exception.GetType().ToString() + ": " + exception.Message;
                    }
                }

                bool isValidInput = false;
                if (message == null)
                {
                    isValidInput = true;
                    message = SR.GetString(SR.MaskedTextBoxTypeValidationSucceeded);
                }
                
                TypeValidationEventArgs tve = new TypeValidationEventArgs(this.validatingType, isValidInput, parseRetVal, message);
                OnTypeValidationCompleted(tve);

                if( e != null ) 
                {
                    e.Cancel = tve.Cancel;
                }
            }

            return parseRetVal;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Evénement lorsque le champ de Date de Fin est validé ou non.
        /// S'il n'est pas valide une erreur ce lance et le focus est remis sur le champ.
        /// </summary>
        /// <param name="sender"> Contrôle de l'événement.</param>
        /// <param name="e">Arguments.</param>
        private void maskedTextBoxDateF_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
        {
            //"  /  /" représente la maskedTextbox vide
            if (e.IsValidInput || maskedTextBoxDateF.Text == "  /  /")
            {
                error.SetError(maskedTextBoxDateF, "");
                buttonValider.Enabled = true;
            }
            else
            {
                error.SetError(maskedTextBoxDateF, "Veuillez entrer une date correcte");
                maskedTextBoxDateF.Focus();
                buttonValider.Enabled = false;

            }
        }
 /// <summary>
 /// Raises the TypeValidationCompleted event.
 /// </summary>
 /// <param name="e">An EventArgs that contains the event data.</param>
 protected virtual void OnTypeValidationCompleted(TypeValidationEventArgs e)
 {
     if (TypeValidationCompleted != null)
         TypeValidationCompleted(this, e);
 }
Ejemplo n.º 29
0
 private void tBoxSyncValue_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     try
       {
     if (e.IsValidInput)
     {
       if (!(e.ReturnValue is MaskValidationType))
     return;
       this.SyncValue = (e.ReturnValue as MaskValidationType).ArrayValue;
     }
     else
     {
       this.SyncValue = MaskValidationType.InvalidMask.ArrayValue;
       throw new Exception("Wrong Sync word entered.  Message: " + e.Message);
     }
       }
       catch (Exception ex)
       {
     this.OnError((byte) 1, ex.Message);
       }
 }
Ejemplo n.º 30
0
 private void maskedTextBox1_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         toolTipActive.ToolTipTitle = "Invalid input";
         toolTipActive.Show("Enter the timeout parameter as days hours:minutes:seconds (dd hh:mm:ss)", maskedTextBox1, maskedTextBox1.Location, 5000);
         e.Cancel = true;
     }
 }
 private void txtHasta_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
 {
     if (!e.IsValidInput)
     {
         toolTip1.ToolTipTitle = "Fecha Invalida";
         toolTip1.Show("El Formato Correcto es el siguiente: dd/mm/aaaa.", txtHasta, 0, -20, 5000);
     }
 }