示例#1
0
        internal IAsyncAction LoadImageAsync(GalleryImagePlaceHolder image)
        {
            var pageIndex = MathHelper.GetPageIndexOfRecord(PageSize, image.PageID - 1);
            var lpAc      = this.loadingPageArray[pageIndex];

            if (lpAc != null && lpAc.Status == AsyncStatus.Started)
            {
                return(lpAc);
            }
            return(this.loadingPageArray[pageIndex] = Run(async token =>
            {
                var images = (IList <GalleryImage>)await base.LoadPageAsync(pageIndex);
                var offset = MathHelper.GetStartIndexOfPage(PageSize, pageIndex);
                for (var i = 0; i < images.Count; i++)
                {
                    var ph = this[i + offset] as GalleryImagePlaceHolder;
                    if (ph == null)
                    {
                        continue;
                    }
                    this[i + offset] = images[i];
                }
                await Task.Yield();
                this.loadingPageArray[pageIndex] = null;
            }).AsMulticast());
        }
示例#2
0
 protected IAsyncOperation <IEnumerable <GalleryImage> > LoadPageLocalilyAsync(int pageIndex)
 {
     return(Task.Run <IEnumerable <GalleryImage> >(async() =>
     {
         this.LoadImageModels();
         var currentPageSize = MathHelper.GetSizeOfPage(this.RecordCount, PageSize, pageIndex);
         var loadList = new GalleryImage[currentPageSize];
         for (var i = 0; i < currentPageSize; i++)
         {
             var model = this.GalleryImageModels[this.Count + i];
             if (model == null)
             {
                 loadList[i] = new GalleryImagePlaceHolder(this, this.Count + i + 1);
             }
             else
             {
                 loadList[i] = await GalleryImage.LoadCachedImageAsync(this, model, model.Image);
             }
         }
         return loadList;
     }).AsAsyncOperation());
 }