示例#1
0
        public void TestThatGetPreferenceOnNonExistingKeyReturnsFallbackValue <T>(T value)
        {
            T fallbackValue   = value;
            T preferenceValue = PreferencesSettings.GetPreference <T>("NonExistingPreference", fallbackValue);

            Assert.Equal(fallbackValue, preferenceValue);
        }
        private void ButtonSetDefaultSettings_Click(object sender, RoutedEventArgs e)
        {
            String     selectedItem = settings.settingNames[this.vm.setting.ComboBoxSelectedIndex];
            List <int> changed      = new List <int>();

            for (int i = 0; i < settings.settingNames.Count; ++i)
            {
                PreferencesSettings set = settings.preferencesSettings[i];
                if (!selectedItem.Equals(set.name))
                {
                    if (set.isDefault)
                    {
                        changed.Add(i);
                    }
                    set.isDefault = false;
                }
                else
                {
                    if (!set.isDefault)
                    {
                        changed.Add(i);
                    }
                    set.isDefault = true;
                }
            }

            setDefaultButtons(ref selectedItem);
            this.ButtonSetDefaultSettings.IsEnabled = false;

            for (int i = 0; i < changed.Count; ++i)
            {
                settings.setDefault(changed[i]);
            }
        }
示例#3
0
        public void setLocalization()
        {
            PreferencesSettings           s                = GlobalSettings.getSettings().curPreferencesSettings;
            ScoutLocalization             localization     = globalFuncs.localization;
            ObservableCollection <string> WindowInfoLabels = globalFuncs.localization.WindowInfoLabels;
            int index = -1;

            vm.header.Header             = WindowInfoLabels[++index];
            vm.gamesettings.Header       = WindowInfoLabels[++index];
            vm.gamestatus.Header         = WindowInfoLabels[++index];
            vm.gamestatusinfo.Header     = WindowInfoLabels[++index];
            vm.gameversion.Header        = WindowInfoLabels[++index];
            vm.players.Header            = WindowInfoLabels[++index];
            vm.staff.Header              = WindowInfoLabels[++index];
            vm.teams.Header              = WindowInfoLabels[++index];
            vm.scoutsettings.Header      = WindowInfoLabels[++index];
            vm.settings.Header           = WindowInfoLabels[++index];
            vm.settingsinfo.Header       = s.name;
            vm.language.Header           = WindowInfoLabels[++index];
            vm.languageinfo.Header       = s.language;
            vm.theme.Header              = WindowInfoLabels[++index];
            vm.themeinfo.Header          = s.theme;
            vm.currency.Header           = WindowInfoLabels[++index];
            vm.currencyinfo.Header       = localization.currencies[localization.currenciesNative.IndexOf(s.currency)];
            vm.wage.Header               = WindowInfoLabels[++index];
            vm.wageinfo.Header           = localization.wages[localization.wagesNative.IndexOf(s.wage)];
            vm.heightdistance.Header     = WindowInfoLabels[++index];
            vm.heightdistanceinfo.Header = localization.heights[localization.heightsNative.IndexOf(s.height)];
            vm.weight.Header             = WindowInfoLabels[++index];
            vm.weightinfo.Header         = localization.weights[localization.weightsNative.IndexOf(s.weight)];
            vm.editorsettings.Header     = WindowInfoLabels[++index];
            vm.editing.Header            = WindowInfoLabels[++index];
            vm.editinginfo.Header        = localization.YesNo[localization.editing.IndexOf(s.editing)];
        }
        public void setSettings()
        {
            ScoutLocalization   localization = globalFuncs.localization;
            PreferencesSettings curSettings  = settings.curPreferencesSettings;

            settings.settingSettings         = false;
            vm.setting.ComboBoxSelectedIndex = globalFuncs.getElementIndex(ref settings.settingNames, curSettings.name);
            generalTabItemViewModel.currency.ComboBoxSelectedIndex     = globalFuncs.localization.currenciesNative.IndexOf(curSettings.currency);
            generalTabItemViewModel.wage.ComboBoxSelectedIndex         = globalFuncs.localization.wagesNative.IndexOf(curSettings.wage);
            generalTabItemViewModel.height.ComboBoxSelectedIndex       = globalFuncs.localization.heightsNative.IndexOf(curSettings.height);
            generalTabItemViewModel.weight.ComboBoxSelectedIndex       = globalFuncs.localization.weightsNative.IndexOf(curSettings.weight);
            generalTabItemViewModel.allowEditing.ComboBoxSelectedIndex = globalFuncs.localization.editing.IndexOf(curSettings.editing);
            generalTabItemViewModel.language.ComboBoxSelectedIndex     = globalFuncs.languages.IndexOf(curSettings.language);
            generalTabItemViewModel.theme.ComboBoxSelectedIndex        = globalFuncs.themes.IndexOf(curSettings.theme);
            generalTabItemViewModel.wonderkidsMaxAge.NumericValue      = curSettings.wonderkidsMaxAge;
            generalTabItemViewModel.wonderkidsMinPA.NumericValue       = curSettings.wonderkidsMinPA;
            generalTabItemViewModel.wonderstaffMinPA.NumericValue      = curSettings.wonderstaffMinPA;
            generalTabItemViewModel.wonderteamsMinRep.NumericValue     = curSettings.wonderteamsMinRep;
            //this.GeneralTabItem.wonderkidsMaxAge.NumericUpDown.Value = curSettings.wonderkidsMaxAge;
            //this.GeneralTabItem.wonderkidsMinPA.NumericUpDown.Value = curSettings.wonderkidsMinPA;
            //this.GeneralTabItem.wonderstaffMinPA.NumericUpDown.Value = curSettings.wonderstaffMinPA;
            //this.GeneralTabItem.wonderteamsMinRep.NumericUpDown.Value = curSettings.wonderteamsMinRep;

            this.PlayerColumnsTabItem.ButtonColumnsDefault_Click(null, null);
            this.StaffColumnsTabItem.ButtonColumnsDefault_Click(null, null);
            this.TeamColumnsTabItem.ButtonColumnsDefault_Click(null, null);
            this.ShortlistColumnsTabItem.ButtonColumnsDefault_Click(null, null);
            settings.settingSettings = true;
        }
        public void setLocalization()
        {
            PreferencesSettings           s = GlobalSettings.getSettings().curPreferencesSettings;
            ObservableCollection <string> WindowCustomizeColumnsLabels = globalFuncs.localization.WindowCustomizeColumnsLabels;
            int index = -1;

            vm.header.Header = WindowCustomizeColumnsLabels[++index];
        }
        private void addCustomSetting()
        {
            globalFuncs.FadeInElement(this.ButtonWarning, globalFuncs.elementDuration, globalFuncs.elementFinalOpacity, true);
            settings.addCustomSetting();
            settings.settingSettings = false;
            PreferencesSettings preferencesSettings = settings.preferencesSettings[0];

            vm.setting.ComboBoxSelectedIndex = globalFuncs.getElementIndex(ref settings.settingNames, preferencesSettings.name);
            settings.settingSettings         = true;
        }
