Ejemplo n.º 1
0
        private void NumberBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (NumberBox.IsEnabled)
            {
                NumberBox.Text = NumberBox.Text.Trim();
                int length = NumberBox.Text.Length;

                if (length != 0)
                {
                    double parsedValue;
                    if (!double.TryParse(NumberBox.Text, out parsedValue))
                    {
                        NumberBox.Text = NumberBox.Text.Remove(length - 1);
                        NumberBox.Select(length, 0);
                    }
                    else
                    {
                        timeToSet = Convert.ToInt32(parsedValue * 60);
                    }
                }
                else
                {
                    timeToSet = 0;
                }
            }
        }
Ejemplo n.º 2
0
        private void NumberBox_Leave(object sender, EventArgs e)
        {
            NumberBox.Text = NumberBox.Text.TrimEnd(' ');

            if ((NumberBox.Text == "") || (!Regex.IsMatch(NumberBox.Text, "^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\./0-9]*$")))
            {
                NumberWarningLabel.ForeColor = Color.Red;
            }
            NumberBox.Select(0, 0);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Check if the suffix is a number or not
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void textChangedEventHandler(object sender, TextChangedEventArgs args)
        {
            NumberBox.Select(NumberBox.Text.Length, 0);
            int  c;
            bool isNumeric = int.TryParse(NumberBox.Text, out c);

            if (isNumeric)
            {
                tools.count = c;
            }
            else
            {
                SuffixContent suffixContentForm = new SuffixContent();
                suffixContentForm.Topmost = true;
                suffixContentForm.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                suffixContentForm.ShowDialog();
                //MessageBox.Show("Number field should contain only numbers");
            }
        }
Ejemplo n.º 4
0
 private void FocusNumBox()
 {
     NumberBox.Focus();
     NumberBox.Select(0, NumberBox.Text.Length);
 }