private void ParseDatabaseFile(string databasePath, string songsFolder)
        {
            try
            {
                OsuDbAPI.OsuDbFile osuDatabase = new OsuDbAPI.OsuDbFile(databasePath);

                labelTask.Content = "Processing beatmaps from database...";

                Dictionary <string, string> dTempDatabase = new Dictionary <string, string>();

                int iQueue = 0;

                foreach (OsuDbAPI.Beatmap beatMap in osuDatabase.Beatmaps)
                {
                    progressBar.Value = (100.0 / osuDatabase.Beatmaps.Count) * iQueue++;

                    OsuDbAPI.Beatmap dbBeatmap = beatMap;

                    if (!ReferenceEquals(dbBeatmap, null) && !string.IsNullOrEmpty(dbBeatmap.Hash))
                    {
                        string beatmapPath = string.Format("{0}\\{1}\\{2}", songsFolder, dbBeatmap.FolderName, dbBeatmap.OsuFile);
                        if (!dTempDatabase.ContainsKey(dbBeatmap.Hash))
                        {
                            dTempDatabase.Add(dbBeatmap.Hash, beatmapPath);
                        }
                    }
                }

                progressBar.Value = 100.0;
                dMapsDatabase     = dTempDatabase;

                labelTask.Content = "Finished processing beatmaps from osuDB.";
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error reading osuDB \n" + exp.ToString());
            }
        }
        private Beatmap readBeatmap()
        {
            int n;
            this.fileReader.ReadInt32();
            Beatmap beatmap = new Beatmap();
            beatmap.ArtistName = this.readNullableString();
            beatmap.ArtistNameUnicode = this.readNullableString();
            beatmap.SongTitle = this.readNullableString();
            beatmap.SongTitleUnicode = this.readNullableString();
            beatmap.Creator = this.readNullableString();
            beatmap.Difficulty = this.readNullableString();
            beatmap.AudioFile = this.readNullableString();
            beatmap.Hash = this.readNullableString();
            beatmap.OsuFile = this.readNullableString();
            beatmap.RankedStatus = this.fileReader.ReadByte();
            beatmap.NumHitcircles = this.fileReader.ReadUInt16();
            beatmap.NumSliders = this.fileReader.ReadUInt16();
            beatmap.NumSpinners = this.fileReader.ReadUInt16();
            beatmap.LastModificationTime = new DateTime(this.fileReader.ReadInt64());
            beatmap.ApproachRate = this.fileReader.ReadSingle();
            beatmap.CircleSize = this.fileReader.ReadSingle();
            beatmap.HPDrain = this.fileReader.ReadSingle();
            beatmap.OverallDifficulty = this.fileReader.ReadSingle();
            beatmap.SliderVelocity = this.fileReader.ReadDouble();
            for (int i = 0; i < 4; i++)
            {
                n = this.fileReader.ReadInt32();
                for (int j = 0; j < n; j++)
                {
                    this.readIntDoublePair();
                }
            }
            beatmap.DrainTimeSeconds = this.fileReader.ReadInt32();
            beatmap.DrainTimeMilliseconds = this.fileReader.ReadInt32();
            beatmap.PreviewPoint = this.fileReader.ReadInt32();
            n = this.fileReader.ReadInt32();
            for (int j = 0; j < n; j++)
            {
                this.readTimingPoint();
            }
            beatmap.ID = this.fileReader.ReadInt32();
            beatmap.SetID = this.fileReader.ReadInt32();
            beatmap.ThreadID = this.fileReader.ReadInt32();
            beatmap.GradeOsu = this.fileReader.ReadByte();
            beatmap.GradeTaiko = this.fileReader.ReadByte();
            beatmap.GradeCTB = this.fileReader.ReadByte();
            beatmap.GradeMania = this.fileReader.ReadByte();
            beatmap.LocalOffset = this.fileReader.ReadUInt16();
            beatmap.StackLeniency = this.fileReader.ReadSingle();
            beatmap.GameMode = this.fileReader.ReadByte();
            beatmap.Source = this.readNullableString();
            beatmap.Tags = this.readNullableString();
            beatmap.OnlineOffset = this.fileReader.ReadUInt16();
            beatmap.Font = this.readNullableString();
            beatmap.Unplayed = this.fileReader.ReadBoolean();
            beatmap.LastPlayed = new DateTime(this.fileReader.ReadInt64());
            beatmap.Osz2 = this.fileReader.ReadBoolean();
            beatmap.FolderName = this.readNullableString();
            beatmap.LastCheck = new DateTime(this.fileReader.ReadInt64());
            beatmap.IgnoreHitSounds = this.fileReader.ReadBoolean();
            beatmap.IgnoreSkin = this.fileReader.ReadBoolean();
            beatmap.DisableStoryboard = this.fileReader.ReadBoolean();
            beatmap.DisableVideo = this.fileReader.ReadBoolean();
            beatmap.VisualOverride = this.fileReader.ReadBoolean();
            beatmap.LastModTime = this.fileReader.ReadInt32();
            beatmap.ManiaScrollSpeed = this.fileReader.ReadByte();

            return beatmap;
        }
        private Beatmap readBeatmap()
        {
            int n;

            // only need to read this int if the version is < 20191107.
            // see https://github.com/ppy/osu-wiki/commit/7ce3b8988d9945fe5867029a65750b40d66a3820
            if (this.Version < 20191107)
            {
                this.fileReader.ReadInt32();
            }
            Beatmap beatmap = new Beatmap();

            beatmap.ArtistName        = this.readNullableString();
            beatmap.ArtistNameUnicode = this.readNullableString();
            beatmap.SongTitle         = this.readNullableString();
            beatmap.SongTitleUnicode  = this.readNullableString();
            beatmap.Creator           = this.readNullableString();
            beatmap.Difficulty        = this.readNullableString();
            beatmap.AudioFile         = this.readNullableString();
            beatmap.Hash                 = this.readNullableString();
            beatmap.OsuFile              = this.readNullableString();
            beatmap.RankedStatus         = this.fileReader.ReadByte();
            beatmap.NumHitcircles        = this.fileReader.ReadUInt16();
            beatmap.NumSliders           = this.fileReader.ReadUInt16();
            beatmap.NumSpinners          = this.fileReader.ReadUInt16();
            beatmap.LastModificationTime = new DateTime(this.fileReader.ReadInt64());
            beatmap.ApproachRate         = this.fileReader.ReadSingle();
            beatmap.CircleSize           = this.fileReader.ReadSingle();
            beatmap.HPDrain              = this.fileReader.ReadSingle();
            beatmap.OverallDifficulty    = this.fileReader.ReadSingle();
            beatmap.SliderVelocity       = this.fileReader.ReadDouble();
            for (int i = 0; i < 4; i++)
            {
                n = this.fileReader.ReadInt32();
                for (int j = 0; j < n; j++)
                {
                    this.readIntDoublePair();
                }
            }
            beatmap.DrainTimeSeconds      = this.fileReader.ReadInt32();
            beatmap.DrainTimeMilliseconds = this.fileReader.ReadInt32();
            beatmap.PreviewPoint          = this.fileReader.ReadInt32();
            n = this.fileReader.ReadInt32();
            for (int j = 0; j < n; j++)
            {
                this.readTimingPoint();
            }
            beatmap.ID                = this.fileReader.ReadInt32();
            beatmap.SetID             = this.fileReader.ReadInt32();
            beatmap.ThreadID          = this.fileReader.ReadInt32();
            beatmap.GradeOsu          = this.fileReader.ReadByte();
            beatmap.GradeTaiko        = this.fileReader.ReadByte();
            beatmap.GradeCTB          = this.fileReader.ReadByte();
            beatmap.GradeMania        = this.fileReader.ReadByte();
            beatmap.LocalOffset       = this.fileReader.ReadUInt16();
            beatmap.StackLeniency     = this.fileReader.ReadSingle();
            beatmap.GameMode          = this.fileReader.ReadByte();
            beatmap.Source            = this.readNullableString();
            beatmap.Tags              = this.readNullableString();
            beatmap.OnlineOffset      = this.fileReader.ReadUInt16();
            beatmap.Font              = this.readNullableString();
            beatmap.Unplayed          = this.fileReader.ReadBoolean();
            beatmap.LastPlayed        = new DateTime(this.fileReader.ReadInt64());
            beatmap.Osz2              = this.fileReader.ReadBoolean();
            beatmap.FolderName        = this.readNullableString();
            beatmap.LastCheck         = new DateTime(this.fileReader.ReadInt64());
            beatmap.IgnoreHitSounds   = this.fileReader.ReadBoolean();
            beatmap.IgnoreSkin        = this.fileReader.ReadBoolean();
            beatmap.DisableStoryboard = this.fileReader.ReadBoolean();
            beatmap.DisableVideo      = this.fileReader.ReadBoolean();
            beatmap.VisualOverride    = this.fileReader.ReadBoolean();
            beatmap.LastModTime       = this.fileReader.ReadInt32();
            beatmap.ManiaScrollSpeed  = this.fileReader.ReadByte();

            return(beatmap);
        }