示例#7
0
 public void TestThatSaveUpdatesFile <T>(string name, T value)
 {
     PreferencesSettings.Preferences[name] = value;
     PreferencesSettings.Save();
     using (var fs = new FileStream(PathToPreferencesFile, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         using StreamReader sr = new StreamReader(fs);
         string json = sr.ReadToEnd();
         var    dict = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
         Assert.True(dict.ContainsKey(name));
         Assert.Equal(value, dict[name]);
     }
 }
示例#8
0
        public void ButtonColumnsDefault_Click(object sender, RoutedEventArgs e)
        {
            WrapPanel           wrap        = this.WrapPanelColumns;
            Settings            s           = GlobalSettings.getSettings();
            PreferencesSettings curSettings = s.curPreferencesSettings;

            for (int i = 0; i < wrap.Children.Count; ++i)
            {
                ((CheckBox)wrap.Children[i]).IsChecked = false;
            }
            for (int i = 0; i < curSettings.staffColumns.Count; ++i)
            {
                ((CheckBox)wrap.Children[curSettings.staffColumns[i]]).IsChecked = true;
            }
        }
示例#9
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);
        }
        public void setControlValues(ref Team team, ref TeamGridViewModel r)
        {
            PreferencesSettings           curSettings          = settings.curPreferencesSettings;
            ObservableCollection <String> ProfileGenericLabels = globalFuncs.localization.ProfileGenericLabels;

            this.ID   = r.ID;
            this.name = team.Club.Name;

            this.SelectionButton.Content = this.name;

            string isNational = ProfileGenericLabels[ScoutLocalization.PG_NO];

            if (globalFuncs.localization.regionsNative.Contains(team.Club.Country.Name))
            {
                isNational = ProfileGenericLabels[ScoutLocalization.PG_YES];
            }

            this.buttonlistplayerscontent   = ProfileGenericLabels[ScoutLocalization.PG_LISTPLAYERS];
            this.buttonliststaffcontent     = ProfileGenericLabels[ScoutLocalization.PG_LISTSTAFF];
            this.buttonhealteamcontent      = ProfileGenericLabels[ScoutLocalization.PG_HEALTEAM];
            this.buttonhealteamisenabled    = false;
            this.combolistplayersitems      = this.combolistplayersitemsList;
            this.combolistplayersisenabled  = true;
            this.buttonliststaffisenabled   = true;
            this.buttonlistplayersisenabled = true;

            if (isNational.Equals(ProfileGenericLabels[ScoutLocalization.PG_NO]))
            {
                this.combolistplayersitemsList.Add(ProfileGenericLabels[ScoutLocalization.PG_ALLSQUADS]);
                for (int i = 0; i < team.Club.Teams.Count; ++i)
                {
                    if (team.Club.Teams[i].Type != TeamTypeEnum.Empty)
                    {
                        this.combolistplayersitemsList.Add(team.Club.Teams[i].Type.ToString() + " " + ProfileGenericLabels[ScoutLocalization.PG_TEAM]);
                    }
                }

                if (this.combolistplayersitemsList.Count > 1)
                {
                    if (this.combolistplayersitemsList.Count == 2)
                    {
                        this.combolistplayersitemsList.RemoveAt(0);
                        this.combolistplayersisenabled = false;
                    }
                    this.combolistplayersselecteditem = this.combolistplayersitemsList[0];
                }
            }
            else
            {
                this.buttonlistplayersisenabled = false;
                this.combolistplayersitemsList.Add(ProfileGenericLabels[ScoutLocalization.PG_NATIONPLAYERS]);
            }
            this.combolistplayersselecteditem = this.combolistplayersitemsList[0];

            if (settings.curPreferencesSettings.editing.Equals(ProfileGenericLabels[ScoutLocalization.PG_YES]))
            {
                if (this.combolistplayersitemsList.Count > 1 && isNational.Equals(ProfileGenericLabels[ScoutLocalization.PG_NO]))
                {
                    this.buttonhealteamisenabled = true;
                }
            }

            if (isNational.Equals(ProfileGenericLabels[ScoutLocalization.PG_NO]))
            {
                this.nation  = team.Club.Country.Name;
                this.nation += " (" + team.Club.Country.Continent.Name + ")";
                this.yearfounded.TextBoxText       = team.Club.YearFounded.ToString();
                this.maxattendance.TextBoxText     = team.Club.MaximumAttendance.ToString();
                this.averageattendance.TextBoxText = team.Club.AverageAttendance.ToString();
                this.minattendance.TextBoxText     = team.Club.MinimumAttendance.ToString();

                this.totaltransfer.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_NOBUDGET];
                this.remtransfer.TextBoxText   = ProfileGenericLabels[ScoutLocalization.PG_NOBUDGET];
                this.totalwage.TextBoxText     = ProfileGenericLabels[ScoutLocalization.PG_NOBUDGET];
                this.usedwage.TextBoxText      = ProfileGenericLabels[ScoutLocalization.PG_NOBUDGET];

                // finance details
                if (team.Club.Finances.RemainingTransferBudget != 29476012)
                {
                    this.totaltransfer.TextBoxText = (team.Club.Finances.SeasonTransferBudget * curSettings.currencyMultiplier.multiplier).ToString("C0", curSettings.currencyMultiplier.format);
                    this.remtransfer.TextBoxText   = (team.Club.Finances.RemainingTransferBudget * curSettings.currencyMultiplier.multiplier).ToString("C0", curSettings.currencyMultiplier.format);
                    this.totalwage.TextBoxText     = (team.Club.Finances.WageBudget * curSettings.currencyMultiplier.multiplier).ToString("C0", curSettings.currencyMultiplier.format);
                    this.usedwage.TextBoxText      = (team.Club.Finances.UsedWage * curSettings.currencyMultiplier.multiplier).ToString("C0", curSettings.currencyMultiplier.format);
                }

                this.balance.TextBoxText = (team.Club.Finances.Balance * curSettings.currencyMultiplier.multiplier).ToString("C0", curSettings.currencyMultiplier.format);

                if (team.Club.Finances.TransferRevenueMadeAvailable != 0)
                {
                    this.revenueavailable.TextBoxText = (team.Club.Finances.TransferRevenueMadeAvailable * 0.01f).ToString("P0");
                }
                else
                {
                    this.revenueavailable.TextBoxText = "0%";
                }

                // stadium details
                this.stadiumname = team.Stadium.ToString();
                if (team.Stadium.Owner != null)
                {
                    this.stadiumowner = team.Stadium.Owner.Name.ToString();
                }
                else
                {
                    this.stadiumowner = ProfileGenericLabels[ScoutLocalization.PG_NOOWNER];
                }
                this.stadiumlocation = team.Stadium.City.Name.ToString();
                if (team.Stadium.NearbyStadium != null)
                {
                    this.stadiumnearby = team.Stadium.NearbyStadium.Name;
                }
                else
                {
                    this.stadiumnearby = ProfileGenericLabels[ScoutLocalization.PG_NONEARBYSTADIUM];
                }
                this.decay.TextBoxText        = team.Stadium.Decay.ToString();
                this.fieldwidth.TextBoxText   = (float.Parse(team.Stadium.FieldWidth.ToString())).ToString() + "m";
                this.fieldlength.TextBoxText  = (float.Parse(team.Stadium.FieldLength.ToString())).ToString() + "m";
                this.curcapacity.TextBoxText  = team.Stadium.StadiumCapacity.ToString();
                this.seatcapacity.TextBoxText = team.Stadium.SeatingCapacity.ToString();
                this.expcapacity.TextBoxText  = team.Stadium.ExpansionCapacity.ToString();
                this.usedcapacity.TextBoxText = team.Stadium.UsedCapacity.ToString();
            }
            else
            {
                this.nation = team.Club.Country.Name;
                this.yearfounded.TextBoxText       = ProfileGenericLabels[ScoutLocalization.PG_NONE];
                this.maxattendance.TextBoxText     = ProfileGenericLabels[ScoutLocalization.PG_NONE];
                this.averageattendance.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_NONE];
                this.minattendance.TextBoxText     = ProfileGenericLabels[ScoutLocalization.PG_NONE];

                this.totaltransfer.TextBoxText    = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.remtransfer.TextBoxText      = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.balance.TextBoxText          = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.totalwage.TextBoxText        = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.usedwage.TextBoxText         = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.revenueavailable.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];

                this.stadiumname              = ProfileGenericLabels[ScoutLocalization.PG_NONE];
                this.stadiumowner             = ProfileGenericLabels[ScoutLocalization.PG_NOOWNER];
                this.stadiumlocation          = ProfileGenericLabels[ScoutLocalization.PG_NOLOCATION];
                this.stadiumnearby            = ProfileGenericLabels[ScoutLocalization.PG_NONEARBYSTADIUM];
                this.decay.TextBoxText        = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];;
                this.fieldwidth.TextBoxText   = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.fieldlength.TextBoxText  = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.curcapacity.TextBoxText  = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.seatcapacity.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.expcapacity.TextBoxText  = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
                this.usedcapacity.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
            }

            this.national.TextBoxText           = isNational;
            this.status.TextBoxText             = team.Club.Status.ToString();
            this.maxafclubs.TextBoxText         = team.Club.MaxAffiliatedClubNumber.ToString();
            this.afclubs.TextBoxText            = team.Club.NumberOfAffiliatedClubs.ToString();
            this.trainingfacilities.TextBoxText = team.Club.TrainingFacilities.ToString();
            this.youthfacilities.TextBoxText    = team.Club.YouthFacilities.ToString();
            if (team.Club.YouthAcademy == 0)
            {
                this.youthacademy.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_NO];
            }
            else if (team.Club.YouthAcademy == 1)
            {
                this.youthacademy.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_YES];
            }
            else
            {
                this.youthacademy.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_UNAVAILABLE];
            }
            this.reputation.TextBoxText = team.Reputation.ToString();
        }
        public void addTeamToGrid(Club club, ref TeamGridViewModel newRow, int curTeam)
        {
            PreferencesSettings settings = GlobalSettings.getSettings().curPreferencesSettings;

            newRow.ID   = club.ID;
            newRow.Name = club.Name.ToString();
            if (club.Country == null)
            {
                newRow.Nation = club.Name;
            }
            else
            {
                newRow.Nation = club.Country.Name;
            }
            newRow.Reputation = club.Teams[curTeam].Reputation;
            newRow.Status     = club.ClubStatus.ToString();
            if (club.Teams[curTeam].Stadium != null)
            {
                newRow.Stadium           = club.Teams[curTeam].Stadium.Name;
                newRow.Decay             = club.Teams[curTeam].Stadium.Decay;
                newRow.FieldWidth        = club.Teams[curTeam].Stadium.FieldWidth;
                newRow.FieldLength       = club.Teams[curTeam].Stadium.FieldLength;
                newRow.CurrentCapacity   = club.Teams[curTeam].Stadium.StadiumCapacity;
                newRow.SeatingCapacity   = club.Teams[curTeam].Stadium.SeatingCapacity;
                newRow.ExpansionCapacity = club.Teams[curTeam].Stadium.ExpansionCapacity;
                newRow.UsedCapacity      = club.Teams[curTeam].Stadium.UsedCapacity;
            }
            else
            {
                newRow.Stadium           = " None";
                newRow.Decay             = 0;
                newRow.FieldWidth        = 0;
                newRow.FieldLength       = 0;
                newRow.CurrentCapacity   = 0;
                newRow.SeatingCapacity   = 0;
                newRow.ExpansionCapacity = 0;
                newRow.UsedCapacity      = 0;
            }

            if (club.Finances.RemainingTransferBudget != 29476012)
            {
                newRow.TransferBudget  = (int)(club.Finances.SeasonTransferBudget * settings.currencyMultiplier.multiplier);
                newRow.RemainingBudget = (int)(club.Finances.RemainingTransferBudget * settings.currencyMultiplier.multiplier);
                newRow.WageBudget      = (int)(club.Finances.WageBudget * settings.currencyMultiplier.multiplier);
                newRow.WageUsed        = (int)(club.Finances.UsedWage * settings.currencyMultiplier.multiplier);
            }
            else
            {
                newRow.TransferBudget  = 0;
                newRow.RemainingBudget = 0;
                newRow.WageBudget      = 0;
                newRow.WageUsed        = 0;
            }
            newRow.BudgetBalance            = (int)(club.Finances.Balance * settings.currencyMultiplier.multiplier);
            newRow.TransferRevenueAvailable = (int)(club.Finances.TransferRevenueMadeAvailable * 0.01f);
            newRow.CurrentAffiliatedClubs   = club.TeamNumber;
            newRow.MaxAffiliatedClubs       = club.MaxAffiliatedClubNumber;
            newRow.TrainingFacilities       = club.TrainingFacilities;
            newRow.YouthFacilities          = club.YouthFacilities;
            newRow.MaximumAttendance        = club.MaximumAttendance;
            newRow.AverageAttendance        = club.AverageAttendance;
            newRow.MinimumAttendance        = club.MinimumAttendance;
        }
        public void retrieveFieldsWonder()
        {
            CurrentResultDelegate currentResultDelegate = new CurrentResultDelegate(currentResultWonder);
            FinalResultDelegate   finalResultDelegate   = new FinalResultDelegate(finalResultWonder);

            PreferencesSettings settings = GlobalSettings.getSettings().curPreferencesSettings;

            TEAMSTATE teamState = TEAMSTATE.TS_NONNATIONAL;

            TeamGridViewModel newRow;
            DateTime          timerStart = DateTime.Now;
            double            counter    = 0;
            double            total      = 100.0 / (double)globalFuncs.allClubs.Count;

            foreach (DictionaryEntry entry in globalFuncs.allClubs)
            {
                progressBarValue = counter * total;
                ++counter;

                if (stopSearching)
                {
                    searching     = false;
                    stopSearching = false;
                    break;
                }

                Club club = (Club)entry.Value;
                // check empty name
                if (club.Name.Length == 0)
                {
                    continue;
                }

                int curTeam = 0;
                //for (curTeam = 0; curTeam < club.Teams.Count; ++curTeam)
                //{
                //    if (club.Teams[curTeam].Type == TeamTypeEnum.First)
                //        break;
                //    else if (club.Teams[curTeam].Type == TeamTypeEnum.Amateur)
                //        break;
                //    //else if (club.Teams[curTeam].Type == TeamTypeEnum.Empty)
                //    //  break;
                //}

                if (curTeam == club.Teams.Count)
                {
                    --curTeam;
                }

                teamState = TEAMSTATE.TS_NONNATIONAL;
                if (club.Country != null)
                {
                    if (globalFuncs.localization.regionsNative.Contains(club.Country.Name))
                    {
                        teamState = TEAMSTATE.TS_NATIONAL;
                    }
                }

                // check reputation
                if (club.Teams[curTeam].Reputation <= settings.wonderteamsMinRep)
                {
                    continue;
                }

                newRow           = new TeamGridViewModel();
                newRow.TeamState = teamState;
                addTeamToGrid(club, ref newRow, curTeam);
                //dataTable.Add(newRow);

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

            this.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                finalResultDelegate);
        }
        public void retrieveFields()
        {
            CurrentResultDelegate currentResultDelegate = new CurrentResultDelegate(currentResult);
            FinalResultDelegate   finalResultDelegate   = new FinalResultDelegate(finalResult);

            PreferencesSettings settings = GlobalSettings.getSettings().curPreferencesSettings;

            List <string> name_substrings        = new List <string>();
            bool          empty_name             = globalFuncs.multiEntryTextBox(ref name_substrings, searchUI.name);
            List <string> nationality_substrings = new List <string>();
            bool          empty_nationality      = globalFuncs.multiEntryTextBox(ref nationality_substrings, searchUI.nation);
            List <string> stadium_substrings     = new List <string>();
            bool          empty_stadium          = globalFuncs.multiEntryTextBox(ref stadium_substrings, searchUI.stadium);

            TEAMSTATE teamState = TEAMSTATE.TS_NONNATIONAL;

            TeamGridViewModel newRow;
            DateTime          timerStart = DateTime.Now;
            Club   club            = null;
            string clubName        = "";
            string clubNationality = "";
            string clubStadium     = "";
            double counter         = 0;
            double total           = 100.0 / (double)globalFuncs.allClubs.Count;

            foreach (DictionaryEntry entry in globalFuncs.allClubs)
            {
                progressBarValue = counter * total;
                ++counter;
                if (stopSearching)
                {
                    searching     = false;
                    stopSearching = false;
                    break;
                }

                club = (Club)entry.Value;
                // check empty name
                if (club.Name.Length == 0 && club.Country != null)
                {
                    System.Diagnostics.Debug.WriteLine(club.Name);
                }
                if (club.Name.Length == 0 && club.Country != null)
                {
                    continue;
                }

                // check name
                if (!empty_name)
                {
                    clubName = club.Name.ToLower();
                    globalFuncs.specialCharactersReplacement(ref clubName);
                    int no_of_successes = 0;
                    foreach (string str in name_substrings)
                    {
                        if (clubName.Contains(str))
                        {
                            ++no_of_successes;
                        }
                    }

                    if (no_of_successes != name_substrings.Count)
                    {
                        continue;
                    }
                }

                teamState = TEAMSTATE.TS_NONNATIONAL;
                if (club.Country != null)
                {
                    if (globalFuncs.localization.regionsNative.Contains(club.Country.Name))
                    {
                        teamState = TEAMSTATE.TS_NATIONAL;
                    }
                }

                // check nationality
                if (!empty_nationality)
                {
                    if (club.Country != null)
                    {
                        if (teamState == TEAMSTATE.TS_NONNATIONAL)
                        {
                            clubNationality = club.Country.Name.ToLower();
                        }
                        else
                        {
                            clubNationality = club.Name.ToLower();
                        }

                        int no_of_successes = 0;
                        foreach (string str in nationality_substrings)
                        {
                            if (clubNationality.Contains(str))
                            {
                                ++no_of_successes;
                            }
                        }

                        if (no_of_successes != nationality_substrings.Count)
                        {
                            continue;
                        }

                        if (teamState == TEAMSTATE.TS_NATIONAL)
                        {
                            clubNationality = club.Country.Name.ToLower();
                        }
                    }
                    else
                    {
                        globalFuncs.logging.update("Error: Not added " + club.Name + ". Reason: Country null");
                    }
                }

                // check type
                if (searchUI.teamtypeIndex > 0)
                {
                    if (searchUI.teamtypeIndex == 1 && teamState == TEAMSTATE.TS_NONNATIONAL)
                    {
                        continue;
                    }
                    else if (searchUI.teamtypeIndex == 2 && teamState == TEAMSTATE.TS_NATIONAL)
                    {
                        continue;
                    }
                }

                int curTeam = 0;
                //for (curTeam = 0; curTeam < club.Teams.Count; ++curTeam)
                //{
                //    if (club.Teams[curTeam].Type == TeamTypeEnum.First)
                //        break;
                //    else if (club.Teams[curTeam].Type == TeamTypeEnum.Amateur)
                //        break;
                //    //else if (club.Teams[curTeam].Type == TeamTypeEnum.Empty)
                //    //  break;
                //}

                if (curTeam == club.Teams.Count)
                {
                    --curTeam;
                }
                if (curTeam < 0)
                {
                    continue;
                }

                // check reputation
                if (searchUI.reputationIndex > 0)
                {
                    if (searchUI.reputationIndex == 1 && club.Teams[curTeam].Reputation < 8000)
                    {
                        continue;
                    }
                    else if (searchUI.reputationIndex == 2 && (!(club.Teams[curTeam].Reputation > 5000 && club.Teams[curTeam].Reputation <= 8000)))
                    {
                        continue;
                    }
                    else if (searchUI.reputationIndex == 3 && (!(club.Teams[curTeam].Reputation > 3000 && club.Teams[curTeam].Reputation <= 5000)))
                    {
                        continue;
                    }
                    else if (searchUI.reputationIndex == 4 && (!(club.Teams[curTeam].Reputation > 0 && club.Teams[curTeam].Reputation <= 3000)))
                    {
                        continue;
                    }
                }

                // check region
                if (searchUI.regionIndex > 0 && club.Country != null)
                {
                    if (teamState == TEAMSTATE.TS_NONNATIONAL)
                    {
                        if (!searchUI.regionItem.Contains(club.Country.Continent.Name))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!searchUI.regionItem.Contains(club.Country.Name))
                        {
                            continue;
                        }
                    }
                }

                // check stadium
                if (!empty_stadium)
                {
                    if (club.Teams[curTeam].Stadium != null)
                    {
                        clubStadium = club.Teams[curTeam].Stadium.Name.ToLower();
                        globalFuncs.specialCharactersReplacement(ref clubStadium);
                        int no_of_successes = 0;
                        foreach (string str in stadium_substrings)
                        {
                            if (clubStadium.Contains(str))
                            {
                                ++no_of_successes;
                            }
                        }

                        if (no_of_successes != stadium_substrings.Count)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        globalFuncs.logging.update("Error: No stadium found for " + club.Name);
                        continue;
                    }
                }

                // check transfer budget
                if (searchUI.transferBudgetMin > 0)
                {
                    if (club.Finances.SeasonTransferBudget < searchUI.transferBudgetMin ||
                        club.Finances.SeasonTransferBudget > searchUI.transferBudgetMax)
                    {
                        continue;
                    }
                }
                else
                {
                    if (club.Finances.SeasonTransferBudget > searchUI.transferBudgetMax)
                    {
                        continue;
                    }
                }

                if (searchUI.transferBudgetMin > 0)
                {
                    if (club.Finances.WageBudget < searchUI.wageBudgetMin ||
                        club.Finances.WageBudget > searchUI.wageBudgetMax)
                    {
                        continue;
                    }
                }
                else
                {
                    if (club.Finances.WageBudget < searchUI.wageBudgetMin)
                    {
                        continue;
                    }
                }

                newRow           = new TeamGridViewModel();
                newRow.TeamState = teamState;
                addTeamToGrid(club, ref newRow, curTeam);
                //dataTable.Add(newRow);

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

            this.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                finalResultDelegate);
        }
