mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-03 12:37:40 +08:00
46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public class ImageRef
|
|
{
|
|
public event Action OnClosed;
|
|
|
|
internal string ImageSrc => _showingImageSrc;
|
|
|
|
internal int CurrentIndex => _currentIndex;
|
|
|
|
internal int ImageCount => _images.Count;
|
|
|
|
private IList<Image> _images;
|
|
private string _showingImageSrc;
|
|
private ImageService _imageService;
|
|
private int _currentIndex;
|
|
|
|
public ImageRef(IList<Image> images, ImageService imageService)
|
|
{
|
|
_images = images;
|
|
_imageService = imageService;
|
|
}
|
|
|
|
public void SwitchTo(int index)
|
|
{
|
|
if (index < 0 || index >= _images.Count)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_currentIndex = index;
|
|
_showingImageSrc = _images[index].PreviewSrc;
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
OnClosed?.Invoke();
|
|
_imageService.CloseImage(this);
|
|
}
|
|
}
|
|
}
|