Beispiel #1
0
 private void checkNotePasted(tbpaste tb)                //check if Text entered(either by paste or text change in general) into custom textbox tb is a Note Score Format: ~+-
 {
     if (tb.pasted)                                      //checks if paste event happened in tb
     {
         if (!new Regex(@"^[~\+\-]+$").IsMatch(tb.Text)) //case format is not correct: resets text and flags
         {
             MessageBox.Show($"Invalid value pasted for {tb.Name} - Not a valid Score!");
             tb.pasted = false;
             tb.Clear();
             return;
         }
         tb.pasted = false;
     }
 }
Beispiel #2
0
 private void checkNumberPasted(tbpaste tb)               //check if Text entered(either by paste or text change in general) into custom textbox tb is a Number Format: 11 or 1/11 or 11.1
 {
     if (tb.pasted)                                       //checks if paste event happened in tb
     {
         if (!MainForm.regexNumberValue.IsMatch(tb.Text)) //case not a number format: resets textbox text and flags
         {
             MessageBox.Show($"Invalid value pasted for {tb.Name} - Not a valid Number!");
             tb.pasted = false;
             tb.dot    = false;
             tb.Clear();
             return;
         }
         tb.pasted = false;      //resets pasted flag if number format
     }
     if (tb.Text.Contains('.'))  //checks if dot is present(whether pasted or textchanged in general) and sets flag for that to be true to stop another dot from being typed in future (there's only 1 dot possible for number format to have)
     {
         tb.dot = true;
     }
     else
     {
         tb.dot = false;
     }
 }