예제 #1
0
        protected override void GenerateChildren()
        {
            base.GenerateChildren();
            List <StickerItemData> stickerItemDataList = this._isHorizontal ? this._horizontalStickers : this._verticalStickers;

            if (stickerItemDataList.Count == 0)
            {
                return;
            }
            double num1 = (this.Width - 12.0 * (double)(this.MaxCount + 1)) / (double)this.MaxCount;
            double num2 = 0.0;

            if (this._images.Count == 0 || this._recreateImages)
            {
                this._images.Clear();
                foreach (StickerItemData stickerItemData1 in stickerItemDataList)
                {
                    double num3   = num2 + 12.0;
                    Image  image1 = new Image();
                    double num4   = num1;
                    ((FrameworkElement)image1).Width = num4;
                    double fixedHeight = this._fixedHeight;
                    ((FrameworkElement)image1).Height = fixedHeight;
                    int num5 = 2;
                    image1.Stretch = ((Stretch)num5);
                    Thickness thickness = new Thickness(num3, 12.0, 0.0, 0.0);
                    ((FrameworkElement)image1).Margin = thickness;
                    StickerItemData stickerItemData2 = stickerItemData1;
                    ((FrameworkElement)image1).Tag = stickerItemData2;
                    Image image2 = image1;
                    Interaction.GetBehaviors((DependencyObject)image2).Add((Behavior) new PreviewBehavior()
                    {
                        PreviewUri = (ScaleFactor.GetRealScaleFactor() == 100 ? stickerItemData1.LocalPathBig : stickerItemData1.LocalPathExtraBig)
                    });
                    ((UIElement)image2).Tap += (new EventHandler <System.Windows.Input.GestureEventArgs>(this.image_Tap));
                    num2 = num3 + num1;
                    this._images.Add(image2);
                }
                this._recreateImages = false;
            }
            int index = 0;

            using (List <Image> .Enumerator enumerator = this._images.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Image current = enumerator.Current;
                    if (index < stickerItemDataList.Count)
                    {
                        StickerItemData stickerItemData = stickerItemDataList[index];
                        VeryLowProfileImageLoader.AllowBoostLoading = true;
                        ImageLoader.SetUriSource(current, stickerItemData.LocalPath);
                    }
                    ++index;
                    this.Children.Add((FrameworkElement)current);
                }
            }
        }
예제 #2
0
        protected override void GenerateChildren()
        {
            base.GenerateChildren();
            List <StickerItemData> stickerItemDataList = this._isHorizontal ? this._horizontalStickers : this._verticalStickers;

            if (stickerItemDataList.Count == 0)
            {
                return;
            }
            double num1 = (this.Width - 12.0 * (double)(this.MaxCount + 1)) / (double)this.MaxCount;
            double num2 = 0.0;

            if (this._images.Count == 0 || this._recreateImages)
            {
                this._images.Clear();
                foreach (StickerItemData stickerItemData1 in stickerItemDataList)
                {
                    double left   = num2 + 12.0;
                    Image  image1 = new Image();
                    double num3   = num1;
                    image1.Width = num3;
                    double num4 = this._fixedHeight;
                    image1.Height = num4;
                    int num5 = 2;
                    image1.Stretch = (Stretch)num5;
                    Thickness thickness = new Thickness(left, 12.0, 0.0, 0.0);
                    image1.Margin = thickness;
                    StickerItemData stickerItemData2 = stickerItemData1;
                    image1.Tag = (object)stickerItemData2;
                    Image image2 = image1;
                    Interaction.GetBehaviors((DependencyObject)image2).Add((Behavior) new PreviewBehavior()
                    {
                        PreviewUri = (ScaleFactor.GetRealScaleFactor() == 100 ? stickerItemData1.LocalPathBig : stickerItemData1.LocalPathExtraBig)
                    });
                    image2.Tap += new EventHandler <GestureEventArgs>(this.image_Tap);
                    num2        = left + num1;
                    this._images.Add(image2);
                }
                this._recreateImages = false;
            }
            int index = 0;

            foreach (Image image in this._images)
            {
                if (index < stickerItemDataList.Count)
                {
                    StickerItemData stickerItemData = stickerItemDataList[index];
                    VeryLowProfileImageLoader.AllowBoostLoading = true;
                    ImageLoader.SetUriSource(image, stickerItemData.LocalPath);
                }
                ++index;
                this.Children.Add((FrameworkElement)image);
            }
        }
