Inheritance: BaseIObservable
Esempio n. 1
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;
        }
Esempio n. 2
0
        public void RemoveFromFavorites(BasePost post)
        {
            //Delete files off the drive and remove entry from list/xml file
            var favPost = _favoritesList.FirstOrDefault(x => x.FileMD == post.FileMD);

            if (favPost != null)
            {
                _favoritesList.Remove(favPost);
            }

            UpdateFavoritesConfigFile();
        }
Esempio n. 3
0
        public void AddToFavorites(BasePost webPost, string fileToCopy)
        {
            // Replace http paths with the drive paths to the images, ideally caching should solve this problem, but this needs testing
            BasePost favPost = new BasePost(webPost);

            string thumbPath = string.Empty;
            string bigPath   = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(webPost.PreviewURL))
                {
                    thumbPath = Path.Combine(_favoritesThumbFolder, Path.GetFileName(webPost.PreviewURL));
                    File.Copy(webPost.PreviewURL, thumbPath, true);
                    favPost.PreviewURL = thumbPath;
                    favPost.URLStore   = thumbPath;
                }
                else if (!string.IsNullOrEmpty(webPost.URLStore))
                {
                    thumbPath = Path.Combine(_favoritesThumbFolder, Path.GetFileName(webPost.URLStore));
                    File.Copy(webPost.URLStore, thumbPath, true);
                    favPost.PreviewURL = thumbPath;
                    favPost.URLStore   = thumbPath;
                }
            }
            catch
            {
                //
            }

            try
            {
                bigPath = Path.Combine(_favoritesFolder, Path.GetFileName(fileToCopy));
                File.Copy(fileToCopy, bigPath, true);
                favPost.FullPictureURL = bigPath;
            }
            catch
            {
                //
            }

            //We can ignore the fails, file access for thumbnails isnt always instantly freed if same file is being added/removed
            if (!string.IsNullOrEmpty(thumbPath) && !string.IsNullOrEmpty(bigPath) && _favoritesList.FirstOrDefault(x => x.PreviewURL == thumbPath && x.FullPictureURL == bigPath) == null)
            {
                _favoritesList.Add(favPost);

                UpdateFavoritesConfigFile();
            }
        }
        public void AddToFavorites(BasePost webPost, string fileToCopy)
        {
            // Replace http paths with the drive paths to the images, ideally caching should solve this problem, but this needs testing
            BasePost favPost = new BasePost(webPost);

            string thumbPath = string.Empty;
            string bigPath = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(webPost.PreviewURL))
                {
                    thumbPath = Path.Combine(_favoritesThumbFolder, Path.GetFileName(webPost.PreviewURL));
                    File.Copy(webPost.PreviewURL, thumbPath, true);
                    favPost.PreviewURL = thumbPath;
                    favPost.URLStore = thumbPath;
                }
                else if (!string.IsNullOrEmpty(webPost.URLStore))
                {
                    thumbPath = Path.Combine(_favoritesThumbFolder, Path.GetFileName(webPost.URLStore));
                    File.Copy(webPost.URLStore, thumbPath, true);
                    favPost.PreviewURL = thumbPath;
                    favPost.URLStore = thumbPath;
                }
            }
            catch
            {
                //
            }

            try
            {
                bigPath = Path.Combine(_favoritesFolder, Path.GetFileName(fileToCopy));
                File.Copy(fileToCopy, bigPath, true);
                favPost.FullPictureURL = bigPath;
            }
            catch
            {
                //
            }

            //We can ignore the fails, file access for thumbnails isnt always instantly freed if same file is being added/removed
            if (!string.IsNullOrEmpty(thumbPath) && !string.IsNullOrEmpty(bigPath) && _favoritesList.FirstOrDefault(x => x.PreviewURL == thumbPath && x.FullPictureURL == bigPath) == null)
            {
                _favoritesList.Add(favPost);

                UpdateFavoritesConfigFile();
            }
        }
        public PrviewScreenView(BasePost post, ObservableCollection<BasePost> DowloadList)
        {
            InitializeComponent();

            PreviewVM = new PreviewScreenVM(post, DowloadList);
            DataContext = PreviewVM;

            PreviewVM.AddedImageToFavorites += PreviewVM_AddedImageToFavorites;
            PreviewVM.RemovedImageFromFavorites += PreviewVM_RemovedImageFromFavorites;

            if (GlobalSettings.Instance.PreviewScreenWidth > 0)
            {
                this.Width = GlobalSettings.Instance.PreviewScreenWidth;
                this.Height = GlobalSettings.Instance.PreviewScreenHeight;
            }
        }
        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>();
        }
Esempio n. 7
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;
        }
        public void RemoveFromFavorites(BasePost post)
        {
            //Delete files off the drive and remove entry from list/xml file
            var favPost = _favoritesList.FirstOrDefault(x => x.FileMD == post.FileMD);

            if (favPost != null)
                _favoritesList.Remove(favPost);

            UpdateFavoritesConfigFile();
        }