public static HtmlBuilder Report(Puzzle puzzle, StaticImage drawing) { HtmlBuilder sb = new HtmlBuilder(); sb.AddSection(puzzle.Details.Name); sb.Add("<table class=\"tableformat\"><tr><td>"); GenericDescription desc = new GenericDescription(puzzle.Details); desc.Name = null; // so that the H1 tag is not generated here sb.Add(Report(desc)); if (puzzle.Category != null) sb.AddLabel("Category", puzzle.Category.Details.Name); sb.AddLabel("Order", puzzle.Order.ToString()); sb.AddLabel("Rating", puzzle.Rating); sb.AddLabel("PuzzleID", puzzle.PuzzleID); sb.AddLabel("Size", "{0}x{1}, {2} crates, {3} floor space", puzzle.MasterMap.Map.Size.X, puzzle.MasterMap.Map.Size.Y, puzzle.MasterMap.Map.Count(Cell.Crate), puzzle.MasterMap.Map.Count(Cell.Floor) ); if (puzzle.HasAlternatives) { sb.AddLabel("Alternatives", puzzle.Alternatives.Count.ToString()); } sb.Add("</td><td>"); if (drawing != null) { sb.Add(puzzle.MasterMap, drawing.Draw(puzzle.MasterMap.Map), null); } sb.Add("</td></tr></table>"); return sb; }
/// <summary> /// Set the HTML /// </summary> private void InitHTML() { StringBuilder html = new StringBuilder(File.ReadAllText(FileManager.getContent("$html/Welcome.html"))); XmlProvider prov = new XmlProvider(); Core.Model.Library lib = prov.Load(ProfileController.Current.LibraryLastFile); HtmlBuilder leftpane = new HtmlBuilder(); HtmlBuilder rightpane = new HtmlBuilder(); Current = lib.GetPuzzleByID(ProfileController.Current.LibraryLastPuzzle); if (Current == null) { ProfileController.Current.LibraryLastPuzzle = lib.Puzzles[0].PuzzleID; Current = lib.Puzzles[0]; } if (Current != null) { leftpane.AddSection(null); HtmlReporter.Report(leftpane, Current.Library.Details); rightpane.AddLine("{0}/{1} '<b>{2}</b>'", Current.Order, Current.Library.Puzzles.Count, Current.Details.Name); rightpane.Add("<a href=\"app://Puzzle/{0}\">", Current.PuzzleID); rightpane.Add(Current.MasterMap, DrawingHelper.DrawPuzzle(Current.MasterMap), null); rightpane.Add("</a>"); rightpane.AddLine("<br/><i>Click to play...</i>"); } else { // Library has no puzzles } html = html.Replace("[Details]", leftpane.GetHTMLBody()); html = html.Replace("[Image]", rightpane.GetHTMLBody()); html = html.Replace("[BASEHREF]", FileManager.getContent("$html")); html = html.Replace("[USERNAME]", ProfileController.Current.UserName); htmlView.SetHTML(html.ToString()); }
public static HtmlBuilder Report(PuzzleMap item, StaticImage drawing) { HtmlBuilder sb = new HtmlBuilder(); sb.Add(Report(item.Details)); if (drawing != null) { sb.Add(item, drawing.Draw(item.Map), null); } if (item.HasSolution) { sb.AddLabel("Solutions", item.Solutions.Count.ToString()); } return sb; }