示例#1
0
        private BitmapImage CreateBitmapImageFromPath(string path, bool shouldCompress = false)
        {
            if (path != null && !File.Exists(path.Replace("file:///", "")))
            {
                path = DoujinScrubber.GetDefaultCoverPath(Directory);
            }

            else if (path != null && shouldCompress)
            {
                path = ImageCompressor.CompressImage(path, 40);
            }

            if (path == null)
            {
                return(null);
            }

            BitmapImage newCoverImage = new BitmapImage();

            newCoverImage.BeginInit();
            newCoverImage.UriSource        = new Uri(path, UriKind.Absolute);
            newCoverImage.CacheOption      = BitmapCacheOption.None;
            newCoverImage.CreateOptions    = BitmapCreateOptions.IgnoreImageCache;
            newCoverImage.DecodePixelWidth = 140;
            newCoverImage.EndInit();

            newCoverImage.Freeze();

            return(newCoverImage);
        }
        private void AsyncPopulateDoujinPanel()
        {
            DoujinScrubber ds = new DoujinScrubber();

            if (populateThread != null && populateThread.IsAlive)
            {
                populateThread.Abort();
            }

            populateThread              = new Thread(() => ds.PopulateDoujins());
            populateThread.Name         = "DoujinScrubber Thread";
            populateThread.IsBackground = true;
            populateThread.Start();
        }