示例#1
0
        void addRow(RomMatch romMatch)
        {
            int rowNum = importerBindingSource.Add(romMatch);

            romMatch.BindingSourceIndex = rowNum;
            if (rowNum == 0 && importGridView.Rows.Count > 0)
            {
                importGridView.Rows[0].Selected = true; //if first item select it
            }
        }
示例#2
0
 void importGridView_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex < 0 || e.RowIndex < 0)
     {
         return;
     }
     if (e.ColumnIndex == columnFilename.Index)
     {
         RomMatch romMatch = (RomMatch)importerBindingSource[e.RowIndex];
         importGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = romMatch.ToolTip;
     }
 }
示例#3
0
        void resultsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox      resultsComboBox = (ComboBox)sender;
            RomMatch      romMatch        = resultsComboBox.Tag as RomMatch;
            ScraperResult newResult       = resultsComboBox.SelectedItem as ScraperResult;

            if (newResult != null && newResult != importGridView.CurrentCell.Value)
            {
                importer.UpdateSelectedMatch(romMatch, newResult);
            }
            importGridView.EndEdit();
        }
        public RomMatchViewModel(RomMatch romMatch)
        {
            _statusProperty = new WProperty(typeof(RomMatchStatus), RomMatchStatus.PendingMatch);
            _nameProperty = new WProperty(typeof(string), null);
            _currentMatchProperty = new WProperty(typeof(string), null);
            _contextCommandProperty = new WProperty(typeof(ICommand));

            this.romMatch = romMatch;
            Command = new MethodDelegateCommand(commandDelegate);
            ContextCommand = new MethodDelegateCommand(contextCommandDelegate);
            Update();
        }
 public void Search(string term, Game game)
 {
     invokeAsync(() =>
         {
             RomMatch romMatch = new RomMatch(game) { SearchTitle = term };
             scraperProvider.Update();
             ScraperResult result;
             bool approved;
             List<ScraperResult> results = scraperProvider.GetMatches(romMatch, out result, out approved);
             OnSearchCompleted(new GameSearchCompletedEventArgs(results, result));
         });
 }
 //resets the form, updates the game to search against and starts searching
 internal void Reset(Game game)
 {
     //stop running threads and clear form
     stopAndClear();
     resultsComboBox.Items.Clear();
     closing = false;
     //update details to new game
     this.romMatch      = null;
     this.game          = game;
     searchTextBox.Text = game.Title;
     //start searching
     searchButton_Click(this, new EventArgs());
 }
示例#7
0
        void mergeSelectedRows()
        {
            if (importGridView.SelectedRows.Count < 2)
            {
                return;
            }

            RomMatch romMatch = importGridView.SelectedRows[importGridView.SelectedRows.Count - 1].DataBoundItem as RomMatch;

            if (romMatch == null)
            {
                return;
            }
            Game game = romMatch.Game;

            if (game == null)
            {
                return;
            }

            List <GameDisc> discs       = game.GetDiscs();
            List <Game>     removeGames = new List <Game>();

            for (int x = importGridView.SelectedRows.Count - 2; x > -1; x--)
            {
                RomMatch match = importGridView.SelectedRows[x].DataBoundItem as RomMatch;
                if (match == null || match.Game == null || match.Game.GetDiscs().Count > 1)
                {
                    continue;
                }

                GameDisc disc = new GameDisc(game)
                {
                    Path = match.Game.Path, LaunchFile = match.Game.LaunchFile, Number = discs.Count + 1
                };
                discs.Add(disc);
                removeGames.Add(match.Game);
            }
            lock (DB.Instance.SyncRoot)
            {
                DB.Instance.ExecuteTransaction(removeGames, removeGame =>
                {
                    importer.Remove(removeGame.GameID);
                    removeGame.Delete();
                });

                DB.Instance.ExecuteTransaction(discs, disc => disc.Save());
            }

            romMatch.ResetDisplayInfo();
        }
        //Called when the thumbRetriever has finished searching
        void thumbRetriever_OnSearchCompleted(RomMatch romMatch)
        {
            //Ensure we're on main thread
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate()
                {
                    thumbRetriever_OnSearchCompleted(romMatch);
                }
                                              ));
                return;
            }
            if (retrieverStopping)
            {
                return;
            }
            //reset status
            progressBar.Visible = false;
            statusLabel.Text    = "";
            resultsComboBox.Items.Clear();

            //If there's no results say so and return
            if (romMatch.PossibleGameDetails == null || romMatch.PossibleGameDetails.Count < 1)
            {
                this.romMatch = null;
                resultsComboBox.Items.Add("No results");
                return;
            }

            //select top match if better not found as user can easily change
            if (romMatch.GameDetails == null)
            {
                romMatch.GameDetails = romMatch.PossibleGameDetails[0];
            }

            //keep a reference to the romMatch
            this.romMatch = romMatch;

            //populate the results box
            foreach (ScraperResult result in romMatch.PossibleGameDetails)
            {
                resultsComboBox.Items.Add(result);
            }
            //select the relevent combobox item
            resultsComboBox.SelectedItem = romMatch.GameDetails;
            //start downloading thumbs
            getThumbs(romMatch);
        }
