public Project CreateProject(string origDirPath, string thumbDirPath) { Project project = new Project(); project.OriginalPath = origDirPath; project.ThumbnailPath = thumbDirPath; project.TagTypes = new TagTypeCollection(); Tag tag1 = new Tag(TagType.Default, "a", "あaaほあえljうぇlgkjwヶgawefwefw"); Tag tag2 = new Tag(TagType.Default, "c", "bbb"); Tag tag3 = new Tag(TagType.Default, "b", "あaaほあえljうぇlgkjwヶgawefwefw"); project.Tags.Add(tag1); project.Tags.Add(tag2); project.Tags.Add(tag3); DirectoryInfo dOriginalDirInfo = new DirectoryInfo(project.OriginalFullPath); DirectoryInfo dThumbnailDirInfo = new DirectoryInfo(project.ThumbnailFullPath); if (!dOriginalDirInfo.Exists) { } else { FileInfo[] fInfos = dOriginalDirInfo.GetFiles("*.jpg"); for (int i = 0; i < 100; i++) { foreach (FileInfo fInfo in fInfos) { DenshaImage img = new DenshaImage(project, fInfo.Name); img.AddTag(tag1); img.AddTag(tag2); img.AddTag(tag3); project.AddImage(img); } } } return project; }
public static DenshaImage ReadXml(Project project, XmlNode node) { if (node.Name != "image") return null; string origname = null; string thumbname = null; string extname = null; DateTime time = DateTime.Now; bool use = false; string recital = ""; List<Tag> tags = new List<Tag>(); foreach (XmlNode child in node.ChildNodes) { switch (child.Name) { case "origname": origname = child.InnerText.Trim(); break; case "thumbname": thumbname = child.InnerText.Trim(); break; case "extname": extname = child.InnerText.Trim(); break; case "time": DateTime.TryParseExact(child.InnerText.Trim(), SAVETIME_FORMAT, null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out time); break; case "use": use = child.InnerText.Trim() == "1"; break; case "recital": recital = child.InnerText.Trim(); break; case "tags": { foreach (XmlNode tagNode in child.ChildNodes) { int tagId = -1; int.TryParse(tagNode.InnerText.Trim(), out tagId); Tag tag = project.Tags.FindById(tagId); if (tag != null) tags.Add(tag); } } break; } } if (String.IsNullOrEmpty(origname) || String.IsNullOrEmpty(thumbname)) return null; extname = extname ?? ".jpg"; DenshaImage img = new DenshaImage(project, origname + extname, thumbname + extname); img._isUsed = use; img.Recital = recital; img.ShootingTime = time; foreach (Tag tag in tags) { img.AddTag(tag); } return img; }