Exemple #1
0
        /// <summary>
        /// Sets the variable "value" to the value corresponding to the next array member according to the rules of default culture and increases an Iterator variable by 1. If the value Values[Iterator-1] contains only spaces then "0" is put into the variable value.
        /// </summary>
        public void Set(ref int value)
        {
            if (Values[Iterator - 1].Trim().Length == 0)
            {
                value = 0;
            }
            else
            {
                if (MyStringOperations.IsValidInt(Values[Iterator - 1].Trim()) == false)
                {
                    Tuple <DialogResult, string> LocalAnswer =
                        Form1.GetValueStatic(String.Format("Wrong value has been passed to the function ArrayParser.Set the value is {0}, the first array element is {1}"
                                                           , value, Values[0]));


                    if (LocalAnswer.Item1 != DialogResult.OK)
                    {
                        Iterator++;
                        return;
                    }
                    else
                    {
                        value = Convert.ToInt32(Values[Iterator - 1]);
                    }
                }
                else
                {
                    value = Convert.ToInt32(Values[Iterator - 1]);
                }
            }


            Iterator++;
        }
Exemple #2
0
        /// <summary>
        /// If the control passed as an argument does not store a valid integer then it is cleared
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MyValidationInt(object sender, CancelEventArgs e)
        {
            string MyValue = (sender as TextBox).Text;

            if (MyStringOperations.IsValidInt(MyValue) == false)
            {
                MessageBox.Show("Wrong value");
                e.Cancel = true;
            }
            (sender as TextBox).BackColor = Color.Yellow;
        }
Exemple #3
0
        private void MyValidatingEvent(object sender, CancelEventArgs e)
        {
            string MyValue = (sender as TextBox).Text;

            if (MyStringOperations.IsValidInt(MyValue) == false)
            {
                (sender as TextBox).BackColor = Color.Red;
                e.Cancel = true;
            }
            else
            {
                (sender as TextBox).BackColor = Color.White;
            }
        }