示例#9
0
        //Manual search
        private void findButton_Click(object sender, EventArgs e)
        {
            if (importGridView.SelectedRows.Count == 0)
            {
                return;
            }

            RomMatch          match     = importGridView.SelectedRows[0].DataBoundItem as RomMatch;
            Conf_ManualSearch searchDlg = new Conf_ManualSearch(match.Title);

            if (searchDlg.ShowDialog() == DialogResult.OK)
            {
                match.Title = searchDlg.SearchTerm;
                importer.ReProcess(match);
            }
            updateButtons();
        }
示例#10
0
        void unMergeSelectedRow()
        {
            if (importGridView.SelectedRows.Count != 1)
            {
                return;
            }

            DataGridViewRow selectedRow = importGridView.SelectedRows[0];
            RomMatch        romMatch    = selectedRow.DataBoundItem as RomMatch;

            if (romMatch == null)
            {
                return;
            }
            List <GameDisc> discs = romMatch.Game.GetDiscs();

            if (discs.Count < 2)
            {
                return;
            }
            romMatch.ResetDisplayInfo();
            romMatch.Game.CurrentDiscNum = 1;
            romMatch.Game.SaveGamePlayInfo();
            List <Game> newGames = new List <Game>();

            for (int x = 0; x < discs.Count; x++)
            {
                GameDisc disc = discs[x];
                disc.Delete();
                if (x > 0)
                {
                    Game newGame = new Game(disc.Path, romMatch.Game.ParentEmulator)
                    {
                        LaunchFile = disc.LaunchFile
                    };
                    newGame.Save();
                    newGames.Add(newGame);
                    importerBindingSource.Insert(selectedRow.Index + x, new RomMatch(newGame)
                    {
                        BindingSourceIndex = romMatch.BindingSourceIndex + x
                    });
                }
            }
            importer.AddGames(newGames);
        }
示例#11
0
        //Approve selected match
        void approveButton_Click(object sender, EventArgs e)
        {
            importGridView.EndEdit();
            if (importGridView.SelectedRows.Count < 1)
            {
                return;
            }

            List <RomMatch> matches = new List <RomMatch>();

            foreach (DataGridViewRow row in importGridView.SelectedRows)
            {
                RomMatch romMatch = row.DataBoundItem as RomMatch;
                if (romMatch == null)
                {
                    continue;
                }

                matches.Add(romMatch);
            }

            if (matches.Count == 0)
            {
                return;
            }
            else if (matches.Count == 1)
            {
                importer.Approve(matches[0]);
            }
            else
            {
                BackgroundTaskHandler handler = new BackgroundTaskHandler();
                handler.StatusDelegate = () => { return("Approving roms..."); };
                handler.ActionDelegate = () =>
                {
                    importer.Approve(matches);
                };
                using (Conf_ProgressDialog dlg = new Conf_ProgressDialog(handler))
                    dlg.ShowDialog();
            }

            updateButtons();
        }
