예제 #1
0
        public object Clone()
        {
            BooruTagList cList = new BooruTagList();

            this.ForEach(x => cList.Add(x.Clone() as BooruTag));
            return(cList);
        }
예제 #2
0
        private static void TagDelta(ref BooruTagList Tags, string deltaString)
        {
            var removeTags = new List <string>();
            var addTags    = new List <string>();

            string[] deltaParts = deltaString.Split(new char[1] {
                ' '
            }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string part in deltaParts)
            {
                if (part.StartsWith("_") && part.Length > 1)
                {
                    removeTags.Add(part.Substring(1).ToLower());
                }
                else
                {
                    addTags.Add(part.ToLower());
                }
            }
            for (int i = Tags.Count - 1; !(i < 0); i--)
            {
                if (removeTags.Contains(Tags[i].Tag))
                {
                    Tags.RemoveAt(i);
                }
            }
            foreach (string addTag in addTags)
            {
                Tags.Add(new BooruTag(addTag));
            }
        }
예제 #3
0
        public static BooruTagList FromTable(DataTable Table)
        {
            BooruTagList bTagList = new BooruTagList();

            foreach (DataRow row in Table.Rows)
            {
                bTagList.Add(BooruTag.FromRow(row));
            }
            return(bTagList);
        }
예제 #4
0
        public static BooruTagList FromReader(ReaderWriter Reader)
        {
            uint         count    = Reader.ReadUInt();
            BooruTagList bTagList = new BooruTagList();

            for (uint i = 0; i < count; i++)
            {
                bTagList.Add(BooruTag.FromReader(Reader));
            }
            return(bTagList);
        }
예제 #5
0
        private static ulong AddPost(Stream str, BooruPost Post, BooruTagList Tags, BooruImage Image)
        {
            ulong postID = 0;

            Request(str, RequestCode.Add_Post, (rw) =>
            {
                Post.ToWriter(rw);
                Tags.ToWriter(rw);
                Image.ToWriter(rw);
            }, (rw) => { postID = rw.ReadULong(); });
            return(postID);
        }
예제 #6
0
        public static BooruTagList FromString(string Tags)
        {
            BooruTagList bTagList = new BooruTagList();

            if (!string.IsNullOrWhiteSpace(Tags))
            {
                string[] parts = Tags.Split(new char[4] {
                    ' ', '\r', '\n', '\t'
                }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string part in parts)
                {
                    bTagList.Add(new BooruTag(part.ToLower()));
                }
            }
            return(bTagList);
        }
예제 #7
0
 private static string BooruTagListToString(BooruTagList Tags, bool Color)
 {
     string[] strTags = new string[Tags.Count];
     for (int i = 0; i < strTags.Length; i++)
     {
         if (Color)
         {
             strTags[i] = "\x1b[38;5;" + ColorHelper.GetXTermIndexFromColor(Tags[i].Color) + "m" + Tags[i].Tag;
         }
         else
         {
             strTags[i] = Tags[i].Tag;
         }
     }
     return(string.Join(" ", strTags) + (Color ? "\x1b[0m" : string.Empty));
 }
예제 #8
0
        private static BooruPost GetPost(Stream str, ulong ID)
        {
            BooruPost post = null;

            Request(str, RequestCode.Get_Post, (rw) => rw.Write(ID), (rw) => { post = BooruPost.FromReader(rw); });
            Request(str, RequestCode.Get_PostTags, (rw) => rw.Write(ID), (rw) => { post.Tags = BooruTagList.FromReader(rw); });
            return(post);
        }