Пример #1
0
 private void CancelBtn_Click(object sender, RoutedEventArgs e)
 {
     if (isFromAdd)
     {
         AddGame.Close();
     }
     else
     {
         EditGame.Close();
     }
 }
Пример #2
0
    private void NextBtn_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            if (isFromAdd)
            {
                Definitions.Games.Add(new()
                {
                    Name             = AddGame.GameName,         // Set value
                    Version          = AddGame.GameVersion,      // Set value
                    Description      = DescriptionTextBox.Text,  // Set value
                    FileLocation     = AddGame.GameLocation,     // Set value
                    IconFileLocation = AddGame.GameIconLocation, // Set value
                    IsFavorite       = false,                    // Set value
                    RAWGID           = RAWGID,                   // Set value
                    LastTimePlayed   = 0,                        // Set value
                    TotalTimePlayed  = 0,                        // Set value
                    ProcessName      = "",                       // Set value
                    Platforms        = (Platforms.Count == 0) ? new List <SDK.RAWG.Platform> {
                        Definitions.DefaultPlatform
                    } : Platforms,                                                                                                                    // Get platforms
                    Stores = Stores,
                    AlwaysCheckIfRunning = false,
                    IsUWP   = AddGame.IsUWP,
                    IsSteam = AddGame.IsSteam
                });

                GameSaver.Save(Definitions.Games);       // Save
                Global.ReloadAllPages();                 // Refresh UI

                AddGame.Close();
            }
            else
            {
                GameCard.GameInfo.RAWGID      = RAWGID;                                // Set
                GameCard.GameInfo.Description = DescriptionTextBox.Text;               // Set
                GameCard.GameInfo.Platforms   = Platforms;                             // Set
                GameCard.GameInfo.Stores      = Stores;                                // Set

                Definitions.Games[Definitions.Games.IndexOf(old)] = GameCard.GameInfo; // Update
                GameSaver.Save(Definitions.Games);                                     // Save

                Global.ReloadAllPages();                                               // Refresh UI

                EditGame.Close();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, Properties.Resources.MainWindowTitle, MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }
Пример #3
0
        public void AddGame()
        {
            Game game = new Game();

            var  homeSelector = (ComboBoxItem)_addGame.HomeTeamComboBox.SelectedItem;
            Team homeTeam     = _teamRepository.GetTeamById((long)homeSelector.Tag);

            game.HomeTeam = homeTeam;

            var  awaySelector = (ComboBoxItem)_addGame.AwayTeamComboBox.SelectedItem;
            Team awayTeam     = _teamRepository.GetTeamById((long)awaySelector.Tag);

            game.AwayTeam = awayTeam;

            var  citySelector = (ComboBoxItem)_addGame.CityComboBox.SelectedItem;
            City city         = _cityRepository.GetCityById((long)citySelector.Tag);

            game.City = city;

            List <Referee> referees = new List <Referee>();

            foreach (ListBoxItem item in _addGame.RefereeListBox.Items)
            {
                referees.Add(_refereeRepository.GetRefereeById((long)item.Tag));
            }
            game.Referees     = referees;
            game.NoOfReferees = (int)_addGame.numberOfReferee.Value.Value;

            var     licenceSelector = (ComboBoxItem)_addGame.LicenceComboBox.SelectedItem;
            Licence licence         = _licenceRepository.GetLicenceById((long)licenceSelector.Tag);

            game.MinimalLicence = licence;

            game.Address   = _addGame.AddressTextBox.Text;
            game.StartTime = _addGame.DatePicker.SelectedDate.Value;

            _gameRepository.AddGame(game);

            _addGame.Close();
            ReloadListOfGames();
        }