示例#12
0
        void updateButtons()
        {
            if (importGridView.SelectedRows.Count == 0)
            {
                return;
            }
            else if (importGridView.SelectedRows.Count > 1)
            {
                approveButton.Enabled = true;
                findButton.Enabled    = false;
                mergeButton.Image     = MyEmulators2.Properties.Resources.arrow_join;
                importToolTip.SetToolTip(mergeButton, "Merge into multi-disc game");
                mergeButton.Enabled = true;
                return;
            }
            findButton.Enabled = true;

            RomMatch       match  = importGridView.SelectedRows[0].DataBoundItem as RomMatch;
            RomMatchStatus status = match.Status;

            if (match.IsMultiFile)
            {
                mergeButton.Image = MyEmulators2.Properties.Resources.arrow_divide;
                importToolTip.SetToolTip(mergeButton, "Split multi-disc game");
                mergeButton.Enabled = true;
            }
            else
            {
                mergeButton.Image = MyEmulators2.Properties.Resources.arrow_join;
                importToolTip.SetToolTip(mergeButton, "Merge into multi-disc game");
                mergeButton.Enabled = false;
            }

            //Allow approve only if match has been checked and not ignored
            if ((status == RomMatchStatus.Approved || status == RomMatchStatus.NeedsInput) && importGridView.SelectedRows[0].Cells[columnTitle.Name].Value != null)
            {
                approveButton.Enabled = true;
            }
            else
            {
                approveButton.Enabled = false;
            }
        }
示例#13
0
        public List <ScraperResult> GetMatches(RomMatch romMatch, out ScraperResult bestResult, out bool approved)
        {
            bestResult = null;
            approved   = false;

            List <Scraper> lScrapers = new List <Scraper>(scrapers);

            //get parent title to try and match platform
            string searchPlatform = romMatch.Game.ParentEmulator.PlatformTitle;

            if (searchPlatform == "Unspecified")
            {
                searchPlatform = "";
            }

            ScraperSearchParams searchParams = new ScraperSearchParams()
            {
                Term     = RemoveSpecialChars(romMatch.Title),
                Platform = searchPlatform
            };

            List <ScraperResult> results = new List <ScraperResult>();

            foreach (Scraper scraper in lScrapers)
            {
                if (!doWork())
                {
                    return(null);
                }

                results.AddRange(scraper.GetMatches(searchParams));
            }

            searchPlatform = searchPlatform.ToLower();
            results        = sortResults(results, searchPlatform, out approved);
            if (results.Count > 0)
            {
                bestResult = results[0];
            }

            return(results);
        }
示例#14
0
        //checks if a RomMatch with the same ID is already in the BindingSource, if so it's status is reset else it's added
        bool checkRow(RomMatch romMatch)
        {
            if (importerBindingSource.Contains(romMatch))
            {
                return(true);
            }

            foreach (DataGridViewRow row in importGridView.Rows)
            {
                //Game already in gridview, must be previously ignored. Reset status and return
                RomMatch rowRomMatch = (RomMatch)row.DataBoundItem;
                if (romMatch.ID == rowRomMatch.ID)
                {
                    int rowNum = row.Index;
                    importerBindingSource.RemoveAt(rowNum);
                    romMatch.BindingSourceIndex = rowRomMatch.BindingSourceIndex;
                    importerBindingSource.Insert(rowNum, romMatch);
                    return(true);
                }
            }
            return(false);
        }
示例#15
0
        void startThumbRetrieval(RomMatch romMatch, string platformId)
        {
            if (controllerThread != null && controllerThread.IsAlive)
            {
                controllerThread.Join();
            }

            controllerThread = new Thread(delegate()
            {
                lock (syncRoot)
                {
                    stop();
                    if (OnStatusChanged != null)
                    {
                        OnStatusChanged(ThumbRetrieverStatus.Downloading);
                    }
                    retrieveThumbs(romMatch, platformId);
                }
            })
            {
                Name = "ThumbRetrieverController", IsBackground = true
            };
            controllerThread.Start();
        }
示例#16
0
        void searchGame(string title, Game game)
        {
            RomMatch romMatch = new RomMatch(game);

            romMatch.Title = title; //don't alter game's title
            scraperProvider.Update();
            searchThread = new Thread(new ThreadStart(delegate()
            {
                try
                {
                    ScraperResult result; bool approved;
                    romMatch.PossibleGameDetails = scraperProvider.GetMatches(romMatch, out result, out approved);
                    romMatch.GameDetails         = result;
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                }
                finally
                {
                    if (OnSearchCompleted != null)
                    {
                        OnSearchCompleted(romMatch);
                    }
                    if (OnStatusChanged != null)
                    {
                        OnStatusChanged(ThumbRetrieverStatus.Ready);
                    }
                }
            }
                                                      ))
            {
                Name = "ThumbSearchThread"
            };
            searchThread.Start();
        }