예제 #3
0
 private void CreateAndAddStickersItems()
 {
   Execute.ExecuteOnUIThread((Action) (() =>
   {
     if ((Visibility) Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible && !this.CurrentDataContext.IsRecentStickers)
       ImageLoader.SetUriSource(this.ImageBackground, this.CurrentDataContext.StickerProduct.base_url + "/background.png?" + VeryLowProfileImageLoader.REQUIRE_CACHING_KEY + "=True");
     List<IEnumerable<int>> list1 = this.CurrentDataContext.StickerProduct.stickers.sticker_ids.Partition<int>(StickersConstants.ColumnsCountVerticalOrientation).ToList<IEnumerable<int>>();
     List<IEnumerable<int>> list2 = this.CurrentDataContext.StickerProduct.stickers.sticker_ids.Partition<int>(StickersConstants.ColumnsCountHorizontalOrientation).ToList<IEnumerable<int>>();
     List<IVirtualizable> virtualizableList = new List<IVirtualizable>();
     for (int index = 0; index < list1.Count; ++index)
     {
       List<StickerItemData> verticalStickers = new List<StickerItemData>();
       List<StickerItemData> horizontalStickers = new List<StickerItemData>();
       foreach (int stickerId in list1[index])
       {
         List<StickerItemData> stickerItemDataList = verticalStickers;
         StickerItemData stickerItemData = new StickerItemData();
         stickerItemData.LocalPath = StickersDownloader.Instance.GetLocalPathForStickerId128(this.CurrentDataContext.StickerProduct, stickerId);
         stickerItemData.LocalPathBig = StickersDownloader.Instance.GetLocalPathForStickerId256(this.CurrentDataContext.StickerProduct, stickerId);
         stickerItemData.LocalPathExtraBig = StickersDownloader.Instance.GetLocalPathForStickerId512(this.CurrentDataContext.StickerProduct, stickerId);
         stickerItemData.StickerSetId = this.CurrentDataContext.StickerProduct.id;
         stickerItemData.StickerId = stickerId;
         int num = this.CurrentDataContext.StickerStockItemHeader.IsPurchased ? 1 : (this.CurrentDataContext.IsRecentStickers ? 1 : 0);
         stickerItemData.CanSendSticker = num != 0;
         stickerItemDataList.Add(stickerItemData);
       }
       if (index < list2.Count)
       {
         foreach (int stickerId in list2[index])
         {
           List<StickerItemData> stickerItemDataList = horizontalStickers;
           StickerItemData stickerItemData = new StickerItemData();
           stickerItemData.LocalPath = StickersDownloader.Instance.GetLocalPathForStickerId128(this.CurrentDataContext.StickerProduct, stickerId);
           stickerItemData.LocalPathBig = StickersDownloader.Instance.GetLocalPathForStickerId256(this.CurrentDataContext.StickerProduct, stickerId);
           stickerItemData.LocalPathExtraBig = StickersDownloader.Instance.GetLocalPathForStickerId512(this.CurrentDataContext.StickerProduct, stickerId);
           stickerItemData.StickerSetId = this.CurrentDataContext.StickerProduct.id;
           stickerItemData.StickerId = stickerId;
           int num = this.CurrentDataContext.StickerStockItemHeader.IsPurchased ? 1 : (this.CurrentDataContext.IsRecentStickers ? 1 : 0);
           stickerItemData.CanSendSticker = num != 0;
           stickerItemDataList.Add(stickerItemData);
         }
       }
       StickersItem stickersItem = new StickersItem(StickersConstants.VerticalSpriteWidth, new Thickness(), StickersConstants.HorizontalSpriteWidth, this.IsHorizontal, StickersConstants.StickerHeight, StickersConstants.ColumnsCountVerticalOrientation, StickersConstants.ColumnsCountHorizontalOrientation, verticalStickers, horizontalStickers);
       virtualizableList.Add((IVirtualizable) stickersItem);
     }
     this.myPanel.ClearItems();
     this.myPanel.AddItems((IEnumerable<IVirtualizable>) virtualizableList);
   }));
 }
예제 #4
0
        private void image_Tap(object sender, GestureEventArgs e)
        {
            if (PreviewBehavior.JustShown)
            {
                return;
            }
            StickerItemData stickerItemData = (StickerItemData)((FrameworkElement)sender).Tag;

            if (!stickerItemData.CanSendSticker)
            {
                return;
            }
            EventAggregator.Current.Publish((object)new StickerItemTapEvent()
            {
                StickerItem = stickerItemData
            });
        }
예제 #5
0
        private void image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (PreviewBehavior.JustShown)
            {
                return;
            }
            StickerItemData tag = (StickerItemData)((FrameworkElement)sender).Tag;

            if (!tag.CanSendSticker)
            {
                return;
            }
            EventAggregator.Current.Publish(new StickerItemTapEvent()
            {
                StickerItem = tag
            });
        }