Exemplo n.º 1
0
 private void Form1_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (!System.Text.RegularExpressions.Regex.Match(e.KeyChar.ToString(), @"\d").Success)  //Для проверки вводимых символов,
                                                                                            //в данном примере используется метод
                                                                                            //«Regex.Match». Данный метод ищет во
                                                                                            //входящей строке все вхождения заданного
                                                                                            //регулярного выражения. Регулярное выражение
                                                                                            //представляет собой состоящий из символов
                                                                                            //шаблон, обозначающий последовательность
                                                                                            //символов произвольной длины.
     {
         e.Handled = true;                                                                  //если пользователь ввел нечисло(и не арифметические знаки), и, если да, отменяет KeyPress событие с помощью Handled Свойства.
     }
     else
     {
         if (DisplayText.Text == "0")
         {
             DisplayText.Text = "";
             DisplayText.Text = e.KeyChar.ToString();
         }
         else
         {
             DisplayText.AppendText(e.KeyChar.ToString());
         }
     }
 }
Exemplo n.º 2
0
 private void button16_Click(object sender, EventArgs e)
 {
     if (point == false)
     {
         DisplayText.AppendText(",");
         point = true;
     }
 }
Exemplo n.º 3
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (DisplayText.Text == "0")
     {
         DisplayText.Text = "5";
     }
     else
     {
         DisplayText.AppendText("5");
     }
 }
Exemplo n.º 4
0
        private void Spin(object sender, RoutedEventArgs e)
        {
            int multiplier;

            try
            {
                multiplier  = GetMult();
                _CurrentBet = int.Parse(Bet.Text);
                if (_CurrentBet > _MoneyLeft)
                {
                    DisplayText.AppendText("\n\nYour bet cannot be greater than the money you have left!");
                    return;
                }
                else if (_CurrentBet == 0)
                {
                    DisplayText.AppendText("\n\nYour bet cannot be 0!");
                    return;
                }
            }
            catch (Exception E)
            {
                DisplayText.AppendText("\n\nChoose your space(s), and place your bet.");
                return;
            }

            int r = new Random().Next(38);

            switch (r)
            {
            case 0:                     // 0
                DisplayText.AppendText("\n\nSpun a 0.");
                if ((string)_CurrentRadioButton.Content == "0")
                {
                    _MoneyLeft += _CurrentBet * multiplier;
                    DisplayText.AppendText("\n\nYou won " + (_CurrentBet * multiplier) + ".");
                }
                else
                {
                    _MoneyLeft -= _CurrentBet;
                    DisplayText.AppendText("\n\nYou lost " + _CurrentBet + ".");
                }
                break;

            case 37:                     // 00
                DisplayText.AppendText("\n\nSpun a 00.");
                if ((string)_CurrentRadioButton.Content == "00")
                {
                    _MoneyLeft += _CurrentBet * multiplier;
                    DisplayText.AppendText("\n\nYou won " + (_CurrentBet * multiplier) + ".");
                }
                else
                {
                    _MoneyLeft -= _CurrentBet;
                    DisplayText.AppendText("\n\nYou lost " + _CurrentBet + ".");
                }
                break;

            default:
                DisplayText.AppendText("\n\nSpun a " + r + ".");
                bool win = false;
                switch ((string)_CurrentRadioButton.Content)
                {
                case "Row 1":
                    win = _Row1.Contains(r);
                    break;

                case "Row 2":
                    win = _Row2.Contains(r);
                    break;

                case "Row 3":
                    win = _Row3.Contains(r);
                    break;

                case "Evens":
                    win = r % 2 == 0;
                    break;

                case "Odds":
                    win = r % 2 == 1;
                    break;

                case "Blacks":
                    win = _Blacks.Contains(r);
                    break;

                case "Reds":
                    win = _Reds.Contains(r);
                    break;

                case "1st 12":
                    win = r < 13 && r > 0;
                    break;

                case "2nd 12":
                    win = r < 25 && r > 12;
                    break;

                case "3rd 12":
                    win = r < 37 && r > 24;
                    break;

                case "1-18":
                    win = r > 0 && r < 19;
                    break;

                case "19-36":
                    win = r > 18 && r < 37;
                    break;

                default:
                    win = (string)_CurrentRadioButton.Content == ("" + r);
                    break;
                }

                if (win)
                {
                    _MoneyLeft += _CurrentBet * multiplier;
                    DisplayText.AppendText("\n\nYou won " + (_CurrentBet * multiplier) + ".");
                }
                else
                {
                    _MoneyLeft -= _CurrentBet;
                    DisplayText.AppendText("\n\nYou lost " + _CurrentBet + ".");
                }
                break;
            }
            RemainingMoney.Text = _MoneyLeft + "";
            if (DisplayText.LineCount > 50)
            {
            }
        }