Esempio n. 1
0
        public XmlElement CreateGenericDescriptionTable(GenericDescription desc, bool displayname)
        {
            XmlElement table = report.CreateElement("table");
            table.SetAttribute("class", "tableinfo");

            if (displayname && !string.IsNullOrEmpty(desc.Name))
            table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "Name", desc.Name);

            if (desc.DateSpecified)
            table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "Created", desc.Date);

            if (!string.IsNullOrEmpty(desc.Description))
            table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "Description", desc.Description);
            if (desc.Author != null)
            {
                if (!string.IsNullOrEmpty(desc.Author.Name))
                table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "Author", desc.Author.Name);
            if (!string.IsNullOrEmpty(desc.Author.Email ))
                table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "Email", desc.Author.Email);
            if (!string.IsNullOrEmpty(desc.Author.Homepage))
                table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "Web", desc.Author.Homepage);
            }
            if (!string.IsNullOrEmpty(desc.License))
            table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "License", desc.License);
            if (!string.IsNullOrEmpty(desc.Comments))
            table.InnerXml += string.Format("<tr><th>{0}</th><td>{1}</td></tr>", "Comments", desc.Comments);
            return table;
        }
Esempio n. 2
0
 public PuzzleMap(PuzzleMap clone)
 {
     puzzle = clone.puzzle;
     map = new SokobanMap(clone.map);
     solutions = new List<Solution>(clone.solutions);
     details = new GenericDescription(clone.details);
     rating = clone.rating;
     mapID = clone.mapID;
     isMasterMap = clone.IsMasterMap;
 }
Esempio n. 3
0
        public static HtmlBuilder Report(GenericDescription desc)
        {
            if (desc == null) return null;

            HtmlBuilder sb = new HtmlBuilder();

            Report(sb, desc);

            return sb;
        }
        public GenericDescription(GenericDescription copy)
        {
            if (copy == null) return;

            this.Name = copy.Name;
            this.Description = copy.Description;
            this.Author = copy.Author;
            this.Date = copy.Date;
            this.DateSpecified = copy.DateSpecified;
            this.License = copy.License;
            this.Comments = copy.Comments;
        }
Esempio n. 5
0
        public Library(Guid LibraryGUID)
        {
            idProvider = new IDProvider(0);

            puzzles = new List<Puzzle>();
            categories = new Tree<Category>();
            details = new GenericDescription();
            details.Name = "unnamed library";
            details.Description = "a blank library created by SokoSolve";

            libraryID = LibraryGUID.ToString();

            categories.Root.Data  = new Category();
            categories.Root.Data.Details.Name = "Master List";
            categories.Root.Data.CategoryID = "C"+idProvider.GetNextID().ToString();
        }
        public static GenericDescription Combine(GenericDescription lhs, GenericDescription rhs)
        {
            if (lhs == null && rhs == null) return null;
            if (lhs == null && rhs != null) return rhs;
            if (lhs != null && rhs == null) return lhs;

            GenericDescription res = new GenericDescription();
            res.Author = Combine(lhs.Author, rhs.Author);
            res.Comments = Combine(lhs.Comments, rhs.Comments);
            res.Date = Combine(lhs.Date, rhs.Date);
            res.DateSpecified = res.Date != DateTime.MinValue;
            res.Description = Combine(lhs.Description, rhs.Description);
            res.License = Combine(lhs.License, rhs.License);
            res.Name = Combine(lhs.Name, rhs.Name);
            return res;
        }
Esempio n. 7
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;
        }
Esempio n. 8
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;
        }
Esempio n. 9
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;
        }
Esempio n. 10
0
        public GenericDescription Consolidate(Puzzle puzzle)
        {
            GenericDescription res = new GenericDescription(puzzle.Details);
            if (string.IsNullOrEmpty(res.Name)) res.Name = details.Name;
            if (string.IsNullOrEmpty(res.Description)) res.Description = details.Description;
            if (string.IsNullOrEmpty(res.Comments)) res.Comments = details.Comments;
            if (res.Author == null)
            {
                res.Author = details.Author;
            }
            else
            {
                if (string.IsNullOrEmpty(res.Author.Name)) res.Author.Name = details.Author.Name;
            }
            if (!res.DateSpecified && details.DateSpecified)
            {
                res.DateSpecified = true;
                res.Date = details.Date;
            }

            return res;
        }
Esempio n. 11
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="myLibrary"></param>
 public Puzzle(Library myLibrary)
 {
     maps = new List<PuzzleMap>();
     details = new GenericDescription();
     library = myLibrary;
 }