internal IList<MoviePage> ExtractSearchResults(string htmlPage) { IList<MoviePage> result = new List<MoviePage> (); IList<MatchDegrees> matchDegrees = FindMatchDegrees (htmlPage) .OrderByDescending (x => x.Index) .ToList (); Regex regex = new Regex ( "[0-9]+\\. <a href=\"([^\"]+)[^>]+>[^>]+>([^<]+)<font size=\"1\"> / ([^<^>]+)</font> \\(([0-9]+)\\)</a><br>"); MatchCollection matches = regex.Matches (htmlPage); foreach (Match match in matches) { string movieName = Utils.DecodeHtml (match.Groups[2].Value); string originalMovieName = Utils.DecodeHtml (match.Groups[3].Value); string relativeLink = match.Groups[1].Value; string yearAsString = match.Groups[4].Value; DegreeOfMatch degree = matchDegrees.First (x => x.Index < match.Index).Degree; int year; if (!int.TryParse (yearAsString, out year)) throw new Exception ("Year could not be parsed as string: \"" + yearAsString + "\""); MoviePage newMovie = new MoviePage (movieName, originalMovieName, relativeLink, year, degree); result.Add (newMovie); } return result; }
private void MouseDoubleClick(object sender, MouseButtonEventArgs args) { MoviePageVM selected = gridView.SelectedItem as MoviePageVM; if (selected == null) return; SelectedMoviePage = selected.SourceDataModel; Close (); }