private void manualAssignButton_Click(object sender, EventArgs e) { unapprovedGrid.EndEdit(); foreach (DataGridViewRow currRow in unapprovedGrid.SelectedRows) { MovieMatch selectedMatch = (MovieMatch)currRow.DataBoundItem; ManualAssignPopup popup = new ManualAssignPopup(selectedMatch); popup.ShowDialog(this); if (popup.DialogResult == DialogResult.OK) { // create a movie with the user supplied information DBMovieInfo movie = new DBMovieInfo(); movie.Title = popup.Title; movie.Year = popup.Year.GetValueOrDefault(0); // update the match PossibleMatch selectedMovie = new PossibleMatch(); selectedMovie.Movie = movie; MatchResult result = new MatchResult(); result.TitleScore = 0; result.YearScore = 0; result.ImdbMatch = true; selectedMovie.Result = result; selectedMatch.PossibleMatches.Add(selectedMovie); selectedMatch.Selected = selectedMovie; ThreadStart actions = delegate { // Manually Assign Movie MovingPicturesCore.Importer.ManualAssign(selectedMatch); }; Thread thread = new Thread(actions); thread.Name = "ManualUpdateThread"; thread.Start(); } } }
// Returns a possible match set for the given media file(s) // using the given custom search string private void GetMatches(MovieMatch mediaMatch) { List<DBMovieInfo> movieList; List<PossibleMatch> rankedMovieList = new List<PossibleMatch>(); // notify any listeners we are checking for matches if (MovieStatusChanged != null) MovieStatusChanged(mediaMatch, MovieImporterAction.GETTING_MATCHES); // Get the MovieSignature MovieSignature signature = mediaMatch.Signature; // grab a list of movies from our dataProvider and rank each returned movie on // how close a match it is if (mediaMatch.PreferedDataSource != null) movieList = mediaMatch.PreferedDataSource.Provider.Get(signature); else movieList = MovingPicturesCore.DataProviderManager.Get(signature); DBSourceInfo lastSource = null; bool multipleSources = false; foreach (DBMovieInfo currMovie in movieList) { if (lastSource == null) lastSource = currMovie.PrimarySource; // check if our list of possible matches is from multiple sources if (lastSource != currMovie.PrimarySource) multipleSources = true; // Create a Possible Match object PossibleMatch currMatch = new PossibleMatch(); // Add the movie currMatch.Movie = currMovie; // Get the matching score for this movie currMatch.Result = signature.GetMatchResult(currMovie); // Add the match to the ranked movie list rankedMovieList.Add(currMatch); } // if we have multiple sources, make sure we display info about where each possible // match is coming from if (multipleSources) foreach (PossibleMatch currMatch in rankedMovieList) currMatch.DisplaySourceInfo = true; mediaMatch.PossibleMatches = rankedMovieList; }