mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Only change cursor when navigation possible
This commit is contained in:
parent
adf9b6b390
commit
3d57d05895
1 changed files with 19 additions and 20 deletions
|
@ -34,8 +34,10 @@ public class ImageViewer : Form
|
|||
{
|
||||
public Image CurrentImage { get; private set; }
|
||||
public string CurrentImageFilePath { get; private set; }
|
||||
public bool SupportImageNavigation => Images != null && Images.Length > 1;
|
||||
public bool SupportWrap { get; set; }
|
||||
public bool CanNavigate => Images != null && Images.Length > 1;
|
||||
public bool CanNavigateLeft => CanNavigate && (SupportWrap || CurrentImageIndex > 0);
|
||||
public bool CanNavigateRight => CanNavigate && (SupportWrap || CurrentImageIndex < Images.Length - 1);
|
||||
public string[] Images { get; private set; }
|
||||
public int CurrentImageIndex { get; private set; }
|
||||
|
||||
|
@ -81,7 +83,7 @@ private void LoadCurrentImage()
|
|||
|
||||
private void NavigateImage(int position)
|
||||
{
|
||||
if (SupportImageNavigation)
|
||||
if (CanNavigate)
|
||||
{
|
||||
int nextImageIndex = CurrentImageIndex + position;
|
||||
|
||||
|
@ -140,7 +142,7 @@ private void FilterImageFiles()
|
|||
|
||||
private void UpdateIndexLabel()
|
||||
{
|
||||
if (SupportImageNavigation)
|
||||
if (CanNavigate)
|
||||
{
|
||||
string status = CurrentImageIndex + 1 + " / " + Images.Length;
|
||||
string fileName = Helpers.GetFileNameSafe(CurrentImageFilePath);
|
||||
|
@ -210,11 +212,11 @@ private void ImageViewer_Deactivate(object sender, EventArgs e)
|
|||
|
||||
private void pbPreview_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (SupportImageNavigation && e.Location.X < ClientSize.Width * navigationAreaSize)
|
||||
if (CanNavigateLeft && e.Location.X < ClientSize.Width * navigationAreaSize)
|
||||
{
|
||||
NavigateImage(-1);
|
||||
}
|
||||
else if (SupportImageNavigation && e.Location.X > ClientSize.Width * (1 - navigationAreaSize))
|
||||
else if (CanNavigateRight && e.Location.X > ClientSize.Width * (1 - navigationAreaSize))
|
||||
{
|
||||
NavigateImage(1);
|
||||
}
|
||||
|
@ -226,30 +228,27 @@ private void pbPreview_MouseDown(object sender, MouseEventArgs e)
|
|||
|
||||
private void pbPreview_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (SupportImageNavigation)
|
||||
if (CanNavigateLeft && e.Location.X < ClientSize.Width * navigationAreaSize)
|
||||
{
|
||||
if (e.Location.X < ClientSize.Width * navigationAreaSize)
|
||||
{
|
||||
Cursor = Cursors.PanWest;
|
||||
}
|
||||
else if (e.Location.X > ClientSize.Width * (1 - navigationAreaSize))
|
||||
{
|
||||
Cursor = Cursors.PanEast;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor = Cursors.Hand;
|
||||
}
|
||||
Cursor = Cursors.PanWest;
|
||||
}
|
||||
else if (CanNavigateRight && e.Location.X > ClientSize.Width * (1 - navigationAreaSize))
|
||||
{
|
||||
Cursor = Cursors.PanEast;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor = Cursors.Hand;
|
||||
}
|
||||
}
|
||||
|
||||
private void pbPreview_MouseWheel(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
if (CanNavigateLeft && e.Delta > 0)
|
||||
{
|
||||
NavigateImage(-1);
|
||||
}
|
||||
else if (e.Delta < 0)
|
||||
else if (CanNavigateRight && e.Delta < 0)
|
||||
{
|
||||
NavigateImage(1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue