private bool ExportRoundsAsTxtFormatted(string path)
{
StringBuilder strBuilder = new StringBuilder();
foreach (Round round in this.tournament.Rounds)
{
strBuilder.AppendLine("[code=html:0]");
strBuilder.AppendLine("+---------------------------------------------------------+");
strBuilder.AppendFormat("+- {1} {0} --------------------------------------------+", round.Number.ToString().PadLeft(2, ' '), StringTable.CreateRoundWindow_Runda.PadRight(7, ' '));
strBuilder.AppendLine();
strBuilder.AppendLine("+---------------------------------------------------------+");
string wynik = (StringTable.RoundControl_Wynik.Length > 5 ? StringTable.RoundControl_Wynik.Substring(0, 5) : StringTable.RoundControl_Wynik);
strBuilder.AppendFormat("| # | {0} | {2} | {1} |", StringTable.CreateRoundWindow_Gracz1.PadRight(19, ' '), StringTable.CreateRoundWindow_Gracz2.PadRight(19, ' '), wynik.PadRight(5, ' '));
strBuilder.AppendLine();
strBuilder.AppendLine("+---------------------------------------------------------+");
foreach (Game game in round.Games)
{
string name1 = string.Format("{0}", game.Player1Alias);
if (name1.Length > 19) name1 = name1.Substring(0, 19);
string name2 = string.Format("{0}", game.Player2Alias);
if (name2.Length > 19) name2 = name2.Substring(0, 19);
strBuilder.AppendFormat("| {0} | {1} | {2} | {3} |",
game.Number.ToString().PadLeft(3, ' '),
name1.PadLeft(19, ' '),
game.Player1Score.ToString() + " : " + game.Player2Score.ToString(),//Enums.GameScoreToString(game.Score).PadRight(5, ' '),
name2.PadRight(19, ' '));
strBuilder.AppendLine();
}
strBuilder.AppendLine("+---------------------------------------------------------+");
strBuilder.AppendLine("[/code]");
strBuilder.AppendLine();
strBuilder.AppendLine();
}
using (StreamWriter outfile = new StreamWriter(path))
{
outfile.Write(strBuilder.ToString());
}
return true;
}