Exemple #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);
            }
        }
Exemple #2
0
        public void OpdLoad(string filename, MarketSet data)
        {
            // set progress
            SetProgress(0);

            // delegate async csv load
            LoadDelegate ld = new LoadDelegate(Core.Opd.Load);

            ld.BeginInvoke(filename, null, data, new AsyncCallback(this.LoadComplete), null);
        }
Exemple #3
0
        /// <summary>
        /// Loads this ModelNode asynchronously.
        /// </summary>
        internal void BeginLoad()
        {
            lock (m_oAsyncLock)
            {
                if (m_eStatus != LoadState.Unloaded)
                {
                    return;
                }

                LoadDelegate oLoad    = new LoadDelegate(Load);
                AsyncContext oContext = new AsyncContext(m_iLoadSync, oLoad);
                m_oCurrentAsyncResult = oLoad.BeginInvoke(_EndLoad, oContext);
                m_eStatus             = LoadState.Loading;
            }
        }
Exemple #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);
        }
Exemple #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);
                }
            }
        }