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
d9fb2ebdf5
commit
154ba53110
1 changed files with 55 additions and 48 deletions
|
@ -34,7 +34,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 SupportImageNavigation => Images != null && Images.Length > 1;
|
||||
public bool SupportWrap { get; set; }
|
||||
public string[] Images { get; private set; }
|
||||
public int CurrentImageIndex { get; private set; }
|
||||
|
@ -67,19 +67,20 @@ private void LoadImage(Image img)
|
|||
|
||||
private void LoadCurrentImage()
|
||||
{
|
||||
if (!SupportImageNavigation) return;
|
||||
|
||||
if (Images != null && Images.Length > 0)
|
||||
{
|
||||
CurrentImageIndex = CurrentImageIndex.Clamp(0, Images.Length - 1);
|
||||
CurrentImageFilePath = Images[CurrentImageIndex];
|
||||
Image img = ImageHelpers.LoadImage(CurrentImageFilePath);
|
||||
LoadImage(img);
|
||||
UpdateIndexLabel();
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigateImage(int position)
|
||||
{
|
||||
if (!SupportImageNavigation || Images.Length < 2) return;
|
||||
|
||||
if (SupportImageNavigation)
|
||||
{
|
||||
int nextImageIndex = CurrentImageIndex + position;
|
||||
|
||||
if (SupportWrap)
|
||||
|
@ -102,6 +103,7 @@ private void NavigateImage(int position)
|
|||
LoadCurrentImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FilterImageFiles()
|
||||
{
|
||||
|
@ -136,8 +138,8 @@ private void FilterImageFiles()
|
|||
|
||||
private void UpdateIndexLabel()
|
||||
{
|
||||
if (!SupportImageNavigation || Images.Length < 2) return;
|
||||
|
||||
if (SupportImageNavigation)
|
||||
{
|
||||
string status = CurrentImageIndex + 1 + " / " + Images.Length;
|
||||
string fileName = Helpers.GetFileNameSafe(CurrentImageFilePath);
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
|
@ -148,6 +150,7 @@ private void UpdateIndexLabel()
|
|||
lblStatus.Visible = true;
|
||||
lblStatus.Location = new Point((ClientSize.Width - lblStatus.Width) / 2, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowImage(Image img)
|
||||
{
|
||||
|
@ -205,11 +208,11 @@ private void ImageViewer_Deactivate(object sender, EventArgs e)
|
|||
|
||||
private void pbPreview_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Location.X < ClientSize.Width * 0.2)
|
||||
if (SupportImageNavigation && e.Location.X < ClientSize.Width * 0.2)
|
||||
{
|
||||
NavigateImage(-1);
|
||||
}
|
||||
else if (e.Location.X > ClientSize.Width * 0.8)
|
||||
else if (SupportImageNavigation && e.Location.X > ClientSize.Width * 0.8)
|
||||
{
|
||||
NavigateImage(1);
|
||||
}
|
||||
|
@ -220,6 +223,8 @@ private void pbPreview_MouseDown(object sender, MouseEventArgs e)
|
|||
}
|
||||
|
||||
private void pbPreview_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (SupportImageNavigation)
|
||||
{
|
||||
if (e.Location.X < ClientSize.Width * 0.2)
|
||||
{
|
||||
|
@ -234,6 +239,7 @@ private void pbPreview_MouseMove(object sender, MouseEventArgs e)
|
|||
Cursor = Cursors.Hand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void pbPreview_MouseWheel(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
@ -300,6 +306,7 @@ private void InitializeComponent()
|
|||
|
||||
BackColor = SystemColors.Window;
|
||||
Bounds = CaptureHelpers.GetActiveScreenBounds();
|
||||
Cursor = Cursors.Hand;
|
||||
DoubleBuffered = true;
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
// TODO: Translate
|
||||
|
|
Loading…
Reference in a new issue