private void CreateAndAddSprites(SpriteListItemData item) { EmojiSpritesCreator eSpC = new EmojiSpritesCreator(this.CurrentDataContext.StickerProduct.id); if (!eSpC.TryDeserializeSpritePack()) { ((UIElement)this.ProgressBar).Visibility = Visibility.Visible; this.ProgressBar.IsIndeterminate = true; ThreadPool.QueueUserWorkItem((WaitCallback)(o => { Thread.Sleep(800); if (!item.IsSelected) { return; } base.Dispatcher.BeginInvoke((Action)(() => { eSpC.CreateSprites(); this.AddSprites(eSpC); ((UIElement)this.ProgressBar).Visibility = Visibility.Collapsed; this.ProgressBar.IsIndeterminate = false; })); })); } else { this.AddSprites(eSpC); } }
private void AddSprites(EmojiSpritesCreator eSpC) { Execute.ExecuteOnUIThread((Action) (() => { SpritesPack spritesPack = eSpC.SpritesPack; List<SpriteDescription> spritesVertical = spritesPack.SpritesVertical; List<SpriteDescription> spritesHorizontal = spritesPack.SpritesHorizontal; this.myPanel.ClearItems(); List<IVirtualizable> virtualizableList = new List<IVirtualizable>(); for (int index = 0; index < spritesHorizontal.Count; ++index) { SpriteDescription vertSpriteDesc; if (index >= spritesVertical.Count) vertSpriteDesc = new SpriteDescription() { SpritePath = "", Elements = new List<SpriteElementData>() }; else vertSpriteDesc = spritesVertical[index]; SpriteDescription horSpriteDesc = spritesHorizontal[index]; int num = this.IsHorizontal ? 1 : 0; SpriteItem spriteItem = new SpriteItem(vertSpriteDesc, horSpriteDesc, num != 0); if (index == 0) spriteItem.Margin = new Thickness(0.0, 6.0, 0.0, 0.0); virtualizableList.Add((IVirtualizable) spriteItem); } this.myPanel.AddItems((IEnumerable<IVirtualizable>) virtualizableList); })); }
private void AddSprites(EmojiSpritesCreator eSpC) { Execute.ExecuteOnUIThread((Action)(() => { SpritesPack spritesPack = eSpC.SpritesPack; List <SpriteDescription> spritesVertical = spritesPack.SpritesVertical; List <SpriteDescription> spritesHorizontal = spritesPack.SpritesHorizontal; this.myPanel.ClearItems(); List <IVirtualizable> virtualizableList = new List <IVirtualizable>(); for (int index = 0; index < spritesVertical.Count || index < spritesHorizontal.Count; ++index) { SpriteItem spriteItem = new SpriteItem(index < spritesVertical.Count ? spritesVertical[index] : new SpriteDescription(), index < spritesHorizontal.Count ? spritesHorizontal[index] : new SpriteDescription(), this.IsHorizontal); if (index == 0) { spriteItem.Margin = new Thickness(0.0, 6.0, 0.0, 0.0); } virtualizableList.Add((IVirtualizable)spriteItem); } this.myPanel.AddItems((IEnumerable <IVirtualizable>)virtualizableList); })); }