示例#1
0
        public static Tags GetCopyTestMockTags()
        {
            Tags tags = new Tags();

            tags.AddSite("Site 01");
            tags.AddSite("Site 02");

            tags.AddActress("คนที่ 01");
            tags.AddActress("คนที่ 02");
            tags.AddActress("คนที่ 03");

            List <Tag> taglist = new List <Tag>();
            Tag        tag01   = new Tag("ทดสอบ 01");

            tag01.AddMembers(GetMemberSet_01()); // Set 01
            taglist.Add(tag01);

            Tag tag02 = new Tag("ทดสอบ 02");

            tag02.AddMembers(GetMemberSet_02()); // Set 02
            taglist.Add(tag02);

            Tag tag03 = new Tag("ทดสอบ 03");

            tag03.AddMembers(GetMemberSet_05()); // Set 05
            taglist.Add(tag03);

            Tag site01 = new Tag("Site 01");

            site01.Type = "S";
            site01.AddMembers(GetMemberSet_03()); // Set 03
            taglist.Add(site01);

            Tag site02 = new Tag("Site 02");

            site02.Type = "S";
            site02.AddMembers(GetMemberSet_04()); // Set 04
            taglist.Add(site02);

            Tag acc01 = new Tag("คนที่ 01");

            acc01.Type = "A";
            acc01.AddMembers(GetMemberSet_03()); // Set 03
            taglist.Add(acc01);

            Tag acc02 = new Tag("คนที่ 02");

            acc02.Type = "A";
            acc02.AddMembers(GetMemberSet_04()); // Set 04
            taglist.Add(acc02);

            Tag acc03 = new Tag("คนที่ 03");

            acc03.Type = "A";
            acc03.AddMembers(GetMemberSet_06()); // Set 06
            taglist.Add(acc03);

            tags.Taglist = taglist;

            return(tags);
        }
示例#2
0
        private void tagdir(string path, Tags taglib)
        {
            Log("Tagging images in directory: " + path);

            // Directory name.
            string dir = Path.GetFileName(path);

            // 1. List all image files.
            var imgs = Directory.GetFiles(path).Where(f => IsAnImageFile(Path.GetFileName(f)));

            if (imgs.Count() == 0)
            {
                Log("Not found any image file.");
                return;
            }

            // 2. Derive tags from directory name.
            string[] tags = DeriveTagList(dir);
            // 3. Add site tag to tag lib.
            taglib.AddSite(tags[0]); // first tag is always a Site.
            // 4. Add actress tag to tag lib.
            for (int i = 1; i < tags.Length; i++)
            // a.k.a. Actress name.
            {
                Match match = Regex.Match(tags[i], ACT_NAME_PATTERN);
                if (match.Success) // filter only tags that start and end with a single quote
                // a.k.a. Actress name.
                {
                    string ac = match.Groups[1].Value;                         // Get Actress name (with out single quote).
                    tags[i] = Regex.Replace(ac, ACT_NAME_JOINER_PATTERN, " "); // Replace - or _ with '1 space'
                    taglib.AddActress(tags[i]);
                }
            }

            IList <string> imgnames = new List <string>(imgs.Count());

            // 5. Write extended properties to files.
            foreach (string fpath in imgs)
            {
                WriteTagsToFile(fpath, tags);
                // Collect file name to new list.
                string fname = Path.GetFileName(fpath);
                imgnames.Add(fname);
            }

            // 6. Add all image file names as member of every tags.
            foreach (string tagname in tags)
            {
                Tag tag = taglib.GetOrCreateTag(tagname);
                if (taglib.Sites.Contains(tagname))
                {
                    tag.Type = TagType.S.ToString();
                }
                else if (taglib.Actresses.Contains(tagname))
                {
                    tag.Type = TagType.A.ToString();
                }
                tag.AddMembers(imgnames.ToArray());
            }

            // 7. Copy all files to parent directory.
            CopyImgFilesToParent(path, imgs.ToArray());

            // 8. Archive this image directory.
            ArchiveDirectory(path);
        }