private void ShowStats(DatabaseImportStats stats)
        {
            if (stats == null)
            {
                return;
            }

            var total = stats.GetTotal();

            MessageBox.Show(
                string.Format(
                    "Finished.\n" +
                    "Games imported: {0}\n" +
                    "Games skipped: {1}\n" +
                    "Positions imported: {2}\n" +
                    "Average white elo: {3}\n" +
                    "Average black elo: {4}\n" +
                    "Min elo: {5}\n" +
                    "Max elo: {6}\n" +
                    "Min date: {7}\n" +
                    "Max date: {8}",
                    total.NumGames,
                    total.NumSkippedGames,
                    total.NumPositions,
                    total.TotalWhiteElo / total.NumGamesWithElo,
                    total.TotalBlackElo / total.NumGamesWithElo,
                    total.MinElo,
                    total.MaxElo,
                    total.MinDate.ToString('-'),
                    total.MaxDate.ToString('-')
                    )
                );
        }
        private void ProgressCallback(JsonValue progressReport)
        {
            if (progressReport["operation"] == "import")
            {
                if (progressReport.ContainsKey("imported_file_path"))
                {
                    string path = progressReport["imported_file_path"];
                    SetFileImported(path);

                    ulong filesize = (ulong)new System.IO.FileInfo(path).Length;
                    TotalFileSizeAlreadyImported += filesize;
                    SetImportProgress((int)(TotalFileSizeAlreadyImported * 100 / TotalFileSizeBeingImported));
                }

                if (progressReport["finished"] == true && progressReport.ContainsKey("stats"))
                {
                    ImportStats = new DatabaseImportStats(progressReport["stats"]);
                }
            }
            else if (progressReport["operation"] == "merge")
            {
                SetMergeProgress((int)(progressReport["overall_progress"] * 100.0));
            }
            else
            {
                return;
            }

            if (InvokeRequired)
            {
                Invoke(new Action(RefreshProgress));
            }
            else
            {
                RefreshProgress();
            }
        }