private Beatmap FindBeatmapInDatabase(Replay replay) { Beatmap beatMap = null; if (!string.IsNullOrEmpty(osuFilePath)) { beatMap = new Beatmap(osuFilePath); } if (!ReferenceEquals(beatMap, null) && replay.MapHash.Equals(beatMap.BeatmapHash)) { return(beatMap); } else { if (dMapsDatabase.ContainsKey(replay.MapHash)) { return(new Beatmap(dMapsDatabase[replay.MapHash])); } else { return(null); } } }
private void button_AnalyzeFolder_Click(object sender, RoutedEventArgs e) { var sb = new StringBuilder(); labelTask.Content = "Analyzing replays in folder..."; try { var directory = new DirectoryInfo(settings.pathReplays); var files = directory.GetFiles(); var replaysFiles = (from file in files where file.Extension == ".osr" select file.FullName).ToList(); progressBar_Analyzing.Value = 0.0; int iQueue = 0; foreach (string file in replaysFiles) { progressBar_Analyzing.Value = (100.0 / replaysFiles.Count) * iQueue++; string path = file; Replay replay = new Replay(path, true, true); Beatmap map = FindBeatmapInDatabase(replay); sb.AppendLine(Program.ReplayAnalyzing(map, replay, onlyMainInfo_checkbox.IsChecked != null && onlyMainInfo_checkbox.IsChecked.Value).ToString()); } } catch (Exception exp) { MessageBox.Show(exp.ToString()); } finally { progressBar_Analyzing.Value = 100.0; labelTask.Content = "Finished analyzing replays in folder..."; SaveResult(sb); } }
private void button_AnalyzeReplays_Click(object sender, RoutedEventArgs e) { Beatmap beatMap = null; StringBuilder sb = new StringBuilder(); labelTask.Content = "Analyzing replays..."; progressBar_Analyzing.Value = 0; bool onlyMainInfo = onlyMainInfo_checkbox.IsChecked != null && onlyMainInfo_checkbox.IsChecked.Value; var tasks = new List <Task>(); if (listReplays.Count > 0) { bool found = false; foreach (Replay replay in listReplays) { var a = Task.Run(() => { beatMap = FindBeatmapInDatabase(replay); string newLine; if (!ReferenceEquals(beatMap, null)) { found = true; newLine = Program.ReplayAnalyzing(beatMap, replay, onlyMainInfo).ToString(); } else { newLine = $"{replay.Filename} does not correspond to any known map"; } lock (sb) { sb.AppendLine(newLine); } doOnUIThread(() => progressBar_Analyzing.Value += (100.0 / listReplays.Count)); }); tasks.Add(a); } Task.Run(() => { Task.WaitAll(tasks.ToArray()); doOnUIThread(() => { labelTask.Content = "Finished analyzing replays."; SaveResult(sb); if (!found) { sb.AppendLine("You have probably not imported the map(s). Make sure to load your osu DB using the button."); } }); }); } else { MessageBox.Show("Error! No replays selected."); } }