mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added SupportWrap property
This commit is contained in:
parent
0c035baf0e
commit
3c68d36b1c
1 changed files with 12 additions and 6 deletions
|
@ -35,6 +35,7 @@ public class ImageViewer : Form
|
|||
public Image CurrentImage { get; private set; }
|
||||
public string CurrentImageFilePath { get; private set; }
|
||||
public bool SupportImageNavigation => Images != null && Images.Length > 0;
|
||||
public bool SupportWrap { get; set; }
|
||||
public string[] Images { get; private set; }
|
||||
public int CurrentImageIndex { get; private set; }
|
||||
|
||||
|
@ -81,15 +82,20 @@ private void NavigateImage(int position)
|
|||
|
||||
int nextImageIndex = CurrentImageIndex + position;
|
||||
|
||||
if (nextImageIndex > Images.Length - 1)
|
||||
if (SupportWrap)
|
||||
{
|
||||
nextImageIndex = 0;
|
||||
}
|
||||
else if (nextImageIndex < 0)
|
||||
{
|
||||
nextImageIndex = Images.Length - 1;
|
||||
if (nextImageIndex > Images.Length - 1)
|
||||
{
|
||||
nextImageIndex = 0;
|
||||
}
|
||||
else if (nextImageIndex < 0)
|
||||
{
|
||||
nextImageIndex = Images.Length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
nextImageIndex = nextImageIndex.Clamp(0, Images.Length - 1);
|
||||
|
||||
if (CurrentImageIndex != nextImageIndex)
|
||||
{
|
||||
CurrentImageIndex = nextImageIndex;
|
||||
|
|
Loading…
Reference in a new issue