Class ImageSourceCache
Class for managing all bitmaps, which are registered for Mapsui drawing
Implements
Inherited Members
Namespace: Mapsui.Styles
Assembly: Mapsui.dll
Syntax
public sealed class ImageSourceCache : IFetchableSource
Properties
| Edit this page View SourceId
The layer identifier.
Declaration
public int Id { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceClearCache()
Clears the cache of this layer. Call this if source data has was invalidated or the layer is removed.
Declaration
public void ClearCache()
FetchAllImageDataAsync(ConcurrentDictionary<string, string>)
This variant is currently only used in tests. By awaiting the method the user can be sure that the images are loaded.
Declaration
public Task<bool> FetchAllImageDataAsync(ConcurrentDictionary<string, string> sourceToSourceId)
Parameters
| Type | Name | Description |
|---|---|---|
| ConcurrentDictionary<string, string> | sourceToSourceId |
Returns
| Type | Description |
|---|---|
| Task<bool> |
Get(Image)
Get a image from the cache
Declaration
public byte[]? Get(Image image)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | image |
Returns
| Type | Description |
|---|---|
| byte[] |
GetFetchJobs(int, int)
Gets the fetch requests for this layer. The requests are based on the viewport stored within the layer.
Declaration
public FetchJob[] GetFetchJobs(int activeFetchCount, int availableFetchSlots)
Parameters
| Type | Name | Description |
|---|---|---|
| int | activeFetchCount | Number of active fetches for this layer. It is relevant if the layer itself has a maximum on the number of active fetches for itself. |
| int | availableFetchSlots | Number of available fetch slots in the caller. It is the maximum number of fetch jobs the method should return. |
Returns
| Type | Description |
|---|---|
| FetchJob[] |
TryRegisterAsync(string, string)
Register an image for drawing
Declaration
public Task<bool> TryRegisterAsync(string sourceId, string source)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceId | |
| string | source |
Returns
| Type | Description |
|---|---|
| Task<bool> | If true a new image was registered and a refresh is needed. If false the image was already registered and no refresh is needed. |
Unregister(Image)
Unregister a image from the cache
Declaration
public byte[]? Unregister(Image image)
Parameters
| Type | Name | Description |
|---|---|---|
| Image | image |
Returns
| Type | Description |
|---|---|
| byte[] |
ViewportChanged(FetchInfo)
Informs the layer that the viewport has changed and it should update its data accordingly.
Declaration
public void ViewportChanged(FetchInfo fetchInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| FetchInfo | fetchInfo |
Events
| Edit this page View SourceFetchRequested
Indicates to the listener that it should fetch data again. This event is raised when there was a change in source data, so only relevant for dynamic data. The fetches triggered by viewport changes do not depend on it.
Declaration
public event EventHandler<FetchRequestedEventArgs>? FetchRequested
Event Type
| Type | Description |
|---|---|
| EventHandler<FetchRequestedEventArgs> |