public void ButtonWonder_Click(object sender, RoutedEventArgs e)
        {
            globalFuncs.scoutTimer.start();

            if (searching)
            {
                stopSearching = true;
                searching     = false;
                return;
            }

            this.windowMain.CurrentGameDate.Text      = context.fm.MetaData.IngameDate.ToLongDateString();
            this.windowMain.vm.tabteams.TextBlockText = globalFuncs.localization.WindowMainLabels[2];
            this.vm.wonder.TextBlockText = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_STOP];
            //this.ButtonWonder.IsEnabled = false;
            this.vm.results.Text = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_SEARCHING] + "...";
            setControlAvailability(false);
            this.ButtonSearch.IsEnabled = false;

            SearchDelegate d = new SearchDelegate(this.retrieveFieldsWonder);

            d.BeginInvoke(null, null);
            ProgressBarDelegate p = new ProgressBarDelegate(this.updateProgressBar);

            p.BeginInvoke(null, null);
        }
Example #2
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);
            }
        }
        public void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            globalFuncs.scoutTimer.start();

            if (searching)
            {
                stopSearching = true;
                searching     = false;
                return;
            }

            this.windowMain.CurrentGameDate.Text      = context.fm.MetaData.IngameDate.ToLongDateString();
            this.windowMain.vm.tabteams.TextBlockText = globalFuncs.localization.WindowMainLabels[2];
            this.vm.search.TextBlockText = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_STOP];
            //this.ButtonSearch.IsEnabled = false;
            setControlAvailability(false);
            this.ButtonWonder.IsEnabled = false;
            this.vm.results.Text        = globalFuncs.localization.SearchingResults[ScoutLocalization.SR_SEARCHING] + "...";

            searchUI.name    = this.name.TextBox.Text.ToLower();
            searchUI.nation  = this.nation.TextBox.Text.ToLower();
            searchUI.stadium = this.stadium.TextBox.Text.ToLower();
            globalFuncs.specialCharactersReplacement(ref searchUI.name);
            globalFuncs.specialCharactersReplacement(ref searchUI.nation);
            globalFuncs.specialCharactersReplacement(ref searchUI.stadium);
            searchUI.teamtypeIndex = this.teamtype.ComboBox.SelectedIndex;
            if (this.teamtype.ComboBox.SelectedItem != null)
            {
                searchUI.teamtypeItem = (String)this.teamtype.ComboBox.SelectedItem;
            }
            searchUI.regionIndex = this.region.ComboBox.SelectedIndex;
            if (this.region.ComboBox.SelectedItem != null)
            {
                searchUI.regionItem = globalFuncs.localization.regionsNative[searchUI.regionIndex];
            }
            searchUI.reputationIndex = this.reputation.ComboBox.SelectedIndex;
            if (this.reputation.ComboBox.SelectedItem != null)
            {
                searchUI.reputationItem = (String)this.reputation.ComboBox.SelectedItem;
            }
            searchUI.transferBudgetMin = (int)this.transferBudget.NumericUpDownMin.Value;
            searchUI.transferBudgetMax = (int)this.transferBudget.NumericUpDownMax.Value;
            searchUI.wageBudgetMin     = (int)this.wageBudget.NumericUpDownMin.Value;
            searchUI.wageBudgetMax     = (int)this.wageBudget.NumericUpDownMax.Value;

            SearchDelegate d = new SearchDelegate(this.retrieveFields);

            d.BeginInvoke(null, null);
            ProgressBarDelegate p = new ProgressBarDelegate(this.updateProgressBar);

            p.BeginInvoke(null, null);
        }
Example #4
0
        public void addToShortlist(int ID)
        {
            List <int> playersToLoad = new List <int>();

            playersToLoad.Add(ID);
            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 playersToLoad, null, null);
            ProgressBarDelegate p = new ProgressBarDelegate(this.updateProgressBar);

            p.BeginInvoke(null, null);
        }
Example #5
0
        public void loadShortlist()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Sports Interactive\\Football Manager 2011\\shortlists";
            openFileDialog.Multiselect      = true;
            openFileDialog.DefaultExt       = "slf";
            // The Filter property requires a search string after the pipe ( | )
            openFileDialog.Filter = "FM2011 Shortlists (*.slf)|*.slf";//|CSV Spreadsheet(*.csv)|*.csv";
            openFileDialog.ShowDialog();
            if (openFileDialog.FileNames.Length > 0)
            {
                string     ext           = openFileDialog.FileName.Substring(openFileDialog.FileName.LastIndexOf(".") + 1);
                List <int> playersToLoad = new List <int>();
                if (ext.Equals("slf"))
                {
                    int count = 0;
                    foreach (string filename in openFileDialog.FileNames)
                    {
                        ++count;
                        using (FileStream stream = new FileStream(filename, FileMode.Open))
                        {
                            byte[] header = new byte[14];
                            stream.Read(header, 0, header.Length);
                            byte[] shortlistNameLengthByte = new byte[4];
                            stream.Read(shortlistNameLengthByte, 0, shortlistNameLengthByte.Length);
                            int      shortlistNameLength = globalFuncs.ReadInt32(shortlistNameLengthByte);
                            byte[][] shortlistNameChar   = new byte[shortlistNameLength][];
                            for (int i = 0; i < shortlistNameLength; ++i)
                            {
                                shortlistNameChar[i] = new byte[2];
                                stream.Read(shortlistNameChar[i], 0, shortlistNameChar[i].Length);
                            }

                            byte[] bogusByte = new byte[2];
                            stream.Read(bogusByte, 0, bogusByte.Length);
                            int bogus = globalFuncs.ReadInt16(bogusByte);

                            byte[] noItemsByte = new byte[4];
                            stream.Read(noItemsByte, 0, noItemsByte.Length);
                            int noItems = globalFuncs.ReadInt32(noItemsByte);

                            byte[][] playersIDByte = new byte[noItems][];
                            for (int i = 0; i < noItems; ++i)
                            {
                                playersIDByte[i] = new byte[4];
                                stream.Read(playersIDByte[i], 0, playersIDByte[i].Length);
                                playersToLoad.Add(globalFuncs.ReadInt32(playersIDByte[i]));
                            }

                            byte[] endByte = new byte[4];
                            stream.Read(endByte, 0, 1);
                            int end = globalFuncs.ReadInt32(endByte);
                        }
                    }
                }
                else if (ext.Equals("csv"))
                {
                    int    count     = 0;
                    string separator = ",";
                    if (ext.Equals("txt"))
                    {
                        separator = " ";
                    }
                    foreach (string filename in openFileDialog.FileNames)
                    {
                        ++count;
                        using (FileStream stream = new FileStream(filename, FileMode.Open))
                        {
                            using (StreamReader sw = new StreamReader(stream))
                            {
                                string     columnLine = sw.ReadLine();
                                List <int> players    = new List <int>();

                                while (!sw.EndOfStream)
                                {
                                    string token = sw.ReadLine();
                                    string t     = token;
                                    token = token.Substring(0, token.IndexOf(separator));
                                    char[] rem = { '"', ',', '\\' };
                                    token = token.TrimStart(rem);
                                    token = token.TrimEnd(rem);
                                    playersToLoad.Add(Int32.Parse(token));
                                }
                            }
                        }
                    }
                }

                if (playersToLoad.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 playersToLoad, null, null);
                    ProgressBarDelegate p = new ProgressBarDelegate(this.updateProgressBar);
                    p.BeginInvoke(null, null);
                }
            }
        }