コード例 #1
0
        public void addToShortlist(ref DataGrid playerDataGrid)
        {
            List <int> playerRows = new List <int>();

            for (int i = 0; i < playerDataGrid.SelectedItems.Count; ++i)
            {
                PlayerGridViewModel row = (PlayerGridViewModel)playerDataGrid.SelectedItems[i];
                if (!context.shortlistIDList.Contains(row.ID))
                {
                    playerRows.Add(row.ID);
                }
            }

            if (playerRows.Count > 0)
            {
                globalFuncs.scoutTimer.start();
                this.windowMain.CurrentGameDate.Text          = context.fm.MetaData.IngameDate.ToLongDateString();
                this.windowMain.vm.tabshortlist.TextBlockText = globalFuncs.localization.WindowMainLabels[3];
                setControlAvailability(false);
                this.vm.results.Text = "Importing...";

                LoadDelegate d = new LoadDelegate(this.loadShortlistPlayers);
                d.BeginInvoke(ref playerRows, null, null);
                ProgressBarDelegate p = new ProgressBarDelegate(this.updateProgressBar);
                p.BeginInvoke(null, null);
            }
        }
コード例 #2
0
        public void addToContext(BaseObject obj, GridViewModel r)
        {
            int index = checkExists((int)r.ID);

            if (index == -1)
            {
                ProfileViewModel vm = null;
                if (obj is Player)
                {
                    vm = new ProfilePlayerViewModel();
                    Player player          = (Player)obj;
                    PlayerGridViewModel _r = (PlayerGridViewModel)r;
                    ((ProfilePlayerViewModel)vm).setProfileViewModel(ref player, ref _r);
                }
                else if (obj is Staff)
                {
                    vm = new ProfileStaffViewModel();
                    Staff staff           = (Staff)obj;
                    StaffGridViewModel _r = (StaffGridViewModel)r;
                    ((ProfileStaffViewModel)vm).setProfileViewModel(ref staff, ref _r);
                }
                else if (obj is Team)
                {
                    vm = new ProfileTeamViewModel();
                    Team team            = (Team)obj;
                    TeamGridViewModel _r = (TeamGridViewModel)r;
                    ((ProfileTeamViewModel)vm).setProfileViewModel(ref team, ref _r);
                }
                data.Add(vm);
                if (data.Count > 12)
                {
                    data.RemoveAt(0);
                }
            }
        }
コード例 #3
0
 public void currentResult(PlayerGridViewModel newRow)
 {
     if (newRow != null)
     {
         dataTable.Add(newRow);
     }
     this.vm.results.Text = dataTable.Count + " shortlist entries found.";
     this.windowMain.vm.tabshortlist.TextBlockText = globalFuncs.localization.WindowMainLabels[3] +
                                                     " (" + dataTable.Count + ")";
 }
コード例 #4
0
        public void addShortlistPlayerToGrid(Player player, ref PlayerGridViewModel newRow, ref string playerPosition, ref string playerClub, ref List <String> playerNationalities)
        {
            PreferencesSettings settings = GlobalSettings.getSettings().curPreferencesSettings;

            context.shortlistIDList.Add(player.ID, context.shortlistIDList.Count);

            for (int i = 0; i < this.windowMain.PlayerSearch.dataTable.Count; ++i)
            {
                PlayerGridViewModel r = this.windowMain.PlayerSearch.dataTable[i];
                if (player.ID == r.ID)
                {
                    r.S = true;
                    r.imageButton.ImageSource = globalFuncs.shortlistSelected;
                    break;
                }
            }

            this.windowMain.PlayerSearch.addPlayerToGrid(player, ref newRow, ref playerPosition, ref playerClub, ref playerNationalities);
        }
コード例 #5
0
 private void removeShortlistPlayers(ref List <int> playerRows)
 {
     if (playerRows.Count > 0)
     {
         this.windowMain.CurrentGameDate.Text          = context.fm.MetaData.IngameDate.ToLongDateString();
         this.windowMain.vm.tabshortlist.TextBlockText = globalFuncs.localization.WindowMainLabels[3];
         setControlAvailability(false);
         ObservableCollection <PlayerGridViewModel> playerGridDataTable = this.windowMain.PlayerSearch.dataTable;
         for (int i = 0; i < playerRows.Count; ++i)
         {
             int playertoremoverowID = playerRows[i];
             for (int j = 0; j < this.dataTable.Count; ++j)
             {
                 PlayerGridViewModel shortlistrow = this.dataTable[j];
                 if (shortlistrow.ID == playertoremoverowID)
                 {
                     for (int k = 0; k < playerGridDataTable.Count; ++k)
                     {
                         PlayerGridViewModel r = playerGridDataTable[k];
                         if (r.ID == shortlistrow.ID)
                         {
                             r.S = false;
                             r.imageButton.ImageSource = globalFuncs.shortlistUnselected;
                             break;
                         }
                     }
                     shortlistrow.S = false;
                     context.shortlistIDList.Remove(shortlistrow.ID);
                     this.dataTable.Remove(shortlistrow);
                     break;
                 }
             }
         }
         setControlAvailability(true);
         this.vm.results.Text = dataTable.Count + " shortlist entries found.";
         this.windowMain.vm.tabshortlist.TextBlockText = globalFuncs.localization.WindowMainLabels[3];
         if (this.dataTable.Count > 0)
         {
             this.windowMain.vm.tabshortlist.TextBlockText += " (" + dataTable.Count + ")";
         }
     }
 }
