Esempio n. 1
0
        public DogNameEnum PlaceBetNoDogSelectedValidation(Label labelNotification, ComboBox comboBox)
        {
            object selectedItem = comboBox.SelectedItem;

            if (selectedItem != null)
            {
                DogNameEnum dogSelected = (DogNameEnum)selectedItem;
                if (dogSelected == 0)
                {
                    labelNotification.Content    = ClientValidation.BetValidationComboBoxNoDogSelectedWarning();
                    labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
                }
                else
                {
                    var allDogs         = Enum.GetValues(typeof(DogNameEnum)).Cast <DogNameEnum>().ToList();
                    var selectedDogName = allDogs.Where(a => a.ToString() == dogSelected.ToString()).FirstOrDefault();
                    return(selectedDogName);
                }
            }
            else
            {
                labelNotification.Content    = ClientValidation.BetValidationComboBoxNoDogSelectedWarning();
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
            }
            return(0);
        }
Esempio n. 2
0
        public GuyNameEnum PlaceBetNoBettingGuySelectedValidation(Label labelNotification, ComboBox comboBox)
        {
            object selectedItem = comboBox.SelectedItem;

            if (selectedItem != null)
            {
                var guyBetting = (GuyNameEnum)selectedItem;
                if (guyBetting == 0)
                {
                    labelNotification.Content    = ClientValidation.BetValidationComboBoxNoGuySelectedWarning();
                    labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
                }
                else
                {
                    var allGuys         = Enum.GetValues(typeof(GuyNameEnum)).Cast <GuyNameEnum>().ToList();
                    var selectedGuyName = allGuys.Where(a => a.ToString() == guyBetting.ToString()).FirstOrDefault();
                    return(selectedGuyName);
                }
            }
            else
            {
                labelNotification.Content    = ClientValidation.BetValidationComboBoxNoGuySelectedWarning();
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
            }
            return(0);
        }
Esempio n. 3
0
 private void SetStandardNotifications(List <Label> standardLabels)
 {
     foreach (var label in standardLabels)
     {
         label.Content    = ClientValidation.StandardNotification();
         label.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Standard);
     }
 }
Esempio n. 4
0
        public void BtnAddGuy_Click(ComboBox comboBoxGuys, Label labelNotification, GuyNameEnum guyName)
        {
            ICommand newGuyCommand = _commandInvoker.GetCommand(ActionCommandEnum.NewGuyToPalaceStadium);
            var      notification  = newGuyCommand.Execute(guyName);
            var      allGuys       = (List <IGuy>)_dogRacePalaceStadium.GetAllGuysInTheStadium();

            comboBoxGuys.ItemsSource     = allGuys.Select(a => a.Name).ToList();
            labelNotification.Content    = notification.Description;
            labelNotification.Foreground = NotificationColors.GetBrushColor(notification.Code);
        }
Esempio n. 5
0
        public int PlaceBetMinimum2DogsInRacetrackValidation(Label labelNotification, ComboBox comboBox)
        {
            var dogsInRacetrackCount = comboBox.Items.Count;

            if (dogsInRacetrackCount < 2)
            {
                labelNotification.Content    = ClientValidation.BetValidationLessThan2DogsInRacetrackWarning();
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
            }
            return(dogsInRacetrackCount);
        }
Esempio n. 6
0
        public void BtnMakeDeposit_Click(Label labelNotification, GuyNameEnum guyName, int amountDeposit)
        {
            ICommand    makeDepositCommand = _commandInvoker.GetCommand(ActionCommandEnum.DepositMoneyInGuyPocket);
            CashDeposit deposit            = new CashDeposit()
            {
                GuyName = guyName, CashAmount = amountDeposit
            };
            var notification = makeDepositCommand.Execute(deposit);

            labelNotification.Content    = notification.Description;
            labelNotification.Foreground = NotificationColors.GetBrushColor(notification.Code);
        }
Esempio n. 7
0
        public void BtnPlaceBet_Click(Label LblBetNotification, List <Label> allGuysLabels, ListBox listBoxBetsPlaced, GuyNameEnum guyName, DogNameEnum dogName, int betAmount)
        {
            ICommand       placeBetCommand = _commandInvoker.GetCommand(ActionCommandEnum.PlaceBet);
            BettingAccount bettingAccount  = new BettingAccount()
            {
                BettingAccountHolderName = guyName, BettingDogNameSelected = dogName, BettingAmount = betAmount
            };
            var notification = placeBetCommand.Execute(bettingAccount);

            LblBetNotification.Content    = notification.Description;
            LblBetNotification.Foreground = NotificationColors.GetBrushColor(notification.Code);
            listBoxBetsPlaced.ItemsSource = _bettingBank.GetAllBetsAsDescriptions();
            UpdateGuysLabels(allGuysLabels);
        }
