コード例 #1
0
        public static HtmlBuilder Report(GenericDescription desc)
        {
            if (desc == null) return null;

            HtmlBuilder sb = new HtmlBuilder();

            Report(sb, desc);

            return sb;
        }
コード例 #2
0
        public static HtmlBuilder Report(HtmlBuilder Builder, GenericDescription desc)
        {
            if (desc == null) return Builder;

            HtmlBuilder sb = Builder;

            if (desc.Name != null) sb.AddSection(desc.Name);

            if (!string.IsNullOrEmpty(desc.Description))  sb.AddLine(desc.Description.Replace("\n", "<br/>\n"));
            if (desc.DateSpecified) sb.AddLabel("Created", desc.Date.ToString("R"));
            if (!string.IsNullOrEmpty(desc.License)) sb.AddLabel("License", desc.License);
            if (desc.Author != null)
            {
                if (!string.IsNullOrEmpty(desc.Author.Name)) sb.AddLabel("Author", desc.Author.Name);
                if (!string.IsNullOrEmpty(desc.Author.Email)) sb.AddLabel("Email", desc.Author.Email);
                if (!string.IsNullOrEmpty(desc.Author.Homepage)) sb.AddLabel("Web", string.Format("<a href=\"{0}\">{0}</a>", desc.Author.Homepage));
            }
            if (!string.IsNullOrEmpty(desc.Comments)) sb.AddLine(desc.Comments.Replace("\n", "<br/>\n"));
            if (desc.Name != null) sb.EndSection();

            return sb;
        }
コード例 #3
0
        public static HtmlBuilder Report(GenericDescription desc)
        {
            if (desc == null) return null;

            HtmlBuilder sb = new HtmlBuilder();

            if (desc.Name != null) sb.AddSection(desc.Name);

            sb.AddLine(desc.Description);
            if (desc.DateSpecified) sb.AddLabel("Created", desc.Date.ToString());
            if (desc.License != null) sb.AddLabel("License", desc.License);
            if (desc.Author != null)
            {
                if (desc.Author.Name != null) sb.AddLabel("Author", desc.Author.Name);
                if (desc.Author.Email != null) sb.AddLabel("Email", desc.Author.Email);
                if (desc.Author.Homepage != null) sb.AddLabel("Web", string.Format("<a href=\"{0}\">{0}</a>", desc.Author.Homepage));
            }
            sb.AddLine(desc.Comments);
            if (desc.Name != null)  sb.EndSection();

            return sb;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
ファイル: Welcome.cs プロジェクト: rfrfrf/SokoSolve-Sokoban
        /// <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());
        }
コード例 #6
0
        public void Add(HtmlBuilder body)
        {
            if (body == null) return;

            htmlBody.Append(body.GetHTMLBody());
        }
コード例 #7
0
        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;
        }