diff --git a/Casino/Blackjack.xaml b/Casino/Blackjack.xaml
index 8f8efe0..34af542 100644
--- a/Casino/Blackjack.xaml
+++ b/Casino/Blackjack.xaml
@@ -35,5 +35,6 @@
+
diff --git a/Casino/Blackjack.xaml.cs b/Casino/Blackjack.xaml.cs
index 34de294..7902287 100644
--- a/Casino/Blackjack.xaml.cs
+++ b/Casino/Blackjack.xaml.cs
@@ -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();
+ }
+ }
+ }
}
}
diff --git a/Casino/Busfahrer.xaml b/Casino/Busfahrer.xaml
index 6ed45af..42355fb 100644
--- a/Casino/Busfahrer.xaml
+++ b/Casino/Busfahrer.xaml
@@ -35,7 +35,9 @@
-
+
+
+
diff --git a/Casino/Busfahrer.xaml.cs b/Casino/Busfahrer.xaml.cs
index f0ae250..c4224a7 100644
--- a/Casino/Busfahrer.xaml.cs
+++ b/Casino/Busfahrer.xaml.cs
@@ -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;
@@ -20,7 +21,7 @@ namespace Casino
///
public partial class Busfahrer : Window
{
-
+
public Busfahrer()
{
@@ -35,7 +36,7 @@ namespace Casino
byte[] img = db.GetCardImage(Bild);
Bild_4.Source = ByteArrayToImage(img);
-
+
}
@@ -49,6 +50,7 @@ namespace Casino
image.StreamSource = ms;
image.EndInit();
}
+
return image;
}
@@ -65,5 +67,37 @@ 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();
+ }
+ }
+ }
}
}