コード例 #6
0
        private void dataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            PlayerGridViewModel item = e.Row.Item as PlayerGridViewModel;

            if (item != null)
            {
                if (item.ClubState == PLAYERCLUBSTATE.PCS_FREE)
                {
                    e.Row.Foreground = App.Current.Resources["PlayerFreeForeground"] as SolidColorBrush;
                }
                else if (item.ClubState == PLAYERCLUBSTATE.PCS_LOAN)
                {
                    e.Row.Foreground = App.Current.Resources["PlayerLoanForeground"] as SolidColorBrush;
                }
                else if (item.ClubState == PLAYERCLUBSTATE.PCS_COOWN)
                {
                    e.Row.Foreground = App.Current.Resources["PlayerCoOwnForeground"] as SolidColorBrush;
                }
            }
        }
コード例 #7
0
        public void loadShortlistPlayers(ref List <int> playersID)
        {
            CurrentResultDelegate currentResultDelegate = new CurrentResultDelegate(currentResult);
            FinalResultDelegate   finalResultDelegate   = new FinalResultDelegate(finalResult);

            List <string> player_positions = new List <string>();
            List <string> player_sides     = new List <string>();

            PLAYERCLUBSTATE playerClubState = PLAYERCLUBSTATE.PCS_FREE;
            PLAYEREUSTATE   playerEUState   = PLAYEREUSTATE.PES_NONEU;

            PlayerGridViewModel newRow;
            List <String>       playerNationalities = new List <String>();
            String   playerClub = "";
            Contract contract   = null;
            double   counter    = 0;
            double   total      = 100.0 / (double)context.fm.Players.Count();

            // remove duplicate rows
            for (int i = 0; i < playersID.Count; ++i)
            {
                if (context.shortlistIDList.Contains(playersID[i]))
                {
                    playersID.Remove(playersID[i]);
                }
            }

            foreach (Player _player in context.fm.Players)
            {
                progressBarValue = counter * total;
                ++counter;
                Player player = null;
                for (int i = 0; i < playersID.Count; ++i)
                {
                    // check ID
                    player = null;
                    if (_player.ID.Equals(playersID[i]))
                    {
                        if (!context.shortlistIDList.Contains(_player.ID))
                        {
                            player = _player;
                            playersID.RemoveAt(i);
                            break;
                        }
                    }
                }

                if (player != null)
                {
                    // check position
                    string playerPosition = "";
                    context.find_player_position(player, ref playerPosition, ref player_positions, ref player_sides, true);

                    // check club
                    playerClub      = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_FREEPLAYER];
                    playerClubState = PLAYERCLUBSTATE.PCS_FREE;
                    context.findPlayerContractQuery(player, ref contract, ref playerClub, ref playerClubState);

                    // check nation
                    playerNationalities.Clear();
                    playerNationalities.Add(player.Nationality.Name);
                    // other nationalities
                    List <PlayerRelations> relations = player.Relations.Relations;
                    if (player.Relations != null)
                    {
                        for (int playerRelationIndex = 0; playerRelationIndex < player.Relations.RelationsTotal; ++playerRelationIndex)
                        {
                            if (relations[playerRelationIndex].RelationType == RelationType.OtherNationality)
                            {
                                playerNationalities.Add(relations[playerRelationIndex].Country.Name);
                            }
                        }
                    }
                    // check EU
                    playerEUState = PLAYEREUSTATE.PES_NONEU;
                    for (int i = 0; i < playerNationalities.Count; ++i)
                    {
                        if (globalFuncs.EUcountries.Contains(playerNationalities[i]))
                        {
                            playerEUState = PLAYEREUSTATE.PES_EU;
                            break;
                        }
                    }

                    newRow           = new PlayerGridViewModel();
                    newRow.EUState   = playerEUState;
                    newRow.ClubState = playerClubState;
                    addShortlistPlayerToGrid(player, ref newRow, ref playerPosition, ref playerClub, ref playerNationalities);

                    this.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        currentResultDelegate, newRow);
                }
            }

            this.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                finalResultDelegate);
        }