mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Filter image files
This commit is contained in:
parent
961e445d52
commit
2a9600edd4
1 changed files with 33 additions and 0 deletions
|
@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -52,6 +53,7 @@ private ImageViewer(string[] images, int currentImageIndex = 0)
|
|||
|
||||
Images = images;
|
||||
CurrentImageIndex = currentImageIndex;
|
||||
FilterImageFiles();
|
||||
LoadCurrentImage();
|
||||
}
|
||||
|
||||
|
@ -95,6 +97,37 @@ private void NavigateImage(int position)
|
|||
}
|
||||
}
|
||||
|
||||
private void FilterImageFiles()
|
||||
{
|
||||
List<string> filteredImages = new List<string>();
|
||||
|
||||
for (int i = 0; i < Images.Length; i++)
|
||||
{
|
||||
string imageFilePath = Images[i];
|
||||
|
||||
bool isImageFile = !string.IsNullOrEmpty(imageFilePath) && Helpers.IsImageFile(imageFilePath);
|
||||
|
||||
if (i == CurrentImageIndex)
|
||||
{
|
||||
if (isImageFile)
|
||||
{
|
||||
CurrentImageIndex = filteredImages.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentImageIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (isImageFile)
|
||||
{
|
||||
filteredImages.Add(imageFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
Images = filteredImages.ToArray();
|
||||
}
|
||||
|
||||
private void UpdateIndexLabel()
|
||||
{
|
||||
if (!SupportsImageNavigation || Images.Length < 2) return;
|
||||
|
|
Loading…
Reference in a new issue