Files
WIR-MACHEN-ALLE-ARM/Casino/Blackjack.xaml.cs
T
2026-09-09 11:19:24 +02:00

96 lines
2.5 KiB
C#

using System;
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;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Casino
{
/// <summary>
/// Interaktionslogik für Blackjack.xaml
/// </summary>
public partial class Blackjack : Window
{
public Blackjack()
{
InitializeComponent();
rand();
LoadCard(55);
}
private void LoadCard(int Bild)
{
Database db = new Database();
byte[] img = db.GetCardImage(Bild);//2-10
Dealer_Bild_1.Source = ByteArrayToImage(img);
}
private BitmapImage ByteArrayToImage(byte[] bytes)
{
BitmapImage image = new BitmapImage();
using (MemoryStream ms = new MemoryStream(bytes))
{
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.StreamSource = ms;
image.EndInit();
}
return image;
}
private int rand()
{
Random ran = new Random();
int temp = ran.Next(13, 66);
Console.WriteLine(temp);
return 0;
}
private void Hauptmenue(object sender, RoutedEventArgs e)
{
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();
}
}
}
}
}