Esempio n. 8
0
        private void BtnStartRace_Click(object sender, RoutedEventArgs e)
        {
            var validatedTrackdistance = _objValidator.TrackDistanceValidation(LblNotificationTrackDistance, TrackDistanceComboBox);

            if (validatedTrackdistance > 0)
            {
                Dispatcher.Invoke(() => {
                    objMediator.BtnStartRace_Click(ListBoxBetsPlaced, AllGuysLabelsList(), AllWinnerNotificationLabelsList(), AllStandardNotificationsLabelsList());
                });
            }
            else
            {
                LblRace.Content    = ClientValidation.DistanceSetWarning();
                LblRace.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
            }
        }
Esempio n. 9
0
        public GuyNameEnum MakeDepositGuySelectedValidation(Label labelNotification, List <RadioButton> guysRadioButtons)
        {
            RadioButton selectedRadioBtnGuy = guysRadioButtons.Where(a => a.IsChecked == true).FirstOrDefault();

            if (selectedRadioBtnGuy == null)
            {
                labelNotification.Content    = ClientValidation.CashDepositValidationRadioBtnNoGuyNameWarning();
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
            }
            else
            {
                var selectedGuy       = selectedRadioBtnGuy.Content.ToString();
                var allGuys           = Enum.GetValues(typeof(GuyNameEnum)).Cast <GuyNameEnum>().ToList();
                var guyForCashDeposit = allGuys.Where(name => name.ToString() == selectedGuy).FirstOrDefault();
                return(guyForCashDeposit);
            }
            return(0);
        }
Esempio n. 10
0
        public int CashValidation(Label labelNotification, IntegerUpDown integerUpDownControl)
        {
            int fail = -1;
            int?cash = integerUpDownControl.Value;

            if (cash == null)
            {
                labelNotification.Content    = ClientValidation.CashValidationNoCashWarning();
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
                return(fail);
            }
            if (cash < 0)
            {
                labelNotification.Content    = ClientValidation.CashValidationCashMustBePositiveValueWarning();
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
                return(fail);
            }
            return((int)cash);
        }
Esempio n. 11
0
        public int PlaceBetMinimumAndMaximumBetValidation(int betAmount, Label labelNotification)
        {
            int fail = -1, minimumBet = 5, maximumBet = 15;

            if (betAmount < minimumBet)
            {
                labelNotification.Content    = ClientValidation.BetValidationWrongAmountLessThanMinimumWarning(minimumBet);
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
                return(fail);
            }

            else if (betAmount > maximumBet)
            {
                labelNotification.Content    = ClientValidation.BetValidationWrongAmountMoreThanMaximumWarning(maximumBet);
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
                return(fail);
            }
            return(betAmount);
        }
Esempio n. 12
0
        public int BtnAddDog_Click(ComboBox comboBoxDogs, Label labelNotification, List <Image> dogImages)
        {
            ICommand newDogCommand = _commandInvoker.GetCommand(ActionCommandEnum.NewDogToRacetrack);
            var      notification  = newDogCommand.Execute(dogImages);

            if (notification.Items < 2)
            {
                labelNotification.Content    = notification.Description + "\nMin number of dogs for a race is 2";
                labelNotification.Foreground = NotificationColors.GetBrushColor(notification.Code);
            }
            else if (notification.Items >= 2)
            {
                labelNotification.Content    = notification.Description;
                labelNotification.Foreground = NotificationColors.GetBrushColor(notification.Code);
            }
            var allDogsNames = _racetrack.GetAllDogsInRacetrack().Select(a => a.Name).ToList();

            comboBoxDogs.ItemsSource = allDogsNames;
            return(notification.Items);
        }
Esempio n. 13
0
        public int TrackDistanceValidation(Label labelNotification, ComboBox comboBox)
        {
            int    defaultValue = -1;
            object item         = comboBox.SelectedItem;

            if (item != null)
            {
                ComboBoxItem comboBoxItem = (ComboBoxItem)item;
                bool         parseSuccess = Int32.TryParse(comboBoxItem.Content.ToString(), out defaultValue);
                if (!parseSuccess)
                {
                    labelNotification.Content    = ClientValidation.DistanceSetWarning();
                    labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
                }
            }
            else
            {
                labelNotification.Content    = ClientValidation.DistanceSetWarning();
                labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Warning);
            }
            return(defaultValue);
        }
Esempio n. 14
0
 private void DisplayStandardBetNotification()
 {
     LblBetNotification.Content    = ClientValidation.StandardBettingNotification();
     LblBetNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Standard);
 }
Esempio n. 15
0
 private void DisplayStandardRaceGoNotification()
 {
     LblRace.Content    = ClientValidation.StandardNotification();
     LblRace.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Standard);
 }
Esempio n. 16
0
 public void TrackDistanceComboBox_SelectionChanged(int selectedItemValue, Label labelNotification)
 {
     racetrackDistance            = selectedItemValue;
     labelNotification.Content    = AllNotifications.DistanceSetOk();
     labelNotification.Foreground = NotificationColors.GetBrushColor(NotificationEnum.Ok);
 }