protected override async void Start() { _dataExchangeService = Mvx.Resolve<IDataExchangeService>(); _downloadCache = Mvx.Resolve<IDownloadCache>(); Input.SubscribeToMultiGesture(args => { if (CameraNode == null) { return; } if (args.DDist < 0) { CameraNode.Translate(-Vector3.UnitZ * 0.1f); } else { CameraNode.Translate(Vector3.UnitZ * 0.1f); } }); await CreateScene(); Input.KeyDown += args => { System.Diagnostics.Debug.WriteLine("Key code: "+args.Key); if(args.Key == Key.Esc) Exit(); }; // Stitch images with EmguCV //await MariusCvStitch(); }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, Func<UIView> getNativeControl, Action<UIImage, bool> doWithImage, nfloat imageScale) : base(mainThreadDispatcher, miniLogger, parameters) { _getNativeControl = getNativeControl; _doWithImage = doWithImage; _imageScale = imageScale; DownloadCache = downloadCache; }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, Func<Image> getNativeControl, Action<WriteableBitmap, bool> doWithImage) : base(mainThreadDispatcher, miniLogger, parameters) { _getNativeControl = getNativeControl; _doWithImage = doWithImage; DownloadCache = downloadCache; }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, nfloat imageScale, ITarget<UIImage, ImageLoaderTask> target, bool clearCacheOnOutOfMemory) : base(mainThreadDispatcher, miniLogger, parameters, true, clearCacheOnOutOfMemory) { if (target == null) throw new ArgumentNullException(nameof(target)); _target = target; DownloadCache = downloadCache; }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, ImageView imageView) : base(mainThreadDispatcher, miniLogger, parameters) { CancellationToken = new CancellationTokenSource(); Context = Android.App.Application.Context.ApplicationContext; DownloadCache = downloadCache; _imageWeakReference = new WeakReference<ImageView>(imageView); UseFadeInBitmap = true; }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, ImageView imageView) : base(mainThreadDispatcher, miniLogger, parameters, true) { DownloadCache = downloadCache; if (imageView != null) { _imageWeakReference = new WeakReference<ImageView>(imageView); } }
/// <summary> /// Initialize ImageService default values. This can only be done once: during app start. /// </summary> /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param> /// <param name="httpClient">.NET HttpClient to use. If null then a ModernHttpClient is instanciated.</param> /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param> /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param> /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param> /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param> public static void Initialize(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null) { lock (_initializeLock) { if (_initialized) throw new Exception("FFImageLoading.ImageService is already initialized"); } InitializeIfNeeded(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache); }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, nfloat imageScale, ITarget <UIImage, ImageLoaderTask> target, bool clearCacheOnOutOfMemory) : base(mainThreadDispatcher, miniLogger, parameters, true, clearCacheOnOutOfMemory) { if (target == null) { throw new ArgumentNullException(nameof(target)); } _target = target; DownloadCache = downloadCache; }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, ITarget <BitmapDrawable, ImageLoaderTask> target) : base(mainThreadDispatcher, miniLogger, parameters, true, ImageService.Instance.Config.VerboseLoadingCancelledLogging) { if (target == null) { throw new ArgumentNullException(nameof(target)); } _target = target; DownloadCache = downloadCache; }
public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, ITarget <BitmapDrawable, ImageLoaderTask> target) : base(mainThreadDispatcher, miniLogger, parameters, true) { if (target == null) { throw new ArgumentNullException(nameof(target)); } _target = target; DownloadCache = downloadCache; }
public static void Initialize(int?maxCacheSize = null, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool?loadWithTransparencyChannel = null, bool?fadeAnimationEnabled = null, bool?transformPlaceholders = null, InterpolationMode?downsampleInterpolationMode = null, int httpHeadersTimeout = 15, int httpReadTimeout = 30 ) { var cfg = new Configuration(); if (httpClient != null) { cfg.HttpClient = httpClient; } if (scheduler != null) { cfg.Scheduler = scheduler; } if (logger != null) { cfg.Logger = logger; } if (diskCache != null) { cfg.DiskCache = diskCache; } if (downloadCache != null) { cfg.DownloadCache = downloadCache; } if (loadWithTransparencyChannel.HasValue) { cfg.LoadWithTransparencyChannel = loadWithTransparencyChannel.Value; } if (fadeAnimationEnabled.HasValue) { cfg.FadeAnimationEnabled = fadeAnimationEnabled.Value; } if (transformPlaceholders.HasValue) { cfg.TransformPlaceholders = transformPlaceholders.Value; } if (downsampleInterpolationMode.HasValue) { cfg.DownsampleInterpolationMode = downsampleInterpolationMode.Value; } cfg.HttpHeadersTimeout = httpHeadersTimeout; cfg.HttpReadTimeout = httpReadTimeout; if (maxCacheSize.HasValue) { cfg.MaxCacheSize = maxCacheSize.Value; } Initialize(cfg); }
/// <summary> /// Initialize ImageService default values. This can only be done once: during app start. /// </summary> /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param> /// <param name="httpClient">.NET HttpClient to use. If null then a ModernHttpClient is instanciated.</param> /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param> /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param> /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param> /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param> public static void Initialize(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null) { lock (_initializeLock) { if (_initialized) { throw new Exception("FFImageLoading.ImageService is already initialized"); } } InitializeIfNeeded(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache); }
/// <summary> /// Initializes a new instance of the <see cref="FileDownloader"/> class. /// </summary> /// <param name="downloadCache">IDownloadCache instance</param> internal FileDownloader(IDownloadCache downloadCache) { DnsFallbackResolver = null; MaxAttempts = 60; DelayBetweenAttempts = TimeSpan.FromSeconds(3); SafeWaitTimeout = TimeSpan.FromSeconds(15); SourceStreamReadTimeout = TimeSpan.FromSeconds(5); this.downloadCache = downloadCache; disposed = false; attemptTimer.Elapsed += OnDownloadAttemptTimer; }
public static IDataResolver GetResolver(ImageSource source, TaskParameter parameter, IDownloadCache downloadCache) { switch (source) { case ImageSource.ApplicationBundle: case ImageSource.CompiledResource: case ImageSource.Filepath: return new FilePathDataResolver(source); case ImageSource.Url: return new UrlDataResolver(parameter, downloadCache); default: throw new ArgumentException("Unknown type of ImageSource"); } }
/// <summary> /// Initializes a new instance of the <see cref="FileDownloader"/> class. /// </summary> /// <param name="downloadCache">IDownloadCache instance</param> public FileDownloader(IDownloadCache downloadCache) { this.DnsFallbackResolver = null; this.MaxAttempts = 60; this.DelayBetweenAttempts = TimeSpan.FromSeconds(3); this.SafeWaitTimeout = TimeSpan.FromSeconds(15); this.SourceStreamReadTimeout = TimeSpan.FromSeconds(5); this.downloadCache = downloadCache; this.disposed = false; this.attemptTimer.Elapsed += this.OnDownloadAttemptTimer; }
public Configuration(int maxCacheSize, HttpClient httpClient, IWorkScheduler scheduler, IMiniLogger logger, IDiskCache diskCache, IDownloadCache downloadCache, bool loadWithTransparencyChannel, bool fadeAnimationEnabled, int httpHeadersTimeout, int httpReadTimeout ) { MaxCacheSize = maxCacheSize; HttpClient = httpClient; Scheduler = scheduler; Logger = logger; DiskCache = diskCache; DownloadCache = downloadCache; LoadWithTransparencyChannel = loadWithTransparencyChannel; FadeAnimationEnabled = fadeAnimationEnabled; HttpHeadersTimeout = httpHeadersTimeout; HttpReadTimeout = httpReadTimeout; }
public Configuration(int maxCacheSize, HttpClient httpClient, IWorkScheduler scheduler, IMiniLogger logger, IDiskCache diskCache, IDownloadCache downloadCache, bool loadWithTransparencyChannel, bool fadeAnimationEnabled, bool transformPlaceholders, InterpolationMode downsampleInterpolationMode, int httpHeadersTimeout, int httpReadTimeout ) { MaxCacheSize = maxCacheSize; HttpClient = httpClient; Scheduler = scheduler; Logger = logger; DiskCache = diskCache; DownloadCache = downloadCache; LoadWithTransparencyChannel = loadWithTransparencyChannel; FadeAnimationEnabled = fadeAnimationEnabled; TransformPlaceholders = transformPlaceholders; DownsampleInterpolationMode = downsampleInterpolationMode; HttpHeadersTimeout = httpHeadersTimeout; HttpReadTimeout = httpReadTimeout; }
private static void InitializeIfNeeded(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool loadWithTransparencyChannel = false, bool fadeAnimationEnabled = true, int httpHeadersTimeout = HttpHeadersTimeout, int httpReadTimeout = HttpReadTimeout ) { if (_initialized) return; lock (_initializeLock) { if (_initialized) return; var userDefinedConfig = new Configuration(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache, loadWithTransparencyChannel, fadeAnimationEnabled, httpHeadersTimeout, httpReadTimeout); Config = GetDefaultConfiguration(userDefinedConfig); _initialized = true; } }
/// <summary> /// Initialize ImageService default values. This can only be done once: during app start. /// </summary> /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param> /// <param name="httpClient">.NET HttpClient to use. If null then a.NET HttpClient is instanciated.</param> /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param> /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param> /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param> /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param> /// <param name="loadWithTransparencyChannel">Gets a value indicating whether images should be loaded with transparency channel. On Android we save 50% of the memory without transparency since we use 2 bytes per pixel instead of 4.</param> /// <param name="fadeAnimationEnabled">Defines if fading should be performed while loading images.</param> /// <param name="transformPlaceholders">Defines if transforms should be applied to placeholders.</param> /// <param name="downsampleInterpolationMode">Defines default downsample interpolation mode.</param> /// <param name="httpHeadersTimeout">Maximum time in seconds to wait to receive HTTP headers before the HTTP request is cancelled.</param> /// <param name="httpReadTimeout">Maximum time in seconds to wait before the HTTP request is cancelled.</param> public static void Initialize(int? maxCacheSize = null, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool? loadWithTransparencyChannel = null, bool? fadeAnimationEnabled = null, bool? transformPlaceholders = null, InterpolationMode? downsampleInterpolationMode = null, int httpHeadersTimeout = HttpHeadersTimeout, int httpReadTimeout = HttpReadTimeout ) { lock (_initializeLock) { _initialized = false; if (Config != null) { // If DownloadCache is not updated but HttpClient is then we inform DownloadCache if (httpClient != null && downloadCache == null) { downloadCache = Config.DownloadCache; downloadCache.DownloadHttpClient = httpClient; } logger.Debug("Skip configuration for maxCacheSize and diskCache. They cannot be redefined."); maxCacheSize = Config.MaxCacheSize; diskCache = Config.DiskCache; // Redefine these if they were provided only httpClient = httpClient ?? Config.HttpClient; scheduler = scheduler ?? Config.Scheduler; logger = logger ?? Config.Logger; downloadCache = downloadCache ?? Config.DownloadCache; loadWithTransparencyChannel = loadWithTransparencyChannel ?? Config.LoadWithTransparencyChannel; fadeAnimationEnabled = fadeAnimationEnabled ?? Config.FadeAnimationEnabled; transformPlaceholders = transformPlaceholders ?? Config.TransformPlaceholders; downsampleInterpolationMode = downsampleInterpolationMode ?? Config.DownsampleInterpolationMode; } InitializeIfNeeded(maxCacheSize ?? 0, httpClient, scheduler, logger, diskCache, downloadCache, loadWithTransparencyChannel ?? false, fadeAnimationEnabled ?? true, transformPlaceholders ?? true, downsampleInterpolationMode ?? InterpolationMode.Default, httpHeadersTimeout, httpReadTimeout ); } }
/// <summary> /// Initialize ImageService default values. This can only be done once: during app start. /// </summary> /// <param name="maxCacheSize">Max cache size. If zero then 20% of the memory will be used.</param> /// <param name="httpClient">.NET HttpClient to use. If null then a ModernHttpClient is instanciated.</param> /// <param name="scheduler">Work scheduler used to organize/schedule loading tasks.</param> /// <param name="logger">Basic logger. If null a very simple implementation that prints to console is used.</param> /// <param name="diskCache">Disk cache. If null a default disk cache is instanciated that uses a journal mechanism.</param> /// <param name="downloadCache">Download cache. If null a default download cache is instanciated, which relies on the DiskCache</param> /// <param name="loadWithTransparencyChannel">Gets a value indicating whether images should be loaded with transparency channel. On Android we save 50% of the memory without transparency since we use 2 bytes per pixel instead of 4.</param> /// <param name="fadeAnimationEnabled">Defines if fading should be performed while loading images.</param> /// <param name="transformPlaceholders">Defines if transforms should be applied to placeholders.</param> /// <param name="downsampleInterpolationMode">Defines default downsample interpolation mode.</param> /// <param name="httpHeadersTimeout">Maximum time in seconds to wait to receive HTTP headers before the HTTP request is cancelled.</param> /// <param name="httpReadTimeout">Maximum time in seconds to wait before the HTTP request is cancelled.</param> public static void Initialize(int?maxCacheSize = null, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool?loadWithTransparencyChannel = null, bool?fadeAnimationEnabled = null, bool?transformPlaceholders = null, InterpolationMode?downsampleInterpolationMode = null, int httpHeadersTimeout = HttpHeadersTimeout, int httpReadTimeout = HttpReadTimeout ) { lock (_initializeLock) { _initialized = false; if (Config != null) { // If DownloadCache is not updated but HttpClient is then we inform DownloadCache if (httpClient != null && downloadCache == null) { downloadCache = Config.DownloadCache; downloadCache.DownloadHttpClient = httpClient; } logger.Debug("Skip configuration for maxCacheSize and diskCache. They cannot be redefined."); maxCacheSize = Config.MaxCacheSize; diskCache = Config.DiskCache; // Redefine these if they were provided only httpClient = httpClient ?? Config.HttpClient; scheduler = scheduler ?? Config.Scheduler; logger = logger ?? Config.Logger; downloadCache = downloadCache ?? Config.DownloadCache; loadWithTransparencyChannel = loadWithTransparencyChannel ?? Config.LoadWithTransparencyChannel; fadeAnimationEnabled = fadeAnimationEnabled ?? Config.FadeAnimationEnabled; transformPlaceholders = transformPlaceholders ?? Config.TransformPlaceholders; downsampleInterpolationMode = downsampleInterpolationMode ?? Config.DownsampleInterpolationMode; } InitializeIfNeeded(maxCacheSize ?? 0, httpClient, scheduler, logger, diskCache, downloadCache, loadWithTransparencyChannel ?? false, fadeAnimationEnabled ?? true, transformPlaceholders ?? true, downsampleInterpolationMode ?? InterpolationMode.Default, httpHeadersTimeout, httpReadTimeout ); } }
private static void InitializeIfNeeded(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null) { if (_initialized) { return; } lock (_initializeLock) { if (_initialized) { return; } var userDefinedConfig = new Configuration(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache); Config = GetDefaultConfiguration(userDefinedConfig); _initialized = true; } }
protected ImageLoaderTaskBase(IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, IDownloadCache downloadCache, bool clearCacheOnOutOfMemory, bool verboseLoadingCancelledLogging) { _verboseLoadingCancelledLogging = verboseLoadingCancelledLogging; _clearCacheOnOutOfMemory = clearCacheOnOutOfMemory; CancellationToken = new CancellationTokenSource(); DownloadCache = downloadCache; Parameters = parameters; NumberOfRetryNeeded = parameters.RetryCount; MainThreadDispatcher = mainThreadDispatcher; Logger = miniLogger; ConfigureParameters(); _hasCustomCacheKey = !string.IsNullOrWhiteSpace(Parameters.CustomCacheKey); _keys = new ConcurrentDictionary <string, string>(); _transformationsKey = new Lazy <string>(() => { if (Parameters.Transformations == null || Parameters.Transformations.Count == 0) { return(string.Empty); } return(";" + string.Join(";", Parameters.Transformations.Select(t => t.Key))); }); _downsamplingKey = new Lazy <string>(() => { if (Parameters.DownSampleSize == null) { return(string.Empty); } return(string.Concat(";", Parameters.DownSampleSize.Item1, "x", Parameters.DownSampleSize.Item2)); }); _rawKey = new Lazy <string>(() => GetKeyInternal(null, true)); _streamKey = new Lazy <string>(() => "Stream" + GetNextStreamIndex()); }
public static void Initialize(int? maxCacheSize = null, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null, bool? loadWithTransparencyChannel = null, bool? fadeAnimationEnabled = null, bool? transformPlaceholders = null, InterpolationMode? downsampleInterpolationMode = null, int httpHeadersTimeout = 15, int httpReadTimeout = 30 ) { var cfg = new Configuration(); if (httpClient != null) cfg.HttpClient = httpClient; if (scheduler != null) cfg.Scheduler = scheduler; if (logger != null) cfg.Logger = logger; if (diskCache != null) cfg.DiskCache = diskCache; if (downloadCache != null) cfg.DownloadCache = downloadCache; if (loadWithTransparencyChannel.HasValue) cfg.LoadWithTransparencyChannel = loadWithTransparencyChannel.Value; if (fadeAnimationEnabled.HasValue) cfg.FadeAnimationEnabled = fadeAnimationEnabled.Value; if (transformPlaceholders.HasValue) cfg.TransformPlaceholders = transformPlaceholders.Value; if (downsampleInterpolationMode.HasValue) cfg.DownsampleInterpolationMode = downsampleInterpolationMode.Value; cfg.HttpHeadersTimeout = httpHeadersTimeout; cfg.HttpReadTimeout = httpReadTimeout; if (maxCacheSize.HasValue) cfg.MaxCacheSize = maxCacheSize.Value; Initialize(cfg); }
public void Dispose() { Parameters = null; DownloadCache = null; }
public UrlStreamResolver(TaskParameter parameter, IDownloadCache downloadCache) { Parameters = parameter; DownloadCache = downloadCache; }
public static IStreamResolver GetResolver(ImageSource source, TaskParameter parameter, IDownloadCache downloadCache) { switch (source) { case ImageSource.ApplicationBundle: return(new ApplicationBundleStreamResolver()); case ImageSource.CompiledResource: return(new CompiledResourceStreamResolver()); case ImageSource.Filepath: return(new FilePathStreamResolver()); case ImageSource.Url: return(new UrlStreamResolver(parameter, downloadCache)); default: throw new ArgumentException("Unknown type of ImageSource"); } }
private static void InitializeIfNeeded(int maxCacheSize = 0, HttpClient httpClient = null, IWorkScheduler scheduler = null, IMiniLogger logger = null, IDiskCache diskCache = null, IDownloadCache downloadCache = null) { if (_initialized) return; lock (_initializeLock) { if (_initialized) return; var userDefinedConfig = new Configuration(maxCacheSize, httpClient, scheduler, logger, diskCache, downloadCache); Config = GetDefaultConfiguration(userDefinedConfig); _initialized = true; } }
/// <summary> /// This constructor is useful for child classes only. It can help when having a totally different loading logic. /// </summary> /// <param name="miniLogger">Logger</param> /// <param name="key">Key.</param> /// <param name="imageView">Image view.</param> protected ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, string key, ImageView imageView) : this(downloadCache, mainThreadDispatcher, miniLogger, TaskParameter.FromFile(key), imageView) { }
public static IDataResolver GetResolver(ImageSource source, TaskParameter parameter, IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher) { switch (source) { case ImageSource.ApplicationBundle: case ImageSource.Filepath: return(new FilePathDataResolver(source)); case ImageSource.CompiledResource: return(new AssetCatalogDataResolver(mainThreadDispatcher)); case ImageSource.Url: return(new UrlDataResolver(parameter, downloadCache)); default: throw new ArgumentException("Unknown type of ImageSource"); } }
/// <summary> /// This constructor is useful for child classes only. It can help when having a totally different loading logic. /// </summary> /// <param name="miniLogger">Logger</param> /// <param name="key">Key.</param> /// <param name="imageView">Image view.</param> protected ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, string key, ITarget <BitmapDrawable, ImageLoaderTask> target) : this(downloadCache, mainThreadDispatcher, miniLogger, TaskParameter.FromFile(key), target) { }