using System;
using Avalonia;
using Avalonia.Animation;
using Avalonia.Labs.Controls;
using Avalonia.Media;
namespace StabilityMatrix.Avalonia.Controls.VendorLabs;
public partial class BetterAsyncImage
{
///
/// Defines the property.
///
public static readonly StyledProperty PlaceholderSourceProperty = AvaloniaProperty.Register<
BetterAsyncImage,
IImage?
>(nameof(PlaceholderSource));
///
/// Defines the property.
///
public static readonly StyledProperty SourceProperty = AvaloniaProperty.Register<
BetterAsyncImage,
Uri?
>(nameof(Source));
///
/// Defines the property.
///
public static readonly StyledProperty StretchProperty = AvaloniaProperty.Register<
BetterAsyncImage,
Stretch
>(nameof(Stretch), Stretch.Uniform);
///
/// Defines the property.
///
public static readonly StyledProperty PlaceholderStretchProperty = AvaloniaProperty.Register<
BetterAsyncImage,
Stretch
>(nameof(PlaceholderStretch), Stretch.Uniform);
///
/// Defines the property.
///
public static readonly DirectProperty StateProperty =
AvaloniaProperty.RegisterDirect(
nameof(State),
o => o.State,
(o, v) => o.State = v
);
///
/// Defines the property.
///
public static readonly StyledProperty ImageTransitionProperty =
AvaloniaProperty.Register(
nameof(ImageTransition),
new CrossFade(TimeSpan.FromSeconds(0.25))
);
///
/// Defines the property.
///
public static readonly DirectProperty IsCacheEnabledProperty =
AvaloniaProperty.RegisterDirect(
nameof(IsCacheEnabled),
o => o.IsCacheEnabled,
(o, v) => o.IsCacheEnabled = v
);
private bool _isCacheEnabled;
///
/// Gets or sets the placeholder image.
///
public IImage? PlaceholderSource
{
get => GetValue(PlaceholderSourceProperty);
set => SetValue(PlaceholderSourceProperty, value);
}
///
/// Gets or sets the uri pointing to the image resource
///
public Uri? Source
{
get => GetValue(SourceProperty);
set => SetValue(SourceProperty, value);
}
///
/// Gets or sets a value controlling how the image will be stretched.
///
public Stretch Stretch
{
get { return GetValue(StretchProperty); }
set { SetValue(StretchProperty, value); }
}
///
/// Gets or sets a value controlling how the placeholder will be stretched.
///
public Stretch PlaceholderStretch
{
get { return GetValue(StretchProperty); }
set { SetValue(StretchProperty, value); }
}
///
/// Gets the current loading state of the image.
///
public AsyncImageState State
{
get => _state;
private set => SetAndRaise(StateProperty, ref _state, value);
}
///
/// Gets or sets the transition to run when the image is loaded.
///
public IPageTransition? ImageTransition
{
get => GetValue(ImageTransitionProperty);
set => SetValue(ImageTransitionProperty, value);
}
///
/// Gets or sets whether to use cache for retrieved images
///
public bool IsCacheEnabled
{
get => _isCacheEnabled;
set => SetAndRaise(IsCacheEnabledProperty, ref _isCacheEnabled, value);
}
}