Exemplo n.º 1
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(tbContent.Text))
     {
         MessageBox.Show("Der neue Name darf nicht leer sein.");
         return;
     }
     if (IsValidHandler?.Invoke(tbContent.Text) == true)
     {
         clicked = true;
         this.Close();
         return;
     }
     MessageBox.Show("Der Name ist schon vergeben.");
     return;
 }
Exemplo n.º 2
0
        // Helper method for detecting if a variable is a variable.
        // uses isValid in determining if a string could be a variable
        private bool couldBeAVariable(string s)
        {
            int n;

            if (!char.IsLetter(s[0])) //if the first letter is not a letter
            {
                return(false);
            }
            bool intSwitch = false; //used to test if a letter comes after a number

            for (int i = 1; i < s.Count(); i++)
            {
                if (Int32.TryParse(s[i].ToString(), out n))
                {
                    intSwitch = true;
                }
                else if (intSwitch)
                {
                    return(false);
                }
            }
            return(IsValid.Invoke(s)); //passed my tests now check isValid
        }