Zahlenbox hinzugefügt

This commit is contained in:
2026-09-09 10:49:09 +02:00
parent 003c82344e
commit ae8efa449a
4 changed files with 71 additions and 3 deletions
+31
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -60,5 +61,35 @@ namespace Casino
{
Close();
}
private static readonly Regex _regex = new Regex("[^0-9]+€"); // Regex to match non-numeric input
//nur nummern
private void TextBox_OnPreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !_regex.IsMatch(e.Text);
}
// Keine Spaces
private void TextBox_OnPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
e.Handled = true;
}
}
//das man nichts reinkopieren kann außer Zahlen
private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(typeof(String)))
{
var text = (String)e.DataObject.GetData((typeof(String)));
if (!_regex.IsMatch((string)text))
{
e.CancelCommand();
}
}
}
}
}