示例#17
0
 public void Ignore(RomMatch romMatch)
 {
     Ignore(new RomMatch[] { romMatch });
 }
示例#18
0
 public void UpdateSelectedMatch(RomMatch romMatch, ScraperResult newResult)
 {
     if (newResult == null)
         return;
     lock (lookupSync)
     {
         if (lookupMatch.ContainsKey(romMatch.ID))
         {
             romMatch = lookupMatch[romMatch.ID];
             lock (romMatch.SyncRoot)
             {
                 RemoveFromMatchLists(romMatch);
                 romMatch.Status = RomMatchStatus.Approved;
                 romMatch.CurrentThreadId = null;
                 romMatch.HighPriority = true;
             }
             romMatch.GameDetails = newResult;
             romMatch.Game.InfoChecked = false;
             romMatch.Game.SaveInfoCheckedStatus();
             lookupMatch[romMatch.ID] = romMatch;
             lock (priorityApprovedMatches)
                 priorityApprovedMatches.Add(romMatch);
             setRomStatus(romMatch, RomMatchStatus.Approved);
         }
     }
 }
示例#19
0
 public void Approve(RomMatch romMatch)
 {
     Approve(new RomMatch[] { romMatch });
 }
示例#20
0
        /// <summary>
        /// Resets RomMatch status and re-retrieves info
        /// </summary>
        /// <param name="romMatch"></param>
        public void ReProcess(RomMatch romMatch)
        {
            if (romMatch == null)
                return;

            lock (lookupSync)
            {
                if (lookupMatch.ContainsKey(romMatch.ID))
                    romMatch = lookupMatch[romMatch.ID];
                lock (romMatch.SyncRoot)
                {
                    RemoveFromMatchLists(romMatch);
                    romMatch.Status = RomMatchStatus.PendingMatch;
                    romMatch.HighPriority = true;
                    romMatch.CurrentThreadId = null;
                    romMatch.GameDetails = null;
                    romMatch.PossibleGameDetails = new List<ScraperResult>();
                }
                lookupMatch[romMatch.ID] = romMatch;
            }
            romMatch.Game.InfoChecked = false;
            romMatch.Game.SaveInfoCheckedStatus();
            setRomStatus(romMatch, RomMatchStatus.PendingMatch);
            lock (priorityPendingMatches)
                priorityPendingMatches.Add(romMatch);
        }
示例#21
0
        public void AddGames(IEnumerable<Game> games)
        {
            lock (importStatusLock)
            {
                List<int> gameIds = new List<int>();
                EmulatorsCore.Database.ExecuteTransaction(games, game =>
                {
                    if (game == null)
                        return;

                    if (!game.Id.HasValue)
                        game.Commit();
                    else if (gameIds.Contains(game.Id.Value))
                        return;

                    gameIds.Add(game.Id.Value);
                    RomMatch romMatch;
                    lock (lookupSync)
                    {
                        if (lookupMatch.ContainsKey(game.Id.Value))
                        {
                            romMatch = lookupMatch[game.Id.Value];
                            lock (romMatch.SyncRoot)
                            {
                                RemoveFromMatchLists(romMatch);
                                romMatch.CurrentThreadId = null;
                                romMatch.Status = RomMatchStatus.Removed;
                            }
                        }
                        game.Reset();
                        romMatch = new RomMatch(game);
                        lookupMatch[game.Id.Value] = romMatch;
                    }

                    game.InfoChecked = false;
                    game.SaveInfoCheckedStatus();
                    setRomStatus(romMatch, RomMatchStatus.PendingMatch);
                    lock (priorityPendingMatches)
                        priorityPendingMatches.Add(romMatch);

                });

                if (importerStatus != ImportAction.ImportRestarting && importerStatus != ImportAction.ImportStarted)
                {
                    justRefresh = false;
                    Restart();
                }
            }
        }
示例#22
0
 public RomStatusEventArgs(RomMatch romMatch, RomMatchStatus status)
 {
     RomMatch = romMatch;
     Status = status;
 }