示例#14
0
        public void setControlValues(ref Staff staff, ref StaffGridViewModel r)
        {
            PreferencesSettings           curSettings          = settings.curPreferencesSettings;
            ObservableCollection <String> ProfileGenericLabels = globalFuncs.localization.ProfileGenericLabels;

            String wageExtended = globalFuncs.localization.wages
                                  [globalFuncs.localization.wagesNative.IndexOf(curSettings.wageMultiplier.extended)];

            this.ID = r.ID;
            // personal details
            this.SelectionButton.Content = staff.ToString();
            this.fullname = this.SelectionButton.Content;
            this.club     = r.Club;
            this.nation   = staff.Nationality.Name + " (" + staff.Nationality.Continent.Name + ")";
            if (staff.InternationalCaps != 0)
            {
                this.international = staff.InternationalCaps.ToString() + " " +
                                     ProfileGenericLabels[ScoutLocalization.PG_CAPS] +
                                     "/" + staff.InternationalGoals.ToString() + " " +
                                     ProfileGenericLabels[ScoutLocalization.PG_GOALS];
            }
            else
            {
                this.international = ProfileGenericLabels[ScoutLocalization.PG_UNCAPPED];
            }
            this.birthdate = staff.DateOfBirth.Date.ToShortDateString();
            this.age       = staff.Age.ToString() + " " + ProfileGenericLabels[ScoutLocalization.PG_YEARSOLD];

            string staffRole = "";
            string empty     = "";

            context.find_staff_role(staff, ref staffRole, ref empty, true);
            if (staffRole.Length == 0)
            {
                this.role = ProfileGenericLabels[ScoutLocalization.PG_NOROLE];
            }
            else
            {
                this.role = staffRole;
            }
            if (role.Equals(globalFuncs.localization.SearchingResults[ScoutLocalization.SR_FREEAGENT]) ||
                role.Equals(globalFuncs.localization.SearchingResults[ScoutLocalization.R_CHAIRMAN]) ||
                role.Equals(globalFuncs.localization.SearchingResults[ScoutLocalization.R_DIRECTOR]) || staff.Contract == null)
            {
                this.contractstarted.TextBoxText  = ProfileGenericLabels[ScoutLocalization.PG_NOCONTRACT];
                this.contractexpiring.TextBoxText = ProfileGenericLabels[ScoutLocalization.PG_NOCONTRACT];
                this.wage.TextBoxText             = ProfileGenericLabels[ScoutLocalization.PG_NOWAGE];
            }
            else
            {
                this.contractstarted.TextBoxText  = staff.Contract.ContractStarted.Date.ToShortDateString();
                this.contractexpiring.TextBoxText = staff.Contract.ContractExpiryDate.Date.ToShortDateString();
                this.wage.TextBoxText             = (staff.Contract.WagePerWeek * curSettings.wageMultiplier.multiplier * curSettings.currencyMultiplier.multiplier).ToString("C0", curSettings.currencyMultiplier.format) + " " + wageExtended;
            }

            if (staff.NationalTeam != null)
            {
                if (staff.NationalTeam.Club != null)
                {
                    if (staff.NationalTeam.Club.Country != null)
                    {
                        if (globalFuncs.localization.regionsNative.Contains(staff.NationalTeam.Club.Country.Name))
                        {
                            this.club = staff.NationalTeam.Club.Name;
                        }
                    }
                }
            }

            this.ca = staff.CurrentCoachingAbility + " " + globalFuncs.localization.PlayerSearchLabels[ScoutLocalization.L_CA];
            this.pa = staff.PotentialCoachingAbility + " " + globalFuncs.localization.PlayerSearchLabels[ScoutLocalization.L_PA];

            this.worldrep    = r.WorldReputation;
            this.nationalrep = r.NationalReputation;
            this.localrep    = r.LocalReputation;

            int index = -1;

            this.depth              = contexts[++index];
            this.directness         = contexts[++index];
            this.flamboyancy        = contexts[++index];
            this.flexibility        = contexts[++index];
            this.freeroles          = contexts[++index];
            this.marking            = contexts[++index];
            this.offside            = contexts[++index];
            this.pressing           = contexts[++index];
            this.sittingback        = contexts[++index];
            this.tempo              = contexts[++index];
            this.useofplaymaker     = contexts[++index];
            this.useofsubstitutions = contexts[++index];
            this.width              = contexts[++index];
            this.adaptability       = contexts[++index];
            this.ambition           = contexts[++index];
            this.controversy        = contexts[++index];
            this.determination      = contexts[++index];
            this.loyalty            = contexts[++index];
            this.pressure           = contexts[++index];
            this.professionalism    = contexts[++index];
            this.sportsmanship      = contexts[++index];
            //this.temperament = contexts[++index];
            this.judgingplayerability   = contexts[++index];
            this.judgingplayerpotential = contexts[++index];
            this.levelofdiscipline      = contexts[++index];
            this.motivating             = contexts[++index];
            this.physiotherapy          = contexts[++index];
            this.tacticalknowledge      = contexts[++index];
            this.attacking             = contexts[++index];
            this.defending             = contexts[++index];
            this.fitness               = contexts[++index];
            this.goalkeepers           = contexts[++index];
            this.mental                = contexts[++index];
            this.player                = contexts[++index];
            this.tactical              = contexts[++index];
            this.technical             = contexts[++index];
            this.manmanagement         = contexts[++index];
            this.workingwithyoungsters = contexts[++index];
            this.buyingplayers         = contexts[++index];
            this.hardnessoftraining    = contexts[++index];
            this.mindgames             = contexts[++index];
            this.squadrotation         = contexts[++index];
            this.business              = contexts[++index];
            this.intereference         = contexts[++index];
            this.patience              = contexts[++index];
            this.resources             = contexts[++index];

            index = -1;
            CoachingRatings cr = (CoachingRatings)context.staffCRID[r.ID];

            this.rfitness                 = contextsratings[++index];
            this.rfitness.ImageSource     = App.Current.Resources[cr.Fitness + "star"] as ImageSource;
            this.rgoalkeepers             = contextsratings[++index];
            this.rgoalkeepers.ImageSource = App.Current.Resources[cr.Goalkeepers + "star"] as ImageSource;
            this.rtactics                 = contextsratings[++index];
            this.rtactics.ImageSource     = App.Current.Resources[cr.Tactics + "star"] as ImageSource;
            this.rballcontrol             = contextsratings[++index];
            this.rballcontrol.ImageSource = App.Current.Resources[cr.BallControl + "star"] as ImageSource;
            this.rdefending               = contextsratings[++index];
            this.rdefending.ImageSource   = App.Current.Resources[cr.Defending + "star"] as ImageSource;
            this.rattacking               = contextsratings[++index];
            this.rattacking.ImageSource   = App.Current.Resources[cr.Attacking + "star"] as ImageSource;
            this.rshooting                = contextsratings[++index];
            this.rshooting.ImageSource    = App.Current.Resources[cr.Shooting + "star"] as ImageSource;
            this.rsetpieces               = contextsratings[++index];
            this.rsetpieces.ImageSource   = App.Current.Resources[cr.SetPieces + "star"] as ImageSource;

            this.depth.TextBoxText              = r.Depth;
            this.directness.TextBoxText         = r.Directness;
            this.flamboyancy.TextBoxText        = r.Flamboyancy;
            this.flexibility.TextBoxText        = r.Flexibility;
            this.freeroles.TextBoxText          = r.FreeRoles;
            this.marking.TextBoxText            = r.Marking;
            this.offside.TextBoxText            = r.Offside;
            this.pressing.TextBoxText           = r.Pressing;
            this.sittingback.TextBoxText        = r.SittingBack;
            this.tempo.TextBoxText              = r.Tempo;
            this.useofplaymaker.TextBoxText     = r.UseOfPlaymaker;
            this.useofsubstitutions.TextBoxText = r.UseOfSubstitutions;
            this.width.TextBoxText              = r.Width;
            this.adaptability.TextBoxText       = r.Adaptability;
            this.ambition.TextBoxText           = r.Ambition;
            this.controversy.TextBoxText        = r.Controversy;
            this.determination.TextBoxText      = r.Determination;
            this.loyalty.TextBoxText            = r.Loyalty;
            this.pressure.TextBoxText           = r.Pressure;
            this.professionalism.TextBoxText    = r.Professionalism;
            this.sportsmanship.TextBoxText      = r.Sportsmanship;
            //this.temperament.TextBoxText = r.Temperament;
            this.judgingplayerability.TextBoxText   = r.JudgingPlayerAbility;
            this.judgingplayerpotential.TextBoxText = r.JudgingPlayerPotential;
            this.levelofdiscipline.TextBoxText      = r.LevelOfDiscipline;
            this.motivating.TextBoxText             = r.Motivating;
            this.physiotherapy.TextBoxText          = r.Physiotherapy;
            this.tacticalknowledge.TextBoxText      = r.TacticalKnowledge;
            this.attacking.TextBoxText             = r.Attacking;
            this.defending.TextBoxText             = r.Defending;
            this.fitness.TextBoxText               = r.Fitness;
            this.goalkeepers.TextBoxText           = r.Goalkeepers;
            this.mental.TextBoxText                = r.Mental;
            this.player.TextBoxText                = r.Player;
            this.tactical.TextBoxText              = r.Tactical;
            this.technical.TextBoxText             = r.Technical;
            this.manmanagement.TextBoxText         = r.ManManagement;
            this.workingwithyoungsters.TextBoxText = r.WorkingWithYoungsters;
            this.buyingplayers.TextBoxText         = r.BuyingPlayers;
            this.hardnessoftraining.TextBoxText    = r.HardnessOfTraining;
            this.mindgames.TextBoxText             = r.MindGames;
            this.squadrotation.TextBoxText         = r.SquadRotation;
            this.business.TextBoxText              = r.Business;
            this.intereference.TextBoxText         = r.Interference;
            this.patience.TextBoxText              = r.Patience;
            this.resources.TextBoxText             = r.Resources;

            this.depth.TextBoxForeground              = globalFuncs.setAttributeForeground(r.Depth);
            this.directness.TextBoxForeground         = globalFuncs.setAttributeForeground(r.Directness);
            this.flamboyancy.TextBoxForeground        = globalFuncs.setAttributeForeground(r.Flamboyancy);
            this.flexibility.TextBoxForeground        = globalFuncs.setAttributeForeground(r.Flexibility);
            this.freeroles.TextBoxForeground          = globalFuncs.setAttributeForeground(r.FreeRoles);
            this.marking.TextBoxForeground            = globalFuncs.setAttributeForeground(r.Marking);
            this.offside.TextBoxForeground            = globalFuncs.setAttributeForeground(r.Offside);
            this.pressing.TextBoxForeground           = globalFuncs.setAttributeForeground(r.Pressing);
            this.sittingback.TextBoxForeground        = globalFuncs.setAttributeForeground(r.SittingBack);
            this.tempo.TextBoxForeground              = globalFuncs.setAttributeForeground(r.Tempo);
            this.useofplaymaker.TextBoxForeground     = globalFuncs.setAttributeForeground(r.UseOfPlaymaker);
            this.useofsubstitutions.TextBoxForeground = globalFuncs.setAttributeForeground(r.UseOfSubstitutions);
            this.width.TextBoxForeground              = globalFuncs.setAttributeForeground(r.Width);
            this.adaptability.TextBoxForeground       = globalFuncs.setAttributeForeground(r.Adaptability);
            this.ambition.TextBoxForeground           = globalFuncs.setAttributeForeground(r.Ambition);
            this.controversy.TextBoxForeground        = globalFuncs.setAttributeForeground(r.Controversy);
            this.determination.TextBoxForeground      = globalFuncs.setAttributeForeground(r.Determination);
            this.loyalty.TextBoxForeground            = globalFuncs.setAttributeForeground(r.Loyalty);
            this.pressure.TextBoxForeground           = globalFuncs.setAttributeForeground(r.Pressure);
            this.professionalism.TextBoxForeground    = globalFuncs.setAttributeForeground(r.Professionalism);
            this.sportsmanship.TextBoxForeground      = globalFuncs.setAttributeForeground(r.Sportsmanship);
            //this.temperament.TextBoxForeground = globalFuncs.setAttributeForeground(r.Temperament);
            this.judgingplayerability.TextBoxForeground   = globalFuncs.setAttributeForeground(r.JudgingPlayerAbility);
            this.judgingplayerpotential.TextBoxForeground = globalFuncs.setAttributeForeground(r.JudgingPlayerPotential);
            this.levelofdiscipline.TextBoxForeground      = globalFuncs.setAttributeForeground(r.LevelOfDiscipline);
            this.motivating.TextBoxForeground             = globalFuncs.setAttributeForeground(r.Motivating);
            this.physiotherapy.TextBoxForeground          = globalFuncs.setAttributeForeground(r.Physiotherapy);
            this.tacticalknowledge.TextBoxForeground      = globalFuncs.setAttributeForeground(r.TacticalKnowledge);
            this.attacking.TextBoxForeground             = globalFuncs.setAttributeForeground(r.Attacking);
            this.defending.TextBoxForeground             = globalFuncs.setAttributeForeground(r.Defending);
            this.fitness.TextBoxForeground               = globalFuncs.setAttributeForeground(r.Fitness);
            this.goalkeepers.TextBoxForeground           = globalFuncs.setAttributeForeground(r.Goalkeepers);
            this.mental.TextBoxForeground                = globalFuncs.setAttributeForeground(r.Mental);
            this.player.TextBoxForeground                = globalFuncs.setAttributeForeground(r.Player);
            this.tactical.TextBoxForeground              = globalFuncs.setAttributeForeground(r.Tactical);
            this.technical.TextBoxForeground             = globalFuncs.setAttributeForeground(r.Technical);
            this.manmanagement.TextBoxForeground         = globalFuncs.setAttributeForeground(r.ManManagement);
            this.workingwithyoungsters.TextBoxForeground = globalFuncs.setAttributeForeground(r.WorkingWithYoungsters);
            this.buyingplayers.TextBoxForeground         = globalFuncs.setAttributeForeground(r.BuyingPlayers);
            this.hardnessoftraining.TextBoxForeground    = globalFuncs.setAttributeForeground(r.HardnessOfTraining);
            this.mindgames.TextBoxForeground             = globalFuncs.setAttributeForeground(r.MindGames);
            this.squadrotation.TextBoxForeground         = globalFuncs.setAttributeForeground(r.SquadRotation);
            this.business.TextBoxForeground              = globalFuncs.setAttributeForeground(r.Business);
            this.intereference.TextBoxForeground         = globalFuncs.setAttributeForeground(r.Interference);
            this.patience.TextBoxForeground              = globalFuncs.setAttributeForeground(r.Patience);
            this.resources.TextBoxForeground             = globalFuncs.setAttributeForeground(r.Resources);
        }
示例#15
0
 public PreferencesSettingsTests()
 {
     PreferencesSettings.Init(PathToPreferencesFile);
 }
示例#16
0
 protected static T GetPreference <T>(string name)
 {
     return(PreferencesSettings.GetPreference <T>(name));
 }
示例#17
0
 public void TestThatUpdatePreferenceUpdatesDictionary <T>(string name, T value)
 {
     PreferencesSettings.UpdatePreference(name, value);
     Assert.Equal(value, PreferencesSettings.GetPreference <T>(name));
 }