Ejemplo n.º 1
0
        /// <summary>
        /// Лист Рекордов
        /// </summary>
        private void RecordsButtonClick(object sender, RoutedEventArgs e)
        {
            recordsList.Items.Clear();

            TourWCF.ServiceClient service = new TourWCF.ServiceClient();
            var data = service.GetData();

            foreach (var rec in data)
            {
                recordsList.Items.Add($"{rec.FirstPlayer} && {rec.SecondPlayer} :: Total Score: {rec.TotalScore}, WIN: {rec.Win}, " +
                                      $"{rec.dateTime.Day}.{rec.dateTime.Month}.{rec.dateTime.Year}");
            }

            service.Close();

            SettingFieldWelcome.Visibility = Visibility.Hidden;
            RecordsField.Visibility        = Visibility.Visible;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Выход из режима игры в Меню
        /// </summary>
        private void StopButtonClick(object sender, RoutedEventArgs e)
        {
            if (gameClient == null)
            {
                return;
            }

            if (gameClient.MovesLeft == 0 && gameClient.OldMove.Count != 0)
            {
                List <TourWCF.Record> data;

                TourWCF.ServiceClient service = new TourWCF.ServiceClient();
                data = service.GetData().ToList();

                string         win    = gameClient.OldMove.Count == 100 ? "Draw" : gameClient.FirstOrSecondGamer == 0 ? "Red" : "Green";
                TourWCF.Record record = new TourWCF.Record();
                record.FirstPlayer  = greenPlayerName.Text;
                record.SecondPlayer = redPlayerName.Text;
                record.TotalScore   = gameClient.OldMove.Count;
                record.Win          = win;
                record.dateTime     = DateTime.Now;
                record.RoomCode     = data.Count() + 1;

                data.Add(record);

                service.SetData(data.ToArray());

                service.Close();
            }

            greenPlayerName.Text = string.Empty;
            redPlayerName.Text   = string.Empty;
            gameClient           = null;
            GameFieldInit();
            SettingFieldWelcome.Visibility = Visibility.Visible;
            SettingField.Visibility        = Visibility.Hidden;
            GameField.IsEnabled            = false;
            HelpButton.IsEnabled           = true;
            StopButton.Visibility          = Visibility.Hidden;
        }