示例#23
0
        void delRomButton_Click(object sender, EventArgs e)
        {
            if (importGridView.SelectedRows.Count < 1)
            {
                return;
            }

            if (MessageBox.Show(
                    "Are you sure you want to delete the selected Game(s) and add them to the ignored files list?",
                    "Delete Game(s)?",
                    MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            List <Game> games = new List <Game>();

            foreach (DataGridViewRow row in importGridView.SelectedRows)
            {
                RomMatch match = row.DataBoundItem as RomMatch;
                if (match != null && match.Game != null)
                {
                    games.Add(match.Game);
                }
            }

            BackgroundTaskHandler <Game> handler = new BackgroundTaskHandler <Game>()
            {
                Items = games
            };

            handler.StatusDelegate = o => { return("removing " + o.Title); };
            handler.ActionDelegate = o =>
            {
                importer.Remove(o.GameID);
                using (ThumbGroup thumbGroup = new ThumbGroup(o))
                {
                    try
                    {
                        if (System.IO.Directory.Exists(thumbGroup.ThumbPath))
                        {
                            System.IO.Directory.Delete(thumbGroup.ThumbPath, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Error deleting {0} thumb directory - {1}", o.Title, ex.Message);
                    }
                }

                Options.Instance.AddIgnoreFile(o.Path);
                foreach (GameDisc disc in o.GetDiscs())
                {
                    Options.Instance.AddIgnoreFile(disc.Path);
                }
                return(true);
            };

            using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler))
                progressDlg.ShowDialog();

            string sql = "DELETE FROM {0} WHERE gameid IN ({1})";
            string ids = "";

            for (int x = 0; x < games.Count; x++)
            {
                if (x > 0)
                {
                    ids += ",";
                }
                ids += games[x].GameID;
            }
            lock (DB.Instance.SyncRoot)
            {
                DB.Instance.Execute(sql, Game.TABLE_NAME, ids);
                DB.Instance.Execute(sql, GameDisc.TABLE_NAME, ids);
            }
        }
示例#24
0
        void refreshRow(int rowIndex)
        {
            if (rowIndex < 0 || rowIndex >= importGridView.Rows.Count)
            {
                return;
            }

            Image    statusIcon = new Bitmap(1, 1);
            string   statusTxt  = "";
            RomMatch romMatch   = importGridView.Rows[rowIndex].DataBoundItem as RomMatch;

            if (romMatch == null)
            {
                return;
            }

            switch (romMatch.Status)
            {
            case RomMatchStatus.PendingHash:     //reset match status
                statusTxt  = "";
                statusIcon = MyEmulators2.Properties.Resources.information;
                break;

            case RomMatchStatus.NeedsInput:     //user input requested
                statusTxt  = "Needs input";
                statusIcon = MyEmulators2.Properties.Resources.information;
                break;

            case RomMatchStatus.Approved:     //match user/auto approved
                statusTxt  = "Approved";
                statusIcon = MyEmulators2.Properties.Resources.approved;
                break;

            case RomMatchStatus.Committed:     //Game updated and commited
                statusTxt  = "Commited";
                statusIcon = MyEmulators2.Properties.Resources.accept;
                break;

            default:
                return;
            }

            //set status icon
            importGridView.Rows[rowIndex].Cells[columnIcon.Name].Value       = statusIcon;
            importGridView.Rows[rowIndex].Cells[columnIcon.Name].ToolTipText = statusTxt;

            //setup ComboBox cell with possible matches
            DataGridViewComboBoxCell comboBox = (DataGridViewComboBoxCell)importGridView.Rows[rowIndex].Cells[columnTitle.Name]; //get the ComboBox cell

            comboBox.DisplayMember = "DisplayMember";
            comboBox.ValueMember   = "Self";
            comboBox.Value         = null;
            comboBox.Items.Clear(); //remove any leftovers

            bool check = romMatch.GameDetails != null;

            foreach (ScraperResult details in romMatch.PossibleGameDetails)
            {
                int index = comboBox.Items.Add(details); //possible matches

                if (check && romMatch.GameDetails.SiteId == details.SiteId)
                {
                    comboBox.Value = comboBox.Items[index];
                }
            }

            if (!check && comboBox.Items.Count > 0)
            {
                comboBox.Value = comboBox.Items[0]; //select first value
            }
        }
示例#25
0
        //update and commit game
        void commitGame(RomMatch romMatch)
        {
            Game dbGame = EmulatorsCore.Database.Get<Game>(romMatch.ID);
            if (dbGame == null)
                return; //game deleted

            ScraperGame details = romMatch.ScraperGame;
            if (details == null)
                return;

            dbGame.Title = details.Title == null ? "" : details.Title;
            dbGame.Developer = details.Company == null ? "" : details.Company;
            dbGame.Description = details.Description == null ? "" : details.Description;
            dbGame.Genre = details.Genre == null ? "" : details.Genre;
            
            int year;
            if (!int.TryParse(details.Year, out year))
                year = 0;
            dbGame.Year = year;
            
            double grade;
            if (!double.TryParse(details.Grade, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out grade))
                grade = 0;
            while (grade > 10)
                grade = grade / 10;
            dbGame.Grade = (int)Math.Round(grade);

            if (!doWork)
                return;

            dbGame.InfoChecked = true;
            dbGame.Commit();
        }
示例#26
0
 void updateItem(RomMatch romMatch, RomMatchStatus newStatus)
 {
     lock (syncRoot)
     {
         RomMatchViewModel model;
         if (itemsDictionary.TryGetValue(romMatch.ID, out model))
         {
             if (newStatus == RomMatchStatus.Ignored || newStatus == RomMatchStatus.Removed)
             {
                 itemsDictionary.Remove(romMatch.ID);
                 items.Remove(model);
             }
             else
             {
                 model.Update();
                 return;
             }
         }
         else
         {
             model = new RomMatchViewModel(romMatch);
             itemsDictionary[romMatch.ID] = model;
             items.Add(model);
         }
     }
     items.FireChange();
 }
示例#27
0
        //This is written a bit weird, we initialise both threads before starting
        //then first thread retrieves list of thumb url's, then starts second thread dloading screens,
        //then starts dloading covers itself
        void retrieveThumbs(RomMatch romMatch, string platformId)
        {
            if (romMatch != null)
            {
                if (romMatch.GameDetails == null)
                {
                    return;
                }
            }
            else if (platformId == null)
            {
                return;
            }

            IEnumerable <string> covers  = null;
            IEnumerable <string> screens = null;
            IEnumerable <string> fanarts = null;

            //initialise first thread
            thumbThread1 = new Thread(new ThreadStart(delegate()
            {
                try
                {
                    //get thumb url's
                    if (romMatch != null)
                    {
                        string dummy1, dummy2;
                        Scraper scraper = romMatch.GameDetails.DataProvider;
                        covers          = scraper.GetCoverUrls(romMatch.GameDetails, out dummy1, out dummy2);
                        screens         = scraper.GetScreenUrls(romMatch.GameDetails, out dummy1, out dummy2);
                        fanarts         = scraper.GetFanartUrls(romMatch.GameDetails, out dummy1);
                    }
                    else
                    {
                        new EmulatorScraper().GetThumbs(platformId, out covers, out screens);
                    }

                    if (!doWork)
                    {
                        return;
                    }

                    //start second thread retrieving screens
                    thumbThread2.Start();
                    //then retrieve covers
                    downloadThumbs(covers, true);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                }
                finally
                {
                    if (thumbThread2 != null && thumbThread2.IsAlive)
                    {
                        thumbThread2.Join();
                    }
                    if (OnDownloadComplete != null)
                    {
                        OnDownloadComplete();
                    }
                    if (OnStatusChanged != null)
                    {
                        OnStatusChanged(ThumbRetrieverStatus.Ready);
                    }
                }
            }
                                                      ))
            {
                Name = "ThumbDownloadThread1"
            };

            //initialise second thread
            thumbThread2 = new Thread(new ThreadStart(delegate()
            {
                try
                {
                    downloadThumbs(screens, false);
                    downloadThumbs(fanarts, false);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                }
            }
                                                      ))
            {
                Name = "ThumbDownloadThread2"
            };

            //start dload
            thumbThread1.Start();
        }
示例#28
0
 bool saveImage(SafeImage image, RomMatch romMatch, ThumbGroup thumbGroup, ThumbType thumbType)
 {
     if (!doWork)
         return false;
     lock (romMatch.SyncRoot)
     {
         if (!romMatch.OwnedByThread())
             return false;
         if (image != null)
         {
             thumbGroup.GetThumbObject(thumbType).SetSafeImage(image.Image);
             thumbGroup.SaveThumb(thumbType);
         }
     }
     return true;
 }
示例#29
0
 void setRomStatus(RomMatch romMatch, RomMatchStatus status)
 {
     if (ImporterStatus == ImportAction.ImportRestarting)
         return;
     OnRomStatusChanged(new RomStatusEventArgs(romMatch, status));
 }
示例#30
0
        SafeImage getImage(string url, RomMatch romMatch)
        {
            if (string.IsNullOrEmpty(url))
                return null;
            BitmapDownloadResult result = ImageHandler.BeginBitmapFromWeb(url);
            if (result == null)
                return null;

            while (!result.IsCompleted)
            {
                if (!doWork || !romMatch.OwnedByThread())
                {
                    result.Cancel();
                    return null;
                }
                Thread.Sleep(100);
            }
            return result.SafeImage;
        }
 //stop any running threads, clear the thumb panels and
 //start downloading thumbs
 void getThumbs(RomMatch romMatch)
 {
     progressBar.Visible = true;
     statusLabel.Text    = "Downloading thumbs...";
     thumbRetriever.RetrieveThumbs(romMatch);
 }
示例#32
0
        // removes the given match from all pending process lists
        private void RemoveFromMatchLists(RomMatch match)
        {
            lock (pendingMatches)
                if (pendingMatches.Contains(match))
                    pendingMatches.Remove(match);

            lock (priorityPendingMatches)
                if (priorityPendingMatches.Contains(match))
                    priorityPendingMatches.Remove(match);

            lock (matchesNeedingInput)
                if (matchesNeedingInput.Contains(match))
                    matchesNeedingInput.Remove(match);

            lock (approvedMatches)
                if (approvedMatches.Contains(match))
                    approvedMatches.Remove(match);

            lock (priorityApprovedMatches)
                if (priorityApprovedMatches.Contains(match))
                    priorityApprovedMatches.Remove(match);

            lock (commitedMatches)
                if (commitedMatches.Contains(match))
                    commitedMatches.Remove(match);

            lock (lookupSync)
                if (lookupMatch.ContainsKey(match.ID))
                    lookupMatch.Remove(match.ID);
        }
示例#33
0
        void addToList(RomMatch romMatch, RomMatchStatus newStatus, List<RomMatch> list, List<RomMatch> priorityList)
        {
            lock (romMatch.SyncRoot)
            {
                if (!romMatch.OwnedByThread())
                    return;
                romMatch.CurrentThreadId = null;
                romMatch.Status = newStatus;

                if (priorityList != null && romMatch.HighPriority)
                    lock (priorityList)
                        priorityList.Add(romMatch);
                else if (list != null)
                    lock (list)
                        list.Add(romMatch);
                setRomStatus(romMatch, newStatus);
            }
        }
        public List<ScraperResult> GetMatches(RomMatch romMatch, out ScraperResult bestResult, out bool approved)
        {
            bestResult = null;
            approved = false;
            List<Scraper> lScrapers;

            lock (scraperSync)
                lScrapers = new List<Scraper>(scrapers);

            //get parent title to try and match platform
            string searchPlatform = romMatch.Game.ParentEmulator.Platform;
            if (searchPlatform == "Unspecified")
                searchPlatform = "";

            string searchTerm = RemoveSpecialChars(romMatch.SearchTitle);
            string filename = romMatch.IsDefaultSearchTerm ? romMatch.Filename : null;
            ScraperSearchParams searchParams = new ScraperSearchParams()
            {
                Term = searchTerm,
                Platform = searchPlatform,
                Filename = filename
            };

            List<ScraperResult> results = new List<ScraperResult>();
            int priority = 0;
            foreach (Scraper scraper in lScrapers)
            {
                if (!doWork())
                    return null;
                foreach (ScraperResult result in scraper.GetMatches(searchParams))
                {
                    result.Priority = priority;
                    results.Add(result);
                }
                priority++;
            }

            searchPlatform = searchPlatform.ToLower();
            results = sortResults(results, searchPlatform, out approved);
            if (results.Count > 0)
                bestResult = results[0];

            return results;
        }
示例#35
0
 public void RetrieveThumbs(RomMatch romMatch)
 {
     startThumbRetrieval(romMatch, null);
 }