2021-01-27 13:23:15 +08:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2021-01-25 02:05:18 +08:00
|
|
|
|
|
|
|
|
|
namespace AntDesign
|
|
|
|
|
{
|
|
|
|
|
public partial class ImagePreview
|
|
|
|
|
{
|
|
|
|
|
[Parameter]
|
2021-01-30 22:39:56 +08:00
|
|
|
|
public ImageRef ImageRef { get; set; }
|
2021-01-25 02:05:18 +08:00
|
|
|
|
|
|
|
|
|
private int _zoomOutTimes = 1;
|
|
|
|
|
private int _rotateTimes;
|
2021-01-27 13:23:15 +08:00
|
|
|
|
private bool _visible = true;
|
2021-01-25 02:05:18 +08:00
|
|
|
|
|
2021-01-27 13:23:15 +08:00
|
|
|
|
private async Task HandleClose()
|
2021-01-25 02:05:18 +08:00
|
|
|
|
{
|
2021-01-27 13:23:15 +08:00
|
|
|
|
_visible = false;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
// Blocking DOM removal
|
|
|
|
|
await Task.Delay(200);
|
2021-01-30 23:39:40 +08:00
|
|
|
|
|
|
|
|
|
ImageRef.Close();
|
2021-01-25 02:05:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleZoomIn()
|
|
|
|
|
{
|
|
|
|
|
_zoomOutTimes++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleZoomOut()
|
|
|
|
|
{
|
|
|
|
|
if (_zoomOutTimes > 1)
|
|
|
|
|
{
|
|
|
|
|
_zoomOutTimes--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleRotateRight()
|
|
|
|
|
{
|
|
|
|
|
_rotateTimes++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleRotateLeft()
|
|
|
|
|
{
|
|
|
|
|
_rotateTimes--;
|
|
|
|
|
}
|
2021-01-27 13:23:15 +08:00
|
|
|
|
|
|
|
|
|
private DialogOptions GetDialogOptions()
|
|
|
|
|
{
|
|
|
|
|
return new DialogOptions()
|
|
|
|
|
{
|
|
|
|
|
PrefixCls = "ant-image-preview",
|
|
|
|
|
Closable = false,
|
|
|
|
|
Footer = null,
|
|
|
|
|
MaskClosable = true,
|
|
|
|
|
OnCancel = async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleClose();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-01-25 02:05:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|