Exemplo n.º 1
0
        private void InitializePunter()
        {
            int i = 0;

            foreach (var punter in CommonCodeSingleton.Instance.getRandomSequence(CommonClass.Racer_Parameter_Type.Punter))
            {
                string name = "";
                switch (++i)
                {
                case 1: name = "Punter 1"; break;

                case 2: name = "Punter 2"; break;

                case 3: name = "Punter 3"; break;

                default: throw new NotImplementedException("Punter Class not defined.");
                }

                PunterModelClass model = new PunterModelClass(punter, name);

                PunterList.Add(new { ImageSource = model.Image.Source, Model = model });
                //PunterListView.Items.Add(model);

                //PunterListView.MouseDown += (sender, e) => PunterListView_MouseDown(model, e);
            }
            PunterListView.ItemsSource = PunterList;
        }
Exemplo n.º 2
0
        private void BettingButton_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedRunnerName.Content.ToString() != string.Empty)
            {
                //int runner_ID = int.Parse(SelectedRunnerName.Content.ToString().Substring(6));

                if (PunterListView.SelectedIndex > -1)
                {
                    //int index = PunterListView.SelectedIndex;

                    dynamic          Content = PunterListView.SelectedItem;
                    PunterModelClass model   = Content.Model as PunterModelClass;
                    PunterBaseClass  punter  = model.Punter;

                    punter.Bet     = Convert.ToInt32(BetSlider.Value);
                    punter.RacerID = int.Parse(SelectedRunnerName.Content.ToString().Substring(6));

                    if (punter.Bet == 0)
                    {
                        punter.RacerID = PunterBaseClass.NO_RACER_SELECTED;
                    }
                }
            }
            SelectedRunner.Source        = null;
            SelectedRunnerName.Content   = string.Empty;
            MoneyLabel.Content           = string.Empty;
            PunterListView.SelectedIndex = -1;
        }
Exemplo n.º 3
0
        private void PunterListView_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (PunterListView.SelectedIndex == -1)
            {
                return;
            }

            dynamic          Content = (sender as ListBoxItem).Content;
            PunterModelClass model   = Content.Model as PunterModelClass;
            PunterBaseClass  punter  = model.Punter;

            /*
             * //MessageBox.Show($"{Content.Model.Name} has been selected!!!");
             * SelectedPunter.Source = model.Image.Source;
             * SelectedPunterName.Content = model.Name;
             */
            if (punter.RacerID != PunterBaseClass.NO_RACER_SELECTED && punter.Bet > 0)
            {
                Image  image = null;
                string name  = string.Empty;
                switch (punter.RacerID)
                {
                case 1: image = image1; name = "1"; break;

                case 2: image = image2; name = "2"; break;

                case 3: image = image3; name = "3"; break;

                case 4: image = image4; name = "4"; break;

                default: throw new NotSupportedException();
                }
                SelectedRunner.Source      = image.Source;
                SelectedRunnerName.Content = "Piggy " + name;
            }
            else
            {
                SelectedRunner.Source      = null;
                SelectedRunnerName.Content = string.Empty;
            }

            MoneyLabel.Content = punter.Bet;
            BetSlider.Maximum  = punter.Money;
            BetSlider.Value    = punter.Bet;
        }
Exemplo n.º 4
0
 private void CheckForWinner(int winner_id)
 {
     foreach (dynamic item in PunterList)
     {
         PunterModelClass model  = item.Model;
         PunterBaseClass  punter = model.Punter;
         if (punter.RacerID != PunterBaseClass.NO_RACER_SELECTED)
         {
             if (punter.RacerID == winner_id)
             {
                 punter.WinGame();
             }
             else
             {
                 punter.LoseGame();
             }
         }
     }
 }