예제 #1
0
        //请在APP起动的时候调用
        public async static void TryInit() {
            var options = new DisplayImageOptions.Builder()
                .CacheInMemory(false)
                .CacheOnDisk(true)
                .Build();

            var root = ApplicationData.Current.LocalFolder;
            //图标
            var iconDir = await root.CreateFolderAsync("icon", CreationCollisionOption.OpenIfExists);
            Icon = ImageLoader.Register("icon", new ImageLoaderConfiguration.Builder()
                                .ThreadPoolSize(5)
                                .TasksProcessingOrder(QueueProcessingType.FIFO)
                                .DiskCache(new DiskCache(iconDir, new Md5FileNameGenerator()))
                                .DefaultDisplayImageOptions(options)
                                .ImageDownloader(new HttpClientImageDownloader())
                                .Build());

            //像册
            var photoDir = await root.CreateFolderAsync("photo", CreationCollisionOption.OpenIfExists);
            Photo = ImageLoader.Register("photo", new ImageLoaderConfiguration.Builder()
                                .ThreadPoolSize(5)
                                .TasksProcessingOrder(QueueProcessingType.FIFO)
                                .DiskCache(new DiskCache(photoDir, new Md5FileNameGenerator()))
                                .DefaultDisplayImageOptions(options)
                                .ImageDownloader(new HttpClientImageDownloaderEx()) //使用自定义扩展支持高级用法
                                .Build());
        }
예제 #2
0
        public ImageLoader CurrentLoader() {
            if (_CurrentLoader == null) {
                if (string.IsNullOrEmpty(Loader))
                    _CurrentLoader = ImageLoader.Default;
                else
                    _CurrentLoader = ImageLoader.Get(Loader);
            }

            return _CurrentLoader;
        }
예제 #3
0
 public static ImageLoader Register(string key, ImageLoaderConfiguration config) {
     var temp = new ImageLoader().Init(config);
     _libs[key] = temp;
     return temp;
 }