コード例 #1
0
        private static List <StickerSpriteItem> CreateStickerSetSprites(TLStickerSet stickerSet)
        {
            if (stickerSet == null)
            {
                return(null);
            }

            const int stickersPerRow = 4;
            var       sprites        = new List <StickerSpriteItem>();
            var       stickers       = new List <TLStickerItem>();

            for (var i = 1; i <= stickerSet.Stickers.Count; i++)
            {
                stickers.Add((TLStickerItem)stickerSet.Stickers[i - 1]);

                if (i % stickersPerRow == 0 || i == stickerSet.Stickers.Count)
                {
                    var item = new StickerSpriteItem(stickersPerRow, stickers, 96.0, 438.0, true);
                    sprites.Add(item);
                    stickers.Clear();
                }
            }

            return(sprites);
        }
コード例 #2
0
        private void LoadStickerSet(string key, List <TLDocument22> stickerSet)
        {
            var stickerPerRow = 4;

            var setId = key;
            List <VListItemBase> sprites;

            if (!_stickerSetSprites.TryGetValue(setId, out sprites) ||
                (key == RecentlyUsedMasksKey && _reloadRecentMasks) ||
                (key == RecentlyUsedStickersKey && _reloadRecentStickers))
            {
                if (key == RecentlyUsedStickersKey && _reloadRecentStickers)
                {
                    _reloadRecentStickers = false;
                }
                if (key == RecentlyUsedMasksKey && _reloadRecentMasks)
                {
                    _reloadRecentMasks = false;
                }

                sprites = new List <VListItemBase>();
                var stickers = new List <TLStickerItem>();
                for (var i = 1; i <= stickerSet.Count; i++)
                {
                    stickers.Add(new TLStickerItem {
                        Document = stickerSet[i - 1]
                    });

                    if (i % stickerPerRow == 0 || i == stickerSet.Count)
                    {
                        var item = new StickerSpriteItem(stickerPerRow, new List <TLStickerItem>(stickers), 90.0, 472.0, StickerPanel_MouseEnter);
                        item.StickerSelected += OnStickerSelected;
                        sprites.Add(item);
                        stickers.Clear();
                    }
                }

                _stickerSetSprites[setId] = sprites;
            }

            if (key == RecentlyUsedMasksKey)
            {
                _recentMasksSprites = sprites;
            }
            else if (key == RecentlyUsedStickersKey)
            {
                _recentStickersSprites = sprites;
            }

            CurrentSprites = sprites;
            AddSprites(sprites);
        }