Class CachedImage
- Namespace
- FFImageLoading.Forms
- Assembly
- FFImageLoading.Forms.dll
public class CachedImage : View
- Inheritance
-
CachedImage
Constructors
CachedImage()
CachedImage by Daniel Luberda
public CachedImage()
Fields
AspectProperty
The aspect property.
public static readonly BindableProperty AspectProperty
Field Value
- BindableProperty
BitmapOptimizationsProperty
The bitmap optimizations property.
public static readonly BindableProperty BitmapOptimizationsProperty
Field Value
- BindableProperty
CacheDurationProperty
The cache duration property.
public static readonly BindableProperty CacheDurationProperty
Field Value
- BindableProperty
CacheTypeProperty
The cache type property.
public static readonly BindableProperty CacheTypeProperty
Field Value
- BindableProperty
DownloadProgressCommandProperty
The DownloadProgressCommandProperty.
public static readonly BindableProperty DownloadProgressCommandProperty
Field Value
- BindableProperty
DownloadStartedCommandProperty
The DownloadStartedCommandProperty.
public static readonly BindableProperty DownloadStartedCommandProperty
Field Value
- BindableProperty
DownsampleHeightProperty
The downsample height property.
public static readonly BindableProperty DownsampleHeightProperty
Field Value
- BindableProperty
DownsampleToViewSizeProperty
The downsample to view size property.
public static readonly BindableProperty DownsampleToViewSizeProperty
Field Value
- BindableProperty
DownsampleUseDipUnitsProperty
The downsample use dip units property.
public static readonly BindableProperty DownsampleUseDipUnitsProperty
Field Value
- BindableProperty
DownsampleWidthProperty
The downsample width property.
public static readonly BindableProperty DownsampleWidthProperty
Field Value
- BindableProperty
ErrorCommandProperty
The ErrorCommandProperty.
public static readonly BindableProperty ErrorCommandProperty
Field Value
- BindableProperty
ErrorPlaceholderProperty
The error placeholder property.
public static readonly BindableProperty ErrorPlaceholderProperty
Field Value
- BindableProperty
FadeAnimationDurationProperty
The fade animation duration property.
public static readonly BindableProperty FadeAnimationDurationProperty
Field Value
- BindableProperty
FadeAnimationEnabledProperty
The fade animation enabled property.
public static readonly BindableProperty FadeAnimationEnabledProperty
Field Value
- BindableProperty
FadeAnimationForCachedImagesProperty
The fade animation for cached images enabled property.
public static readonly BindableProperty FadeAnimationForCachedImagesProperty
Field Value
- BindableProperty
FileWriteFinishedCommandProperty
The FileWriteFinishedCommandProperty.
public static readonly BindableProperty FileWriteFinishedCommandProperty
Field Value
- BindableProperty
FinishCommandProperty
The FinishCommandProperty.
public static readonly BindableProperty FinishCommandProperty
Field Value
- BindableProperty
InvalidateLayoutAfterLoadedProperty
The invalidate layout after loaded property.
public static readonly BindableProperty InvalidateLayoutAfterLoadedProperty
Field Value
- BindableProperty
IsLoadingProperty
The is loading property.
public static readonly BindableProperty IsLoadingProperty
Field Value
- BindableProperty
IsLoadingPropertyKey
The is loading property key.
public static readonly BindablePropertyKey IsLoadingPropertyKey
Field Value
- BindablePropertyKey
IsOpaqueProperty
The is opaque property.
public static readonly BindableProperty IsOpaqueProperty
Field Value
- BindableProperty
LoadingDelayProperty
The loading delay property.
public static readonly BindableProperty LoadingDelayProperty
Field Value
- BindableProperty
LoadingPlaceholderProperty
The loading placeholder property.
public static readonly BindableProperty LoadingPlaceholderProperty
Field Value
- BindableProperty
LoadingPriorityProperty
The loading priority property.
public static readonly BindableProperty LoadingPriorityProperty
Field Value
- BindableProperty
RetryCountProperty
The retry count property.
public static readonly BindableProperty RetryCountProperty
Field Value
- BindableProperty
RetryDelayProperty
The retry delay property.
public static readonly BindableProperty RetryDelayProperty
Field Value
- BindableProperty
SourceProperty
The source property.
public static readonly BindableProperty SourceProperty
Field Value
- BindableProperty
SuccessCommandProperty
The SuccessCommandProperty.
public static readonly BindableProperty SuccessCommandProperty
Field Value
- BindableProperty
TransformPlaceholdersProperty
The TransformPlaceholders property.
public static readonly BindableProperty TransformPlaceholdersProperty
Field Value
- BindableProperty
TransformationsProperty
The transformations property.
public static readonly BindableProperty TransformationsProperty
Field Value
- BindableProperty
Properties
Aspect
Gets or sets the aspect.
public Aspect Aspect { get; set; }
Property Value
- Aspect
The aspect.
BitmapOptimizations
Enables or disables the bitmap optimizations.
public bool? BitmapOptimizations { get; set; }
Property Value
- bool?
The bitmap optimizations.
CacheDuration
How long the file will be cached on disk.
public TimeSpan? CacheDuration { get; set; }
Property Value
CacheKeyFactory
Gets or sets the cache custom key factory.
public ICacheKeyFactory CacheKeyFactory { get; set; }
Property Value
- ICacheKeyFactory
The cache key factory.
CacheType
Set the cache storage type, (Memory, Disk, All). by default cache is set to All.
public CacheType? CacheType { get; set; }
Property Value
- CacheType?
CustomDataResolver
Gets or sets the custom data resolver for eg. SVG support (another nuget)
public IDataResolver CustomDataResolver { get; set; }
Property Value
- IDataResolver
The custom data resolver.
DownloadProgressCommand
Gets or sets the DownloadProgressCommand. This callback can be used for reading download progress Command parameter: DownloadProgressEventArgs
public ICommand DownloadProgressCommand { get; set; }
Property Value
- ICommand
The download started command.
DownloadStartedCommand
Gets or sets the DownloadStartedCommand. Occurs when an image starts downloading from web. Command parameter: DownloadStartedEventArgs
public ICommand DownloadStartedCommand { get; set; }
Property Value
- ICommand
The download started command.
DownsampleHeight
Reduce memory usage by downsampling the image. Aspect ratio will be kept even if width/height values are incorrect. Optional DownsampleHeight parameter, if value is higher than zero it will try to downsample to this height while keeping aspect ratio.
public double DownsampleHeight { get; set; }
Property Value
DownsampleToViewSize
Reduce memory usage by downsampling the image. Aspect ratio will be kept even if width/height values are incorrect. DownsampleWidth and DownsampleHeight properties will be automatically set to view size
public bool DownsampleToViewSize { get; set; }
Property Value
- bool
true
if downsample to view size; otherwise,false
.
DownsampleUseDipUnits
If set to true
DownsampleWidth and DownsampleHeight properties
will use density independent pixels for downsampling
public bool DownsampleUseDipUnits { get; set; }
Property Value
- bool
true
if downsample use dip units; otherwise,false
.
DownsampleWidth
Reduce memory usage by downsampling the image. Aspect ratio will be kept even if width/height values are incorrect. Optional DownsampleWidth parameter, if value is higher than zero it will try to downsample to this width while keeping aspect ratio.
public double DownsampleWidth { get; set; }
Property Value
ErrorCommand
Gets or sets the ErrorCommand. Occurs after image loading error. Command parameter: CachedImageEvents.ErrorEventArgs
public ICommand ErrorCommand { get; set; }
Property Value
- ICommand
The error command.
ErrorPlaceholder
Gets or sets the error placeholder image.
public ImageSource ErrorPlaceholder { get; set; }
Property Value
- ImageSource
FadeAnimationDuration
Sets fade animation effect duration. By default this value comes from ImageService.Instance.Config.FadeAnimationDuration.
public int? FadeAnimationDuration { get; set; }
Property Value
- int?
FadeAnimationEnabled
Indicates if the fade animation effect should be enabled. By default this value comes from ImageService.Instance.Config.FadeAnimationEnabled.
public bool? FadeAnimationEnabled { get; set; }
Property Value
- bool?
FadeAnimationForCachedImages
Indicates if the fade animation effect for cached images should be enabled. By default this value comes from ImageService.Instance.Config.FadeAnimationForCachedImages.
public bool? FadeAnimationForCachedImages { get; set; }
Property Value
- bool?
FileWriteFinishedCommand
Gets or sets the FileWriteFinishedCommand. Called after file is succesfully written to the disk. Command parameter: FileWriteFinishedEventArgs
public ICommand FileWriteFinishedCommand { get; set; }
Property Value
- ICommand
The download started command.
FinishCommand
Gets or sets the FinishCommand. Occurs after every image loading. Command parameter: CachedImageEvents.FinishEventArgs
public ICommand FinishCommand { get; set; }
Property Value
- ICommand
The finish command.
FixedAndroidMotionEventHandler
[Obsolete]
public static bool FixedAndroidMotionEventHandler { get; set; }
Property Value
FixedOnMeasureBehavior
[Obsolete]
public static bool FixedOnMeasureBehavior { get; set; }
Property Value
InvalidateLayoutAfterLoaded
Specifies if view layout should be invalidated after image is loaded.
public bool? InvalidateLayoutAfterLoaded { get; set; }
Property Value
- bool?
The invalidate layout after loaded.
IsDesignModeEnabled
protected static bool IsDesignModeEnabled { get; }
Property Value
IsLoading
Gets a value indicating whether this instance is loading.
public bool IsLoading { get; }
Property Value
- bool
true
if this instance is loading; otherwise,false
.
IsOpaque
Gets or sets a value indicating whether this instance is opaque.
public bool IsOpaque { get; set; }
Property Value
- bool
true
if this instance is opaque; otherwise,false
.
LoadingDelay
Sets delay in milliseconds before image loading
public int? LoadingDelay { get; set; }
Property Value
- int?
LoadingPlaceholder
Gets or sets the loading placeholder image.
public ImageSource LoadingPlaceholder { get; set; }
Property Value
- ImageSource
LoadingPriority
Defines the loading priority, the default is LoadingPriority.Normal
public LoadingPriority LoadingPriority { get; set; }
Property Value
- LoadingPriority
RetryCount
If image loading fails automatically retry it a number of times, with a specific delay. Sets number of retries.
public int RetryCount { get; set; }
Property Value
RetryDelay
If image loading fails automatically retry it a number of times, with a specific delay. Sets delay in milliseconds between each trial
public int RetryDelay { get; set; }
Property Value
Source
Gets or sets the source.
public ImageSource Source { get; set; }
Property Value
- ImageSource
The source.
SuccessCommand
Gets or sets the SuccessCommand. Occurs after image loading success. Command parameter: CachedImageEvents.SuccessEventArgs
public ICommand SuccessCommand { get; set; }
Property Value
- ICommand
The success command.
TransformPlaceholders
Indicates if transforms should be applied to placeholders. By default this value comes from ImageService.Instance.Config.TransformPlaceholders.
public bool? TransformPlaceholders { get; set; }
Property Value
- bool?
The transform placeholders.
Transformations
Gets or sets the transformations.
public List<ITransformation> Transformations { get; set; }
Property Value
- List<ITransformation>
The transformations.
Methods
Cancel()
Cancels image loading tasks
public void Cancel()
CoerceImageSource(object)
protected virtual ImageSource CoerceImageSource(object newValue)
Parameters
newValue
object
Returns
- ImageSource
GetImageAsJpgAsync(int, int, int)
Gets the image as JPG.
public Task<byte[]> GetImageAsJpgAsync(int quality = 90, int desiredWidth = 0, int desiredHeight = 0)
Parameters
Returns
GetImageAsPngAsync(int, int)
Gets the image as PNG
public Task<byte[]> GetImageAsPngAsync(int desiredWidth = 0, int desiredHeight = 0)
Parameters
Returns
InvalidateCache(string, CacheType, bool)
Invalidates cache for a specified key.
public static Task InvalidateCache(string key, CacheType cacheType, bool removeSimilar = false)
Parameters
key
stringImage key.
cacheType
CacheTypeCache type.
removeSimilar
boolIf set to
true
removes all image cache variants (downsampling and transformations variants)
Returns
InvalidateCache(ImageSource, CacheType, bool)
Invalidates cache for a specified image source.
public static Task InvalidateCache(ImageSource source, CacheType cacheType, bool removeSimilar = false)
Parameters
source
ImageSourceImage source.
cacheType
CacheTypeCache type.
removeSimilar
boolIf set to
true
removes all image cache variants (downsampling and transformations variants)
Returns
OnBindingContextChanged()
protected override void OnBindingContextChanged()
OnMeasure(double, double)
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
Parameters
Returns
- SizeRequest
OnSizeAllocated(double, double)
protected override void OnSizeAllocated(double width, double height)
Parameters
ReloadImage()
Reloads the image.
public void ReloadImage()
SetIsLoading(bool)
public void SetIsLoading(bool isLoading)
Parameters
isLoading
bool
SetupOnBeforeImageLoading(TaskParameter)
Setups the on before image loading. You can add additional logic here to configure image loader settings before loading
protected virtual void SetupOnBeforeImageLoading(TaskParameter imageLoader)
Parameters
imageLoader
TaskParameterImage loader.
SetupOnBeforeImageLoading(out TaskParameter, IImageSourceBinding, IImageSourceBinding, IImageSourceBinding)
Setups the on before image loading. You can add additional logic here to configure image loader settings before loading
protected virtual void SetupOnBeforeImageLoading(out TaskParameter imageLoader, IImageSourceBinding source, IImageSourceBinding loadingPlaceholderSource, IImageSourceBinding errorPlaceholderSource)
Parameters
imageLoader
TaskParameterImage loader.
source
IImageSourceBindingSource.
loadingPlaceholderSource
IImageSourceBindingLoading placeholder source.
errorPlaceholderSource
IImageSourceBindingError placeholder source.
Events
DownloadProgress
This callback can be used for reading download progress
public event EventHandler<CachedImageEvents.DownloadProgressEventArgs> DownloadProgress
Event Type
DownloadStarted
Occurs when an image starts downloading from web.
public event EventHandler<CachedImageEvents.DownloadStartedEventArgs> DownloadStarted
Event Type
Error
Occurs after image loading error.
public event EventHandler<CachedImageEvents.ErrorEventArgs> Error
Event Type
FileWriteFinished
Called after file is succesfully written to the disk.
public event EventHandler<CachedImageEvents.FileWriteFinishedEventArgs> FileWriteFinished
Event Type
Finish
Occurs after every image loading.
public event EventHandler<CachedImageEvents.FinishEventArgs> Finish
Event Type
Success
Occurs after image loading success.
public event EventHandler<CachedImageEvents.SuccessEventArgs> Success