示例#1
0
        public void RemoveSticker(TLDocumentBase document)
        {
            for (var i = 0; i < Documents.Count; i++)
            {
                if (Documents[i].Index == document.Index)
                {
                    Documents.RemoveAt(i);
                    break;
                }
            }

            Hash = TLUtils.GetFavedStickersHash(Documents);

            var document54 = document as TLDocument54;

            if (document54 != null)
            {
                var emoticon = document54.Emoticon;
                if (!string.IsNullOrEmpty(emoticon))
                {
                    for (var i = 0; i < Packs.Count; i++)
                    {
                        if (Packs[i].Emoticon.ToString() == emoticon)
                        {
                            for (int j = 0; j < Packs[i].Documents.Count; j++)
                            {
                                if (Packs[i].Documents[j].Value == document54.Index)
                                {
                                    Packs[i].Documents.RemoveAt(j);
                                    break;
                                }
                            }

                            if (Packs[i].Documents.Count == 0)
                            {
                                Packs.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public void AddSticker(TLDocumentBase document)
        {
            Documents.Insert(0, document);
            Hash = TLUtils.GetFavedStickersHash(Documents);

            var document54 = document as TLDocument54;

            if (document54 != null)
            {
                var emoticon = document54.Emoticon;
                if (!string.IsNullOrEmpty(emoticon))
                {
                    var added = false;
                    for (var i = 0; i < Packs.Count; i++)
                    {
                        if (Packs[i].Emoticon.ToString() == emoticon)
                        {
                            var item = Packs[i].Documents.FirstOrDefault(x => x.Value == document54.Index);
                            if (item == null)
                            {
                                Packs[i].Documents.Insert(0, document54.Id);
                                added = true;
                                break;
                            }
                        }
                    }
                    if (!added)
                    {
                        Packs.Insert(0, new TLStickerPack {
                            Emoticon = new TLString(emoticon), Documents = new TLVector <TLLong> {
                                document54.Id
                            }
                        });
                    }
                }
            }
        }