Пример #1
0
        /// <summary>
        /// Main view model for the BooruReader window
        /// </summary>
        public MainScreenVM()
            : base()
        {
            _imageList = new ObservableCollection<BasePost>();
            _previewList = new List<PrviewScreenView>();
            _postFetcher = new PostsFetcher();
            _threadList = new List<BasePost>();
            _imageLoader = new BackgroundWorker();
            _cache = new ImageCache();
            DownloadList = new ObservableCollection<BasePost>();
            DownloadList.CollectionChanged += DowloadList_CollectionChanged;
            _imageLoader.DoWork += BackgroundLoaderWork;
            _imageLoader.RunWorkerCompleted += ServerListLoadWorkerCompleted;
            _imageLoader.WorkerSupportsCancellation = true;
            _showedLastPageWarning = false;
            //Ugly hack for settings vm
            GlobalSettings.Instance.MainScreenVM = this;
            SettingsOpen = false;
            IsFavoritesMode = false;
            _favorites = new FavoriteHandler();

            InitialiseDelegates();

            ProgressBarVisibility = Visibility.Hidden;
        }
        public PreviewScreenVM(BasePost post, ObservableCollection<BasePost> downloadList)
        {
            _post = post;
            _downloadList = downloadList;
            ImageCache cache = new ImageCache();
            _favoriteshandler = new FavoriteHandler();

            // KBR 20150405 Issue #5: extend GetImage to take a progress handler, so the preview download progress is visible
            PreviewPost = post;
            ImageSource = cache.GetImage(post.FileMD, post.FullPictureURL, LateFilePath, _post.client_DownloadProgressChanged);

            //ImageSource = _post.FullPictureURL;
            ShowTagList = Visibility.Collapsed;

            string[] splitter = { " ", "\n", "\r" };
            TagList = new ObservableCollection<string>(post.Dimensions.Split(splitter, StringSplitOptions.RemoveEmptyEntries));
            //if (!string.IsNullOrEmpty(post.Tags))
            //    _taglist = new ObservableCollection<string>(post.Tags.Split(splitter, StringSplitOptions.RemoveEmptyEntries));
            //else
            //    _taglist = new ObservableCollection<string>();
        }
Пример #3
0
        /// <summary>
        /// Constructor that SHOULD be used for images
        /// </summary>
        /// <param name="post"></param>
        /// <param name="isUIImage"></param>
        public BasePost(BasePost post, bool isUIImage = false)
        {
            _cache = new ImageCache();

            ImageRating = post.ImageRating;
            FullPictureURL = post.FullPictureURL;

            if (isUIImage)
            {
                _extension = UtilityFunctions.GetUrlExtension(post.PreviewURL);
                urlStore = PreviewURL = _cache.GetImage(post.FileMD, post.PreviewURL, LateFilePath, null, false);
            }
            else
                urlStore = PreviewURL = post.PreviewURL;

            FileMD = post.FileMD;
            Tags = post.Tags.Trim();
            _width = post._width;
            _height = post._height;
            PostId = post.PostId;
            IsVisible = true;

            Dimensions = "Resolution " + _width + "x" + _height + "\n" + "Tags: " + "\n" + Tags;
        }
        private void LateFilePath(object e, AsyncCompletedEventArgs args)
        {
            //Yeah, I know, should really pass the flippin thing as a argument.
            ImageCache cache = new ImageCache();

            ImageSource = cache.GetImage(_post.FileMD, _post.FullPictureURL, LateFilePath);

            if (CopyWhenReady)
            {
                _post.SaveImage(ImageSource);

                if (_downloadList.FirstOrDefault(x => x == _post) == null)
                    _downloadList.Add(_post);
            }

            if (_favoriteWhenReady)
                _favoriteshandler.AddToFavorites(_post, ImageSource);

            // KBR 20150405 Issue #5: hide preview download progress on completion
            PreviewPost.ProgressBarVisible = Visibility.Collapsed;
        }