예제 #1
0
 public PictureController(IPictureDataProvider _pictureDataProvider, IArticleService _articleService, IGalleryService _galleryService, IThumbnailGeneratorService _thumbnailGenerator)
 {
     pictureDataProvider = _pictureDataProvider;
     articleService = _articleService;
     this._galleryService = _galleryService;
     this._thumbnailGenerator = _thumbnailGenerator;
 }
예제 #2
0
 private void Innit()
 {
     _downloader = new Downloader();
     _downloader.ProgressChanged += (s, e) => { Curtain.AnimateProgressBar(e); };
     _daydreamProvider            = new DayDreamDataProvider();
     _thumbClickedHandler         = ThumbImage_MouseLeftButtonUp;
     Scraper.InstanciateAllDerivedTypes();
     _favoriteSaver = new FavoritesSaver();
     //Scraper.InstanciateSpecificType(new WallpaperScraper.Derived.Suwalls());
     InnitCurtain();
 }
예제 #3
0
        /// <summary>
        ///     Fill n images to queue
        /// </summary>
        /// <param name="count">number of images to load</param>
        /// <param name="queue">queue of ImageCell to fill</param>
        /// <param name="provider">data provider</param>
        /// <returns></returns>
        private async Task FillImages(int count, Queue <ImageCell> queue, IPictureDataProvider provider)
        {
            if (count < 1)
            {
                ExManager.Ex(new InvalidOperationException("FillImageQueue is passed with 0"));
            }
            var tasks = new List <Task>();

            for (int i = count; i > 0; i--)
            {
                tasks.Add(
                    DisplayAnImage(
                        GetCachedData(await provider.GetData().ConfigureAwait(false)), queue, provider));
                await Task.Delay(_thumbDownloadDelay);
            }
            await Task.WhenAll(tasks);
        }
예제 #4
0
 public GalleryService(IPictureDataProvider _pictureDataProvider,
     IThumbnailGeneratorService _thumbnailGeneratorService)
 {
     pictureDataProvider = _pictureDataProvider;
     this._thumbnailGeneratorService = _thumbnailGeneratorService;
 }
 public EventsListController(IArticleService articleService, IPictureDataProvider pictureDataProvider)
 {
     this.articleService = articleService;
     this.pictureDataProvider = pictureDataProvider;
 }
예제 #6
0
        public EventListsModel GetEventListModel(DateTime? fromDate, DateTime? toDate, string codeStart, IPictureDataProvider pictureDataProvider)
        {
            IArticleService articleService = this;
            var galleries = pictureDataProvider.Galleries();

            var from = "/";
            var articles = articleService.AllArticles()
                .Where(a => galleries.Contains(a.Code) && a.EventFrom != null && a.Language == HttpContext.Current.Language());

            if (fromDate != null) articles = articles.Where(a => a.EventFrom >= fromDate);
            if (toDate != null) articles = articles.Where(a => a.EventTo <= toDate);
            if (codeStart != null) articles = articles.Where(a => a.Code.StartsWith(codeStart));

            var events = articles
                .OrderByDescending(a => a.EventFrom)
                .ToList()
                .Select(a => new EventsListModel()
                {
                    Code = a.Code,
                    EventFrom = a.EventFrom,
                    EventTo = a.EventTo,
                    Menu = a.Menu  ?? a.Title ?? a.Code,
                    Title = a.Title,
                    TopPics = pictureDataProvider
                        .Pictures
                        .Where(pct => pct.Gallery.Equals(a.Code))
                        .OrderBy(pct => pct.Sort)
                        .Take(1)
                        .Select(pct =>
                            new TopPic()
                            {
                                Image = (@from + pct.fDirectory + "/" + pct.fName).Replace(@"\", "/"),
                                Thumb = (@from + pct.fDirectory + "/" + pct.smallFName).Replace(@"\", "/"),
                                Width = pct.width ?? 0,
                                Height = pct.height ?? 0
                            })
                        .ToList()
                });

            return new EventListsModel()
            {
                Events = events,
                ShowYears = true
            };
        }
예제 #7
0
        //download and display cell
        private async Task DisplayAnImage(PictureData pictureData, Queue <ImageCell> queue, IPictureDataProvider provider)
        {
            var bitmap = pictureData.ThumbBitmap ?? await pictureData.GetThumbBitmap().ConfigureAwait(false);

            if (bitmap == null)
            {
                Debug.WriteLine("Thumb download failed, scraper: " + pictureData.Scraper.SiteName);
                if (provider.CanSupplyWhenFail)
                //replace with another image
                {
                    Debug.WriteLine("Replace fail thumb...");
                    await FillImages(1, queue, provider).ConfigureAwait(false);
                }
                else
                {
                    //fixed set, cant replace, displays default error image
                    UiInvoke(() => { throw new NotImplementedException(); });
                }
                return;
            }
            bool needCached = CacheData(pictureData);

            if (queue.Count == 0)
            {
                Debug.WriteLine("Queue is empty, can not display image.");
                return;
            }
            var cell = queue.Dequeue();

            //when a favorited data is randomly loaded marks it as so
            pictureData.IsFavorite = _favoriteSaver.CheckFavorite(pictureData);
            UiInvoke(() =>
            {
                //cell.SetValue(ImageCell.IsImageDownloaded, true);
                cell.SetData(pictureData);
                //no effect when data is taken from cached
                if (needCached)
                {
                    cell.BeginStoryboard((Storyboard)TryFindResource("fadeInEffect"));
                }
            });

            RaiseThumbDowloaded();
        }
예제 #8
0
 public PictureDataContainer(IPictureDataProvider provider)
 {
     Files = provider.GetPictureData();
 }