public void write(Dictionary<int, TeamController> teamControllers, double trophyTime)
        {
            moveMainTexFile();
            List<Team> trophyTeamList = new List<Team>();
            // create pdf for every category and csv if necessary
            foreach (int key in teamControllers.Keys)
            {
                var teamController = teamControllers[key];
                createPdf("Klasse " + key, "Klasse " + key, teamController, false);

                trophyTeamList.AddRange(teamController.Teams);
                if (exportCsv)
                {
                    doExportCsv("Ergebnis Klasse " + key, teamController, false);
                }
            }

            // custom sorting for trophy ranking
            trophyTeamList.Sort(delegate(Team x, Team y)
            {
                double xDifferenceToTrophyTime = Math.Abs(trophyTime - x.TrophyTime);
                double yDifferenceToTrophyTime = Math.Abs(trophyTime - y.TrophyTime);

                return xDifferenceToTrophyTime.CompareTo(yDifferenceToTrophyTime);
            });

            // create pdf for trophy ranking and csv if necessary
            TeamController trophyController = new TeamController(trophyTeamList);
            createPdf("Trophy-Wertung", "Trophy-Wertung - Trophy-Zeit: " + trophyTime.ToString("N") + "s", trophyController, true);

            if (exportCsv)
            {
                doExportCsv("Ergebnis Trophy-Wertung", trophyController, true);
            }

            cleanUp();
        }
        private void createPdf(string fileName, string headline, TeamController teamController, bool isTrophy)
        {
            TeamControllerToLatexController latexWriter = new TeamControllerToLatexController(teamController);
            latexWriter.setTitle(headline);
            latexWriter.setIsTrophy(isTrophy);

            File.WriteAllText(FolderPath + "\\table.tex", latexWriter.GenerateLatex());

            Process latexCompile = new Process();
            latexCompile.StartInfo.FileName = "pdflatex";
            latexCompile.StartInfo.Arguments = "-output-directory=\"" + FolderPath + "\" \"" + FolderPath + "\\main.tex\"";

            latexCompile.Start();
            latexCompile.WaitForExit();

            latexCompile.Start();
            latexCompile.WaitForExit();

            if (File.Exists(FolderPath + "\\" + fileName + ".pdf"))
            {
                File.Delete(FolderPath + "\\" + fileName + ".pdf");
            }
            File.Move(FolderPath + "\\main.pdf", FolderPath + "\\" + fileName + ".pdf");
        }
        private void doExportCsv(string title, TeamController teamController, bool isTrophy)
        {
            using (fileHelperEngine.BeginWriteFile(FolderPath + "\\" + title + ".csv"))
            {
                ObservableCollection<Team> teamList = teamController.Teams;

                foreach (Team t in teamList)
                {
                    foreach (Racer r in t.Skiers)
                    {
                        ExportRacer w = new ExportRacer(r);
                        fileHelperEngine.WriteNext(w);
                    }
                    ExportRacer sledger = new ExportRacer(t.Sledger);
                    if (!isTrophy)
                    {
                        sledger.TeamTime = t.TeamTime;
                    }
                    else
                    {
                        sledger.TeamTime = t.TrophyTime;
                    }
                    fileHelperEngine.WriteNext(sledger);
                }
            }
        }
 public TeamControllerToLatexController(TeamController tc)
 {
     teamController = tc;
     isTrophy = false;
 }